commit
ae71f6b01b
26173
build/potree/potree.js
Normal file
26173
build/potree/potree.js
Normal file
File diff suppressed because it is too large
Load Diff
88
examples/ept.html
Normal file
88
examples/ept.html
Normal file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title>Potree Viewer</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/perfect-scrollbar/css/perfect-scrollbar.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
<script src="../libs/openlayers3/ol.js"></script>
|
||||
<script src="../libs/i18next/i18next.js"></script>
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
|
||||
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
||||
<div id="potree_render_area"></div>
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(2*1000*1000);
|
||||
viewer.loadSettingsFromURL();
|
||||
|
||||
viewer.setDescription("Loading Entwine-generated EPT format");
|
||||
|
||||
viewer.loadGUI(() => {
|
||||
viewer.setLanguage('en');
|
||||
$("#menu_appearance").next().show();
|
||||
});
|
||||
|
||||
var path = "../pointclouds/lion_takanawa_ept_laz/ept.json";
|
||||
var name = "lion";
|
||||
|
||||
var getQueryParam = function(name) {
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(window.location.href);
|
||||
if (!results || !results[2]) return null;
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
var r = getQueryParam('r');
|
||||
if (r) {
|
||||
name = r;
|
||||
var http = 'http';
|
||||
if (r.substr(0, http.length) == http) path = name;
|
||||
else path = "../pointclouds/" + name + "/ept.json";
|
||||
}
|
||||
|
||||
Potree.loadPointCloud(path, name, function(e){
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
|
||||
let material = e.pointcloud.material;
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
viewer.fitToScreen(0.5);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
88
examples/ept_binary.html
Normal file
88
examples/ept_binary.html
Normal file
@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title>Potree Viewer</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../build/potree/potree.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jquery-ui/jquery-ui.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/perfect-scrollbar/css/perfect-scrollbar.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/openlayers3/ol.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/spectrum/spectrum.css">
|
||||
<link rel="stylesheet" type="text/css" href="../libs/jstree/themes/mixed/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="../libs/jquery/jquery-3.1.1.min.js"></script>
|
||||
<script src="../libs/spectrum/spectrum.js"></script>
|
||||
<script src="../libs/perfect-scrollbar/js/perfect-scrollbar.jquery.js"></script>
|
||||
<script src="../libs/jquery-ui/jquery-ui.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.min.js"></script>
|
||||
<script src="../libs/other/BinaryHeap.js"></script>
|
||||
<script src="../libs/tween/tween.min.js"></script>
|
||||
<script src="../libs/d3/d3.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
<script src="../libs/openlayers3/ol.js"></script>
|
||||
<script src="../libs/i18next/i18next.js"></script>
|
||||
<script src="../libs/jstree/jstree.js"></script>
|
||||
<script src="../build/potree/potree.js"></script>
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
|
||||
<!-- INCLUDE ADDITIONAL DEPENDENCIES HERE -->
|
||||
<!-- INCLUDE SETTINGS HERE -->
|
||||
|
||||
<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">
|
||||
<div id="potree_render_area"></div>
|
||||
<div id="potree_sidebar_container"> </div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
|
||||
|
||||
viewer.setEDLEnabled(true);
|
||||
viewer.setFOV(60);
|
||||
viewer.setPointBudget(2*1000*1000);
|
||||
viewer.loadSettingsFromURL();
|
||||
|
||||
viewer.setDescription("Loading Entwine-generated EPT format");
|
||||
|
||||
viewer.loadGUI(() => {
|
||||
viewer.setLanguage('en');
|
||||
$("#menu_appearance").next().show();
|
||||
});
|
||||
|
||||
var path = "../pointclouds/lion_takanawa_ept_bin/ept.json";
|
||||
var name = "lion";
|
||||
|
||||
var getQueryParam = function(name) {
|
||||
name = name.replace(/[\[\]]/g, "\\$&");
|
||||
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
|
||||
results = regex.exec(window.location.href);
|
||||
if (!results || !results[2]) return null;
|
||||
return decodeURIComponent(results[2].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
var r = getQueryParam('r');
|
||||
if (r) {
|
||||
name = r;
|
||||
var http = 'http';
|
||||
if (r.substr(0, http.length) == http) path = name;
|
||||
else path = "../pointclouds/" + name + "/ept.json";
|
||||
}
|
||||
|
||||
Potree.loadPointCloud(path, name, function(e){
|
||||
viewer.scene.addPointCloud(e.pointcloud);
|
||||
|
||||
let material = e.pointcloud.material;
|
||||
material.size = 1;
|
||||
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
|
||||
viewer.fitToScreen(0.5);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
76
gulpfile.js
76
gulpfile.js
@ -36,6 +36,12 @@ let workers = {
|
||||
"LASDecoderWorker": [
|
||||
"src/workers/LASDecoderWorker.js"
|
||||
],
|
||||
"EptLaszipDecoderWorker": [
|
||||
"src/workers/EptLaszipDecoderWorker.js"
|
||||
],
|
||||
"EptBinaryDecoderWorker": [
|
||||
"src/workers/EptBinaryDecoderWorker.js"
|
||||
],
|
||||
"GreyhoundBinaryDecoderWorker": [
|
||||
"libs/plasio/workers/laz-perf.js",
|
||||
"src/workers/GreyhoundBinaryDecoderWorker.js",
|
||||
@ -67,11 +73,11 @@ let shaders = [
|
||||
gulp.task("workers", function(){
|
||||
|
||||
for(let workerName of Object.keys(workers)){
|
||||
|
||||
|
||||
gulp.src(workers[workerName])
|
||||
.pipe(concat(`${workerName}.js`))
|
||||
.pipe(gulp.dest('build/potree/workers'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
@ -118,7 +124,7 @@ gulp.task('examples_page', function() {
|
||||
for(let file of files){
|
||||
let isHandled = false;
|
||||
for(let url of urls){
|
||||
|
||||
|
||||
if(file.indexOf(url) !== -1){
|
||||
isHandled = true;
|
||||
}
|
||||
@ -132,7 +138,7 @@ gulp.task('examples_page', function() {
|
||||
.filter(file => file.indexOf(".html") > 0)
|
||||
.filter(file => file !== "page.html");
|
||||
|
||||
|
||||
|
||||
for(let file of unhandled){
|
||||
unhandledCode += `
|
||||
<a href="${file}" class="unhandled">${file}</a>
|
||||
@ -167,7 +173,7 @@ gulp.task('examples_page', function() {
|
||||
</a>
|
||||
`;
|
||||
}
|
||||
|
||||
|
||||
|
||||
let page = `
|
||||
<html>
|
||||
@ -180,30 +186,30 @@ gulp.task('examples_page', function() {
|
||||
}
|
||||
|
||||
.thumb{
|
||||
background-size: 140px 140px;
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid black;
|
||||
box-shadow: 3px 3px 3px 0px #555;
|
||||
margin: 0px;
|
||||
background-size: 140px 140px;
|
||||
width: 140px;
|
||||
height: 140px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid black;
|
||||
box-shadow: 3px 3px 3px 0px #555;
|
||||
margin: 0px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.thumb-label{
|
||||
font-size: large;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
color: #FFF;
|
||||
text-shadow:black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px;
|
||||
font-size: large;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
color: #FFF;
|
||||
text-shadow:black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px, black 0 0 5px;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.unhandled_container{
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
margin-top: 50px;
|
||||
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
margin-top: 50px;
|
||||
|
||||
}
|
||||
|
||||
.unhandled{
|
||||
@ -251,8 +257,8 @@ gulp.task('examples_page', function() {
|
||||
grid-row-start: 1;
|
||||
grid-row-end: 1;
|
||||
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
margin-top: 20px
|
||||
}
|
||||
|
||||
@ -271,8 +277,8 @@ gulp.task('examples_page', function() {
|
||||
grid-row-start: 2;
|
||||
grid-row-end: 2;
|
||||
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
@ -299,7 +305,7 @@ gulp.task('examples_page', function() {
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="unhandled_container">
|
||||
<h1>Other</h1>
|
||||
@ -326,12 +332,12 @@ gulp.task('icons_viewer', function() {
|
||||
let iconsPath = "resources/icons";
|
||||
|
||||
fs.readdir(iconsPath, function(err, items) {
|
||||
|
||||
|
||||
let svgs = items.filter(item => item.endsWith(".svg"));
|
||||
let other = items.filter(item => !item.endsWith(".svg"));
|
||||
|
||||
items = [...svgs, ...other];
|
||||
|
||||
|
||||
let iconsCode = ``;
|
||||
for(let item of items){
|
||||
let extension = path.extname(item);
|
||||
@ -394,11 +400,11 @@ gulp.task('watch', ["build", "webserver"], function() {
|
||||
//gulp.run("webserver");
|
||||
|
||||
let watchlist = [
|
||||
'src/**/*.js',
|
||||
'src/**/*.css',
|
||||
'src/**/*.html',
|
||||
'src/**/*.vs',
|
||||
'src/**/*.fs',
|
||||
'src/**/*.js',
|
||||
'src/**/*.css',
|
||||
'src/**/*.html',
|
||||
'src/**/*.vs',
|
||||
'src/**/*.fs',
|
||||
'resources/**/*',
|
||||
'examples//**/*.json',
|
||||
];
|
||||
@ -406,7 +412,7 @@ gulp.task('watch', ["build", "webserver"], function() {
|
||||
let blacklist = [
|
||||
'resources/icons/index.html'
|
||||
];
|
||||
|
||||
|
||||
let watcher = watch(watchlist, cb => {
|
||||
|
||||
{ // abort if blacklisted
|
||||
@ -504,7 +510,7 @@ let encodeShader = function(fileName, varname, opt){
|
||||
//console.log(fname);
|
||||
|
||||
let content = new Buffer(b).toString();
|
||||
|
||||
|
||||
let prep = `\Shaders["${fname}"] = \`${content}\`\n`;
|
||||
|
||||
joinedContent += prep;
|
||||
|
||||
@ -22,19 +22,28 @@ function readAs(buf, Type, offset, count) {
|
||||
}
|
||||
|
||||
function parseLASHeader(arraybuffer) {
|
||||
var o = {};
|
||||
var o = { };
|
||||
|
||||
o.pointsOffset = readAs(arraybuffer, Uint32Array, 32*3);
|
||||
o.pointsFormatId = readAs(arraybuffer, Uint8Array, 32*3+8);
|
||||
o.pointsFormatId = readAs(arraybuffer, Uint8Array, 32*3+8) & 0x3f;
|
||||
o.pointsStructSize = readAs(arraybuffer, Uint16Array, 32*3+8+1);
|
||||
o.pointsCount = readAs(arraybuffer, Uint32Array, 32*3 + 11);
|
||||
|
||||
o.extraBytes = 0;
|
||||
|
||||
var start = 32*3 + 35;
|
||||
o.scale = readAs(arraybuffer, Float64Array, start, 3); start += 24; // 8*3
|
||||
switch (o.pointsFormatId) {
|
||||
case 0: o.extraBytes = o.pointsStructSize - 20; break;
|
||||
case 1: o.extraBytes = o.pointsStructSize - 28; break;
|
||||
case 2: o.extraBytes = o.pointsStructSize - 26; break;
|
||||
case 3: o.extraBytes = o.pointsStructSize - 34; break;
|
||||
}
|
||||
|
||||
o.pointsCount = readAs(arraybuffer, Uint32Array, 32 * 3 + 11);
|
||||
|
||||
var start = 32 * 3 + 35;
|
||||
o.scale = readAs(arraybuffer, Float64Array, start, 3); start += 24;
|
||||
o.offset = readAs(arraybuffer, Float64Array, start, 3); start += 24;
|
||||
|
||||
var bounds = readAs(arraybuffer, Float64Array, start, 6); start += 48; // 8*6;
|
||||
var bounds = readAs(arraybuffer, Float64Array, start, 6); start += 48;
|
||||
o.maxs = [bounds[0], bounds[2], bounds[4]];
|
||||
o.mins = [bounds[1], bounds[3], bounds[5]];
|
||||
|
||||
@ -65,9 +74,8 @@ function handleEvent(msg) {
|
||||
|
||||
case "header":
|
||||
if (!instance)
|
||||
throw new Error("You need to open the file before trying to read header");
|
||||
|
||||
|
||||
throw new Error(
|
||||
"You need to open the file before reading the header");
|
||||
|
||||
var header = parseLASHeader(instance.arraybuffer);
|
||||
header.pointsFormatId &= 0x3f;
|
||||
@ -77,31 +85,45 @@ function handleEvent(msg) {
|
||||
|
||||
case "read":
|
||||
if (!instance)
|
||||
throw new Error("You need to open the file before trying to read stuff");
|
||||
throw new Error(
|
||||
"You need to open the file before trying to read");
|
||||
|
||||
var start = msg.start, count = msg.count, skip = msg.skip;
|
||||
var o = instance;
|
||||
|
||||
if (!o.header)
|
||||
throw new Error("You need to query header before reading, I maintain state that way, sorry :(");
|
||||
throw new Error(
|
||||
"You need to query header before reading");
|
||||
|
||||
var pointsToRead = Math.min(count * skip, o.header.pointsCount - o.readOffset);
|
||||
let h = o.header;
|
||||
|
||||
var pointsToRead = Math.min(
|
||||
count * skip, h.pointsCount - o.readOffset);
|
||||
var bufferSize = Math.ceil(pointsToRead / skip);
|
||||
var pointsRead = 0;
|
||||
|
||||
let buffer = new ArrayBuffer(bufferSize * o.header.pointsStructSize);
|
||||
let buffer = new ArrayBuffer(bufferSize * h.pointsStructSize);
|
||||
let this_buf = new Uint8Array(buffer);
|
||||
var buf_read = Module._malloc(o.header.pointsStructSize);
|
||||
var buf_read = Module._malloc(h.pointsStructSize);
|
||||
|
||||
for (var i = 0 ; i < pointsToRead ; i ++) {
|
||||
o.getPoint(buf_read);
|
||||
|
||||
if (i % skip === 0) {
|
||||
var a = new Uint8Array(Module.HEAPU8.buffer, buf_read, o.header.pointsStructSize);
|
||||
this_buf.set(a, pointsRead * o.header.pointsStructSize, o.header.pointsStructSize);
|
||||
pointsRead ++;
|
||||
var a = new Uint8Array(
|
||||
Module.HEAPU8.buffer,
|
||||
buf_read,
|
||||
h.pointsStructSize);
|
||||
|
||||
this_buf.set(
|
||||
a,
|
||||
pointsRead * h.pointsStructSize,
|
||||
h.pointsStructSize);
|
||||
|
||||
++pointsRead;
|
||||
}
|
||||
|
||||
o.readOffset ++;
|
||||
++o.readOffset;
|
||||
}
|
||||
Module._free(buf_read);
|
||||
|
||||
@ -117,7 +139,6 @@ function handleEvent(msg) {
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case "close":
|
||||
if (instance !== null) {
|
||||
Module._free(instance.buf);
|
||||
@ -126,7 +147,7 @@ function handleEvent(msg) {
|
||||
}else{
|
||||
debugger;
|
||||
}
|
||||
|
||||
|
||||
postMessage({ type: "close", status: 1});
|
||||
break;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
1241
package-lock.json
generated
1241
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
7
pointclouds/lion_takanawa_ept_bin/ept-build.json
Normal file
7
pointclouds/lion_takanawa_ept_bin/ept-build.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"overflowDepth" : 0,
|
||||
"overflowThreshold" : 32768,
|
||||
"software" : "Entwine",
|
||||
"trustHeaders" : true,
|
||||
"version" : "2.0.0"
|
||||
}
|
||||
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/0-0-0-0.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/0-0-0-0.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-0-0.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-0-0.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-0-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-0-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-1-0.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-1-0.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-1-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-0-1-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-0-0.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-0-0.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-0-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-0-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-1-0.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/1-1-1-0.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-1-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-1-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-1-2.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-1-2.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-2-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-0-2-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-0-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-0-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-1-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-1-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-1-2.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-1-2.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-2-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-2-1.bin
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-3-1.bin
Normal file
BIN
pointclouds/lion_takanawa_ept_bin/ept-data/2-1-3-1.bin
Normal file
Binary file not shown.
18
pointclouds/lion_takanawa_ept_bin/ept-hierarchy/0-0-0-0.json
Normal file
18
pointclouds/lion_takanawa_ept_bin/ept-hierarchy/0-0-0-0.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"0-0-0-0" : 35091,
|
||||
"1-0-0-0" : 28672,
|
||||
"1-0-0-1" : 24212,
|
||||
"1-0-1-0" : 21577,
|
||||
"1-0-1-1" : 33380,
|
||||
"1-1-0-0" : 25549,
|
||||
"1-1-0-1" : 444,
|
||||
"1-1-1-0" : 42454,
|
||||
"2-0-1-1" : 548,
|
||||
"2-0-1-2" : 774,
|
||||
"2-0-2-1" : 1864,
|
||||
"2-1-0-1" : 531,
|
||||
"2-1-1-1" : 50549,
|
||||
"2-1-1-2" : 42267,
|
||||
"2-1-2-1" : 33788,
|
||||
"2-1-3-1" : 289
|
||||
}
|
||||
7102
pointclouds/lion_takanawa_ept_bin/ept-sources/0.json
Normal file
7102
pointclouds/lion_takanawa_ept_bin/ept-sources/0.json
Normal file
File diff suppressed because it is too large
Load Diff
7102
pointclouds/lion_takanawa_ept_bin/ept-sources/100.json
Normal file
7102
pointclouds/lion_takanawa_ept_bin/ept-sources/100.json
Normal file
File diff suppressed because it is too large
Load Diff
3402
pointclouds/lion_takanawa_ept_bin/ept-sources/list.json
Normal file
3402
pointclouds/lion_takanawa_ept_bin/ept-sources/list.json
Normal file
File diff suppressed because it is too large
Load Diff
117
pointclouds/lion_takanawa_ept_bin/ept.json
Normal file
117
pointclouds/lion_takanawa_ept_bin/ept.json
Normal file
@ -0,0 +1,117 @@
|
||||
{
|
||||
"bounds" :
|
||||
[
|
||||
-7,
|
||||
-1,
|
||||
-6,
|
||||
3,
|
||||
9,
|
||||
4
|
||||
],
|
||||
"boundsConforming" :
|
||||
[
|
||||
-5,
|
||||
1,
|
||||
-4,
|
||||
1,
|
||||
7,
|
||||
3
|
||||
],
|
||||
"dataType" : "binary",
|
||||
"hierarchyType" : "json",
|
||||
"points" : 341989,
|
||||
"schema" :
|
||||
[
|
||||
{
|
||||
"name" : "X",
|
||||
"offset" : -2,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Y",
|
||||
"offset" : 4,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Z",
|
||||
"offset" : -1,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Intensity",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ReturnNumber",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "NumberOfReturns",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ScanDirectionFlag",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "EdgeOfFlightLine",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Classification",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ScanAngleRank",
|
||||
"size" : 4,
|
||||
"type" : "float"
|
||||
},
|
||||
{
|
||||
"name" : "UserData",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "PointSourceId",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Red",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Green",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Blue",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "OriginId",
|
||||
"size" : 4,
|
||||
"type" : "unsigned"
|
||||
}
|
||||
],
|
||||
"srs" :
|
||||
{
|
||||
},
|
||||
"ticks" : 256,
|
||||
"version" : "0.0.0"
|
||||
}
|
||||
7
pointclouds/lion_takanawa_ept_laz/ept-build.json
Normal file
7
pointclouds/lion_takanawa_ept_laz/ept-build.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"overflowDepth" : 0,
|
||||
"overflowThreshold" : 32768,
|
||||
"software" : "Entwine",
|
||||
"trustHeaders" : true,
|
||||
"version" : "2.0.0"
|
||||
}
|
||||
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/0-0-0-0.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/0-0-0-0.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-0-0.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-0-0.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-0-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-0-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-1-0.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-1-0.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-1-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-0-1-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-0-0.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-0-0.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-0-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-0-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-1-0.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/1-1-1-0.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-1-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-1-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-1-2.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-1-2.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-2-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-0-2-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-0-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-0-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-1-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-1-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-1-2.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-1-2.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-2-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-2-1.laz
Normal file
Binary file not shown.
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-3-1.laz
Normal file
BIN
pointclouds/lion_takanawa_ept_laz/ept-data/2-1-3-1.laz
Normal file
Binary file not shown.
18
pointclouds/lion_takanawa_ept_laz/ept-hierarchy/0-0-0-0.json
Normal file
18
pointclouds/lion_takanawa_ept_laz/ept-hierarchy/0-0-0-0.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"0-0-0-0" : 35091,
|
||||
"1-0-0-0" : 28672,
|
||||
"1-0-0-1" : 24212,
|
||||
"1-0-1-0" : 21577,
|
||||
"1-0-1-1" : 33380,
|
||||
"1-1-0-0" : 25549,
|
||||
"1-1-0-1" : 444,
|
||||
"1-1-1-0" : 42454,
|
||||
"2-0-1-1" : 548,
|
||||
"2-0-1-2" : 774,
|
||||
"2-0-2-1" : 1864,
|
||||
"2-1-0-1" : 531,
|
||||
"2-1-1-1" : 50549,
|
||||
"2-1-1-2" : 42267,
|
||||
"2-1-2-1" : 33788,
|
||||
"2-1-3-1" : 289
|
||||
}
|
||||
7102
pointclouds/lion_takanawa_ept_laz/ept-sources/0.json
Normal file
7102
pointclouds/lion_takanawa_ept_laz/ept-sources/0.json
Normal file
File diff suppressed because it is too large
Load Diff
7102
pointclouds/lion_takanawa_ept_laz/ept-sources/100.json
Normal file
7102
pointclouds/lion_takanawa_ept_laz/ept-sources/100.json
Normal file
File diff suppressed because it is too large
Load Diff
3402
pointclouds/lion_takanawa_ept_laz/ept-sources/list.json
Normal file
3402
pointclouds/lion_takanawa_ept_laz/ept-sources/list.json
Normal file
File diff suppressed because it is too large
Load Diff
117
pointclouds/lion_takanawa_ept_laz/ept.json
Normal file
117
pointclouds/lion_takanawa_ept_laz/ept.json
Normal file
@ -0,0 +1,117 @@
|
||||
{
|
||||
"bounds" :
|
||||
[
|
||||
-7,
|
||||
-1,
|
||||
-6,
|
||||
3,
|
||||
9,
|
||||
4
|
||||
],
|
||||
"boundsConforming" :
|
||||
[
|
||||
-5,
|
||||
1,
|
||||
-4,
|
||||
1,
|
||||
7,
|
||||
3
|
||||
],
|
||||
"dataType" : "laszip",
|
||||
"hierarchyType" : "json",
|
||||
"points" : 341989,
|
||||
"schema" :
|
||||
[
|
||||
{
|
||||
"name" : "X",
|
||||
"offset" : -2,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Y",
|
||||
"offset" : 4,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Z",
|
||||
"offset" : -1,
|
||||
"scale" : 0.001,
|
||||
"size" : 4,
|
||||
"type" : "signed"
|
||||
},
|
||||
{
|
||||
"name" : "Intensity",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ReturnNumber",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "NumberOfReturns",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ScanDirectionFlag",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "EdgeOfFlightLine",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Classification",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "ScanAngleRank",
|
||||
"size" : 4,
|
||||
"type" : "float"
|
||||
},
|
||||
{
|
||||
"name" : "UserData",
|
||||
"size" : 1,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "PointSourceId",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Red",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Green",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "Blue",
|
||||
"size" : 2,
|
||||
"type" : "unsigned"
|
||||
},
|
||||
{
|
||||
"name" : "OriginId",
|
||||
"size" : 4,
|
||||
"type" : "unsigned"
|
||||
}
|
||||
],
|
||||
"srs" :
|
||||
{
|
||||
},
|
||||
"ticks" : 256,
|
||||
"version" : "0.0.0"
|
||||
}
|
||||
304
src/PointCloudEptGeometry.js
Normal file
304
src/PointCloudEptGeometry.js
Normal file
@ -0,0 +1,304 @@
|
||||
import {PointCloudTreeNode} from "./PointCloudTree.js";
|
||||
|
||||
class U {
|
||||
static toVector3(v, offset) {
|
||||
return new THREE.Vector3().fromArray(v, offset || 0);
|
||||
}
|
||||
|
||||
static toBox3(b) {
|
||||
return new THREE.Box3(U.toVector3(b), U.toVector3(b, 3));
|
||||
};
|
||||
|
||||
static findDim(schema, name) {
|
||||
var dim = schema.find((dim) => dim.name == name);
|
||||
if (!dim) throw new Error('Failed to find ' + name + ' in schema');
|
||||
return dim;
|
||||
}
|
||||
|
||||
static sphereFrom(b) {
|
||||
return b.getBoundingSphere(new THREE.Sphere());
|
||||
}
|
||||
};
|
||||
|
||||
export class PointCloudEptGeometry {
|
||||
constructor(url, info) {
|
||||
let version = info.version;
|
||||
let schema = info.schema;
|
||||
let bounds = info.bounds;
|
||||
let boundsConforming = info.boundsConforming;
|
||||
|
||||
let xyz = [
|
||||
U.findDim(schema, 'X'),
|
||||
U.findDim(schema, 'Y'),
|
||||
U.findDim(schema, 'Z')
|
||||
];
|
||||
let scale = xyz.map((d) => d.scale || 1);
|
||||
let offset = xyz.map((d) => d.offset || 0);
|
||||
this.eptScale = U.toVector3(scale);
|
||||
this.eptOffset = U.toVector3(offset);
|
||||
|
||||
this.url = url;
|
||||
this.info = info;
|
||||
this.type = 'ept';
|
||||
|
||||
this.schema = schema;
|
||||
this.ticks = info.ticks;
|
||||
this.boundingBox = U.toBox3(bounds);
|
||||
this.tightBoundingBox = U.toBox3(boundsConforming);
|
||||
this.offset = U.toVector3([0, 0, 0]);
|
||||
this.boundingSphere = U.sphereFrom(this.boundingBox);
|
||||
this.tightBoundingSphere = U.sphereFrom(this.tightBoundingBox);
|
||||
this.version = new Potree.Version('1.6');
|
||||
|
||||
this.projection = null;
|
||||
this.fallbackProjection = null;
|
||||
|
||||
if (info.srs && info.srs.horizontal) {
|
||||
this.projection = info.srs.authority + ':' + info.srs.horizontal;
|
||||
}
|
||||
|
||||
if (info.srs.wkt) {
|
||||
if (!this.projection) this.projection = info.srs.wkt;
|
||||
else this.fallbackProjection = info.srs.wkt;
|
||||
}
|
||||
|
||||
this.pointAttributes = 'LAZ';
|
||||
this.spacing =
|
||||
(this.boundingBox.max.x - this.boundingBox.min.x) / this.ticks;
|
||||
|
||||
let hierarchyType = info.hierarchyType || 'json';
|
||||
|
||||
let dataType = info.dataType || 'laszip';
|
||||
this.loader = dataType == 'binary'
|
||||
? new Potree.EptBinaryLoader()
|
||||
: new Potree.EptLaszipLoader();
|
||||
}
|
||||
};
|
||||
|
||||
export class EptKey {
|
||||
constructor(ept, b, d, x, y, z) {
|
||||
this.ept = ept;
|
||||
this.b = b;
|
||||
this.d = d;
|
||||
this.x = x || 0;
|
||||
this.y = y || 0;
|
||||
this.z = z || 0;
|
||||
}
|
||||
|
||||
name() {
|
||||
return this.d + '-' + this.x + '-' + this.y + '-' + this.z;
|
||||
}
|
||||
|
||||
step(a, b, c) {
|
||||
let min = this.b.min.clone();
|
||||
let max = this.b.max.clone();
|
||||
let dst = new THREE.Vector3().subVectors(max, min);
|
||||
|
||||
if (a) min.x += dst.x / 2;
|
||||
else max.x -= dst.x / 2;
|
||||
|
||||
if (b) min.y += dst.y / 2;
|
||||
else max.y -= dst.y / 2;
|
||||
|
||||
if (c) min.z += dst.z / 2;
|
||||
else max.z -= dst.z / 2;
|
||||
|
||||
return new Potree.EptKey(
|
||||
this.ept,
|
||||
new THREE.Box3(min, max),
|
||||
this.d + 1,
|
||||
this.x * 2 + a,
|
||||
this.y * 2 + b,
|
||||
this.z * 2 + c);
|
||||
}
|
||||
|
||||
children() {
|
||||
var result = [];
|
||||
for (var a = 0; a < 2; ++a) {
|
||||
for (var b = 0; b < 2; ++b) {
|
||||
for (var c = 0; c < 2; ++c) {
|
||||
var add = this.step(a, b, c).name();
|
||||
if (!result.includes(add)) result = result.concat(add);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export class PointCloudEptGeometryNode extends PointCloudTreeNode {
|
||||
constructor(ept, b, d, x, y, z) {
|
||||
super();
|
||||
|
||||
this.ept = ept;
|
||||
this.key = new Potree.EptKey(
|
||||
this.ept,
|
||||
b || this.ept.boundingBox,
|
||||
d || 0,
|
||||
x,
|
||||
y,
|
||||
z);
|
||||
|
||||
this.id = PointCloudEptGeometryNode.IDCount++;
|
||||
this.geometry = null;
|
||||
this.boundingBox = this.key.b;
|
||||
this.tightBoundingBox = this.boundingBox;
|
||||
this.spacing = this.ept.spacing / Math.pow(2, this.key.d);
|
||||
this.boundingSphere = U.sphereFrom(this.boundingBox);
|
||||
|
||||
// These are set during hierarchy loading.
|
||||
this.hasChildren = false;
|
||||
this.children = { };
|
||||
this.numPoints = -1;
|
||||
|
||||
this.level = this.key.d;
|
||||
this.loaded = false;
|
||||
this.loading = false;
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
|
||||
let k = this.key;
|
||||
this.name = this.toPotreeName(k.d, k.x, k.y, k.z);
|
||||
this.index = parseInt(this.name.charAt(this.name.length - 1));
|
||||
}
|
||||
|
||||
isGeometryNode() { return true; }
|
||||
getLevel() { return this.level; }
|
||||
isTreeNode() { return false; }
|
||||
isLoaded() { return this.loaded; }
|
||||
getBoundingSphere() { return this.boundingSphere; }
|
||||
getBoundingBox() { return this.boundingBox; }
|
||||
url() { return this.ept.url + 'ept-data/' + this.filename(); }
|
||||
getNumPoints() { return this.numPoints; }
|
||||
|
||||
filename() { return this.key.name(); }
|
||||
|
||||
getChildren() {
|
||||
let children = [];
|
||||
|
||||
for (let i = 0; i < 8; i++) {
|
||||
if (this.children[i]) {
|
||||
children.push(this.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
addChild(child) {
|
||||
this.children[child.index] = child;
|
||||
child.parent = this;
|
||||
}
|
||||
|
||||
load() {
|
||||
if (this.loaded || this.loading) return;
|
||||
if (Potree.numNodesLoading >= Potree.maxNodesLoading) return;
|
||||
|
||||
this.loading = true;
|
||||
++Potree.numNodesLoading;
|
||||
|
||||
if (this.numPoints == -1) this.loadHierarchy();
|
||||
this.loadPoints();
|
||||
}
|
||||
|
||||
loadPoints(){
|
||||
this.ept.loader.load(this);
|
||||
}
|
||||
|
||||
async loadHierarchy() {
|
||||
let nodes = { };
|
||||
nodes[this.filename()] = this;
|
||||
this.hasChildren = false;
|
||||
|
||||
let eptHierarchyFile =
|
||||
`${this.ept.url}ept-hierarchy/${this.filename()}.json`;
|
||||
|
||||
let response = await fetch(eptHierarchyFile);
|
||||
let hier = await response.json();
|
||||
|
||||
// Since we want to traverse top-down, and 10 comes
|
||||
// lexicographically before 9 (for example), do a deep sort.
|
||||
var keys = Object.keys(hier).sort((a, b) => {
|
||||
let [da, xa, ya, za] = a.split('-').map((n) => parseInt(n, 10));
|
||||
let [db, xb, yb, zb] = b.split('-').map((n) => parseInt(n, 10));
|
||||
if (da < db) return -1; if (da > db) return 1;
|
||||
if (xa < xb) return -1; if (xa > xb) return 1;
|
||||
if (ya < yb) return -1; if (ya > yb) return 1;
|
||||
if (za < zb) return -1; if (za > zb) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
keys.forEach((v) => {
|
||||
let [d, x, y, z] = v.split('-').map((n) => parseInt(n, 10));
|
||||
let a = x & 1, b = y & 1, c = z & 1;
|
||||
let parentName =
|
||||
(d - 1) + '-' + (x >> 1) + '-' + (y >> 1) + '-' + (z >> 1);
|
||||
|
||||
let parentNode = nodes[parentName];
|
||||
if (!parentNode) return;
|
||||
parentNode.hasChildren = true;
|
||||
|
||||
let key = parentNode.key.step(a, b, c);
|
||||
|
||||
let node = new Potree.PointCloudEptGeometryNode(
|
||||
this.ept,
|
||||
key.b,
|
||||
key.d,
|
||||
key.x,
|
||||
key.y,
|
||||
key.z);
|
||||
|
||||
node.level = d;
|
||||
node.numPoints = hier[v];
|
||||
|
||||
parentNode.addChild(node);
|
||||
nodes[key.name()] = node;
|
||||
});
|
||||
}
|
||||
|
||||
doneLoading(bufferGeometry, tightBoundingBox, np, mean) {
|
||||
bufferGeometry.boundingBox = this.boundingBox;
|
||||
this.geometry = bufferGeometry;
|
||||
this.tightBoundingBox = tightBoundingBox;
|
||||
this.numPoints = np;
|
||||
this.mean = mean;
|
||||
this.loaded = true;
|
||||
this.loading = false;
|
||||
--Potree.numNodesLoading;
|
||||
}
|
||||
|
||||
toPotreeName(d, x, y, z) {
|
||||
var name = 'r';
|
||||
|
||||
for (var i = 0; i < d; ++i) {
|
||||
var shift = d - i - 1;
|
||||
var mask = 1 << shift;
|
||||
var step = 0;
|
||||
|
||||
if (x & mask) step += 4;
|
||||
if (y & mask) step += 2;
|
||||
if (z & mask) step += 1;
|
||||
|
||||
name += step;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
dispose() {
|
||||
if (this.geometry && this.parent != null) {
|
||||
this.geometry.dispose();
|
||||
this.geometry = null;
|
||||
this.loaded = false;
|
||||
|
||||
// this.dispatchEvent( { type: 'dispose' } );
|
||||
for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
|
||||
let handler = this.oneTimeDisposeHandlers[i];
|
||||
handler();
|
||||
}
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PointCloudEptGeometryNode.IDCount = 0;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
|
||||
import {PointCloudTreeNode} from "./PointCloudTree.js";
|
||||
|
||||
export class PointCloudGreyhoundGeometry{
|
||||
|
||||
@ -25,3 +25,291 @@ export class PointCloudGreyhoundGeometry{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export class PointCloudGreyhoundGeometryNode extends PointCloudTreeNode {
|
||||
constructor(name, pcoGeometry, boundingBox, scale, offset) {
|
||||
super();
|
||||
|
||||
this.id = Potree.PointCloudGreyhoundGeometryNode.IDCount++;
|
||||
this.name = name;
|
||||
this.index = parseInt(name.charAt(name.length - 1));
|
||||
this.pcoGeometry = pcoGeometry;
|
||||
this.geometry = null;
|
||||
this.boundingBox = boundingBox;
|
||||
this.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
|
||||
this.scale = scale;
|
||||
this.offset = offset;
|
||||
this.children = {};
|
||||
this.numPoints = 0;
|
||||
this.level = null;
|
||||
this.loaded = false;
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
this.baseLoaded = false;
|
||||
|
||||
let bounds = this.boundingBox.clone();
|
||||
bounds.min.sub(this.pcoGeometry.boundingBox.getCenter());
|
||||
bounds.max.sub(this.pcoGeometry.boundingBox.getCenter());
|
||||
|
||||
if (this.scale) {
|
||||
bounds.min.multiplyScalar(1 / this.scale);
|
||||
bounds.max.multiplyScalar(1 / this.scale);
|
||||
}
|
||||
|
||||
// This represents the bounds for this node in the reference frame of the
|
||||
// global bounds from `info`, centered around the origin, and then scaled
|
||||
// by our selected scale.
|
||||
this.greyhoundBounds = bounds;
|
||||
|
||||
// This represents the offset between the coordinate system described above
|
||||
// and our pcoGeometry bounds.
|
||||
this.greyhoundOffset = this.pcoGeometry.offset.clone().add(
|
||||
this.pcoGeometry.boundingBox.getSize().multiplyScalar(0.5)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
isGeometryNode() { return true; }
|
||||
isTreeNode() { return false; }
|
||||
isLoaded() { return this.loaded; }
|
||||
getBoundingSphere() { return this.boundingSphere; }
|
||||
getBoundingBox() { return this.boundingBox; }
|
||||
getLevel() { return this.level; };
|
||||
getChildren() {
|
||||
let children = [];
|
||||
|
||||
for (let i = 0; i < 8; ++i) {
|
||||
if (this.children[i]) {
|
||||
children.push(this.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
getURL() {
|
||||
let schema = this.pcoGeometry.schema;
|
||||
let bounds = this.greyhoundBounds;
|
||||
|
||||
let boundsString =
|
||||
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
|
||||
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
|
||||
|
||||
let url = '' + this.pcoGeometry.serverURL +
|
||||
'read?depthBegin=' +
|
||||
(this.baseLoaded ?
|
||||
(this.level + this.pcoGeometry.baseDepth) : 0) +
|
||||
'&depthEnd=' + (this.level + this.pcoGeometry.baseDepth + 1) +
|
||||
'&bounds=[' + boundsString + ']' +
|
||||
'&schema=' + JSON.stringify(schema) +
|
||||
'&compress=true';
|
||||
|
||||
if (this.scale) {
|
||||
url += '&scale=' + this.scale;
|
||||
}
|
||||
|
||||
if (this.greyhoundOffset) {
|
||||
let offset = this.greyhoundOffset;
|
||||
url += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']';
|
||||
}
|
||||
|
||||
if (!this.baseLoaded) this.baseLoaded = true;
|
||||
|
||||
return url;
|
||||
};
|
||||
|
||||
addChild(child) {
|
||||
this.children[child.index] = child;
|
||||
child.parent = this;
|
||||
};
|
||||
|
||||
load() {
|
||||
if (
|
||||
this.loading === true ||
|
||||
this.loaded === true ||
|
||||
Potree.numNodesLoading >= Potree.maxNodesLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
Potree.numNodesLoading++;
|
||||
|
||||
if (
|
||||
this.level % this.pcoGeometry.hierarchyStepSize === 0 &&
|
||||
this.hasChildren) {
|
||||
this.loadHierarchyThenPoints();
|
||||
} else {
|
||||
this.loadPoints();
|
||||
}
|
||||
}
|
||||
|
||||
loadPoints() { this.pcoGeometry.loader.load(this); };
|
||||
|
||||
loadHierarchyThenPoints() {
|
||||
// From Greyhound (Cartesian) ordering for the octree to Potree-default
|
||||
let transform = [0, 2, 1, 3, 4, 6, 5, 7];
|
||||
|
||||
let makeBitMask = function (node) {
|
||||
let mask = 0;
|
||||
Object.keys(node).forEach(function (key) {
|
||||
if (key === 'swd') mask += 1 << transform[0];
|
||||
else if (key === 'nwd') mask += 1 << transform[1];
|
||||
else if (key === 'swu') mask += 1 << transform[2];
|
||||
else if (key === 'nwu') mask += 1 << transform[3];
|
||||
else if (key === 'sed') mask += 1 << transform[4];
|
||||
else if (key === 'ned') mask += 1 << transform[5];
|
||||
else if (key === 'seu') mask += 1 << transform[6];
|
||||
else if (key === 'neu') mask += 1 << transform[7];
|
||||
});
|
||||
return mask;
|
||||
};
|
||||
|
||||
let parseChildrenCounts = function (base, parentName, stack) {
|
||||
let keys = Object.keys(base);
|
||||
let child;
|
||||
let childName;
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (key === 'n') return;
|
||||
switch (key) {
|
||||
case 'swd':
|
||||
child = base.swd; childName = parentName + transform[0];
|
||||
break;
|
||||
case 'nwd':
|
||||
child = base.nwd; childName = parentName + transform[1];
|
||||
break;
|
||||
case 'swu':
|
||||
child = base.swu; childName = parentName + transform[2];
|
||||
break;
|
||||
case 'nwu':
|
||||
child = base.nwu; childName = parentName + transform[3];
|
||||
break;
|
||||
case 'sed':
|
||||
child = base.sed; childName = parentName + transform[4];
|
||||
break;
|
||||
case 'ned':
|
||||
child = base.ned; childName = parentName + transform[5];
|
||||
break;
|
||||
case 'seu':
|
||||
child = base.seu; childName = parentName + transform[6];
|
||||
break;
|
||||
case 'neu':
|
||||
child = base.neu; childName = parentName + transform[7];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
stack.push({
|
||||
children: makeBitMask(child),
|
||||
numPoints: child.n,
|
||||
name: childName
|
||||
});
|
||||
|
||||
parseChildrenCounts(child, childName, stack);
|
||||
});
|
||||
};
|
||||
|
||||
// Load hierarchy.
|
||||
let callback = function (node, greyhoundHierarchy) {
|
||||
let decoded = [];
|
||||
node.numPoints = greyhoundHierarchy.n;
|
||||
parseChildrenCounts(greyhoundHierarchy, node.name, decoded);
|
||||
|
||||
let nodes = {};
|
||||
nodes[node.name] = node;
|
||||
let pgg = node.pcoGeometry;
|
||||
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
let name = decoded[i].name;
|
||||
let numPoints = decoded[i].numPoints;
|
||||
let index = parseInt(name.charAt(name.length - 1));
|
||||
let parentName = name.substring(0, name.length - 1);
|
||||
let parentNode = nodes[parentName];
|
||||
let level = name.length - 1;
|
||||
let boundingBox = Potree.GreyhoundLoader.createChildAABB(
|
||||
parentNode.boundingBox, index);
|
||||
|
||||
let currentNode = new Potree.PointCloudGreyhoundGeometryNode(
|
||||
name, pgg, boundingBox, node.scale, node.offset);
|
||||
|
||||
currentNode.level = level;
|
||||
currentNode.numPoints = numPoints;
|
||||
currentNode.hasChildren = decoded[i].children > 0;
|
||||
currentNode.spacing = pgg.spacing / Math.pow(2, level);
|
||||
parentNode.addChild(currentNode);
|
||||
nodes[name] = currentNode;
|
||||
}
|
||||
|
||||
node.loadPoints();
|
||||
};
|
||||
|
||||
if (this.level % this.pcoGeometry.hierarchyStepSize === 0) {
|
||||
let depthBegin = this.level + this.pcoGeometry.baseDepth;
|
||||
let depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2;
|
||||
|
||||
let bounds = this.greyhoundBounds;
|
||||
|
||||
let boundsString =
|
||||
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
|
||||
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
|
||||
|
||||
let hurl = '' + this.pcoGeometry.serverURL +
|
||||
'hierarchy?bounds=[' + boundsString + ']' +
|
||||
'&depthBegin=' + depthBegin +
|
||||
'&depthEnd=' + depthEnd;
|
||||
|
||||
if (this.scale) {
|
||||
hurl += '&scale=' + this.scale;
|
||||
}
|
||||
|
||||
if (this.greyhoundOffset) {
|
||||
let offset = this.greyhoundOffset;
|
||||
hurl += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']';
|
||||
}
|
||||
|
||||
let xhr = Potree.XHRFactory.createXMLHttpRequest();
|
||||
xhr.open('GET', hurl, true);
|
||||
|
||||
let that = this;
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200 || xhr.status === 0) {
|
||||
let greyhoundHierarchy = JSON.parse(xhr.responseText) || { };
|
||||
callback(that, greyhoundHierarchy);
|
||||
} else {
|
||||
console.log(
|
||||
'Failed to load file! HTTP status:', xhr.status,
|
||||
'file:', hurl
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
xhr.send(null);
|
||||
} catch (e) {
|
||||
console.log('fehler beim laden der punktwolke: ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getNumPoints() { return this.numPoints; };
|
||||
|
||||
dispose() {
|
||||
if (this.geometry && this.parent != null) {
|
||||
this.geometry.dispose();
|
||||
this.geometry = null;
|
||||
this.loaded = false;
|
||||
|
||||
// this.dispatchEvent( { type: 'dispose' } );
|
||||
for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
|
||||
let handler = this.oneTimeDisposeHandlers[i];
|
||||
handler();
|
||||
}
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PointCloudGreyhoundGeometryNode.IDCount = 0;
|
||||
|
||||
|
||||
@ -1,315 +0,0 @@
|
||||
|
||||
|
||||
import { EventDispatcher } from "./EventDispatcher";
|
||||
import { PointCloudTreeNode } from "./PointCloudTree";
|
||||
|
||||
|
||||
export class PointCloudGreyhoundGeometryNode extends PointCloudTreeNode{
|
||||
|
||||
constructor(name, pcoGeometry, boundingBox, scale, offset){
|
||||
|
||||
this.id = PointCloudGreyhoundGeometryNode.IDCount++;
|
||||
|
||||
this.name = name;
|
||||
this.index = parseInt(name.charAt(name.length - 1));
|
||||
this.pcoGeometry = pcoGeometry;
|
||||
this.geometry = null;
|
||||
this.boundingBox = boundingBox;
|
||||
this.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
|
||||
this.scale = scale;
|
||||
this.offset = offset;
|
||||
this.children = {};
|
||||
this.numPoints = 0;
|
||||
this.level = null;
|
||||
this.loaded = false;
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
this.baseLoaded = false;
|
||||
|
||||
let bounds = this.boundingBox.clone();
|
||||
bounds.min.sub(this.pcoGeometry.boundingBox.getCenter(new THREE.Vector3()));
|
||||
bounds.max.sub(this.pcoGeometry.boundingBox.getCenter(new THREE.Vector3()));
|
||||
|
||||
if (this.scale) {
|
||||
bounds.min.multiplyScalar(1 / this.scale);
|
||||
bounds.max.multiplyScalar(1 / this.scale);
|
||||
}
|
||||
|
||||
// This represents the bounds for this node in the reference frame of the
|
||||
// global bounds from `info`, centered around the origin, and then scaled
|
||||
// by our selected scale.
|
||||
this.greyhoundBounds = bounds;
|
||||
|
||||
// This represents the offset between the coordinate system described above
|
||||
// and our pcoGeometry bounds.
|
||||
this.greyhoundOffset = this.pcoGeometry.offset.clone().add(
|
||||
this.pcoGeometry.boundingBox.getSize(new THREE.Vector3()).multiplyScalar(0.5)
|
||||
);
|
||||
}
|
||||
|
||||
isGeometryNode(){
|
||||
return true;
|
||||
}
|
||||
|
||||
isTreeNode(){
|
||||
return false;
|
||||
}
|
||||
|
||||
isLoaded(){
|
||||
return this.loaded;
|
||||
}
|
||||
|
||||
getBoundingSphere(){
|
||||
return this.boundingSphere;
|
||||
}
|
||||
|
||||
getBoundingBox(){
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
getLevel(){
|
||||
return this.level;
|
||||
}
|
||||
|
||||
getChildren(){
|
||||
let children = [];
|
||||
|
||||
for (let i = 0; i < 8; ++i) {
|
||||
if (this.children[i]) {
|
||||
children.push(this.children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
getURL(){
|
||||
let schema = this.pcoGeometry.schema;
|
||||
let bounds = this.greyhoundBounds;
|
||||
|
||||
let boundsString =
|
||||
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
|
||||
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
|
||||
|
||||
let url = '' + this.pcoGeometry.serverURL +
|
||||
'read?depthBegin=' +
|
||||
(this.baseLoaded ? (this.level + this.pcoGeometry.baseDepth) : 0) +
|
||||
'&depthEnd=' + (this.level + this.pcoGeometry.baseDepth + 1) +
|
||||
'&bounds=[' + boundsString + ']' +
|
||||
'&schema=' + JSON.stringify(schema) +
|
||||
'&compress=true';
|
||||
|
||||
if (this.scale) {
|
||||
url += '&scale=' + this.scale;
|
||||
}
|
||||
|
||||
if (this.greyhoundOffset) {
|
||||
let offset = this.greyhoundOffset;
|
||||
url += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']';
|
||||
}
|
||||
|
||||
if (!this.baseLoaded) this.baseLoaded = true;
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
addChild(child){
|
||||
this.children[child.index] = child;
|
||||
child.parent = this;
|
||||
}
|
||||
|
||||
load(){
|
||||
if (
|
||||
this.loading === true ||
|
||||
this.loaded === true ||
|
||||
Potree.numNodesLoading >= Potree.maxNodesLoading) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
Potree.numNodesLoading++;
|
||||
|
||||
if (
|
||||
this.level % this.pcoGeometry.hierarchyStepSize === 0 &&
|
||||
this.hasChildren) {
|
||||
this.loadHierarchyThenPoints();
|
||||
} else {
|
||||
this.loadPoints();
|
||||
}
|
||||
}
|
||||
|
||||
loadPoints(){
|
||||
this.pcoGeometry.loader.load(this);
|
||||
}
|
||||
|
||||
loadHierarchyThenPoints(){
|
||||
// From Greyhound (Cartesian) ordering for the octree to Potree-default
|
||||
let transform = [0, 2, 1, 3, 4, 6, 5, 7];
|
||||
|
||||
let makeBitMask = function (node) {
|
||||
let mask = 0;
|
||||
Object.keys(node).forEach(function (key) {
|
||||
if (key === 'swd') mask += 1 << transform[0];
|
||||
else if (key === 'nwd') mask += 1 << transform[1];
|
||||
else if (key === 'swu') mask += 1 << transform[2];
|
||||
else if (key === 'nwu') mask += 1 << transform[3];
|
||||
else if (key === 'sed') mask += 1 << transform[4];
|
||||
else if (key === 'ned') mask += 1 << transform[5];
|
||||
else if (key === 'seu') mask += 1 << transform[6];
|
||||
else if (key === 'neu') mask += 1 << transform[7];
|
||||
});
|
||||
return mask;
|
||||
};
|
||||
|
||||
let parseChildrenCounts = function (base, parentName, stack) {
|
||||
let keys = Object.keys(base);
|
||||
let child;
|
||||
let childName;
|
||||
|
||||
keys.forEach(function (key) {
|
||||
if (key === 'n') return;
|
||||
switch (key) {
|
||||
case 'swd':
|
||||
child = base.swd; childName = parentName + transform[0];
|
||||
break;
|
||||
case 'nwd':
|
||||
child = base.nwd; childName = parentName + transform[1];
|
||||
break;
|
||||
case 'swu':
|
||||
child = base.swu; childName = parentName + transform[2];
|
||||
break;
|
||||
case 'nwu':
|
||||
child = base.nwu; childName = parentName + transform[3];
|
||||
break;
|
||||
case 'sed':
|
||||
child = base.sed; childName = parentName + transform[4];
|
||||
break;
|
||||
case 'ned':
|
||||
child = base.ned; childName = parentName + transform[5];
|
||||
break;
|
||||
case 'seu':
|
||||
child = base.seu; childName = parentName + transform[6];
|
||||
break;
|
||||
case 'neu':
|
||||
child = base.neu; childName = parentName + transform[7];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
stack.push({
|
||||
children: makeBitMask(child),
|
||||
numPoints: child.n,
|
||||
name: childName
|
||||
});
|
||||
|
||||
parseChildrenCounts(child, childName, stack);
|
||||
});
|
||||
};
|
||||
|
||||
// Load hierarchy.
|
||||
let callback = function (node, greyhoundHierarchy) {
|
||||
let decoded = [];
|
||||
node.numPoints = greyhoundHierarchy.n;
|
||||
parseChildrenCounts(greyhoundHierarchy, node.name, decoded);
|
||||
|
||||
let nodes = {};
|
||||
nodes[node.name] = node;
|
||||
let pgg = node.pcoGeometry;
|
||||
|
||||
for (let i = 0; i < decoded.length; i++) {
|
||||
let name = decoded[i].name;
|
||||
let numPoints = decoded[i].numPoints;
|
||||
let index = parseInt(name.charAt(name.length - 1));
|
||||
let parentName = name.substring(0, name.length - 1);
|
||||
let parentNode = nodes[parentName];
|
||||
let level = name.length - 1;
|
||||
let boundingBox = Potree.GreyhoundLoader.createChildAABB(
|
||||
parentNode.boundingBox, index);
|
||||
|
||||
let currentNode = new Potree.PointCloudGreyhoundGeometryNode(
|
||||
name, pgg, boundingBox, node.scale, node.offset);
|
||||
|
||||
currentNode.level = level;
|
||||
currentNode.numPoints = numPoints;
|
||||
currentNode.hasChildren = decoded[i].children > 0;
|
||||
currentNode.spacing = pgg.spacing / Math.pow(2, level);
|
||||
parentNode.addChild(currentNode);
|
||||
nodes[name] = currentNode;
|
||||
}
|
||||
|
||||
node.loadPoints();
|
||||
};
|
||||
|
||||
if (this.level % this.pcoGeometry.hierarchyStepSize === 0) {
|
||||
let depthBegin = this.level + this.pcoGeometry.baseDepth;
|
||||
let depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2;
|
||||
|
||||
let bounds = this.greyhoundBounds;
|
||||
|
||||
let boundsString =
|
||||
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
|
||||
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
|
||||
|
||||
let hurl = '' + this.pcoGeometry.serverURL +
|
||||
'hierarchy?bounds=[' + boundsString + ']' +
|
||||
'&depthBegin=' + depthBegin +
|
||||
'&depthEnd=' + depthEnd;
|
||||
|
||||
if (this.scale) {
|
||||
hurl += '&scale=' + this.scale;
|
||||
}
|
||||
|
||||
if (this.greyhoundOffset) {
|
||||
let offset = this.greyhoundOffset;
|
||||
hurl += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']';
|
||||
}
|
||||
|
||||
let xhr = Potree.XHRFactory.createXMLHttpRequest();
|
||||
xhr.open('GET', hurl, true);
|
||||
|
||||
let that = this;
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200 || xhr.status === 0) {
|
||||
let greyhoundHierarchy = JSON.parse(xhr.responseText) || { };
|
||||
callback(that, greyhoundHierarchy);
|
||||
} else {
|
||||
console.log(
|
||||
'Failed to load file! HTTP status:', xhr.status,
|
||||
'file:', hurl
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
xhr.send(null);
|
||||
} catch (e) {
|
||||
console.log('fehler beim laden der punktwolke: ' + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getNumPoints(){
|
||||
return this.numPoints;
|
||||
}
|
||||
|
||||
dispose(){
|
||||
if (this.geometry && this.parent != null) {
|
||||
this.geometry.dispose();
|
||||
this.geometry = null;
|
||||
this.loaded = false;
|
||||
|
||||
// this.dispatchEvent( { type: 'dispose' } );
|
||||
for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
|
||||
let handler = this.oneTimeDisposeHandlers[i];
|
||||
handler();
|
||||
}
|
||||
this.oneTimeDisposeHandlers = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
PointCloudGreyhoundGeometryNode.IDCount = 0;
|
||||
@ -140,6 +140,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
|
||||
// TODO read projection from file instead
|
||||
this.projection = geometry.projection;
|
||||
this.fallbackProjection = geometry.fallbackProjection;
|
||||
|
||||
this.root = this.pcoGeometry.root;
|
||||
}
|
||||
@ -272,7 +273,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
}
|
||||
|
||||
computeVisibilityTextureData(nodes, camera){
|
||||
|
||||
|
||||
if(Potree.measureTimings) performance.mark("computeVisibilityTextureData-start");
|
||||
|
||||
let data = new Uint8Array(nodes.length * 4);
|
||||
@ -352,11 +353,11 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
}
|
||||
|
||||
var a = 10;
|
||||
|
||||
|
||||
if(Potree.measureTimings){
|
||||
performance.mark("computeVisibilityTextureData-end");
|
||||
performance.measure("render.computeVisibilityTextureData", "computeVisibilityTextureData-start", "computeVisibilityTextureData-end");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
data: data,
|
||||
@ -374,7 +375,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
|
||||
let start = new THREE.Vector3(profile.points[i + 0].x, profile.points[i + 0].y, bsWorld.center.z);
|
||||
let end = new THREE.Vector3(profile.points[i + 1].x, profile.points[i + 1].y, bsWorld.center.z);
|
||||
|
||||
|
||||
let closest = new THREE.Line3(start, end).closestPointToPoint(bsWorld.center, true, new THREE.Vector3());
|
||||
let distance = closest.distanceTo(bsWorld.center);
|
||||
|
||||
@ -476,12 +477,12 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
*
|
||||
*
|
||||
* The return value is an array with all segments of the profile path
|
||||
* let segment = {
|
||||
* start: THREE.Vector3,
|
||||
* end: THREE.Vector3,
|
||||
* points: {}
|
||||
* project: function()
|
||||
* };
|
||||
* let segment = {
|
||||
* start: THREE.Vector3,
|
||||
* end: THREE.Vector3,
|
||||
* points: {}
|
||||
* project: function()
|
||||
* };
|
||||
*
|
||||
* The project() function inside each segment can be used to transform
|
||||
* that segments point coordinates to line up along the x-axis.
|
||||
@ -596,7 +597,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
*
|
||||
*
|
||||
* params.pickWindowSize: Look for points inside a pixel window of this size.
|
||||
* Use odd values: 1, 3, 5, ...
|
||||
* Use odd values: 1, 3, 5, ...
|
||||
*
|
||||
*
|
||||
* TODO: only draw pixels that are actually read with readPixels().
|
||||
@ -606,9 +607,9 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
|
||||
let renderer = viewer.renderer;
|
||||
let pRenderer = viewer.pRenderer;
|
||||
|
||||
|
||||
performance.mark("pick-start");
|
||||
|
||||
|
||||
let getVal = (a, b) => a !== undefined ? a : b;
|
||||
|
||||
let pickWindowSize = getVal(params.pickWindowSize, 17);
|
||||
@ -629,7 +630,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
if (nodes.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
if (!this.pickState) {
|
||||
let scene = new THREE.Scene();
|
||||
|
||||
@ -649,7 +650,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
scene: scene
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
let pickState = this.pickState;
|
||||
let pickMaterial = pickState.material;
|
||||
|
||||
@ -677,7 +678,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
}else{
|
||||
pickMaterial.clipBoxes = [];
|
||||
}
|
||||
|
||||
|
||||
this.updateMaterial(pickMaterial, nodes, camera, renderer);
|
||||
}
|
||||
|
||||
@ -686,7 +687,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
pickState.renderTarget.setSize(width, height);
|
||||
|
||||
let pixelPos = new THREE.Vector2(params.x, params.y);
|
||||
|
||||
|
||||
let gl = renderer.getContext();
|
||||
gl.enable(gl.SCISSOR_TEST);
|
||||
gl.scissor(
|
||||
@ -694,24 +695,24 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
parseInt(pixelPos.y - (pickWindowSize - 1) / 2),
|
||||
parseInt(pickWindowSize), parseInt(pickWindowSize));
|
||||
|
||||
|
||||
|
||||
renderer.state.buffers.depth.setTest(pickMaterial.depthTest);
|
||||
renderer.state.buffers.depth.setMask(pickMaterial.depthWrite);
|
||||
renderer.state.setBlending(THREE.NoBlending);
|
||||
|
||||
|
||||
{ // RENDER
|
||||
renderer.setRenderTarget(pickState.renderTarget);
|
||||
gl.clearColor(0, 0, 0, 0);
|
||||
renderer.clearTarget( pickState.renderTarget, true, true, true );
|
||||
|
||||
|
||||
let tmp = this.material;
|
||||
this.material = pickMaterial;
|
||||
|
||||
|
||||
pRenderer.renderOctree(this, nodes, camera, pickState.renderTarget);
|
||||
|
||||
|
||||
this.material = tmp;
|
||||
}
|
||||
|
||||
|
||||
let clamp = (number, min, max) => Math.min(Math.max(min, number), max);
|
||||
|
||||
let x = parseInt(clamp(pixelPos.x - (pickWindowSize - 1) / 2, 0, width));
|
||||
@ -721,14 +722,14 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
|
||||
let pixelCount = w * h;
|
||||
let buffer = new Uint8Array(4 * pixelCount);
|
||||
|
||||
gl.readPixels(x, y, pickWindowSize, pickWindowSize, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
|
||||
|
||||
|
||||
gl.readPixels(x, y, pickWindowSize, pickWindowSize, gl.RGBA, gl.UNSIGNED_BYTE, buffer);
|
||||
|
||||
renderer.setRenderTarget(null);
|
||||
renderer.state.reset();
|
||||
renderer.setScissorTest(false);
|
||||
gl.disable(gl.SCISSOR_TEST);
|
||||
|
||||
|
||||
let pixels = buffer;
|
||||
let ibuffer = new Uint32Array(buffer.buffer);
|
||||
|
||||
@ -763,13 +764,13 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// DEBUG: show panel with pick image
|
||||
//{
|
||||
//{
|
||||
// let img = Utils.pixelsArrayToImage(buffer, w, h);
|
||||
// let screenshot = img.src;
|
||||
//
|
||||
@ -790,36 +791,36 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
// //$(this.debugWindow.document).append($(`<img src="${screenshot}"/>`));
|
||||
// //this.debugWindow.document.write('<img src="'+screenshot+'"/>');
|
||||
//}
|
||||
|
||||
|
||||
|
||||
for(let hit of hits){
|
||||
let point = {};
|
||||
|
||||
|
||||
if (!nodes[hit.pcIndex]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
let node = nodes[hit.pcIndex];
|
||||
let pc = node.sceneNode;
|
||||
let geometry = node.geometryNode.geometry;
|
||||
|
||||
|
||||
for(let attributeName in geometry.attributes){
|
||||
let attribute = geometry.attributes[attributeName];
|
||||
|
||||
|
||||
if (attributeName === 'position') {
|
||||
let x = attribute.array[3 * hit.pIndex + 0];
|
||||
let y = attribute.array[3 * hit.pIndex + 1];
|
||||
let z = attribute.array[3 * hit.pIndex + 2];
|
||||
|
||||
|
||||
let position = new THREE.Vector3(x, y, z);
|
||||
position.applyMatrix4(pc.matrixWorld);
|
||||
|
||||
|
||||
point[attributeName] = position;
|
||||
} else if (attributeName === 'indices') {
|
||||
|
||||
|
||||
} else if (attributeName === 'gpsTime') {
|
||||
let values = attribute.array.slice(attribute.itemSize * hit.pIndex, attribute.itemSize * (hit.pIndex + 1)) ;
|
||||
|
||||
|
||||
values[0] += node.geometryNode.gpsTime.offset;
|
||||
|
||||
point[attributeName] = values;
|
||||
@ -839,7 +840,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
// point[attribute.name] = value;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
hit.point = point;
|
||||
@ -860,7 +861,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
//return sorted[0].point;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
* getFittedBoxGen(boxNode){
|
||||
@ -879,7 +880,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
let posOffset = buffer.offset("position");
|
||||
let stride = buffer.stride;
|
||||
let view = new DataView(buffer.data);
|
||||
|
||||
|
||||
let objectToBox = new THREE.Matrix4().multiplyMatrices(worldToBox, node.sceneNode.matrixWorld);
|
||||
|
||||
let pos = new THREE.Vector4();
|
||||
@ -938,7 +939,7 @@ export class PointCloudOctree extends PointCloudTree {
|
||||
let posOffset = buffer.offset("position");
|
||||
let stride = buffer.stride;
|
||||
let view = new DataView(buffer.data);
|
||||
|
||||
|
||||
let objectToBox = new THREE.Matrix4().multiplyMatrices(worldToBox, node.sceneNode.matrixWorld);
|
||||
|
||||
let pos = new THREE.Vector4();
|
||||
|
||||
@ -8,8 +8,8 @@ export * from "./EventDispatcher.js";
|
||||
export * from "./Features.js";
|
||||
export * from "./KeyCodes.js";
|
||||
export * from "./LRU.js";
|
||||
export * from "./PointCloudEptGeometry.js";
|
||||
export * from "./PointCloudGreyhoundGeometry.js";
|
||||
export * from "./PointCloudGreyhoundGeometryNode.js";
|
||||
export * from "./PointCloudOctree.js";
|
||||
export * from "./PointCloudOctreeGeometry.js";
|
||||
export * from "./PointCloudTree.js";
|
||||
@ -31,6 +31,9 @@ export * from "./materials/NormalizationMaterial.js";
|
||||
export * from "./materials/PointCloudMaterial.js";
|
||||
|
||||
export * from "./loader/POCLoader.js";
|
||||
export * from "./loader/EptLoader.js";
|
||||
export * from "./loader/ept/BinaryLoader.js";
|
||||
export * from "./loader/ept/LaszipLoader.js";
|
||||
export * from "./loader/GreyhoundBinaryLoader.js";
|
||||
export * from "./loader/GreyhoundLoader.js";
|
||||
export * from "./loader/PointAttributes.js";
|
||||
@ -65,6 +68,7 @@ import {Enum} from "./Enum";
|
||||
import {LRU} from "./LRU";
|
||||
import {POCLoader} from "./loader/POCLoader";
|
||||
import {GreyhoundLoader} from "./loader/GreyhoundLoader";
|
||||
import {EptLoader} from "./loader/EptLoader";
|
||||
import {PointCloudOctree} from "./PointCloudOctree";
|
||||
import {WorkerPool} from "./WorkerPool";
|
||||
|
||||
@ -111,6 +115,16 @@ export function loadPointCloud(path, name, callback){
|
||||
// load pointcloud
|
||||
if (!path){
|
||||
// TODO: callback? comment? Hello? Bueller? Anyone?
|
||||
} else if (path.indexOf('ept.json') > 0) {
|
||||
Potree.EptLoader.load(path, function(geometry) {
|
||||
if (!geometry) {
|
||||
console.error(new Error(`failed to load point cloud from URL: ${path}`));
|
||||
}
|
||||
else {
|
||||
let pointcloud = new PointCloudOctree(geometry);
|
||||
loaded(pointcloud);
|
||||
}
|
||||
});
|
||||
} else if (path.indexOf('greyhound://') === 0){
|
||||
// We check if the path string starts with 'greyhound:', if so we assume it's a greyhound server URL.
|
||||
GreyhoundLoader.load(path, function (geometry) {
|
||||
@ -209,7 +223,7 @@ export function loadPointCloud(path, name, callback){
|
||||
});
|
||||
elButtonContainer.find("label:first").each( (index, value) => {
|
||||
$(value).css("border-radius", "4px 0px 0px 4px");
|
||||
|
||||
|
||||
});
|
||||
elButtonContainer.find("label:last").each( (index, value) => {
|
||||
$(value).css("border-radius", "0px 4px 4px 0px");
|
||||
|
||||
21
src/loader/EptLoader.js
Normal file
21
src/loader/EptLoader.js
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @author Connor Manning
|
||||
*/
|
||||
|
||||
export class EptLoader {
|
||||
static async load(file, callback) {
|
||||
|
||||
let response = await fetch(file);
|
||||
let json = await response.json();
|
||||
|
||||
let url = file.substr(0, file.lastIndexOf('ept.json'));
|
||||
let geometry = new Potree.PointCloudEptGeometry(url, json);
|
||||
let root = new Potree.PointCloudEptGeometryNode(geometry);
|
||||
|
||||
geometry.root = root;
|
||||
geometry.root.load();
|
||||
|
||||
callback(geometry);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4,7 +4,6 @@ import {Version} from "../Version";
|
||||
import {XHRFactory} from "../XHRFactory";
|
||||
import {PointAttributes, PointAttribute} from "./PointAttributes";
|
||||
import {PointCloudGreyhoundGeometry} from "../PointCloudGreyhoundGeometry";
|
||||
import {PointCloudGreyhoundGeometryNode} from "../PointCloudGreyhoundGeometryNode";
|
||||
import {GreyhoundBinaryLoader} from "./GreyhoundBinaryLoader";
|
||||
|
||||
/**
|
||||
@ -143,7 +142,7 @@ export class GreyhoundLoader{
|
||||
|
||||
}
|
||||
|
||||
//loadInfoJSON(url, callback) {
|
||||
//loadInfoJSON(url, callback) {
|
||||
//}
|
||||
|
||||
/**
|
||||
|
||||
106
src/loader/ept/BinaryLoader.js
Normal file
106
src/loader/ept/BinaryLoader.js
Normal file
@ -0,0 +1,106 @@
|
||||
import {XHRFactory} from "../../XHRFactory.js";
|
||||
|
||||
export class EptBinaryLoader {
|
||||
load(node) {
|
||||
if (node.loaded) return;
|
||||
|
||||
let url = node.url() + '.bin';
|
||||
|
||||
let xhr = XHRFactory.createXMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
let buffer = xhr.response;
|
||||
this.parse(node, buffer);
|
||||
} else {
|
||||
console.log('Failed ' + url + ': ' + xhr.status);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
xhr.send(null);
|
||||
}
|
||||
catch (e) {
|
||||
console.log('Failed request: ' + e);
|
||||
}
|
||||
}
|
||||
|
||||
parse(node, buffer) {
|
||||
let workerPath = Potree.scriptPath +
|
||||
'/workers/EptBinaryDecoderWorker.js';
|
||||
let worker = Potree.workerPool.getWorker(workerPath);
|
||||
|
||||
worker.onmessage = function(e) {
|
||||
let g = new THREE.BufferGeometry();
|
||||
let numPoints = e.data.numPoints;
|
||||
|
||||
let position = new Float32Array(e.data.position);
|
||||
g.addAttribute('position', new THREE.BufferAttribute(position, 3));
|
||||
|
||||
let indices = new Uint8Array(e.data.indices);
|
||||
g.addAttribute('indices', new THREE.BufferAttribute(indices, 4));
|
||||
|
||||
if (e.data.color) {
|
||||
let color = new Uint8Array(e.data.color);
|
||||
g.addAttribute('color',
|
||||
new THREE.BufferAttribute(color, 4, true));
|
||||
}
|
||||
if (e.data.intensity) {
|
||||
let intensity = new Float32Array(e.data.intensity);
|
||||
g.addAttribute('intensity',
|
||||
new THREE.BufferAttribute(intensity, 1));
|
||||
}
|
||||
if (e.data.classification) {
|
||||
let classification = new Uint8Array(e.data.classification);
|
||||
g.addAttribute('classification',
|
||||
new THREE.BufferAttribute(classification, 1));
|
||||
}
|
||||
if (e.data.returnNumber) {
|
||||
let returnNumber = new Uint8Array(e.data.returnNumber);
|
||||
g.addAttribute('returnNumber',
|
||||
new THREE.BufferAttribute(returnNumber, 1));
|
||||
}
|
||||
if (e.data.numberOfReturns) {
|
||||
let numberOfReturns = new Uint8Array(e.data.numberOfReturns);
|
||||
g.addAttribute('numberOfReturns',
|
||||
new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
}
|
||||
if (e.data.pointSourceId) {
|
||||
let pointSourceId = new Uint16Array(e.data.pointSourceId);
|
||||
g.addAttribute('pointSourceID',
|
||||
new THREE.BufferAttribute(pointSourceId, 1));
|
||||
}
|
||||
|
||||
g.attributes.indices.normalized = true;
|
||||
|
||||
let tightBoundingBox = new THREE.Box3(
|
||||
new THREE.Vector3().fromArray(e.data.tightBoundingBox.min),
|
||||
new THREE.Vector3().fromArray(e.data.tightBoundingBox.max)
|
||||
);
|
||||
|
||||
node.doneLoading(
|
||||
g,
|
||||
tightBoundingBox,
|
||||
numPoints,
|
||||
new THREE.Vector3(...e.data.mean));
|
||||
|
||||
Potree.workerPool.returnWorker(workerPath, worker);
|
||||
};
|
||||
|
||||
let toArray = (v) => [v.x, v.y, v.z];
|
||||
let message = {
|
||||
buffer: buffer,
|
||||
schema: node.ept.schema,
|
||||
scale: node.ept.eptScale,
|
||||
offset: node.ept.eptOffset,
|
||||
mins: toArray(node.key.b.min)
|
||||
};
|
||||
|
||||
worker.postMessage(message, [message.buffer]);
|
||||
}
|
||||
};
|
||||
|
||||
169
src/loader/ept/LaszipLoader.js
Normal file
169
src/loader/ept/LaszipLoader.js
Normal file
@ -0,0 +1,169 @@
|
||||
import {XHRFactory} from "../../XHRFactory.js";
|
||||
|
||||
/**
|
||||
* laslaz code taken and adapted from plas.io js-laslaz
|
||||
* http://plas.io/
|
||||
* https://github.com/verma/plasio
|
||||
*
|
||||
* Thanks to Uday Verma and Howard Butler
|
||||
*
|
||||
*/
|
||||
|
||||
export class EptLaszipLoader {
|
||||
load(node) {
|
||||
if (node.loaded) return;
|
||||
|
||||
let url = node.url() + '.laz';
|
||||
|
||||
let xhr = XHRFactory.createXMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200) {
|
||||
let buffer = xhr.response;
|
||||
this.parse(node, buffer);
|
||||
} else {
|
||||
console.log('Failed ' + url + ': ' + xhr.status);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(null);
|
||||
}
|
||||
|
||||
parse(node, buffer){
|
||||
let lf = new LASFile(buffer);
|
||||
let handler = new EptLazBatcher(node);
|
||||
|
||||
lf.open()
|
||||
.then(() => {
|
||||
lf.isOpen = true;
|
||||
return lf.getHeader();
|
||||
})
|
||||
.then((header) => {
|
||||
let i = 0;
|
||||
let np = header.pointsCount;
|
||||
|
||||
let toArray = (v) => [v.x, v.y, v.z];
|
||||
let mins = toArray(node.key.b.min);
|
||||
let maxs = toArray(node.key.b.max);
|
||||
|
||||
let read = () => {
|
||||
let p = lf.readData(1000000, 0, 1);
|
||||
return p.then(function (data) {
|
||||
let d = new LASDecoder(
|
||||
data.buffer,
|
||||
header.pointsFormatId,
|
||||
header.pointsStructSize,
|
||||
data.count,
|
||||
header.scale,
|
||||
header.offset,
|
||||
mins,
|
||||
maxs);
|
||||
d.extraBytes = header.extraBytes;
|
||||
d.pointsFormatId = header.pointsFormatId;
|
||||
handler.push(d);
|
||||
|
||||
i += data.count;
|
||||
|
||||
if (data.hasMoreData) {
|
||||
return read();
|
||||
}
|
||||
else {
|
||||
header.totalRead = i;
|
||||
header.versionAsString = lf.versionAsString;
|
||||
header.isCompressed = lf.isCompressed;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return read();
|
||||
})
|
||||
.then(() => lf.close())
|
||||
.then(() => lf.isOpen = false)
|
||||
.catch((err) => {
|
||||
console.log('Error reading LAZ:', err);
|
||||
if (lf.isOpen) {
|
||||
lf.close().then(() => {
|
||||
lf.isOpen = false;
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
else throw err;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export class EptLazBatcher {
|
||||
constructor(node) { this.node = node; }
|
||||
|
||||
push(las) {
|
||||
let workerPath = Potree.scriptPath +
|
||||
'/workers/EptLaszipDecoderWorker.js';
|
||||
let worker = Potree.workerPool.getWorker(workerPath);
|
||||
|
||||
worker.onmessage = (e) => {
|
||||
let g = new THREE.BufferGeometry();
|
||||
let numPoints = las.pointsCount;
|
||||
|
||||
let positions = new Float32Array(e.data.position);
|
||||
let colors = new Uint8Array(e.data.color);
|
||||
|
||||
let intensities = new Float32Array(e.data.intensity);
|
||||
let classifications = new Uint8Array(e.data.classification);
|
||||
let returnNumbers = new Uint8Array(e.data.returnNumber);
|
||||
let numberOfReturns = new Uint8Array(e.data.numberOfReturns);
|
||||
let pointSourceIDs = new Uint16Array(e.data.pointSourceID);
|
||||
let indices = new Uint8Array(e.data.indices);
|
||||
|
||||
g.addAttribute('position',
|
||||
new THREE.BufferAttribute(positions, 3));
|
||||
g.addAttribute('color',
|
||||
new THREE.BufferAttribute(colors, 4, true));
|
||||
g.addAttribute('intensity',
|
||||
new THREE.BufferAttribute(intensities, 1));
|
||||
g.addAttribute('classification',
|
||||
new THREE.BufferAttribute(classifications, 1));
|
||||
g.addAttribute('returnNumber',
|
||||
new THREE.BufferAttribute(returnNumbers, 1));
|
||||
g.addAttribute('numberOfReturns',
|
||||
new THREE.BufferAttribute(numberOfReturns, 1));
|
||||
g.addAttribute('pointSourceID',
|
||||
new THREE.BufferAttribute(pointSourceIDs, 1));
|
||||
g.addAttribute('indices',
|
||||
new THREE.BufferAttribute(indices, 4));
|
||||
|
||||
g.attributes.indices.normalized = true;
|
||||
|
||||
let tightBoundingBox = new THREE.Box3(
|
||||
new THREE.Vector3().fromArray(e.data.tightBoundingBox.min),
|
||||
new THREE.Vector3().fromArray(e.data.tightBoundingBox.max)
|
||||
);
|
||||
|
||||
this.node.doneLoading(
|
||||
g,
|
||||
tightBoundingBox,
|
||||
numPoints,
|
||||
new THREE.Vector3(...e.data.mean));
|
||||
|
||||
Potree.workerPool.returnWorker(workerPath, worker);
|
||||
};
|
||||
|
||||
let message = {
|
||||
buffer: las.arrayb,
|
||||
numPoints: las.pointsCount,
|
||||
pointSize: las.pointSize,
|
||||
pointFormatID: las.pointsFormatId,
|
||||
scale: las.scale,
|
||||
offset: las.offset,
|
||||
mins: las.mins,
|
||||
maxs: las.maxs
|
||||
};
|
||||
|
||||
worker.postMessage(message, [message.buffer]);
|
||||
};
|
||||
};
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
proj4.defs('UTM10N', '+proj=utm +zone=10 +ellps=GRS80 +datum=NAD83 +units=m +no_defs');
|
||||
|
||||
export class MapView{
|
||||
|
||||
|
||||
constructor (viewer) {
|
||||
this.viewer = viewer;
|
||||
|
||||
@ -576,7 +576,24 @@ export class MapView{
|
||||
}
|
||||
|
||||
if (!this.sceneProjection) {
|
||||
this.setSceneProjection(pointcloud.projection);
|
||||
try {
|
||||
this.setSceneProjection(pointcloud.projection);
|
||||
}
|
||||
catch (e) {
|
||||
console.log('Failed projection:', e);
|
||||
|
||||
if (pointcloud.fallbackProjection) {
|
||||
try {
|
||||
console.log('Trying fallback projection...');
|
||||
this.setSceneProjection(pointcloud.fallbackProjection);
|
||||
console.log('Set projection from fallback');
|
||||
}
|
||||
catch (e) {
|
||||
console.log('Failed fallback projection:', e);
|
||||
}
|
||||
}
|
||||
else return;
|
||||
}
|
||||
}
|
||||
|
||||
let mapExtent = this.getMapExtent();
|
||||
@ -597,6 +614,7 @@ export class MapView{
|
||||
constrainResolution: false
|
||||
});
|
||||
|
||||
if (pointcloud.pcoGeometry.type == 'ept') return;
|
||||
let url = pointcloud.pcoGeometry.url + '/../sources.json';
|
||||
$.getJSON(url, (data) => {
|
||||
let sources = data.sources;
|
||||
@ -667,8 +685,8 @@ export class MapView{
|
||||
if (resized) {
|
||||
this.map.updateSize();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
//
|
||||
let camera = this.viewer.scene.getActiveCamera();
|
||||
|
||||
let scale = this.map.getView().getResolution();
|
||||
|
||||
209
src/workers/EptBinaryDecoderWorker.js
Normal file
209
src/workers/EptBinaryDecoderWorker.js
Normal file
@ -0,0 +1,209 @@
|
||||
Potree = { };
|
||||
|
||||
onmessage = function(event) {
|
||||
let buffer = event.data.buffer;
|
||||
let view = new DataView(buffer);
|
||||
let schema = event.data.schema;
|
||||
let scale = event.data.scale;
|
||||
let offset = event.data.offset;
|
||||
let mins = event.data.mins;
|
||||
|
||||
let dimensions = schema.reduce((p, c) => {
|
||||
p[c.name] = c;
|
||||
return p;
|
||||
}, { });
|
||||
|
||||
let dimOffset = (name) => {
|
||||
let offset = 0;
|
||||
for (var i = 0; i < schema.length; ++i) {
|
||||
if (schema[i].name == name) return offset;
|
||||
offset += schema[i].size;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
let getExtractor = (name) => {
|
||||
let offset = dimOffset(name);
|
||||
let type = dimensions[name].type;
|
||||
let size = dimensions[name].size;
|
||||
|
||||
if (type == 'signed') switch (size) {
|
||||
case 1: return (p) => view.getInt8(p + offset);
|
||||
case 2: return (p) => view.getInt16(p + offset, true);
|
||||
case 4: return (p) => view.getInt32(p + offset, true);
|
||||
case 8: return (p) => view.getInt64(p + offset, true);
|
||||
}
|
||||
if (type == 'unsigned') switch (size) {
|
||||
case 1: return (p) => view.getUint8(p + offset);
|
||||
case 2: return (p) => view.getUint16(p + offset, true);
|
||||
case 4: return (p) => view.getUint32(p + offset, true);
|
||||
case 8: return (p) => view.getUint64(p + offset, true);
|
||||
}
|
||||
if (type == 'float') switch (size) {
|
||||
case 4: return (p) => view.getFloat32(p + offset, true);
|
||||
case 8: return (p) => view.getFloat64(p + offset, true);
|
||||
}
|
||||
|
||||
let str = JSON.stringify(dimensions[name]);
|
||||
throw new Error(`Invalid dimension specification for ${name}: ${str}`);
|
||||
};
|
||||
|
||||
let pointSize = schema.reduce((p, c) => p + c.size, 0);
|
||||
let numPoints = buffer.byteLength / pointSize;
|
||||
|
||||
let xyzBuffer, rgbBuffer, intensityBuffer, classificationBuffer,
|
||||
returnNumberBuffer, numberOfReturnsBuffer, pointSourceIdBuffer;
|
||||
let xyz, rgb, intensity, classification, returnNumber, numberOfReturns,
|
||||
pointSourceId;
|
||||
let xyzExtractor, rgbExtractor, intensityExtractor, classificationExtractor,
|
||||
returnNumberExtractor, numberOfReturnsExtractor, pointSourceIdExtractor;
|
||||
let twoByteColor = false;
|
||||
|
||||
if (dimensions['X'] && dimensions['Y'] && dimensions['Z']) {
|
||||
xyzBuffer = new ArrayBuffer(numPoints * 4 * 3);
|
||||
xyz = new Float32Array(xyzBuffer);
|
||||
xyzExtractor = [
|
||||
getExtractor('X'),
|
||||
getExtractor('Y'),
|
||||
getExtractor('Z')
|
||||
];
|
||||
}
|
||||
|
||||
if (dimensions['Red'] && dimensions['Green'] && dimensions['Blue']) {
|
||||
rgbBuffer = new ArrayBuffer(numPoints * 4);
|
||||
rgb = new Uint8Array(rgbBuffer);
|
||||
rgbExtractor = [
|
||||
getExtractor('Red'),
|
||||
getExtractor('Green'),
|
||||
getExtractor('Blue')
|
||||
];
|
||||
|
||||
let r, g, b, pos;
|
||||
for (let i = 0; i < numPoints && !twoByteColor; ++i) {
|
||||
pos = i * pointSize;
|
||||
r = rgbExtractor[0](pos);
|
||||
g = rgbExtractor[1](pos);
|
||||
b = rgbExtractor[2](pos);
|
||||
if (r > 255 || g > 255 || b > 255) twoByteColor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (dimensions['Intensity']) {
|
||||
intensityBuffer = new ArrayBuffer(numPoints * 4);
|
||||
intensity = new Float32Array(intensityBuffer);
|
||||
intensityExtractor = getExtractor('Intensity');
|
||||
}
|
||||
|
||||
if (dimensions['Classification']) {
|
||||
classificationBuffer = new ArrayBuffer(numPoints);
|
||||
classification = new Uint8Array(classificationBuffer);
|
||||
classificationExtractor = getExtractor('Classification');
|
||||
}
|
||||
|
||||
if (dimensions['ReturnNumber']) {
|
||||
returnNumberBuffer = new ArrayBuffer(numPoints);
|
||||
returnNumber = new Uint8Array(returnNumberBuffer);
|
||||
returnNumberExtractor = getExtractor('ReturnNumber');
|
||||
}
|
||||
|
||||
if (dimensions['NumberOfReturns']) {
|
||||
numberOfReturnsBuffer = new ArrayBuffer(numPoints);
|
||||
numberOfReturns = new Uint8Array(numberOfReturnsBuffer);
|
||||
numberOfReturnsExtractor = getExtractor('NumberOfReturns');
|
||||
}
|
||||
|
||||
if (dimensions['PointSourceId']) {
|
||||
pointSourceIdBuffer = new ArrayBuffer(numPoints * 2);
|
||||
pointSourceId = new Uint16Array(pointSourceIdBuffer);
|
||||
pointSourceIdExtractor = getExtractor('PointSourceId');
|
||||
}
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
let bounds = {
|
||||
min: [Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE],
|
||||
max: [-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE],
|
||||
};
|
||||
|
||||
let x, y, z, r, g, b;
|
||||
for (let i = 0; i < numPoints; ++i) {
|
||||
let pos = i * pointSize;
|
||||
if (xyz) {
|
||||
x = xyzExtractor[0](pos) * scale.x + offset.x - mins[0];
|
||||
y = xyzExtractor[1](pos) * scale.y + offset.y - mins[1];
|
||||
z = xyzExtractor[2](pos) * scale.z + offset.z - mins[2];
|
||||
|
||||
mean[0] += x / numPoints;
|
||||
mean[1] += y / numPoints;
|
||||
mean[2] += z / numPoints;
|
||||
|
||||
bounds.min[0] = Math.min(bounds.min[0], x);
|
||||
bounds.min[1] = Math.min(bounds.min[1], y);
|
||||
bounds.min[2] = Math.min(bounds.min[2], z);
|
||||
|
||||
bounds.max[0] = Math.max(bounds.max[0], x);
|
||||
bounds.max[1] = Math.max(bounds.max[1], y);
|
||||
bounds.max[2] = Math.max(bounds.max[2], z);
|
||||
|
||||
xyz[3 * i + 0] = x;
|
||||
xyz[3 * i + 1] = y;
|
||||
xyz[3 * i + 2] = z;
|
||||
}
|
||||
|
||||
if (rgb) {
|
||||
r = rgbExtractor[0](pos);
|
||||
g = rgbExtractor[1](pos);
|
||||
b = rgbExtractor[2](pos);
|
||||
|
||||
if (twoByteColor) {
|
||||
r /= 256;
|
||||
g /= 256;
|
||||
b /= 256;
|
||||
}
|
||||
|
||||
rgb[4 * i + 0] = r;
|
||||
rgb[4 * i + 1] = g;
|
||||
rgb[4 * i + 2] = b;
|
||||
}
|
||||
|
||||
if (intensity) intensity[i] = intensityExtractor(pos);
|
||||
if (classification) classification[i] = classificationExtractor(pos);
|
||||
if (returnNumber) returnNumber[i] = returnNumberExtractor(pos);
|
||||
if (numberOfReturns) numberOfReturns[i] = numberOfReturnsExtractor(pos);
|
||||
if (pointSourceId) pointSourceId[i] = pointSourceIdExtractor(pos);
|
||||
}
|
||||
|
||||
let indicesBuffer = new ArrayBuffer(numPoints * 4);
|
||||
let indices = new Uint32Array(indicesBuffer);
|
||||
for (let i = 0; i < numPoints; ++i) {
|
||||
indices[i] = i;
|
||||
}
|
||||
|
||||
let message = {
|
||||
numPoints: numPoints,
|
||||
tightBoundingBox: bounds,
|
||||
mean: mean,
|
||||
|
||||
position: xyzBuffer,
|
||||
color: rgbBuffer,
|
||||
intensity: intensityBuffer,
|
||||
classification: classificationBuffer,
|
||||
returnNumber: returnNumberBuffer,
|
||||
numberOfReturns: numberOfReturnsBuffer,
|
||||
pointSourceId: pointSourceIdBuffer,
|
||||
indices: indicesBuffer
|
||||
};
|
||||
|
||||
let transferables = [
|
||||
message.position,
|
||||
message.color,
|
||||
message.intensity,
|
||||
message.classification,
|
||||
message.returnNumber,
|
||||
message.numberOfReturns,
|
||||
message.pointSourceId,
|
||||
message.indices
|
||||
].filter((v) => v);
|
||||
|
||||
postMessage(message, transferables);
|
||||
}
|
||||
|
||||
176
src/workers/EptLaszipDecoderWorker.js
Normal file
176
src/workers/EptLaszipDecoderWorker.js
Normal file
@ -0,0 +1,176 @@
|
||||
function readUsingDataView(event) {
|
||||
performance.mark("laslaz-start");
|
||||
|
||||
let buffer = event.data.buffer;
|
||||
let numPoints = event.data.numPoints;
|
||||
let pointSize = event.data.pointSize;
|
||||
let pointFormat = event.data.pointFormatID;
|
||||
let scale = event.data.scale;
|
||||
let offset = event.data.offset;
|
||||
|
||||
let sourceUint8 = new Uint8Array(buffer);
|
||||
let sourceView = new DataView(buffer);
|
||||
|
||||
let tightBoundingBox = {
|
||||
min: [
|
||||
Number.POSITIVE_INFINITY,
|
||||
Number.POSITIVE_INFINITY,
|
||||
Number.POSITIVE_INFINITY
|
||||
],
|
||||
max: [
|
||||
Number.NEGATIVE_INFINITY,
|
||||
Number.NEGATIVE_INFINITY,
|
||||
Number.NEGATIVE_INFINITY
|
||||
]
|
||||
};
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
|
||||
let pBuff = new ArrayBuffer(numPoints * 3 * 4);
|
||||
let cBuff = new ArrayBuffer(numPoints * 4);
|
||||
let iBuff = new ArrayBuffer(numPoints * 4);
|
||||
let clBuff = new ArrayBuffer(numPoints);
|
||||
let rnBuff = new ArrayBuffer(numPoints);
|
||||
let nrBuff = new ArrayBuffer(numPoints);
|
||||
let psBuff = new ArrayBuffer(numPoints * 2);
|
||||
|
||||
let positions = new Float32Array(pBuff);
|
||||
let colors = new Uint8Array(cBuff);
|
||||
let intensities = new Float32Array(iBuff);
|
||||
let classifications = new Uint8Array(clBuff);
|
||||
let returnNumbers = new Uint8Array(rnBuff);
|
||||
let numberOfReturns = new Uint8Array(nrBuff);
|
||||
let pointSourceIDs = new Uint16Array(psBuff);
|
||||
|
||||
// Point format 3 contains an 8-byte GpsTime before RGB values, so make
|
||||
// sure we have the correct color offset.
|
||||
let hasColor = pointFormat == 2 || pointFormat == 3;
|
||||
let co = pointFormat == 2 ? 20 : 28;
|
||||
|
||||
// TODO This should be cached per-resource since this is an expensive check.
|
||||
let twoByteColor = false;
|
||||
if (hasColor) {
|
||||
let r, g, b, pos;
|
||||
for (let i = 0; i < numPoints && !twoByteColor; ++i) {
|
||||
pos = i * pointSize;
|
||||
r = sourceView.getUint16(pos + co, true)
|
||||
g = sourceView.getUint16(pos + co + 2, true)
|
||||
b = sourceView.getUint16(pos + co + 4, true)
|
||||
if (r > 255 || g > 255 || b > 255) twoByteColor = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
// POSITION
|
||||
let ux = sourceView.getInt32(i * pointSize + 0, true);
|
||||
let uy = sourceView.getInt32(i * pointSize + 4, true);
|
||||
let uz = sourceView.getInt32(i * pointSize + 8, true);
|
||||
|
||||
x = ux * scale[0] + offset[0] - event.data.mins[0];
|
||||
y = uy * scale[1] + offset[1] - event.data.mins[1];
|
||||
z = uz * scale[2] + offset[2] - event.data.mins[2];
|
||||
|
||||
positions[3 * i + 0] = x;
|
||||
positions[3 * i + 1] = y;
|
||||
positions[3 * i + 2] = z;
|
||||
|
||||
mean[0] += x / numPoints;
|
||||
mean[1] += y / numPoints;
|
||||
mean[2] += z / numPoints;
|
||||
|
||||
tightBoundingBox.min[0] = Math.min(tightBoundingBox.min[0], x);
|
||||
tightBoundingBox.min[1] = Math.min(tightBoundingBox.min[1], y);
|
||||
tightBoundingBox.min[2] = Math.min(tightBoundingBox.min[2], z);
|
||||
|
||||
tightBoundingBox.max[0] = Math.max(tightBoundingBox.max[0], x);
|
||||
tightBoundingBox.max[1] = Math.max(tightBoundingBox.max[1], y);
|
||||
tightBoundingBox.max[2] = Math.max(tightBoundingBox.max[2], z);
|
||||
|
||||
// INTENSITY
|
||||
let intensity = sourceView.getUint16(i * pointSize + 12, true);
|
||||
intensities[i] = intensity;
|
||||
|
||||
// RETURN NUMBER, stored in the first 3 bits - 00000111
|
||||
// number of returns stored in next 3 bits - 00111000
|
||||
let returnNumberAndNumberOfReturns = sourceView.getUint8(i * pointSize + 14, true);
|
||||
let returnNumber = returnNumberAndNumberOfReturns & 0b0111;
|
||||
let numberOfReturn = (returnNumberAndNumberOfReturns & 0b00111000) >> 3;
|
||||
returnNumbers[i] = returnNumber;
|
||||
numberOfReturns[i] = numberOfReturn;
|
||||
|
||||
// CLASSIFICATION
|
||||
let classification = sourceView.getUint8(i * pointSize + 15, true);
|
||||
classifications[i] = classification;
|
||||
|
||||
// POINT SOURCE ID
|
||||
let pointSourceID = sourceView.getUint16(i * pointSize + 18, true);
|
||||
pointSourceIDs[i] = pointSourceID;
|
||||
|
||||
// COLOR, if available
|
||||
if (hasColor) {
|
||||
let r = sourceView.getUint16(i * pointSize + co, true)
|
||||
let g = sourceView.getUint16(i * pointSize + co + 2, true)
|
||||
let b = sourceView.getUint16(i * pointSize + co + 4, true)
|
||||
|
||||
if (twoByteColor) {
|
||||
r /= 256;
|
||||
g /= 256;
|
||||
b /= 256;
|
||||
}
|
||||
|
||||
colors[4 * i + 0] = r;
|
||||
colors[4 * i + 1] = g;
|
||||
colors[4 * i + 2] = b;
|
||||
colors[4 * i + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
let indices = new ArrayBuffer(numPoints * 4);
|
||||
let iIndices = new Uint32Array(indices);
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
iIndices[i] = i;
|
||||
}
|
||||
|
||||
performance.mark("laslaz-end");
|
||||
|
||||
//{ // print timings
|
||||
// performance.measure("laslaz", "laslaz-start", "laslaz-end");
|
||||
// let measure = performance.getEntriesByType("measure")[0];
|
||||
// let dpp = 1000 * measure.duration / numPoints;
|
||||
// let debugMessage = `${measure.duration.toFixed(3)} ms, ${numPoints} points, ${dpp.toFixed(3)} µs / point`;
|
||||
// console.log(debugMessage);
|
||||
//}
|
||||
performance.clearMarks();
|
||||
performance.clearMeasures();
|
||||
|
||||
let message = {
|
||||
mean: mean,
|
||||
position: pBuff,
|
||||
color: cBuff,
|
||||
intensity: iBuff,
|
||||
classification: clBuff,
|
||||
returnNumber: rnBuff,
|
||||
numberOfReturns: nrBuff,
|
||||
pointSourceID: psBuff,
|
||||
tightBoundingBox: tightBoundingBox,
|
||||
indices: indices
|
||||
};
|
||||
|
||||
let transferables = [
|
||||
message.position,
|
||||
message.color,
|
||||
message.intensity,
|
||||
message.classification,
|
||||
message.returnNumber,
|
||||
message.numberOfReturns,
|
||||
message.pointSourceID,
|
||||
message.indices
|
||||
];
|
||||
|
||||
postMessage(message, transferables);
|
||||
};
|
||||
|
||||
|
||||
|
||||
onmessage = readUsingDataView;
|
||||
|
||||
@ -51,7 +51,7 @@ function readUsingTempArrays(event) {
|
||||
let tempInt32 = new Int32Array(temp);
|
||||
let sourceUint8 = new Uint8Array(buffer);
|
||||
let sourceView = new DataView(buffer);
|
||||
|
||||
|
||||
let targetPointSize = 20;
|
||||
let targetBuffer = new ArrayBuffer(numPoints * targetPointSize);
|
||||
let targetView = new DataView(targetBuffer);
|
||||
@ -78,7 +78,7 @@ function readUsingTempArrays(event) {
|
||||
let returnNumbers = new Uint8Array(rnBuff);
|
||||
let numberOfReturns = new Uint8Array(nrBuff);
|
||||
let pointSourceIDs = new Uint16Array(psBuff);
|
||||
|
||||
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
// POSITION
|
||||
tempUint8[0] = sourceUint8[i * sourcePointSize + 0];
|
||||
@ -86,19 +86,19 @@ function readUsingTempArrays(event) {
|
||||
tempUint8[2] = sourceUint8[i * sourcePointSize + 2];
|
||||
tempUint8[3] = sourceUint8[i * sourcePointSize + 3];
|
||||
let x = tempInt32[0];
|
||||
|
||||
|
||||
tempUint8[0] = sourceUint8[i * sourcePointSize + 4];
|
||||
tempUint8[1] = sourceUint8[i * sourcePointSize + 5];
|
||||
tempUint8[2] = sourceUint8[i * sourcePointSize + 6];
|
||||
tempUint8[3] = sourceUint8[i * sourcePointSize + 7];
|
||||
let y = tempInt32[0];
|
||||
|
||||
|
||||
tempUint8[0] = sourceUint8[i * sourcePointSize + 8];
|
||||
tempUint8[1] = sourceUint8[i * sourcePointSize + 9];
|
||||
tempUint8[2] = sourceUint8[i * sourcePointSize + 10];
|
||||
tempUint8[3] = sourceUint8[i * sourcePointSize + 11];
|
||||
let z = tempInt32[0];
|
||||
|
||||
|
||||
x = x * scale[0] + offset[0] - event.data.mins[0];
|
||||
y = y * scale[1] + offset[1] - event.data.mins[1];
|
||||
z = z * scale[2] + offset[2] - event.data.mins[2];
|
||||
@ -184,7 +184,7 @@ function readUsingTempArrays(event) {
|
||||
|
||||
performance.clearMarks();
|
||||
performance.clearMeasures();
|
||||
|
||||
|
||||
let message = {
|
||||
mean: mean,
|
||||
position: pBuff,
|
||||
@ -227,14 +227,14 @@ function readUsingDataView(event) {
|
||||
|
||||
let sourceUint8 = new Uint8Array(buffer);
|
||||
let sourceView = new DataView(buffer);
|
||||
|
||||
|
||||
let targetPointSize = 40;
|
||||
let targetBuffer = new ArrayBuffer(numPoints * targetPointSize);
|
||||
let targetView = new DataView(targetBuffer);
|
||||
|
||||
let tightBoundingBox = {
|
||||
min: [ Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY ],
|
||||
max: [ Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY ]
|
||||
min: [Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE],
|
||||
max: [-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE]
|
||||
};
|
||||
|
||||
let mean = [0, 0, 0];
|
||||
@ -254,7 +254,7 @@ function readUsingDataView(event) {
|
||||
let returnNumbers = new Uint8Array(rnBuff);
|
||||
let numberOfReturns = new Uint8Array(nrBuff);
|
||||
let pointSourceIDs = new Uint16Array(psBuff);
|
||||
|
||||
|
||||
for (let i = 0; i < numPoints; i++) {
|
||||
// POSITION
|
||||
let ux = sourceView.getInt32(i * sourcePointSize + 0, true);
|
||||
@ -306,7 +306,7 @@ function readUsingDataView(event) {
|
||||
pointSourceIDs[i] = pointSourceID;
|
||||
|
||||
// COLOR, if available
|
||||
if (pointFormatID === 2) {
|
||||
if (pointFormatID === 2) {
|
||||
let r = sourceView.getUint16(i * sourcePointSize + 20, true) / 256;
|
||||
let g = sourceView.getUint16(i * sourcePointSize + 22, true) / 256;
|
||||
let b = sourceView.getUint16(i * sourcePointSize + 24, true) / 256;
|
||||
@ -365,4 +365,4 @@ function readUsingDataView(event) {
|
||||
|
||||
|
||||
onmessage = readUsingDataView;
|
||||
//onmessage = readUsingTempArrays;
|
||||
//onmessage = readUsingTempArrays;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user