diff --git a/build/js/potree.js b/build/js/potree.js index 40d7a29a..c962fa6c 100644 --- a/build/js/potree.js +++ b/build/js/potree.js @@ -715,13 +715,16 @@ Potree.PointCloudHeightMaterial = function(parameters){ var size = parameters.size || 1.0; this.min = parameters.min || 0; this.max = parameters.max || 1; + + var gradientTexture = Potree.PointCloudHeightMaterial.generateGradient(); var attributes = {}; var uniforms = { uCol: { type: "c", value: new THREE.Color( 0xffffff ) }, size: { type: "f", value: 1 }, uMin: { type: "f", value: this.min }, - uMax: { type: "f", value: this.max } + uMax: { type: "f", value: this.max }, + gradient: {type: "t", value: gradientTexture} }; this.setValues({ @@ -735,6 +738,39 @@ Potree.PointCloudHeightMaterial = function(parameters){ }); }; + +Potree.PointCloudHeightMaterial.generateGradient = function() { + var size = 64; + + // create canvas + canvas = document.createElement( 'canvas' ); + canvas.width = size; + canvas.height = size; + + // get context + var context = canvas.getContext( '2d' ); + + // draw gradient + context.rect( 0, 0, size, size ); + var gradient = context.createLinearGradient( 0, 0, size, size ); + gradient.addColorStop(0, 'blue'); + gradient.addColorStop(1/5, 'aqua'); + gradient.addColorStop(2/5, 'green') + gradient.addColorStop(3/5, 'yellow'); + gradient.addColorStop(4/5, 'orange'); + gradient.addColorStop(1, 'red'); + + + context.fillStyle = gradient; + context.fill(); + + var texture = new THREE.Texture( canvas ); + texture.needsUpdate = true; + textureImage = texture.image; + + return texture; +} + Potree.PointCloudHeightMaterial.prototype = new THREE.ShaderMaterial(); Object.defineProperty(Potree.PointCloudHeightMaterial.prototype, "size", { @@ -758,6 +794,7 @@ Potree.PointCloudHeightMaterial.vs_points = [ "uniform float size; ", "uniform float uMin; ", "uniform float uMax; ", + "uniform sampler2D gradient; ", " ", "varying vec3 vColor; ", " ", @@ -765,8 +802,10 @@ Potree.PointCloudHeightMaterial.vs_points = [ " vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); ", " vec4 world = modelMatrix * vec4( position, 1.0 ); ", " float w = (world.y - uMin) / (uMax-uMin); ", - " w = clamp(w-0.1, 0.2, 1.0); ", - " vColor = vec3(1.0, 0.0, 0.0) * (w) ; ", + " ", + " vec4 gCol = texture2D(gradient, vec2(w,1.0-w)); ", + " vColor = gCol.rgb; ", + " ", " ", " gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); ", " gl_PointSize = max(2.0, gl_PointSize); ", @@ -838,6 +877,15 @@ Object.defineProperty(Potree.PointCloudColorMaterial.prototype, "size", { } }); +Object.defineProperty(Potree.PointCloudColorMaterial.prototype, "color", { + get: function(){ + return this.uniforms.uCol.value; + }, + set: function(value){ + this.uniforms.uCol.value.copy(value); + } +}); + Potree.PointCloudColorMaterial.vs_points = [ "uniform float size; ", "uniform vec3 uCol; ", @@ -1421,12 +1469,8 @@ Potree.PointCloudOctree.prototype.update = function(camera){ var camObjPos = new THREE.Vector3().setFromMatrixPosition( camMatrixObject ); var ray = new THREE.Ray(camera.position, new THREE.Vector3( 0, 0, -1 ).applyQuaternion( camera.quaternion ) ); - //var ray = new THREE.Ray(camera.position, new THREE.Vector3( 0, -1, 0 ) ); // check visibility - // TODO min and max points - //var minPoints = 1*1000*1000; - //var maxPoints = 5*1000*1000; var stack = []; stack.push(this); while(stack.length > 0){ @@ -1438,25 +1482,18 @@ Potree.PointCloudOctree.prototype.update = function(camera){ } var box = object.boundingBox; - //var tbox = Potree.utils.computeTransformedBoundingBox(box, this.matrixWorld); var distance = box.center().distanceTo(camObjPos); var radius = box.size().length() * 0.5; var visible = true; visible = visible && frustum.intersectsBox(box); if(object.level > 0){ - - //if(this.numVisiblePoints > minPoints && this.numVisiblePoints < maxPoints){ - // cull detail nodes based in distance to camera - visible = visible && Math.pow(radius, 0.8) / distance > (1 / this.LOD); - visible = visible && (this.numVisiblePoints + object.numPoints < Potree.pointLoadLimit); - visible = visible && (this.numVisibleNodes <= this.maxVisibleNodes); - visible = visible && (this.numVisiblePoints <= this.maxVisiblePoints); - //}else if(this.numVisiblePoints > maxPoints){ - // visible = false; - //} - }else{ - //visible = true; + // cull detail nodes based in distance to camera + visible = visible && Math.pow(radius, 0.8) / distance > (1 / this.LOD); + visible = visible && (this.numVisiblePoints + object.numPoints < Potree.pointLoadLimit); + visible = visible && (this.numVisibleNodes <= this.maxVisibleNodes); + visible = visible && (this.numVisiblePoints <= this.maxVisiblePoints); + } // trying to skip higher detail nodes, if parents already cover all holes @@ -1543,21 +1580,8 @@ Potree.PointCloudOctree.prototype.replaceProxy = function(proxy){ var child = geometryNode.children[i]; var childProxy = new Potree.PointCloudOctreeProxyNode(child); node.add(childProxy); - - //for(var j = 0; j < 8; j++){ - // if(child.children[j] !== undefined){ - // var cchild = child.children[j]; - // var cchildProxy = new Potree.PointCloudOctreeProxyNode(cchild); - // childProxy.add(cchildProxy); - // - // - // } - //} } } - }else{ - //geometryNode.load(); - //this.loadQueue.push(geometryNode); } } diff --git a/build/js/potree.min.js b/build/js/potree.min.js index c7245f94..9d94d71c 100644 --- a/build/js/potree.min.js +++ b/build/js/potree.min.js @@ -1,3 +1,3 @@ function Potree(){}function POCLoader(){}function PointAttributeNames(){}function PointAttribute(M,w,D){this.name=M,this.type=w,this.numElements=D,this.byteSize=this.numElements*this.type.size}function PointAttributes(M){if(this.attributes=new Array,this.byteSize=0,this.size=0,null!=M)for(var w in M){var D=M[w];this.attributes.push(D),this.byteSize+=D.byteSize,this.size++}}function LasLazLoader(){}function LRUItem(M){this.previous=null,this.next=null,this.node=M}function LRU(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}Potree.pointLoadLimit=5e7,Potree.workers={},Potree.WorkerManager=function(M){this.code=M,this.instances=[],this.createdInstances=0},Potree.WorkerManager.prototype.getWorker=function(){var M=this.instances.pop();return void 0===M&&(M=Potree.utils.createWorker(this.code),this.createdInstances++),M},Potree.WorkerManager.prototype.returnWorker=function(M){this.instances.push(M)},Potree.WorkerManager.fromUrls=function(M){for(var w="",D=0;D=l?j.pointsCount:j.pointsCount/l,T=function(){var M=D.readData(1e6,0,l);return M.then(function(M){return w.push(new LASDecoder(M.buffer,j.pointsFormatId,j.pointsStructSize,M.count,j.scale,j.offset,j.mins,j.maxs)),W+=M.count,LasLazLoader.progressCB(W/P),M.hasMoreData?T():(j.totalRead=W,j.versionAsString=D.versionAsString,j.isCompressed=D.isCompressed,[D,j,w])})};return T()}).then(function(M){var w=M[0];return LasLazLoader.progressCB(1),w.close().then(function(){return w.isOpen=!1,Promise.delay(200).cancellable()}).then(function(){return M.slice(1)})}).catch(Promise.CancellationError,function(M){if(D.isOpen)return D.close().then(function(){throw D.isOpen=!1,M});throw M})},Potree.PointCloudRGBMaterial=function(M){M=M||{};var w={},D={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10}},j=M.size||1;this.setValues({uniforms:D,attributes:w,vertexShader:Potree.PointCloudRGBMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:j,alphaTest:.9})},Potree.PointCloudRGBMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudRGBMaterial.vs_points=["uniform float size; ","varying vec3 vColor; "," ","void main() { "," vColor = color; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudRGBMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudIntensityMaterial=function(M){M=M||{};var w=M.size||1;this.min=M.min||0,this.max=M.max||1;var D={intensity:{type:"f",value:[]}},j={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max}};this.setValues({uniforms:j,attributes:D,vertexShader:Potree.PointCloudIntensityMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudIntensityMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:w,alphaTest:.9})},Potree.PointCloudIntensityMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudIntensityMaterial.vs_points=["attribute float intensity; ","uniform float size; ","uniform float uMin; ","uniform float uMax; ","varying vec3 vColor; "," ","void main() { "," vColor = vec3(1.0, 1.0, 1.0) * (intensity -uMin) / uMax; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," //gl_PointSize = size * 1.0 / length( mvPosition.xyz ); "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudIntensityMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudHeightMaterial=function(M){M=M||{};var w=M.size||1;this.min=M.min||0,this.max=M.max||1;var D={},j={uCol:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max}};this.setValues({uniforms:j,attributes:D,vertexShader:Potree.PointCloudHeightMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudHeightMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:w,alphaTest:.9})},Potree.PointCloudHeightMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudHeightMaterial.prototype.setBoundingBox=function(M){this.min=M.min.y,this.max=M.max.y,this.uniforms.uMin.value=this.min,this.uniforms.uMax.value=this.max},Potree.PointCloudHeightMaterial.vs_points=["uniform float size; ","uniform float uMin; ","uniform float uMax; "," ","varying vec3 vColor; "," ","void main() { "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," vec4 world = modelMatrix * vec4( position, 1.0 ); "," float w = (world.y - uMin) / (uMax-uMin); "," w = clamp(w-0.1, 0.2, 1.0); "," vColor = vec3(1.0, 0.0, 0.0) * (w) ; "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudHeightMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudColorMaterial=function(M){M=M||{};var w=M.color||(new THREE.Color).setRGB(1,0,0),D=M.size||1,j={},l={uCol:{type:"c",value:w},size:{type:"f",value:1}};this.setValues({uniforms:l,attributes:j,vertexShader:Potree.PointCloudColorMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudColorMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:D,alphaTest:.9})},Potree.PointCloudColorMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudColorMaterial.vs_points=["uniform float size; ","uniform vec3 uCol; ","varying vec3 vColor; "," ","void main() { "," vColor = uCol; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudColorMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],THREE.FirstPersonControls=function(M,w){function D(M){X.enabled!==!1&&(M.preventDefault(),0===M.button?(p=A.ROTATE,Z.set(M.clientX,M.clientY)):2===M.button&&(p=A.PAN,b.set(M.clientX,M.clientY)),X.domElement.addEventListener("mousemove",j,!1),X.domElement.addEventListener("mouseup",l,!1),X.dispatchEvent(h))}function j(M){if(X.enabled!==!1){M.preventDefault();var w=X.domElement===document?X.domElement.body:X.domElement;p===A.ROTATE?(Y.set(M.clientX,M.clientY),t.subVectors(Y,Z),X.rotateLeft(2*Math.PI*t.x/w.clientWidth*X.rotateSpeed),X.rotateUp(2*Math.PI*t.y/w.clientHeight*X.rotateSpeed),Z.copy(Y)):p===A.PAN&&(s.set(M.clientX,M.clientY),K.subVectors(s,b),K.multiplyScalar(5e-4).multiplyScalar(X.moveSpeed),X.pan(K.x,K.y),b.copy(s))}}function l(){X.enabled!==!1&&(X.domElement.removeEventListener("mousemove",j,!1),X.domElement.removeEventListener("mouseup",l,!1),X.dispatchEvent(x),p=A.NONE)}function W(M){if(X.enabled!==!1&&X.noZoom!==!0){M.preventDefault();var w=0;void 0!==M.wheelDelta?w=M.wheelDelta:void 0!==M.detail&&(w=-M.detail),X.moveSpeed+=.001*X.moveSpeed*w,X.moveSpeed=Math.max(.1,X.moveSpeed),X.dispatchEvent(h),X.dispatchEvent(x)}}function P(M){if(X.enabled!==!1)switch(M.keyCode){case X.keys.UP:X.moveForward=!0;break;case X.keys.BOTTOM:X.moveBackward=!0;break;case X.keys.LEFT:X.moveLeft=!0;break;case X.keys.RIGHT:X.moveRight=!0;break;case X.keys.W:X.moveForward=!0;break;case X.keys.S:X.moveBackward=!0;break;case X.keys.A:X.moveLeft=!0;break;case X.keys.D:X.moveRight=!0}}function T(M){switch(M.keyCode){case X.keys.W:X.moveForward=!1;break;case X.keys.S:X.moveBackward=!1;break;case X.keys.A:X.moveLeft=!1;break;case X.keys.D:X.moveRight=!1;break;case X.keys.UP:X.moveForward=!1;break;case X.keys.BOTTOM:X.moveBackward=!1;break;case X.keys.LEFT:X.moveLeft=!1;break;case X.keys.RIGHT:X.moveRight=!1}}this.object=M,this.domElement=void 0!==w?w:document,this.enabled=!0,this.rotateSpeed=1,this.moveSpeed=10,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40,A:"A".charCodeAt(0),S:"S".charCodeAt(0),D:"D".charCodeAt(0),W:"W".charCodeAt(0)};var X=this,Z=new THREE.Vector2,Y=new THREE.Vector2,t=new THREE.Vector2,b=new THREE.Vector2,s=new THREE.Vector2,K=new THREE.Vector2,d=new THREE.Vector3,y=(new THREE.Vector3,0),N=0,c=1,C=new THREE.Vector3,m=new THREE.Vector3,A={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},p=A.NONE;this.position0=this.object.position.clone();var G={type:"change"},h={type:"start"},x={type:"end"};this.rotateLeft=function(M){N-=M},this.rotateUp=function(M){y-=M},this.panLeft=function(M){var w=this.object.matrix.elements;d.set(w[0],w[1],w[2]),d.multiplyScalar(-M),C.add(d)},this.panUp=function(M){var w=this.object.matrix.elements;d.set(w[4],w[5],w[6]),d.multiplyScalar(M),C.add(d)},this.panForward=function(M){var w=this.object.matrix.elements;d.set(w[8],w[9],w[10]),d.multiplyScalar(M),C.add(d)},this.pan=function(M,w){var D=X.domElement===document?X.domElement.body:X.domElement;if(void 0!==X.object.fov){var j=X.object.position,l=j.clone(),W=l.length();W*=Math.tan(X.object.fov/2*Math.PI/180),X.panLeft(2*M*W/D.clientHeight),X.panUp(2*w*W/D.clientHeight)}else void 0!==X.object.top?(X.panLeft(M*(X.object.right-X.object.left)/D.clientWidth),X.panUp(w*(X.object.top-X.object.bottom)/D.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(M){var w=this.object.position;if(void 0!==M&&(this.moveRight&&this.panLeft(-M*this.moveSpeed),this.moveLeft&&this.panLeft(M*this.moveSpeed),this.moveForward&&this.panForward(-M*this.moveSpeed),this.moveBackward&&this.panForward(M*this.moveSpeed)),!C.equals(new THREE.Vector3(0,0,0))){var D={type:"move",translation:C.clone()};this.dispatchEvent(D)}w.add(C),this.object.updateMatrix();var j=(new THREE.Matrix4).makeRotationY(N),l=(new THREE.Matrix4).multiplyMatrices(j,this.object.matrix);this.object.quaternion.setFromRotationMatrix(l),this.object.rotation.x+=y,N=0,y=0,c=1,C.set(0,0,0),m.distanceTo(this.object.position)>0&&(this.dispatchEvent(G),m.copy(this.object.position))},this.reset=function(){p=A.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(M){M.preventDefault()},!1),this.domElement.addEventListener("mousedown",D,!1),this.domElement.addEventListener("mousewheel",W,!1),this.domElement.addEventListener("DOMMouseScroll",W,!1),window.addEventListener("keydown",P,!1),window.addEventListener("keyup",T,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(M){return null==this.items[M.id]},LRU.prototype.touch=function(M){var w;null==this.items[M.id]?(w=new LRUItem(M),w.previous=this.last,this.last=w,null!==w.previous&&(w.previous.next=w),this.items[M.id]=w,this.elements++,null===this.first&&(this.first=w),this.numPoints+=M.numPoints):(w=this.items[M.id],null===w.previous?null!==w.next&&(this.first=w.next,this.first.previous=null,w.previous=this.last,w.next=null,this.last=w,w.previous.next=w):null===w.next||(w.previous.next=w.next,w.next.previous=w.previous,w.previous=this.last,w.next=null,this.last=w,w.previous.next=w))},LRU.prototype.remove=function(){if(null===this.first)return null;var M=this.first;return null!==M.next?(this.first=M.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[M.node.id],this.elements--,this.numPoints-=M.node.numPoints,M.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var M=this.first;return M.node},LRU.prototype.toString=function(){for(var M="{ ",w=this.first;null!==w;)M+=w.node.id,null!==w.next&&(M+=", "),w=w.next;return M+="}",M+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(M){THREE.Object3D.call(this),this.geometryNode=M,this.boundingBox=M.boundingBox,this.name=M.name,this.level=M.level,this.numPoints=M.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree=function(M,w){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=M,this.boundingBox=this.pcoGeometry.root.boundingBox,this.material=w,this.maxVisibleNodes=2e3,this.maxVisiblePoints=2e7,this.level=0,this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.loadQueue=[];var D=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(D)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(M){this.numVisibleNodes=0,this.numVisiblePoints=0,this.loadQueue=[],M.updateMatrixWorld();var w=new THREE.Frustum,D=M.matrixWorldInverse,j=this.matrixWorld,l=M.projectionMatrix,W=(new THREE.Matrix4).multiply(l).multiply(D).multiply(j);w.setFromMatrix(W);var P=M.matrixWorld,T=(new THREE.Matrix4).getInverse(j),X=(new THREE.Matrix4).multiply(T).multiply(P),Z=(new THREE.Vector3).setFromMatrixPosition(X),Y=(new THREE.Ray(M.position,new THREE.Vector3(0,0,-1).applyQuaternion(M.quaternion)),[]);for(Y.push(this);Y.length>0;){var t=Y.shift();if(t instanceof THREE.Mesh||t instanceof THREE.Line)t.visible=!0;else{var b=t.boundingBox,s=b.center().distanceTo(Z),K=.5*b.size().length(),d=!0;if(d=d&&w.intersectsBox(b),t.level>0&&(d=d&&Math.pow(K,.8)/s>1/this.LOD,d=d&&this.numVisiblePoints+t.numPoints0){this.loadQueue.length>=2&&this.loadQueue.sort(function(M,w){return w.lod-M.lod});for(var c=0;cW;W++)if(void 0!==w.children[W]){var P=w.children[W],T=new Potree.PointCloudOctreeProxyNode(P);j.add(T)}}},Potree.PointCloudOctree.prototype.hideDescendants=function(M){for(var w=[],D=0;D0;){var M=w.shift();M.visible=!1;for(var D=0;D0;){var t=l.shift();if(console.log("traversing: "+t.name),t instanceof THREE.PointCloud)for(var b=t.geometry,s=b.attributes.position,K=s.array,d=s.length/s.itemSize,y=0;d>y;y++){var N=new THREE.Vector3(K[3*y],K[3*y+1],K[3*y+2]);N.applyMatrix4(this.matrixWorld);var c=Math.abs(Z.distanceToPoint(N));D/2>c&&Y.push(N)}if(t==this||t.levelw)},Potree.PointCloudOctree.disposeNode=function(M){var w=0,D=0,j=[];M.traverse(function(M){j.push(M)});for(var l=0;l5)){this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++;var M=this.pcoGeometry.pointAttributes;if("LAS"===M||"LAZ"===M){var w=this.pcoGeometry.octreeDir+"/"+this.name+"."+M.toLowerCase();nodesLoadTimes[w]={},nodesLoadTimes[w].start=(new Date).getTime(),LasLazLoader.load(w,new Potree.LasLazBatcher(this,w))}else if("POT"===M){var D=function(M,w){var D=new DataView(w,0,4),j=D.getUint32(0,!0),l=4+j,W=w.slice(4,4+j),P=String.fromCharCode.apply(null,new Uint8Array(W));P=JSON.parse(P),console.log(P);for(var T=P.attributes[0].scale,X=P.attributes[0].offset,Z=P.attributes[0].encoding,Y=new THREE.Vector3(T[0],T[1],T[2]),t=new THREE.Vector3(X[0],X[1],X[2]),b=Z.min,s=(Z.max,Z.bits),K=w.slice(l,l+w.byteLength-l),d=new BitReader(K),N=d.read(32),c=d.read(32),C=d.read(32),m=d.read(8),A=d.read(8),p=d.read(8),G=new THREE.BufferGeometry,h=P.pointcount,i=new Float32Array(3*h),o=new Float32Array(3*h),V=(new THREE.Color,0);VY;Y++)W[3*Y+0]=X[4*Y+0]+M.pcoGeometry.offset.x,W[3*Y+1]=X[4*Y+1]+M.pcoGeometry.offset.y,W[3*Y+2]=X[4*Y+2]+M.pcoGeometry.offset.z,T.setRGB(Z[16*Y+12],Z[16*Y+13],Z[16*Y+14]),P[3*Y+0]=T.r/255,P[3*Y+1]=T.g/255,P[3*Y+2]=T.b/255;j.addAttribute("position",new THREE.BufferAttribute(W,3)),j.addAttribute("color",new THREE.BufferAttribute(P,3)),j.boundingBox=M.boundingBox,M.geometry=j,M.loaded=!0,M.loading=!1,M.pcoGeometry.numNodesLoading--,nodesLoadTimes[w].end=(new Date).getTime();nodesLoadTimes[w].end-nodesLoadTimes[w].start};nodesLoadTimes[w]={},nodesLoadTimes[w].start=(new Date).getTime(),Potree.BinaryNodeLoader.load(this,"",D)}}},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(M,w,D){var j=M.pcoGeometry.octreeDir+"/"+M.name;void 0!==w&&w.length>0&&(j+="."+w);var l=new XMLHttpRequest;l.open("GET",j,!0),l.responseType="arraybuffer",l.overrideMimeType("text/plain; charset=x-user-defined"),l.onreadystatechange=function(){if(4===l.readyState)if(200===l.status||0===l.status){var w=l.response;D(M,w)}else console.log("Failed to load file! HTTP status: "+l.status+", file: "+j)};try{l.send(null)}catch(W){console.log("fehler beim laden der punktwolke: "+W)}},Potree.LasLazBatcher=function(M,w){this.push=function(D){var j=Potree.workers.lasdecoder.getWorker(),l=new THREE.Vector3(D.mins[0],D.mins[1],D.mins[2]),W=new THREE.Vector3(D.maxs[0],D.maxs[1],D.maxs[2]); -l.add(M.pcoGeometry.offset),W.add(M.pcoGeometry.offset),j.onmessage=function(P){for(var T=new THREE.BufferGeometry,X=D.pointsCount,Z=P.data.position,Y=P.data.color,t=P.data.intensity,b=new Uint8Array(P.data.classification),s=new Float32Array(b.byteLength),K=new THREE.Box3,d=new Float32Array(Z),y=0;X>y;y++)s[y]=b[y],K.expandByPoint(new THREE.Vector3(d[3*y+0],d[3*y+1],d[3*y+2]));T.addAttribute("position",new THREE.BufferAttribute(new Float32Array(Z),3)),T.addAttribute("color",new THREE.BufferAttribute(new Float32Array(Y),3)),T.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(t),1)),T.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(s),1)),T.boundingBox=new THREE.Box3(l,W),M.boundingBox=T.boundingBox,M.geometry=T,M.loaded=!0,M.loading=!1,M.pcoGeometry.numNodesLoading--,nodesLoadTimes[w].end=(new Date).getTime();nodesLoadTimes[w].end-nodesLoadTimes[w].start;Potree.workers.lasdecoder.returnWorker(j)};var P={buffer:D.arrayb,numPoints:D.pointsCount,pointSize:D.pointSize,pointFormatID:2,scale:D.scale,offset:D.offset,mins:[M.pcoGeometry.boundingBox.min.x,M.pcoGeometry.boundingBox.min.y,M.pcoGeometry.boundingBox.min.z],maxs:[M.pcoGeometry.boundingBox.max.x,M.pcoGeometry.boundingBox.max.y,M.pcoGeometry.boundingBox.max.z],bbOffset:[M.pcoGeometry.offset.x,M.pcoGeometry.offset.y,M.pcoGeometry.offset.z]};j.postMessage(P,[P.buffer])}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(M){var w=new XMLHttpRequest;return w.open("GET",M,!1),w.send(null),200!==w.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(M,w){var D=[new THREE.Vector3(M.min.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.max.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.min.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.max.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.max.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.min.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.max.y,M.max.z).applyMatrix4(w)],j=new THREE.Box3;return j.setFromPoints(D),j},Potree.utils.addCommas=function(M){M+="",x=M.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var w=/(\d+)(\d{3})/;w.test(x1);)x1=x1.replace(w,"$1,$2");return x1+x2},Potree.utils.createWorker=function(M){var w=new Blob([M],{type:"application/javascript"}),D=new Worker(URL.createObjectURL(w));return D},Potree.utils.loadSkybox=function(M){var w=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),D=new THREE.Scene,j=".jpg",l=[M+"px"+j,M+"nx"+j,M+"py"+j,M+"ny"+j,M+"pz"+j,M+"nz"+j],W=THREE.ImageUtils.loadTextureCube(l,new THREE.CubeRefractionMapping),P=new THREE.MeshBasicMaterial({color:16777215,envMap:W,refractionRatio:.95}),T=THREE.ShaderLib.cube;T.uniforms.tCube.value=W;var P=new THREE.ShaderMaterial({fragmentShader:T.fragmentShader,vertexShader:T.vertexShader,uniforms:T.uniforms,depthWrite:!1,side:THREE.BackSide}),X=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),P);return D.add(X),{camera:w,scene:D}},Potree.utils.createGrid=function(M,w,D,j){for(var l=new THREE.LineBasicMaterial({color:j||8947848}),W=new THREE.Geometry,P=0;w>=P;P++)W.vertices.push(new THREE.Vector3(-(D*M)/2,0,P*D-D*w/2)),W.vertices.push(new THREE.Vector3(+(D*M)/2,0,P*D-D*w/2));for(var P=0;M>=P;P++)W.vertices.push(new THREE.Vector3(P*D-D*M/2,0,-(D*w)/2)),W.vertices.push(new THREE.Vector3(P*D-D*M/2,0,+(D*w)/2));var T=new THREE.Line(W,l,THREE.LinePieces);return T.receiveShadow=!0,T},Potree.TextSprite=function(M){var w=new THREE.Texture,D=new THREE.SpriteMaterial({map:w,useScreenCoordinates:!1});THREE.Sprite.call(this,D),this.borderThickness=4,this.fontface="Arial",this.fontsize=28,this.borderColor={r:0,g:0,b:0,a:1},this.backgroundColor={r:255,g:255,b:255,a:1},this.text="",this.setText(M)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(M){this.text=M,this.update()},Potree.TextSprite.prototype.setBorderColor=function(M){this.borderColor=M,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(M){this.backgroundColor=M,this.update()},Potree.TextSprite.prototype.update=function(){var M=document.createElement("canvas"),w=M.getContext("2d");w.font="Bold "+this.fontsize+"px "+this.fontface;var D=w.measureText(this.text),j=D.width,l=j+2*this.borderThickness,W=1.4*this.fontsize+2*this.borderThickness,M=document.createElement("canvas"),w=M.getContext("2d");w.canvas.width=l,w.canvas.height=W,w.font="Bold "+this.fontsize+"px "+this.fontface,w.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",w.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",w.lineWidth=this.borderThickness,this.roundRect(w,this.borderThickness/2,this.borderThickness/2,j+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),w.strokeStyle="rgba(0, 0, 0, 1.0)",w.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),w.fillStyle="rgba(255, 255, 255, 1.0)",w.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var P=new THREE.Texture(M);P.needsUpdate=!0,this.material.map=P,this.scale.set(.01*l,.01*W,1)},Potree.TextSprite.prototype.roundRect=function(M,w,D,j,l,W){M.beginPath(),M.moveTo(w+W,D),M.lineTo(w+j-W,D),M.quadraticCurveTo(w+j,D,w+j,D+W),M.lineTo(w+j,D+l-W),M.quadraticCurveTo(w+j,D+l,w+j-W,D+l),M.lineTo(w+W,D+l),M.quadraticCurveTo(w,D+l,w,D+l-W),M.lineTo(w,D+W),M.quadraticCurveTo(w,D,w+W,D),M.closePath(),M.fill(),M.stroke()},Potree.MeasuringTool=function(M,w,D){function j(){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[]}function l(M){var w=X();if(w){var D=w.clone(),l=new THREE.MeshNormalMaterial({shading:THREE.SmoothShading}),W=new THREE.SphereGeometry(.4,10,10),P=new THREE.Mesh(W,l);P.position.copy(w),Z.sceneRoot.add(P);var T=new THREE.Mesh(W,l);T.position.copy(w),Z.sceneRoot.add(T);var b=D.x.toFixed(2)+" / "+D.y.toFixed(2)+" / "+D.z.toFixed(2),s=new Potree.TextSprite(b);s.setBorderColor({r:0,g:255,b:0,a:1}),s.material.depthTest=!1,s.material.opacity=0,s.position.copy(w),s.position.y+=.5,Z.sceneRoot.add(s);var K=new Potree.TextSprite(b);K.setBorderColor({r:0,g:255,b:0,a:1}),K.material.depthTest=!1,K.material.opacity=0,K.position.copy(w),K.position.y+=.5,Z.sceneRoot.add(K);var d=new THREE.Color(16711680),y=new THREE.Geometry;y.vertices.push(w.clone(),w.clone()),y.colors.push(d,d,d);var N=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});N.depthTest=!1,sConnection=new THREE.Line(y,N),Z.sceneRoot.add(sConnection);var c=new Potree.TextSprite(0);c.setBorderColor({r:0,g:255,b:0,a:0}),c.setBackgroundColor({r:0,g:255,b:0,a:0}),c.material.depthTest=!1,c.position.copy(w),c.position.y+=.5,Z.sceneRoot.add(c),t===Y.DEFAULT?(t=Y.PICKING,Z.activeMeasurement=new j,Z.activeMeasurement.spheres.push(P)):t===Y.PICKING,Z.activeMeasurement.points.push(w),Z.activeMeasurement.spheres.push(T),Z.activeMeasurement.sphereLabels.push(s),Z.activeMeasurement.sphereLabels.push(K),Z.activeMeasurement.edges.push(sConnection),Z.activeMeasurement.edgeLabels.push(c);var M={type:"newpoint",position:D.clone()};Z.dispatchEvent(M)}}function W(M){if(Z.mouse.x=M.clientX/Z.domElement.clientWidth*2-1,Z.mouse.y=2*-(M.clientY/Z.domElement.clientHeight)+1,t==Y.PICKING&&Z.activeMeasurement){var w=X();if(w){var D=w.clone(),j=Z.activeMeasurement.spheres.length,l=Z.activeMeasurement.spheres[j-1],W=Z.activeMeasurement.sphereLabels[j-1],P=Z.activeMeasurement.edges[j-2],T=Z.activeMeasurement.edgeLabels[j-2],b=D.x.toFixed(2)+" / "+D.y.toFixed(2)+" / "+D.z.toFixed(2);W.setText(b),l.position.copy(w),W.position.copy(w),W.position.y+=.5,P.geometry.vertices[1].copy(w),P.geometry.verticesNeedUpdate=!0,P.geometry.computeBoundingSphere();var s=P.geometry.vertices[1].clone().add(P.geometry.vertices[0]).multiplyScalar(.5),K=P.geometry.vertices[0].distanceTo(P.geometry.vertices[1]).toFixed(2);T.position.copy(s),T.setText(K),T.scale.multiplyScalar(10)}}}function P(){if(t==Y.PICKING){var M=Z.activeMeasurement.spheres.pop(),w=Z.activeMeasurement.edges.pop(),D=Z.activeMeasurement.sphereLabels.pop(),j=Z.activeMeasurement.edgeLabels.pop();Z.sceneRoot.remove(M),Z.sceneRoot.remove(w),Z.sceneRoot.remove(D),Z.sceneRoot.remove(j),Z.measurements.push(Z.activeMeasurement),Z.activeMeasurement=void 0,t=Y.DEFAULT}}function T(M){3===M.which&&P(M)}function X(){var M=new THREE.Vector3(Z.mouse.x,Z.mouse.y,.5),w=new THREE.Projector;w.unprojectVector(M,Z.camera);var D=new THREE.Raycaster;D.params={PointCloud:{threshold:1}},D.ray.set(Z.camera.position,M.sub(Z.camera.position).normalize());var j=[];Z.scene.traverse(function(M){M instanceof Potree.PointCloudOctree&&j.push(M)});var l=D.intersectObjects(j,!0);if(l.length>0){var W=l[0];return W.point}return void 0}var Z=this;this.scene=M,this.camera=w,this.domElement=D,this.mouse={x:0,y:0};var Y={DEFAULT:0,PICKING:1},t=Y.DEFAULT;this.activeMeasurement,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.domElement.addEventListener("dblclick",l,!1),this.domElement.addEventListener("mousemove",W,!1),this.domElement.addEventListener("mousedown",T,!1)},Potree.MeasuringTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.ProfileTool=function(M,w,D){THREE.Object3D.call(this);var j=new THREE.BoxGeometry(1,1,1,1,1,1),l=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.3});this.profileFrustum=new THREE.Mesh(j,l),this.add(this.profileFrustum),this.camera=new THREE.OrthographicCamera(-M/2,M/2,w/2,-w/2,1,1+D),this.add(this.camera),this.setDimension(M,w,D),this.rtProfile=new THREE.WebGLRenderTarget(512,512,{minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBFormat}),this.hudGeometry=new THREE.BoxGeometry(2,2,1),this.hudMaterial=new THREE.MeshBasicMaterial({color:16777215,map:this.rtProfile}),this.hudMaterial.depthTest=!1,this.hudElement=new THREE.Mesh(this.hudGeometry,this.hudMaterial),this.hudElement.scale.set(1,1,1),this.hudElement.position.set(0,0,0)},Potree.ProfileTool.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileTool.prototype.setDimension=function(M,w,D){this.profileFrustum.scale.set(M,w,D),this.width=M,this.height=w,this.depth=D,this.camera.left=-M/2,this.camera.right=M/2,this.camera.top=w/2,this.camera.bottom=-w/2,this.camera.updateProjectionMatrix()},Potree.ProfileTool.prototype.setOrientation=function(M){var w=this.position.clone();this.position.add(M),this.lookAt(w),this.position.copy(w),this.camera.position.copy(w.clone().add(M)),this.camera.lookAt(w)},Potree.ProfileTool.prototype.render=function(M,w){this.camera.matrixWorld.copy(this.matrixWorld),w.traverse(function(M){M instanceof Potree.PointCloudOctree&&(M.material.oldSize=M.material.size,M.material.size=0)}),M.render(w,this.camera,this.rtProfile,!0),w.traverse(function(M){M instanceof Potree.PointCloudOctree&&(M.material.size=M.material.oldSize)})},Potree.TranslationTool=function(M){THREE.Object3D.call(this);var w=this;this.camera=M,this.geometry=new THREE.Geometry,this.material=new THREE.MeshBasicMaterial({color:16777215*Math.random()}),this.STATE={DEFAULT:0,TRANSLATE_X:1,TRANSLATE_Y:2,TRANSLATE_Z:3},this.parts={ARROW_X:{name:"arrow_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.TRANSLATE_X},ARROW_Y:{name:"arrow_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.TRANSLATE_Y},ARROW_Z:{name:"arrow_z",object:void 0,color:new THREE.Color(255),state:this.STATE.TRANSLATE_Z}},this.translateStart,this.state=this.STATE.DEFAULT,this.highlighted,this.targets,this.build=function(){var M=w.createArrow(w.parts.ARROW_X,w.parts.ARROW_X.color);M.rotation.z=-Math.PI/2;var D=w.createArrow(w.parts.ARROW_Y,w.parts.ARROW_Y.color),j=w.createArrow(w.parts.ARROW_Z,w.parts.ARROW_Z.color);j.rotation.x=-Math.PI/2,w.add(M),w.add(D),w.add(j);var l=w.createBox(new THREE.Color(16776960));l.scale.z=.02,l.position.set(.5,.5,0);var W=w.createBox(new THREE.Color(16711935));W.scale.y=.02,W.position.set(.5,0,-.5);var P=w.createBox(new THREE.Color(65535));P.scale.x=.02,P.position.set(0,.5,-.5),w.add(l),w.add(W),w.add(P),w.parts.ARROW_X.object=M,w.parts.ARROW_Y.object=D,w.parts.ARROW_Z.object=j,w.scale.multiplyScalar(5)},this.createBox=function(M){var w=new THREE.BoxGeometry(1,1,1),D=new THREE.MeshBasicMaterial({color:M,transparent:!0,opacity:.5}),j=new THREE.Mesh(w,D);return j},this.createArrow=function(M,w){var D=new THREE.MeshBasicMaterial({color:w}),j=new THREE.CylinderGeometry(.1,.1,3,10,1,!1),l=D,W=new THREE.Mesh(j,l);W.position.y=1.5;var P=new THREE.CylinderGeometry(0,.3,1,10,1,!1),T=D,X=new THREE.Mesh(P,T);X.position.y=3;var Z=new THREE.Object3D;return Z.add(W),Z.add(X),Z.partID=M,Z.material=D,Z},this.setHighlighted=function(M){return void 0===M?void(w.highlighted&&(w.highlighted.object.material.color=w.highlighted.color,w.highlighted=void 0)):(void 0!==w.highlighted&&w.highlighted!==M&&(w.highlighted.object.material.color=w.highlighted.color),w.highlighted=M,void(M.object.material.color=new THREE.Color(16776960)))},this.getHoveredObject=function(M){var D=new THREE.Vector3(M.x,M.y,.5),j=new THREE.Projector;j.unprojectVector(D,w.camera);var l=new THREE.Raycaster;l.ray.set(w.camera.position,D.sub(w.camera.position).normalize());var W=l.intersectObject(w,!0);if(0===W.length)return void w.setHighlighted(void 0);var P=W[0],T=P.object.parent.partID;return T},this.onMouseMove=function(M){var D=M.normalizedPosition;if(w.state===w.STATE.DEFAULT)w.setHighlighted(w.getHoveredObject(D));else if(w.state===w.STATE.TRANSLATE_X||w.state===w.STATE.TRANSLATE_Y||w.state===w.STATE.TRANSLATE_Z){var j=w.start.lineStart.clone(),l=w.start.lineEnd.clone().sub(w.start.lineStart);l.normalize();var W=new THREE.Vector3(D.x,D.y),P=(new THREE.Vector3).subVectors(W,j).dot(l),T=l.clone().multiplyScalar(P).add(j),X=new THREE.Projector;X.unprojectVector(T,w.camera);var Z=T.clone().sub(w.position);w.position.copy(T);for(var Y=0;Y=l?j.pointsCount:j.pointsCount/l,T=function(){var M=D.readData(1e6,0,l);return M.then(function(M){return w.push(new LASDecoder(M.buffer,j.pointsFormatId,j.pointsStructSize,M.count,j.scale,j.offset,j.mins,j.maxs)),W+=M.count,LasLazLoader.progressCB(W/P),M.hasMoreData?T():(j.totalRead=W,j.versionAsString=D.versionAsString,j.isCompressed=D.isCompressed,[D,j,w])})};return T()}).then(function(M){var w=M[0];return LasLazLoader.progressCB(1),w.close().then(function(){return w.isOpen=!1,Promise.delay(200).cancellable()}).then(function(){return M.slice(1)})}).catch(Promise.CancellationError,function(M){if(D.isOpen)return D.close().then(function(){throw D.isOpen=!1,M});throw M})},Potree.PointCloudRGBMaterial=function(M){M=M||{};var w={},D={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10}},j=M.size||1;this.setValues({uniforms:D,attributes:w,vertexShader:Potree.PointCloudRGBMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:j,alphaTest:.9})},Potree.PointCloudRGBMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudRGBMaterial.vs_points=["uniform float size; ","varying vec3 vColor; "," ","void main() { "," vColor = color; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudRGBMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudIntensityMaterial=function(M){M=M||{};var w=M.size||1;this.min=M.min||0,this.max=M.max||1;var D={intensity:{type:"f",value:[]}},j={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max}};this.setValues({uniforms:j,attributes:D,vertexShader:Potree.PointCloudIntensityMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudIntensityMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:w,alphaTest:.9})},Potree.PointCloudIntensityMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudIntensityMaterial.vs_points=["attribute float intensity; ","uniform float size; ","uniform float uMin; ","uniform float uMax; ","varying vec3 vColor; "," ","void main() { "," vColor = vec3(1.0, 1.0, 1.0) * (intensity -uMin) / uMax; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," //gl_PointSize = size * 1.0 / length( mvPosition.xyz ); "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudIntensityMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudHeightMaterial=function(M){M=M||{};var w=M.size||1;this.min=M.min||0,this.max=M.max||1;var D=Potree.PointCloudHeightMaterial.generateGradient(),j={},l={uCol:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max},gradient:{type:"t",value:D}};this.setValues({uniforms:l,attributes:j,vertexShader:Potree.PointCloudHeightMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudHeightMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:w,alphaTest:.9})},Potree.PointCloudHeightMaterial.generateGradient=function(){var M=64;canvas=document.createElement("canvas"),canvas.width=M,canvas.height=M;var w=canvas.getContext("2d");w.rect(0,0,M,M);var D=w.createLinearGradient(0,0,M,M);D.addColorStop(0,"blue"),D.addColorStop(.2,"aqua"),D.addColorStop(.4,"green"),D.addColorStop(.6,"yellow"),D.addColorStop(.8,"orange"),D.addColorStop(1,"red"),w.fillStyle=D,w.fill();var j=new THREE.Texture(canvas);return j.needsUpdate=!0,textureImage=j.image,j},Potree.PointCloudHeightMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Potree.PointCloudHeightMaterial.prototype.setBoundingBox=function(M){this.min=M.min.y,this.max=M.max.y,this.uniforms.uMin.value=this.min,this.uniforms.uMax.value=this.max},Potree.PointCloudHeightMaterial.vs_points=["uniform float size; ","uniform float uMin; ","uniform float uMax; ","uniform sampler2D gradient; "," ","varying vec3 vColor; "," ","void main() { "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," vec4 world = modelMatrix * vec4( position, 1.0 ); "," float w = (world.y - uMin) / (uMax-uMin); "," "," vec4 gCol = texture2D(gradient, vec2(w,1.0-w)); "," vColor = gCol.rgb; "," "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudHeightMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],Potree.PointCloudColorMaterial=function(M){M=M||{};var w=M.color||(new THREE.Color).setRGB(1,0,0),D=M.size||1,j={},l={uCol:{type:"c",value:w},size:{type:"f",value:1}};this.setValues({uniforms:l,attributes:j,vertexShader:Potree.PointCloudColorMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudColorMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:D,alphaTest:.9})},Potree.PointCloudColorMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(M){this.uniforms.size.value=M}}),Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"color",{get:function(){return this.uniforms.uCol.value},set:function(M){this.uniforms.uCol.value.copy(M)}}),Potree.PointCloudColorMaterial.vs_points=["uniform float size; ","uniform vec3 uCol; ","varying vec3 vColor; "," ","void main() { "," vColor = uCol; "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," "," gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(2.0, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudColorMaterial.fs_points_rgb=["varying vec3 vColor; "," ","void main() { "," "," //float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," //float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," //float c = 1.0 - (a + b); "," // "," //if(c < 0.0){ "," // discard; "," //} "," "," gl_FragColor = vec4(vColor, 1.0); ","} "],THREE.FirstPersonControls=function(M,w){function D(M){X.enabled!==!1&&(M.preventDefault(),0===M.button?(p=A.ROTATE,Z.set(M.clientX,M.clientY)):2===M.button&&(p=A.PAN,b.set(M.clientX,M.clientY)),X.domElement.addEventListener("mousemove",j,!1),X.domElement.addEventListener("mouseup",l,!1),X.dispatchEvent(h))}function j(M){if(X.enabled!==!1){M.preventDefault();var w=X.domElement===document?X.domElement.body:X.domElement;p===A.ROTATE?(t.set(M.clientX,M.clientY),Y.subVectors(t,Z),X.rotateLeft(2*Math.PI*Y.x/w.clientWidth*X.rotateSpeed),X.rotateUp(2*Math.PI*Y.y/w.clientHeight*X.rotateSpeed),Z.copy(t)):p===A.PAN&&(s.set(M.clientX,M.clientY),K.subVectors(s,b),K.multiplyScalar(5e-4).multiplyScalar(X.moveSpeed),X.pan(K.x,K.y),b.copy(s))}}function l(){X.enabled!==!1&&(X.domElement.removeEventListener("mousemove",j,!1),X.domElement.removeEventListener("mouseup",l,!1),X.dispatchEvent(x),p=A.NONE)}function W(M){if(X.enabled!==!1&&X.noZoom!==!0){M.preventDefault();var w=0;void 0!==M.wheelDelta?w=M.wheelDelta:void 0!==M.detail&&(w=-M.detail),X.moveSpeed+=.001*X.moveSpeed*w,X.moveSpeed=Math.max(.1,X.moveSpeed),X.dispatchEvent(h),X.dispatchEvent(x)}}function P(M){if(X.enabled!==!1)switch(M.keyCode){case X.keys.UP:X.moveForward=!0;break;case X.keys.BOTTOM:X.moveBackward=!0;break;case X.keys.LEFT:X.moveLeft=!0;break;case X.keys.RIGHT:X.moveRight=!0;break;case X.keys.W:X.moveForward=!0;break;case X.keys.S:X.moveBackward=!0;break;case X.keys.A:X.moveLeft=!0;break;case X.keys.D:X.moveRight=!0}}function T(M){switch(M.keyCode){case X.keys.W:X.moveForward=!1;break;case X.keys.S:X.moveBackward=!1;break;case X.keys.A:X.moveLeft=!1;break;case X.keys.D:X.moveRight=!1;break;case X.keys.UP:X.moveForward=!1;break;case X.keys.BOTTOM:X.moveBackward=!1;break;case X.keys.LEFT:X.moveLeft=!1;break;case X.keys.RIGHT:X.moveRight=!1}}this.object=M,this.domElement=void 0!==w?w:document,this.enabled=!0,this.rotateSpeed=1,this.moveSpeed=10,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40,A:"A".charCodeAt(0),S:"S".charCodeAt(0),D:"D".charCodeAt(0),W:"W".charCodeAt(0)};var X=this,Z=new THREE.Vector2,t=new THREE.Vector2,Y=new THREE.Vector2,b=new THREE.Vector2,s=new THREE.Vector2,K=new THREE.Vector2,d=new THREE.Vector3,y=(new THREE.Vector3,0),N=0,c=1,C=new THREE.Vector3,m=new THREE.Vector3,A={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},p=A.NONE;this.position0=this.object.position.clone();var G={type:"change"},h={type:"start"},x={type:"end"};this.rotateLeft=function(M){N-=M},this.rotateUp=function(M){y-=M},this.panLeft=function(M){var w=this.object.matrix.elements;d.set(w[0],w[1],w[2]),d.multiplyScalar(-M),C.add(d)},this.panUp=function(M){var w=this.object.matrix.elements;d.set(w[4],w[5],w[6]),d.multiplyScalar(M),C.add(d)},this.panForward=function(M){var w=this.object.matrix.elements;d.set(w[8],w[9],w[10]),d.multiplyScalar(M),C.add(d)},this.pan=function(M,w){var D=X.domElement===document?X.domElement.body:X.domElement;if(void 0!==X.object.fov){var j=X.object.position,l=j.clone(),W=l.length();W*=Math.tan(X.object.fov/2*Math.PI/180),X.panLeft(2*M*W/D.clientHeight),X.panUp(2*w*W/D.clientHeight)}else void 0!==X.object.top?(X.panLeft(M*(X.object.right-X.object.left)/D.clientWidth),X.panUp(w*(X.object.top-X.object.bottom)/D.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(M){var w=this.object.position;if(void 0!==M&&(this.moveRight&&this.panLeft(-M*this.moveSpeed),this.moveLeft&&this.panLeft(M*this.moveSpeed),this.moveForward&&this.panForward(-M*this.moveSpeed),this.moveBackward&&this.panForward(M*this.moveSpeed)),!C.equals(new THREE.Vector3(0,0,0))){var D={type:"move",translation:C.clone()};this.dispatchEvent(D)}w.add(C),this.object.updateMatrix();var j=(new THREE.Matrix4).makeRotationY(N),l=(new THREE.Matrix4).multiplyMatrices(j,this.object.matrix);this.object.quaternion.setFromRotationMatrix(l),this.object.rotation.x+=y,N=0,y=0,c=1,C.set(0,0,0),m.distanceTo(this.object.position)>0&&(this.dispatchEvent(G),m.copy(this.object.position))},this.reset=function(){p=A.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(M){M.preventDefault()},!1),this.domElement.addEventListener("mousedown",D,!1),this.domElement.addEventListener("mousewheel",W,!1),this.domElement.addEventListener("DOMMouseScroll",W,!1),window.addEventListener("keydown",P,!1),window.addEventListener("keyup",T,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(M){return null==this.items[M.id]},LRU.prototype.touch=function(M){var w;null==this.items[M.id]?(w=new LRUItem(M),w.previous=this.last,this.last=w,null!==w.previous&&(w.previous.next=w),this.items[M.id]=w,this.elements++,null===this.first&&(this.first=w),this.numPoints+=M.numPoints):(w=this.items[M.id],null===w.previous?null!==w.next&&(this.first=w.next,this.first.previous=null,w.previous=this.last,w.next=null,this.last=w,w.previous.next=w):null===w.next||(w.previous.next=w.next,w.next.previous=w.previous,w.previous=this.last,w.next=null,this.last=w,w.previous.next=w))},LRU.prototype.remove=function(){if(null===this.first)return null;var M=this.first;return null!==M.next?(this.first=M.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[M.node.id],this.elements--,this.numPoints-=M.node.numPoints,M.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var M=this.first;return M.node},LRU.prototype.toString=function(){for(var M="{ ",w=this.first;null!==w;)M+=w.node.id,null!==w.next&&(M+=", "),w=w.next;return M+="}",M+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(M){THREE.Object3D.call(this),this.geometryNode=M,this.boundingBox=M.boundingBox,this.name=M.name,this.level=M.level,this.numPoints=M.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree=function(M,w){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=M,this.boundingBox=this.pcoGeometry.root.boundingBox,this.material=w,this.maxVisibleNodes=2e3,this.maxVisiblePoints=2e7,this.level=0,this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.loadQueue=[];var D=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(D)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(M){this.numVisibleNodes=0,this.numVisiblePoints=0,this.loadQueue=[],M.updateMatrixWorld();var w=new THREE.Frustum,D=M.matrixWorldInverse,j=this.matrixWorld,l=M.projectionMatrix,W=(new THREE.Matrix4).multiply(l).multiply(D).multiply(j);w.setFromMatrix(W);var P=M.matrixWorld,T=(new THREE.Matrix4).getInverse(j),X=(new THREE.Matrix4).multiply(T).multiply(P),Z=(new THREE.Vector3).setFromMatrixPosition(X),t=(new THREE.Ray(M.position,new THREE.Vector3(0,0,-1).applyQuaternion(M.quaternion)),[]);for(t.push(this);t.length>0;){var Y=t.shift();if(Y instanceof THREE.Mesh||Y instanceof THREE.Line)Y.visible=!0;else{var b=Y.boundingBox,s=b.center().distanceTo(Z),K=.5*b.size().length(),d=!0;if(d=d&&w.intersectsBox(b),Y.level>0&&(d=d&&Math.pow(K,.8)/s>1/this.LOD,d=d&&this.numVisiblePoints+Y.numPoints0){this.loadQueue.length>=2&&this.loadQueue.sort(function(M,w){return w.lod-M.lod});for(var c=0;cW;W++)if(void 0!==w.children[W]){var P=w.children[W],T=new Potree.PointCloudOctreeProxyNode(P);j.add(T)}}},Potree.PointCloudOctree.prototype.hideDescendants=function(M){for(var w=[],D=0;D0;){var M=w.shift();M.visible=!1;for(var D=0;D0;){var Y=l.shift();if(console.log("traversing: "+Y.name),Y instanceof THREE.PointCloud)for(var b=Y.geometry,s=b.attributes.position,K=s.array,d=s.length/s.itemSize,y=0;d>y;y++){var N=new THREE.Vector3(K[3*y],K[3*y+1],K[3*y+2]);N.applyMatrix4(this.matrixWorld);var c=Math.abs(Z.distanceToPoint(N));D/2>c&&t.push(N)}if(Y==this||Y.levelw)},Potree.PointCloudOctree.disposeNode=function(M){var w=0,D=0,j=[];M.traverse(function(M){j.push(M)});for(var l=0;l5)){this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++;var M=this.pcoGeometry.pointAttributes;if("LAS"===M||"LAZ"===M){var w=this.pcoGeometry.octreeDir+"/"+this.name+"."+M.toLowerCase();nodesLoadTimes[w]={},nodesLoadTimes[w].start=(new Date).getTime(),LasLazLoader.load(w,new Potree.LasLazBatcher(this,w))}else if("POT"===M){var D=function(M,w){var D=new DataView(w,0,4),j=D.getUint32(0,!0),l=4+j,W=w.slice(4,4+j),P=String.fromCharCode.apply(null,new Uint8Array(W));P=JSON.parse(P),console.log(P);for(var T=P.attributes[0].scale,X=P.attributes[0].offset,Z=P.attributes[0].encoding,t=new THREE.Vector3(T[0],T[1],T[2]),Y=new THREE.Vector3(X[0],X[1],X[2]),b=Z.min,s=(Z.max,Z.bits),K=w.slice(l,l+w.byteLength-l),d=new BitReader(K),N=d.read(32),c=d.read(32),C=d.read(32),m=d.read(8),A=d.read(8),p=d.read(8),G=new THREE.BufferGeometry,h=P.pointcount,i=new Float32Array(3*h),o=new Float32Array(3*h),V=(new THREE.Color,0);Vt;t++)W[3*t+0]=X[4*t+0]+M.pcoGeometry.offset.x,W[3*t+1]=X[4*t+1]+M.pcoGeometry.offset.y,W[3*t+2]=X[4*t+2]+M.pcoGeometry.offset.z,T.setRGB(Z[16*t+12],Z[16*t+13],Z[16*t+14]),P[3*t+0]=T.r/255,P[3*t+1]=T.g/255,P[3*t+2]=T.b/255;j.addAttribute("position",new THREE.BufferAttribute(W,3)),j.addAttribute("color",new THREE.BufferAttribute(P,3)),j.boundingBox=M.boundingBox,M.geometry=j,M.loaded=!0,M.loading=!1,M.pcoGeometry.numNodesLoading--,nodesLoadTimes[w].end=(new Date).getTime(); +nodesLoadTimes[w].end-nodesLoadTimes[w].start};nodesLoadTimes[w]={},nodesLoadTimes[w].start=(new Date).getTime(),Potree.BinaryNodeLoader.load(this,"",D)}}},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(M,w,D){var j=M.pcoGeometry.octreeDir+"/"+M.name;void 0!==w&&w.length>0&&(j+="."+w);var l=new XMLHttpRequest;l.open("GET",j,!0),l.responseType="arraybuffer",l.overrideMimeType("text/plain; charset=x-user-defined"),l.onreadystatechange=function(){if(4===l.readyState)if(200===l.status||0===l.status){var w=l.response;D(M,w)}else console.log("Failed to load file! HTTP status: "+l.status+", file: "+j)};try{l.send(null)}catch(W){console.log("fehler beim laden der punktwolke: "+W)}},Potree.LasLazBatcher=function(M,w){this.push=function(D){var j=Potree.workers.lasdecoder.getWorker(),l=new THREE.Vector3(D.mins[0],D.mins[1],D.mins[2]),W=new THREE.Vector3(D.maxs[0],D.maxs[1],D.maxs[2]);l.add(M.pcoGeometry.offset),W.add(M.pcoGeometry.offset),j.onmessage=function(P){for(var T=new THREE.BufferGeometry,X=D.pointsCount,Z=P.data.position,t=P.data.color,Y=P.data.intensity,b=new Uint8Array(P.data.classification),s=new Float32Array(b.byteLength),K=new THREE.Box3,d=new Float32Array(Z),y=0;X>y;y++)s[y]=b[y],K.expandByPoint(new THREE.Vector3(d[3*y+0],d[3*y+1],d[3*y+2]));T.addAttribute("position",new THREE.BufferAttribute(new Float32Array(Z),3)),T.addAttribute("color",new THREE.BufferAttribute(new Float32Array(t),3)),T.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(Y),1)),T.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(s),1)),T.boundingBox=new THREE.Box3(l,W),M.boundingBox=T.boundingBox,M.geometry=T,M.loaded=!0,M.loading=!1,M.pcoGeometry.numNodesLoading--,nodesLoadTimes[w].end=(new Date).getTime();nodesLoadTimes[w].end-nodesLoadTimes[w].start;Potree.workers.lasdecoder.returnWorker(j)};var P={buffer:D.arrayb,numPoints:D.pointsCount,pointSize:D.pointSize,pointFormatID:2,scale:D.scale,offset:D.offset,mins:[M.pcoGeometry.boundingBox.min.x,M.pcoGeometry.boundingBox.min.y,M.pcoGeometry.boundingBox.min.z],maxs:[M.pcoGeometry.boundingBox.max.x,M.pcoGeometry.boundingBox.max.y,M.pcoGeometry.boundingBox.max.z],bbOffset:[M.pcoGeometry.offset.x,M.pcoGeometry.offset.y,M.pcoGeometry.offset.z]};j.postMessage(P,[P.buffer])}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(M){var w=new XMLHttpRequest;return w.open("GET",M,!1),w.send(null),200!==w.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(M,w){var D=[new THREE.Vector3(M.min.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.min.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.max.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.min.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.min.x,M.max.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.max.y,M.min.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.min.y,M.max.z).applyMatrix4(w),new THREE.Vector3(M.max.x,M.max.y,M.max.z).applyMatrix4(w)],j=new THREE.Box3;return j.setFromPoints(D),j},Potree.utils.addCommas=function(M){M+="",x=M.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var w=/(\d+)(\d{3})/;w.test(x1);)x1=x1.replace(w,"$1,$2");return x1+x2},Potree.utils.createWorker=function(M){var w=new Blob([M],{type:"application/javascript"}),D=new Worker(URL.createObjectURL(w));return D},Potree.utils.loadSkybox=function(M){var w=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),D=new THREE.Scene,j=".jpg",l=[M+"px"+j,M+"nx"+j,M+"py"+j,M+"ny"+j,M+"pz"+j,M+"nz"+j],W=THREE.ImageUtils.loadTextureCube(l,new THREE.CubeRefractionMapping),P=new THREE.MeshBasicMaterial({color:16777215,envMap:W,refractionRatio:.95}),T=THREE.ShaderLib.cube;T.uniforms.tCube.value=W;var P=new THREE.ShaderMaterial({fragmentShader:T.fragmentShader,vertexShader:T.vertexShader,uniforms:T.uniforms,depthWrite:!1,side:THREE.BackSide}),X=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),P);return D.add(X),{camera:w,scene:D}},Potree.utils.createGrid=function(M,w,D,j){for(var l=new THREE.LineBasicMaterial({color:j||8947848}),W=new THREE.Geometry,P=0;w>=P;P++)W.vertices.push(new THREE.Vector3(-(D*M)/2,0,P*D-D*w/2)),W.vertices.push(new THREE.Vector3(+(D*M)/2,0,P*D-D*w/2));for(var P=0;M>=P;P++)W.vertices.push(new THREE.Vector3(P*D-D*M/2,0,-(D*w)/2)),W.vertices.push(new THREE.Vector3(P*D-D*M/2,0,+(D*w)/2));var T=new THREE.Line(W,l,THREE.LinePieces);return T.receiveShadow=!0,T},Potree.TextSprite=function(M){var w=new THREE.Texture,D=new THREE.SpriteMaterial({map:w,useScreenCoordinates:!1});THREE.Sprite.call(this,D),this.borderThickness=4,this.fontface="Arial",this.fontsize=28,this.borderColor={r:0,g:0,b:0,a:1},this.backgroundColor={r:255,g:255,b:255,a:1},this.text="",this.setText(M)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(M){this.text=M,this.update()},Potree.TextSprite.prototype.setBorderColor=function(M){this.borderColor=M,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(M){this.backgroundColor=M,this.update()},Potree.TextSprite.prototype.update=function(){var M=document.createElement("canvas"),w=M.getContext("2d");w.font="Bold "+this.fontsize+"px "+this.fontface;var D=w.measureText(this.text),j=D.width,l=j+2*this.borderThickness,W=1.4*this.fontsize+2*this.borderThickness,M=document.createElement("canvas"),w=M.getContext("2d");w.canvas.width=l,w.canvas.height=W,w.font="Bold "+this.fontsize+"px "+this.fontface,w.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",w.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",w.lineWidth=this.borderThickness,this.roundRect(w,this.borderThickness/2,this.borderThickness/2,j+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),w.strokeStyle="rgba(0, 0, 0, 1.0)",w.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),w.fillStyle="rgba(255, 255, 255, 1.0)",w.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var P=new THREE.Texture(M);P.needsUpdate=!0,this.material.map=P,this.scale.set(.01*l,.01*W,1)},Potree.TextSprite.prototype.roundRect=function(M,w,D,j,l,W){M.beginPath(),M.moveTo(w+W,D),M.lineTo(w+j-W,D),M.quadraticCurveTo(w+j,D,w+j,D+W),M.lineTo(w+j,D+l-W),M.quadraticCurveTo(w+j,D+l,w+j-W,D+l),M.lineTo(w+W,D+l),M.quadraticCurveTo(w,D+l,w,D+l-W),M.lineTo(w,D+W),M.quadraticCurveTo(w,D,w+W,D),M.closePath(),M.fill(),M.stroke()},Potree.MeasuringTool=function(M,w,D){function j(){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[]}function l(M){var w=X();if(w){var D=w.clone(),l=new THREE.MeshNormalMaterial({shading:THREE.SmoothShading}),W=new THREE.SphereGeometry(.4,10,10),P=new THREE.Mesh(W,l);P.position.copy(w),Z.sceneRoot.add(P);var T=new THREE.Mesh(W,l);T.position.copy(w),Z.sceneRoot.add(T);var b=D.x.toFixed(2)+" / "+D.y.toFixed(2)+" / "+D.z.toFixed(2),s=new Potree.TextSprite(b);s.setBorderColor({r:0,g:255,b:0,a:1}),s.material.depthTest=!1,s.material.opacity=0,s.position.copy(w),s.position.y+=.5,Z.sceneRoot.add(s);var K=new Potree.TextSprite(b);K.setBorderColor({r:0,g:255,b:0,a:1}),K.material.depthTest=!1,K.material.opacity=0,K.position.copy(w),K.position.y+=.5,Z.sceneRoot.add(K);var d=new THREE.Color(16711680),y=new THREE.Geometry;y.vertices.push(w.clone(),w.clone()),y.colors.push(d,d,d);var N=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});N.depthTest=!1,sConnection=new THREE.Line(y,N),Z.sceneRoot.add(sConnection);var c=new Potree.TextSprite(0);c.setBorderColor({r:0,g:255,b:0,a:0}),c.setBackgroundColor({r:0,g:255,b:0,a:0}),c.material.depthTest=!1,c.position.copy(w),c.position.y+=.5,Z.sceneRoot.add(c),Y===t.DEFAULT?(Y=t.PICKING,Z.activeMeasurement=new j,Z.activeMeasurement.spheres.push(P)):Y===t.PICKING,Z.activeMeasurement.points.push(w),Z.activeMeasurement.spheres.push(T),Z.activeMeasurement.sphereLabels.push(s),Z.activeMeasurement.sphereLabels.push(K),Z.activeMeasurement.edges.push(sConnection),Z.activeMeasurement.edgeLabels.push(c);var M={type:"newpoint",position:D.clone()};Z.dispatchEvent(M)}}function W(M){if(Z.mouse.x=M.clientX/Z.domElement.clientWidth*2-1,Z.mouse.y=2*-(M.clientY/Z.domElement.clientHeight)+1,Y==t.PICKING&&Z.activeMeasurement){var w=X();if(w){var D=w.clone(),j=Z.activeMeasurement.spheres.length,l=Z.activeMeasurement.spheres[j-1],W=Z.activeMeasurement.sphereLabels[j-1],P=Z.activeMeasurement.edges[j-2],T=Z.activeMeasurement.edgeLabels[j-2],b=D.x.toFixed(2)+" / "+D.y.toFixed(2)+" / "+D.z.toFixed(2);W.setText(b),l.position.copy(w),W.position.copy(w),W.position.y+=.5,P.geometry.vertices[1].copy(w),P.geometry.verticesNeedUpdate=!0,P.geometry.computeBoundingSphere();var s=P.geometry.vertices[1].clone().add(P.geometry.vertices[0]).multiplyScalar(.5),K=P.geometry.vertices[0].distanceTo(P.geometry.vertices[1]).toFixed(2);T.position.copy(s),T.setText(K),T.scale.multiplyScalar(10)}}}function P(){if(Y==t.PICKING){var M=Z.activeMeasurement.spheres.pop(),w=Z.activeMeasurement.edges.pop(),D=Z.activeMeasurement.sphereLabels.pop(),j=Z.activeMeasurement.edgeLabels.pop();Z.sceneRoot.remove(M),Z.sceneRoot.remove(w),Z.sceneRoot.remove(D),Z.sceneRoot.remove(j),Z.measurements.push(Z.activeMeasurement),Z.activeMeasurement=void 0,Y=t.DEFAULT}}function T(M){3===M.which&&P(M)}function X(){var M=new THREE.Vector3(Z.mouse.x,Z.mouse.y,.5),w=new THREE.Projector;w.unprojectVector(M,Z.camera);var D=new THREE.Raycaster;D.params={PointCloud:{threshold:1}},D.ray.set(Z.camera.position,M.sub(Z.camera.position).normalize());var j=[];Z.scene.traverse(function(M){M instanceof Potree.PointCloudOctree&&j.push(M)});var l=D.intersectObjects(j,!0);if(l.length>0){var W=l[0];return W.point}return void 0}var Z=this;this.scene=M,this.camera=w,this.domElement=D,this.mouse={x:0,y:0};var t={DEFAULT:0,PICKING:1},Y=t.DEFAULT;this.activeMeasurement,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.domElement.addEventListener("dblclick",l,!1),this.domElement.addEventListener("mousemove",W,!1),this.domElement.addEventListener("mousedown",T,!1)},Potree.MeasuringTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.ProfileTool=function(M,w,D){THREE.Object3D.call(this);var j=new THREE.BoxGeometry(1,1,1,1,1,1),l=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.3});this.profileFrustum=new THREE.Mesh(j,l),this.add(this.profileFrustum),this.camera=new THREE.OrthographicCamera(-M/2,M/2,w/2,-w/2,1,1+D),this.add(this.camera),this.setDimension(M,w,D),this.rtProfile=new THREE.WebGLRenderTarget(512,512,{minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBFormat}),this.hudGeometry=new THREE.BoxGeometry(2,2,1),this.hudMaterial=new THREE.MeshBasicMaterial({color:16777215,map:this.rtProfile}),this.hudMaterial.depthTest=!1,this.hudElement=new THREE.Mesh(this.hudGeometry,this.hudMaterial),this.hudElement.scale.set(1,1,1),this.hudElement.position.set(0,0,0)},Potree.ProfileTool.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileTool.prototype.setDimension=function(M,w,D){this.profileFrustum.scale.set(M,w,D),this.width=M,this.height=w,this.depth=D,this.camera.left=-M/2,this.camera.right=M/2,this.camera.top=w/2,this.camera.bottom=-w/2,this.camera.updateProjectionMatrix()},Potree.ProfileTool.prototype.setOrientation=function(M){var w=this.position.clone();this.position.add(M),this.lookAt(w),this.position.copy(w),this.camera.position.copy(w.clone().add(M)),this.camera.lookAt(w)},Potree.ProfileTool.prototype.render=function(M,w){this.camera.matrixWorld.copy(this.matrixWorld),w.traverse(function(M){M instanceof Potree.PointCloudOctree&&(M.material.oldSize=M.material.size,M.material.size=0)}),M.render(w,this.camera,this.rtProfile,!0),w.traverse(function(M){M instanceof Potree.PointCloudOctree&&(M.material.size=M.material.oldSize)})},Potree.TranslationTool=function(M){THREE.Object3D.call(this);var w=this;this.camera=M,this.geometry=new THREE.Geometry,this.material=new THREE.MeshBasicMaterial({color:16777215*Math.random()}),this.STATE={DEFAULT:0,TRANSLATE_X:1,TRANSLATE_Y:2,TRANSLATE_Z:3},this.parts={ARROW_X:{name:"arrow_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.TRANSLATE_X},ARROW_Y:{name:"arrow_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.TRANSLATE_Y},ARROW_Z:{name:"arrow_z",object:void 0,color:new THREE.Color(255),state:this.STATE.TRANSLATE_Z}},this.translateStart,this.state=this.STATE.DEFAULT,this.highlighted,this.targets,this.build=function(){var M=w.createArrow(w.parts.ARROW_X,w.parts.ARROW_X.color);M.rotation.z=-Math.PI/2;var D=w.createArrow(w.parts.ARROW_Y,w.parts.ARROW_Y.color),j=w.createArrow(w.parts.ARROW_Z,w.parts.ARROW_Z.color);j.rotation.x=-Math.PI/2,w.add(M),w.add(D),w.add(j);var l=w.createBox(new THREE.Color(16776960));l.scale.z=.02,l.position.set(.5,.5,0);var W=w.createBox(new THREE.Color(16711935));W.scale.y=.02,W.position.set(.5,0,-.5);var P=w.createBox(new THREE.Color(65535));P.scale.x=.02,P.position.set(0,.5,-.5),w.add(l),w.add(W),w.add(P),w.parts.ARROW_X.object=M,w.parts.ARROW_Y.object=D,w.parts.ARROW_Z.object=j,w.scale.multiplyScalar(5)},this.createBox=function(M){var w=new THREE.BoxGeometry(1,1,1),D=new THREE.MeshBasicMaterial({color:M,transparent:!0,opacity:.5}),j=new THREE.Mesh(w,D);return j},this.createArrow=function(M,w){var D=new THREE.MeshBasicMaterial({color:w}),j=new THREE.CylinderGeometry(.1,.1,3,10,1,!1),l=D,W=new THREE.Mesh(j,l);W.position.y=1.5;var P=new THREE.CylinderGeometry(0,.3,1,10,1,!1),T=D,X=new THREE.Mesh(P,T);X.position.y=3;var Z=new THREE.Object3D;return Z.add(W),Z.add(X),Z.partID=M,Z.material=D,Z},this.setHighlighted=function(M){return void 0===M?void(w.highlighted&&(w.highlighted.object.material.color=w.highlighted.color,w.highlighted=void 0)):(void 0!==w.highlighted&&w.highlighted!==M&&(w.highlighted.object.material.color=w.highlighted.color),w.highlighted=M,void(M.object.material.color=new THREE.Color(16776960)))},this.getHoveredObject=function(M){var D=new THREE.Vector3(M.x,M.y,.5),j=new THREE.Projector;j.unprojectVector(D,w.camera);var l=new THREE.Raycaster;l.ray.set(w.camera.position,D.sub(w.camera.position).normalize());var W=l.intersectObject(w,!0);if(0===W.length)return void w.setHighlighted(void 0);var P=W[0],T=P.object.parent.partID;return T},this.onMouseMove=function(M){var D=M.normalizedPosition;if(w.state===w.STATE.DEFAULT)w.setHighlighted(w.getHoveredObject(D));else if(w.state===w.STATE.TRANSLATE_X||w.state===w.STATE.TRANSLATE_Y||w.state===w.STATE.TRANSLATE_Z){var j=w.start.lineStart.clone(),l=w.start.lineEnd.clone().sub(w.start.lineStart);l.normalize();var W=new THREE.Vector3(D.x,D.y),P=(new THREE.Vector3).subVectors(W,j).dot(l),T=l.clone().multiplyScalar(P).add(j),X=new THREE.Projector;X.unprojectVector(T,w.camera);var Z=T.clone().sub(w.position);w.position.copy(T);for(var t=0;t