diff --git a/build/potree/potree.js b/build/potree/potree.js index 8048ae84..d8dca9ec 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -3541,23 +3541,23 @@ } class U { - static toVector3(v, offset) { - return new THREE.Vector3().fromArray(v, offset || 0); - } + 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 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 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()); - } + static sphereFrom(b) { + return b.getBoundingSphere(new THREE.Sphere()); + } } class PointCloudEptGeometry { @@ -3567,13 +3567,13 @@ 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); + 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); @@ -3590,17 +3590,17 @@ this.tightBoundingSphere = U.sphereFrom(this.tightBoundingBox); this.version = new Potree.Version('1.6'); - this.projection = null; - this.fallbackProjection = null; + this.projection = null; + this.fallbackProjection = null; - if (info.srs && info.srs.horizontal) { - this.projection = info.srs.authority + ':' + info.srs.horizontal; - } + 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; - } + if (info.srs.wkt) { + if (!this.projection) this.projection = info.srs.wkt; + else this.fallbackProjection = info.srs.wkt; + } this.pointAttributes = 'LAZ'; this.spacing = @@ -3634,13 +3634,13 @@ let max = this.b.max.clone(); let dst = new THREE.Vector3().subVectors(max, min); - if (a) min.x += dst.x / 2; + if (a) min.x += dst.x / 2; else max.x -= dst.x / 2; - if (b) min.y += dst.y / 2; + if (b) min.y += dst.y / 2; else max.y -= dst.y / 2; - if (c) min.z += dst.z / 2; + if (c) min.z += dst.z / 2; else max.z -= dst.z / 2; return new Potree.EptKey( @@ -3750,7 +3750,7 @@ this.hasChildren = false; let eptHierarchyFile = - `${this.ept.url}ept-hierarchy/${this.filename()}.json`; + `${this.ept.url}ept-hierarchy/${this.filename()}.json`; let response = await fetch(eptHierarchyFile); let hier = await response.json(); @@ -3869,288 +3869,288 @@ } class PointCloudGreyhoundGeometryNode$1 extends PointCloudTreeNode { - constructor(name, pcoGeometry, boundingBox, scale, offset) { - super(); + 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; + 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()); + 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); - } + 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 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) - ); - } + // 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 = []; + 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]); - } - } + for (let i = 0; i < 8; ++i) { + if (this.children[i]) { + children.push(this.children[i]); + } + } - return children; - } + return children; + } - getURL() { - let schema = this.pcoGeometry.schema; - let bounds = this.greyhoundBounds; + 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 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'; + 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.scale) { + url += '&scale=' + this.scale; + } - if (this.greyhoundOffset) { - let offset = this.greyhoundOffset; - url += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']'; - } + if (this.greyhoundOffset) { + let offset = this.greyhoundOffset; + url += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']'; + } - if (!this.baseLoaded) this.baseLoaded = true; + if (!this.baseLoaded) this.baseLoaded = true; - return url; - }; + return url; + }; - addChild(child) { - this.children[child.index] = child; - child.parent = this; - }; + addChild(child) { + this.children[child.index] = child; + child.parent = this; + }; - load() { - if ( - this.loading === true || - this.loaded === true || - Potree.numNodesLoading >= Potree.maxNodesLoading) { - return; - } + load() { + if ( + this.loading === true || + this.loaded === true || + Potree.numNodesLoading >= Potree.maxNodesLoading) { + return; + } - this.loading = true; - Potree.numNodesLoading++; + this.loading = true; + Potree.numNodesLoading++; - if ( - this.level % this.pcoGeometry.hierarchyStepSize === 0 && - this.hasChildren) { - this.loadHierarchyThenPoints(); - } else { - this.loadPoints(); - } - } + if ( + this.level % this.pcoGeometry.hierarchyStepSize === 0 && + this.hasChildren) { + this.loadHierarchyThenPoints(); + } else { + this.loadPoints(); + } + } - loadPoints() { this.pcoGeometry.loader.load(this); }; + 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]; + 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 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; + 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; - } + 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 - }); + stack.push({ + children: makeBitMask(child), + numPoints: child.n, + name: childName + }); - parseChildrenCounts(child, childName, stack); - }); - }; + parseChildrenCounts(child, childName, stack); + }); + }; - // Load hierarchy. - let callback = function (node, greyhoundHierarchy) { - let decoded = []; - node.numPoints = greyhoundHierarchy.n; - parseChildrenCounts(greyhoundHierarchy, node.name, decoded); + // 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; + 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); + 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); + 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; - } + 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(); - }; + node.loadPoints(); + }; - if (this.level % this.pcoGeometry.hierarchyStepSize === 0) { - let depthBegin = this.level + this.pcoGeometry.baseDepth; - let depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2; + 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 bounds = this.greyhoundBounds; - let boundsString = - bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' + - bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z; + 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; + let hurl = '' + this.pcoGeometry.serverURL + + 'hierarchy?bounds=[' + boundsString + ']' + + '&depthBegin=' + depthBegin + + '&depthEnd=' + depthEnd; - if (this.scale) { - hurl += '&scale=' + this.scale; - } + if (this.scale) { + hurl += '&scale=' + this.scale; + } - if (this.greyhoundOffset) { - let offset = this.greyhoundOffset; - hurl += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']'; - } + 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 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 - ); - } - } - }; + 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); - } - } - } + try { + xhr.send(null); + } catch (e) { + console.log('fehler beim laden der punktwolke: ' + e); + } + } + } - getNumPoints() { return this.numPoints; }; + getNumPoints() { return this.numPoints; }; - dispose() { - if (this.geometry && this.parent != null) { - this.geometry.dispose(); - this.geometry = null; - this.loaded = false; + 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 = []; - } - } + // this.dispatchEvent( { type: 'dispose' } ); + for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) { + let handler = this.oneTimeDisposeHandlers[i]; + handler(); + } + this.oneTimeDisposeHandlers = []; + } + } } PointCloudGreyhoundGeometryNode$1.IDCount = 0; @@ -8329,12 +8329,12 @@ void main() { * * * 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. @@ -8449,7 +8449,7 @@ void main() { * * * 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(). @@ -12618,274 +12618,274 @@ void main() { } class EptBinaryLoader { - load(node) { - if (node.loaded) return; + load(node) { + if (node.loaded) return; - let url = node.url() + '.bin'; + 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); - } - } - }; + 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); - } - } + 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); + 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; + 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 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)); + 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)); - } + 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; + 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) - ); + 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)); + node.doneLoading( + g, + tightBoundingBox, + numPoints, + new THREE.Vector3(...e.data.mean)); - Potree.workerPool.returnWorker(workerPath, worker); - }; + 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) - }; + 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]); - } + worker.postMessage(message, [message.buffer]); + } } /** * laslaz code taken and adapted from plas.io js-laslaz - * http://plas.io/ - * https://github.com/verma/plasio + * http://plas.io/ + * https://github.com/verma/plasio * * Thanks to Uday Verma and Howard Butler * */ class EptLaszipLoader { - load(node) { - if (node.loaded) return; + load(node) { + if (node.loaded) return; - let url = node.url() + '.laz'; + 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); - } - } - }; + 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); - } + xhr.send(null); + } - parse(node, buffer){ - let lf = new LASFile(buffer); - let handler = new EptLazBatcher(node); + 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; + 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 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); + 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; + i += data.count; - if (data.hasMoreData) { - return read(); - } - else { - header.totalRead = i; - header.versionAsString = lf.versionAsString; - header.isCompressed = lf.isCompressed; - return null; - } - }); - }; + 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; - }); - } + 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; + }); + } } class EptLazBatcher { - constructor(node) { this.node = node; } + constructor(node) { this.node = node; } - push(las) { - let workerPath = Potree.scriptPath + + push(las) { + let workerPath = Potree.scriptPath + '/workers/EptLaszipDecoderWorker.js'; - let worker = Potree.workerPool.getWorker(workerPath); + let worker = Potree.workerPool.getWorker(workerPath); - worker.onmessage = (e) => { - let g = new THREE.BufferGeometry(); - let numPoints = las.pointsCount; + 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 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); + 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.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; + 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) - ); + 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)); + this.node.doneLoading( + g, + tightBoundingBox, + numPoints, + new THREE.Vector3(...e.data.mean)); - Potree.workerPool.returnWorker(workerPath, worker); - }; + 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 - }; + 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]); - }; + worker.postMessage(message, [message.buffer]); + }; } class GreyhoundBinaryLoader{ @@ -17951,24 +17951,24 @@ void main() { } if (!this.sceneProjection) { - try { - this.setSceneProjection(pointcloud.projection); - } - catch (e) { - console.log('Failed projection:', e); + 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; - } + 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(); @@ -25954,15 +25954,15 @@ ENDSEC if (!path){ // TODO: callback? comment? Hello? Bueller? Anyone? } else if (path.indexOf('ept.json') > 0) { - Potree.EptLoader.load(path, function(geometry) { - if (!geometry) { + 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 { + 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) {