diff --git a/build/js/potree.js b/build/js/potree.js index b2f58bbe..4f3c33ba 100644 --- a/build/js/potree.js +++ b/build/js/potree.js @@ -175,9 +175,9 @@ POCLoader.load = function load(url, params) { var offset = new THREE.Vector3(0,0,0); if(toOrigin){ - offset.set(min.x, min.y, min.z); - boundingBox.min.sub(offset); - boundingBox.max.sub(offset); + offset.set(-min.x, -min.y, -min.z); + boundingBox.min.add(offset); + boundingBox.max.add(offset); } pco.boundingBox = boundingBox; pco.offset = offset; @@ -1638,7 +1638,7 @@ Potree.PointCloudOctree = function(geometry, material){ this.material = material; this.visiblePointsTarget = 2*1000*1000; this.level = 0; - this.position.add(geometry.offset); + this.position.sub(geometry.offset); this.updateMatrix(); this.LODDistance = 20; @@ -2245,9 +2245,9 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ Y = Y + dy; Z = Z + dz; - x = X * scale.x - offset.x; - y = Y * scale.y - offset.y; - z = Z * scale.z - offset.z; + x = X * scale.x + offset.x; + y = Y * scale.y + offset.y; + z = Z * scale.z + offset.z; r = br.read(8); g = br.read(8); @@ -2292,9 +2292,9 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ var uiView = new Uint8Array(buffer); for(var i = 0; i < numPoints; i++){ - positions[3*i+0] = fView[4*i+0] - node.pcoGeometry.offset.x; - positions[3*i+1] = fView[4*i+1] - node.pcoGeometry.offset.y; - positions[3*i+2] = fView[4*i+2] - node.pcoGeometry.offset.z; + positions[3*i+0] = fView[4*i+0] + node.pcoGeometry.offset.x; + positions[3*i+1] = fView[4*i+1] + node.pcoGeometry.offset.y; + positions[3*i+2] = fView[4*i+2] + node.pcoGeometry.offset.z; color.setRGB(uiView[16*i+12], uiView[16*i+13], uiView[16*i+14]); colors[3*i+0] = color.r / 255; diff --git a/build/js/potree.min.js b/build/js/potree.min.js index a26a88e1..595bb4a9 100644 --- a/build/js/potree.min.js +++ b/build/js/potree.min.js @@ -1,2 +1,2 @@ -function Potree(){}function POCLoader(){}function PointAttributeNames(){}function PointAttribute(e,t,o){this.name=e,this.type=t,this.numElements=o,this.byteSize=this.numElements*this.type.size}function PointAttributes(e){if(this.attributes=new Array,this.byteSize=0,this.size=0,null!=e)for(var t in e){var o=e[t];this.attributes.push(o),this.byteSize+=o.byteSize,this.size++}}function LasLazLoader(){}function LRUItem(e){this.previous=null,this.next=null,this.node=e}function LRU(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}Potree.pointLoadLimit=5e7,Potree.workers={},Potree.WorkerManager=function(e){this.code=e,this.instances=[],this.createdInstances=0},Potree.WorkerManager.prototype.getWorker=function(){var e=this.instances.pop();return void 0===e&&(e=Potree.utils.createWorker(this.code),this.createdInstances++),e},Potree.WorkerManager.prototype.returnWorker=function(e){this.instances.push(e)},Potree.WorkerManager.fromUrls=function(e){for(var t="",o=0;o=r?i.pointsCount:i.pointsCount/r,s=function(){var e=o.readData(1e6,0,r);return e.then(function(e){return t.push(new LASDecoder(e.buffer,i.pointsFormatId,i.pointsStructSize,e.count,i.scale,i.offset,i.mins,i.maxs)),n+=e.count,LasLazLoader.progressCB(n/a),e.hasMoreData?s():(i.totalRead=n,i.versionAsString=o.versionAsString,i.isCompressed=o.isCompressed,[o,i,t])})};return s()}).then(function(e){var t=e[0];return LasLazLoader.progressCB(1),t.close().then(function(){return t.isOpen=!1,Promise.delay(200).cancellable()}).then(function(){return e.slice(1)})}).catch(Promise.CancellationError,function(e){if(o.isOpen)return o.close().then(function(){throw o.isOpen=!1,e});throw e})},Potree.PointCloudRGBMaterial=function(e){e=e||{};var t={},o={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10},minSize:{type:"f",value:2}},i=e.size||1,r=e.minSize||2;this.setValues({uniforms:o,attributes:t,vertexShader:Potree.PointCloudRGBMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:i,minSize:r,alphaTest:.9})},Potree.PointCloudRGBMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudRGBMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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.PointCloudRGBInterpolationMaterial=function(e){e=e||{};var t,o,i={},r={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10},minSize:{type:"f",value:2},blendDepth:{type:"f",value:.01}},n=e.size||1,a=e.minSize||2,s=renderer.context.getExtension("EXT_frag_depth");s?(t=Potree.PointCloudRGBInterpolationMaterial.vs_points.join("\n"),o=Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb.join("\n")):(t=Potree.PointCloudRGBMaterial.vs_points.join("\n"),o=Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n")),this.setValues({uniforms:r,attributes:i,vertexShader:t,fragmentShader:o,vertexColors:THREE.VertexColors,size:n,minSize:a,alphaTest:.9})},Potree.PointCloudRGBInterpolationMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"blendDepth",{get:function(){return this.uniforms.blendDepth.value},set:function(e){this.uniforms.blendDepth.value=e}}),Potree.PointCloudRGBInterpolationMaterial.vs_points=[" "," "," ","uniform float size; ","uniform float minSize; ","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(minSize, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb=["#extension GL_EXT_frag_depth : enable ","varying vec3 vColor; ","uniform float blendDepth; "," "," ","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); "," gl_FragDepthEXT = gl_FragCoord.z + blendDepth*(1.0-pow(c, 1.0)) * gl_FragCoord.w ; "," "," //float dist = gl_FragCoord.z / gl_FragCoord.w; "," //float fog = clamp(dist / 2000.0, 0.0, 1.0); "," //fog = min(fog, 0.6); "," //gl_FragColor = gl_FragColor * (1.0-fog) + vec4(170.0, 180.0, 190, 1.0) * fog / 256.0; "," //gl_FragColor.a = 1.0; ","} "],Potree.PointCloudIntensityMaterial=function(e){e=e||{};var t=e.size||1,o=e.minSize||2;this.min=e.min||0,this.max=e.max||1;var i={intensity:{type:"f",value:[]}},r={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},minSize:{type:"f",value:2},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max}};this.setValues({uniforms:r,attributes:i,vertexShader:Potree.PointCloudIntensityMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudIntensityMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,minSize:o,alphaTest:.9})},Potree.PointCloudIntensityMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudIntensityMaterial.vs_points=["attribute float intensity; ","uniform float size; ","uniform float minSize; ","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 * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(minSize, 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(e){e=e||{};var t=e.size||1,o=e.minSize||2;this.min=e.min||0,this.max=e.max||1;var i=Potree.PointCloudHeightMaterial.generateGradient(),r={},n={uCol:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},minSize:{type:"f",value:2},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max},gradient:{type:"t",value:i}};this.setValues({uniforms:n,attributes:r,vertexShader:Potree.PointCloudHeightMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudHeightMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,minSize:o,alphaTest:.9})},Potree.PointCloudHeightMaterial.generateGradient=function(){var e=64;canvas=document.createElement("canvas"),canvas.width=e,canvas.height=e;var t=canvas.getContext("2d");t.rect(0,0,e,e);var o=t.createLinearGradient(0,0,e,e);o.addColorStop(0,"blue"),o.addColorStop(.2,"aqua"),o.addColorStop(.4,"green"),o.addColorStop(.6,"yellow"),o.addColorStop(.8,"orange"),o.addColorStop(1,"red"),t.fillStyle=o,t.fill();var i=new THREE.Texture(canvas);return i.needsUpdate=!0,textureImage=i.image,i},Potree.PointCloudHeightMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudHeightMaterial.prototype.setBoundingBox=function(e){this.min=e.min.y,this.max=e.max.y,this.uniforms.uMin.value=this.min,this.uniforms.uMax.value=this.max},Potree.PointCloudHeightMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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(e){e=e||{};var t=e.color||(new THREE.Color).setRGB(1,0,0),o=e.size||1,i=e.minSize||2,r={},n={uCol:{type:"c",value:t},size:{type:"f",value:1},minSize:{type:"f",value:2}};this.setValues({uniforms:n,attributes:r,vertexShader:Potree.PointCloudColorMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudColorMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:o,minSize:i,alphaTest:.9})},Potree.PointCloudColorMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"color",{get:function(){return this.uniforms.uCol.value},set:function(e){this.uniforms.uCol.value.copy(e)}}),Potree.PointCloudColorMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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(e,t){function o(e){l.enabled!==!1&&(e.preventDefault(),0===e.button?(x=g.ROTATE,d.set(e.clientX,e.clientY)):2===e.button&&(x=g.PAN,h.set(e.clientX,e.clientY)),l.domElement.addEventListener("mousemove",i,!1),l.domElement.addEventListener("mouseup",r,!1),l.dispatchEvent(R))}function i(e){if(l.enabled!==!1){e.preventDefault();var t=l.domElement===document?l.domElement.body:l.domElement;x===g.ROTATE?(u.set(e.clientX,e.clientY),c.subVectors(u,d),l.rotateLeft(2*Math.PI*c.x/t.clientWidth*l.rotateSpeed),l.rotateUp(2*Math.PI*c.y/t.clientHeight*l.rotateSpeed),d.copy(u)):x===g.PAN&&(p.set(e.clientX,e.clientY),m.subVectors(p,h),m.multiplyScalar(5e-4).multiplyScalar(l.moveSpeed),l.pan(m.x,m.y),h.copy(p))}}function r(){l.enabled!==!1&&(l.domElement.removeEventListener("mousemove",i,!1),l.domElement.removeEventListener("mouseup",r,!1),l.dispatchEvent(w),x=g.NONE)}function n(e){if(l.enabled!==!1&&l.noZoom!==!0){e.preventDefault();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),l.moveSpeed+=.001*l.moveSpeed*t,l.moveSpeed=Math.max(.1,l.moveSpeed),l.dispatchEvent(R),l.dispatchEvent(w)}}function a(e){if(l.enabled!==!1)switch(e.keyCode){case l.keys.UP:l.moveForward=!0;break;case l.keys.BOTTOM:l.moveBackward=!0;break;case l.keys.LEFT:l.moveLeft=!0;break;case l.keys.RIGHT:l.moveRight=!0;break;case l.keys.W:l.moveForward=!0;break;case l.keys.S:l.moveBackward=!0;break;case l.keys.A:l.moveLeft=!0;break;case l.keys.D:l.moveRight=!0}}function s(e){switch(e.keyCode){case l.keys.W:l.moveForward=!1;break;case l.keys.S:l.moveBackward=!1;break;case l.keys.A:l.moveLeft=!1;break;case l.keys.D:l.moveRight=!1;break;case l.keys.UP:l.moveForward=!1;break;case l.keys.BOTTOM:l.moveBackward=!1;break;case l.keys.LEFT:l.moveLeft=!1;break;case l.keys.RIGHT:l.moveRight=!1}}this.object=e,this.domElement=void 0!==t?t: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 l=this,d=new THREE.Vector2,u=new THREE.Vector2,c=new THREE.Vector2,h=new THREE.Vector2,p=new THREE.Vector2,m=new THREE.Vector2,E=new THREE.Vector3,f=(new THREE.Vector3,0),v=0,T=1,P=new THREE.Vector3,y=new THREE.Vector3,g={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},x=g.NONE;this.position0=this.object.position.clone();var b={type:"change"},R={type:"start"},w={type:"end"};this.rotateLeft=function(e){v-=e},this.rotateUp=function(e){f-=e},this.panLeft=function(e){var t=this.object.matrix.elements;E.set(t[0],t[1],t[2]),E.multiplyScalar(-e),P.add(E)},this.panUp=function(e){var t=this.object.matrix.elements;E.set(t[4],t[5],t[6]),E.multiplyScalar(e),P.add(E)},this.panForward=function(e){var t=this.object.matrix.elements;E.set(t[8],t[9],t[10]),E.multiplyScalar(e),P.add(E)},this.pan=function(e,t){var o=l.domElement===document?l.domElement.body:l.domElement;if(void 0!==l.object.fov){var i=l.object.position,r=i.clone(),n=r.length();n*=Math.tan(l.object.fov/2*Math.PI/180),l.panLeft(2*e*n/o.clientHeight),l.panUp(2*t*n/o.clientHeight)}else void 0!==l.object.top?(l.panLeft(e*(l.object.right-l.object.left)/o.clientWidth),l.panUp(t*(l.object.top-l.object.bottom)/o.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(e){var t=this.object.position;if(void 0!==e&&(this.moveRight&&this.panLeft(-e*this.moveSpeed),this.moveLeft&&this.panLeft(e*this.moveSpeed),this.moveForward&&this.panForward(-e*this.moveSpeed),this.moveBackward&&this.panForward(e*this.moveSpeed)),!P.equals(new THREE.Vector3(0,0,0))){var o={type:"move",translation:P.clone()};this.dispatchEvent(o)}t.add(P),this.object.updateMatrix();var i=(new THREE.Matrix4).makeRotationY(v),r=(new THREE.Matrix4).multiplyMatrices(i,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=f,v=0,f=0,T=1,P.set(0,0,0),y.distanceTo(this.object.position)>0&&(this.dispatchEvent(b),y.copy(this.object.position))},this.reset=function(){x=g.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",n,!1),this.domElement.addEventListener("DOMMouseScroll",n,!1),window.addEventListener("keydown",a,!1),window.addEventListener("keyup",s,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(e){return null==this.items[e.id]},LRU.prototype.touch=function(e){var t;null==this.items[e.id]?(t=new LRUItem(e),t.previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):(t=this.items[e.id],null===t.previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null===t.next||(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))},LRU.prototype.remove=function(){if(null===this.first)return null;var e=this.first;return null!==e.next?(this.first=e.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[e.node.id],this.elements--,this.numPoints-=e.node.numPoints,e.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var e=this.first;return e.node},LRU.prototype.toString=function(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.boundingBox=e.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileRequest=function(e,t,o,i,r){this.start=e,this.end=t,this.width=o,this.depth=i,this.callback=r,this.loadQueue=[];var n=((new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),(new THREE.Vector3).subVectors(t,e).length(),(new THREE.Vector3).subVectors(t,e).normalize()),a=new THREE.Vector3(0,1,0),s=(new THREE.Vector3).crossVectors(n,a).normalize(),l=s;this.plane=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,e)},Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.root.boundingBox,this.material=t,this.visiblePointsTarget=2e6,this.level=0,this.position.add(e.offset),this.updateMatrix(),this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.loadQueue=[],this.visibleBounds=new THREE.Box3,this.profileRequests=[];var o=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(o)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(e){this.numVisibleNodes=0,this.numVisiblePoints=0,this.loadQueue=[],e.updateMatrixWorld();var t=new THREE.Frustum,o=e.matrixWorldInverse,i=this.matrixWorld,r=e.projectionMatrix,n=(new THREE.Matrix4).multiply(r).multiply(o).multiply(i); -t.setFromMatrix(n);for(var a=e.matrixWorld,s=(new THREE.Matrix4).getInverse(i),l=(new THREE.Matrix4).multiply(s).multiply(a),d=(new THREE.Vector3).setFromMatrixPosition(l),u=(new THREE.Ray(e.position,new THREE.Vector3(0,0,-1).applyQuaternion(e.quaternion)),0);u0;){var E=m.shift();if(E instanceof THREE.Mesh||E instanceof THREE.Line)E.visible=!0;else{var f=E.boundingBox,v=f.center().distanceTo(d),T=.5*f.size().length(),P=Math.pow(T,1)/v,y=t.intersectsBox(f),g=!0;if(E.level>0){var g=P>=1/this.LOD;g||p.push({node:E,lod:P})}var x=y&&g;if(E.visible=x,E.insideFrustum=y,E.inRange=g,E.matrixWorld.multiplyMatrices(E.parent.matrixWorld,E.matrix),x)if(x&&this.showBoundingBox&&E instanceof THREE.PointCloud){if(void 0===E.boundingBoxNode&&void 0!==E.boundingBox){var b=new THREE.BoxHelper(E);E.add(b),E.boundingBoxNode=b}}else this.showBoundingBox||void 0!==E.boundingBoxNode&&(E.remove(E.boundingBoxNode),E.boundingBoxNode=void 0);else this.hideDescendants(E);if(x){if(E instanceof THREE.PointCloud)this.numVisibleNodes++,this.numVisiblePoints+=E.numPoints,Potree.PointCloudOctree.lru.touch(E),E.material=this.material,h.push({node:E,lod:P});else if(E instanceof Potree.PointCloudOctreeProxyNode){var R=E.geometryNode;R.loaded===!0?this.replaceProxy(E):this.loadQueue.push({node:E,lod:P})}for(var u=0;u0;){var E=m.shift();if(E instanceof Potree.PointCloudOctreeProxyNode){var f=Potree.utils.computeTransformedBoundingBox(E.boundingBox,E.matrixWorld),H=f.getBoundingSphere();Math.abs(w.distanceToPoint(H.center))0&&h.length>0){p.sort(function(e,t){return t.lod-e.lod}),h.sort(function(e,t){return e.lod-t.lod});var M=1/h[0].lod,S=Math.min(p.length-1,4),z=1/p[S].lod,L=Math.max(M,z);this.LOD=L}else this.numVisiblePoints>1.1*this.visiblePointsTarget&&(this.LOD*=.95);for(var B=[],u=0;u0){console.log("loading: "+G.loadQueue[0].geometryNode.name);var E=G.loadQueue[0],R=E.geometryNode;if(R.loaded===!0&&void 0!==E.parent){var _=this.replaceProxy(E);_.updateMatrixWorld(),_.matrixWorld.multiplyMatrices(_.parent.matrixWorld,_.matrix)}else E.geometryNode.load()}else{var j=this.getProfile(G.start,G.end,G.width,G.depth);G.callback({type:"finished",points:j}),D.push(G)}}for(var u=0;u-1&&this.profileRequests.splice(k,1)}if(this.loadQueue.length>0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.lod-e.lod});for(var u=0;un;n++)if(void 0!==t.children[n]){var a=t.children[n],s=new Potree.PointCloudOctreeProxyNode(a);i.add(s)}return i}},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o0;){var e=t.shift();e.visible=!1;for(var o=0;o0;){var E=n.shift(),f=0;if(E instanceof THREE.PointCloud)for(var v=E.geometry,T=v.attributes.position,P=T.array,y=T.length/T.itemSize,g=0;y>g;g++){var x=new THREE.Vector3(P[3*g],P[3*g+1],P[3*g+2]);x.applyMatrix4(this.matrixWorld);var b=Math.abs(h.distanceToPoint(x)),R=Math.abs(p.distanceToPoint(x));o/2>b&&s/2>R&&(m.push(x),f++)}if(E==this||E.levelt)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var r=0;r5)){this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++;var e=this.pcoGeometry.pointAttributes;if("LAS"===e||"LAZ"===e){var t=this.pcoGeometry.octreeDir+"/"+this.name+"."+e.toLowerCase();nodesLoadTimes[t]={},nodesLoadTimes[t].start=(new Date).getTime(),LasLazLoader.load(t,new Potree.LasLazBatcher(this,t))}else if("POT"===e){var o=function(e,t){var o=new DataView(t,0,4),i=o.getUint32(0,!0),r=4+i,n=t.slice(4,4+i),a=String.fromCharCode.apply(null,new Uint8Array(n));a=JSON.parse(a),console.log(a);for(var s=a.attributes[0].scale,l=a.attributes[0].offset,d=a.attributes[0].encoding,u=new THREE.Vector3(s[0],s[1],s[2]),c=new THREE.Vector3(l[0],l[1],l[2]),h=d.min,p=(d.max,d.bits),m=t.slice(r,r+t.byteLength-r),E=new BitReader(m),f=E.read(32),v=E.read(32),T=E.read(32),P=E.read(8),g=E.read(8),b=E.read(8),R=new THREE.BufferGeometry,w=a.pointcount,C=new Float32Array(3*w),H=new Float32Array(3*w),A=(new THREE.Color,0);Au;u++)n[3*u+0]=l[4*u+0]-e.pcoGeometry.offset.x,n[3*u+1]=l[4*u+1]-e.pcoGeometry.offset.y,n[3*u+2]=l[4*u+2]-e.pcoGeometry.offset.z,s.setRGB(d[16*u+12],d[16*u+13],d[16*u+14]),a[3*u+0]=s.r/255,a[3*u+1]=s.g/255,a[3*u+2]=s.b/255;i.addAttribute("position",new THREE.BufferAttribute(n,3)),i.addAttribute("color",new THREE.BufferAttribute(a,3)),i.boundingBox=e.boundingBox,e.geometry=i,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,nodesLoadTimes[t].end=(new Date).getTime();nodesLoadTimes[t].end-nodesLoadTimes[t].start};nodesLoadTimes[t]={},nodesLoadTimes[t].start=(new Date).getTime(),Potree.BinaryNodeLoader.load(this,"",o)}}},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(e,t,o){var i=e.pcoGeometry.octreeDir+"/"+e.name;void 0!==t&&t.length>0&&(i+="."+t);var r=new XMLHttpRequest;r.open("GET",i,!0),r.responseType="arraybuffer",r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status||0===r.status){var t=r.response;o(e,t)}else console.log("Failed to load file! HTTP status: "+r.status+", file: "+i)};try{r.send(null)}catch(n){console.log("fehler beim laden der punktwolke: "+n)}},Potree.LasLazBatcher=function(e,t){this.push=function(o){var i=Potree.workers.lasdecoder.getWorker(),r=new THREE.Vector3(o.mins[0],o.mins[1],o.mins[2]),n=new THREE.Vector3(o.maxs[0],o.maxs[1],o.maxs[2]);r.add(e.pcoGeometry.offset),n.add(e.pcoGeometry.offset),i.onmessage=function(a){for(var s=new THREE.BufferGeometry,l=o.pointsCount,d=a.data.position,u=a.data.color,c=a.data.intensity,h=new Uint8Array(a.data.classification),p=new Float32Array(h.byteLength),m=new THREE.Box3,E=new Float32Array(d),f=0;l>f;f++)p[f]=h[f],m.expandByPoint(new THREE.Vector3(E[3*f+0],E[3*f+1],E[3*f+2]));s.addAttribute("position",new THREE.BufferAttribute(new Float32Array(d),3)),s.addAttribute("color",new THREE.BufferAttribute(new Float32Array(u),3)),s.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(c),1)),s.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(p),1)),s.boundingBox=new THREE.Box3(r,n),e.boundingBox=s.boundingBox,e.geometry=s,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,nodesLoadTimes[t].end=(new Date).getTime();nodesLoadTimes[t].end-nodesLoadTimes[t].start;Potree.workers.lasdecoder.returnWorker(i)};var a={buffer:o.arrayb,numPoints:o.pointsCount,pointSize:o.pointSize,pointFormatID:2,scale:o.scale,offset:o.offset,mins:[e.pcoGeometry.boundingBox.min.x,e.pcoGeometry.boundingBox.min.y,e.pcoGeometry.boundingBox.min.z],maxs:[e.pcoGeometry.boundingBox.max.x,e.pcoGeometry.boundingBox.max.y,e.pcoGeometry.boundingBox.max.z],bbOffset:[e.pcoGeometry.offset.x,e.pcoGeometry.offset.y,e.pcoGeometry.offset.z]};i.postMessage(a,[a.buffer])}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),200!==t.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(e,t){var o=[new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.max.z).applyMatrix4(t)],i=new THREE.Box3;return i.setFromPoints(o),i},Potree.utils.addCommas=function(e){e+="",x=e.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var t=/(\d+)(\d{3})/;t.test(x1);)x1=x1.replace(t,"$1,$2");return x1+x2},Potree.utils.createWorker=function(e){var t=new Blob([e],{type:"application/javascript"}),o=new Worker(URL.createObjectURL(t));return o},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),o=new THREE.Scene,i=".jpg",r=[e+"px"+i,e+"nx"+i,e+"py"+i,e+"ny"+i,e+"pz"+i,e+"nz"+i],n=THREE.ImageUtils.loadTextureCube(r,new THREE.CubeRefractionMapping),a=new THREE.MeshBasicMaterial({color:16777215,envMap:n,refractionRatio:.95}),s=THREE.ShaderLib.cube;s.uniforms.tCube.value=n;var a=new THREE.ShaderMaterial({fragmentShader:s.fragmentShader,vertexShader:s.vertexShader,uniforms:s.uniforms,depthWrite:!1,side:THREE.BackSide}),l=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),a);return o.add(l),{camera:t,scene:o}},Potree.utils.createGrid=function(e,t,o,i){for(var r=new THREE.LineBasicMaterial({color:i||8947848}),n=new THREE.Geometry,a=0;t>=a;a++)n.vertices.push(new THREE.Vector3(-(o*e)/2,0,a*o-o*t/2)),n.vertices.push(new THREE.Vector3(+(o*e)/2,0,a*o-o*t/2));for(var a=0;e>=a;a++)n.vertices.push(new THREE.Vector3(a*o-o*e/2,0,-(o*t)/2)),n.vertices.push(new THREE.Vector3(a*o-o*e/2,0,+(o*t)/2));var s=new THREE.Line(n,r,THREE.LinePieces);return s.receiveShadow=!0,s},Potree.TextSprite=function(e){var t=new THREE.Texture,o=new THREE.SpriteMaterial({map:t,useScreenCoordinates:!1});THREE.Sprite.call(this,o),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(e)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(e){this.text=e,this.update()},Potree.TextSprite.prototype.setBorderColor=function(e){this.borderColor=e,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(e){this.backgroundColor=e,this.update()},Potree.TextSprite.prototype.update=function(){var e=document.createElement("canvas"),t=e.getContext("2d");t.font="Bold "+this.fontsize+"px "+this.fontface;var o=t.measureText(this.text),i=o.width,r=i+2*this.borderThickness,n=1.4*this.fontsize+2*this.borderThickness,e=document.createElement("canvas"),t=e.getContext("2d");t.canvas.width=r,t.canvas.height=n,t.font="Bold "+this.fontsize+"px "+this.fontface,t.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",t.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",t.lineWidth=this.borderThickness,this.roundRect(t,this.borderThickness/2,this.borderThickness/2,i+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),t.strokeStyle="rgba(0, 0, 0, 1.0)",t.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),t.fillStyle="rgba(255, 255, 255, 1.0)",t.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var a=new THREE.Texture(e);a.needsUpdate=!0,this.material.map=a,this.scale.set(.01*r,.01*n,1)},Potree.TextSprite.prototype.roundRect=function(e,t,o,i,r,n){e.beginPath(),e.moveTo(t+n,o),e.lineTo(t+i-n,o),e.quadraticCurveTo(t+i,o,t+i,o+n),e.lineTo(t+i,o+r-n),e.quadraticCurveTo(t+i,o+r,t+i-n,o+r),e.lineTo(t+n,o+r),e.quadraticCurveTo(t,o+r,t,o+r-n),e.lineTo(t,o+n),e.quadraticCurveTo(t,o,t+n,o),e.closePath(),e.fill(),e.stroke()},Potree.MeasuringTool=function(e,t,o){function i(){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[]}function r(e){var t=l();if(t){var o=t.clone(),r=new THREE.MeshNormalMaterial({shading:THREE.SmoothShading}),n=new THREE.SphereGeometry(.4,10,10),a=new THREE.Mesh(n,r);a.position.copy(t),d.sceneRoot.add(a);var s=new THREE.Mesh(n,r);s.position.copy(t),d.sceneRoot.add(s);var h=o.x.toFixed(2)+" / "+o.y.toFixed(2)+" / "+o.z.toFixed(2),p=new Potree.TextSprite(h);p.setBorderColor({r:0,g:255,b:0,a:1}),p.material.depthTest=!1,p.material.opacity=0,p.position.copy(t),p.position.y+=.5,d.sceneRoot.add(p);var m=new Potree.TextSprite(h);m.setBorderColor({r:0,g:255,b:0,a:1}),m.material.depthTest=!1,m.material.opacity=0,m.position.copy(t),m.position.y+=.5,d.sceneRoot.add(m);var E=new THREE.Color(16711680),f=new THREE.Geometry;f.vertices.push(t.clone(),t.clone()),f.colors.push(E,E,E);var v=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});v.depthTest=!1,sConnection=new THREE.Line(f,v),d.sceneRoot.add(sConnection);var T=new Potree.TextSprite(0);T.setBorderColor({r:0,g:255,b:0,a:0}),T.setBackgroundColor({r:0,g:255,b:0,a:0}),T.material.depthTest=!1,T.position.copy(t),T.position.y+=.5,d.sceneRoot.add(T),c===u.DEFAULT?(c=u.PICKING,d.activeMeasurement=new i,d.activeMeasurement.spheres.push(a)):c===u.PICKING,d.activeMeasurement.points.push(t),d.activeMeasurement.spheres.push(s),d.activeMeasurement.sphereLabels.push(p),d.activeMeasurement.sphereLabels.push(m),d.activeMeasurement.edges.push(sConnection),d.activeMeasurement.edgeLabels.push(T);var e={type:"newpoint",position:o.clone()};d.dispatchEvent(e)}}function n(e){if(d.mouse.x=e.clientX/d.domElement.clientWidth*2-1,d.mouse.y=2*-(e.clientY/d.domElement.clientHeight)+1,c==u.PICKING&&d.activeMeasurement){var t=l();if(t){var o=t.clone(),i=d.activeMeasurement.spheres.length,r=d.activeMeasurement.spheres[i-1],n=d.activeMeasurement.sphereLabels[i-1],a=d.activeMeasurement.edges[i-2],s=d.activeMeasurement.edgeLabels[i-2],h=o.x.toFixed(2)+" / "+o.y.toFixed(2)+" / "+o.z.toFixed(2);n.setText(h),r.position.copy(t),n.position.copy(t),n.position.y+=.5,a.geometry.vertices[1].copy(t),a.geometry.verticesNeedUpdate=!0,a.geometry.computeBoundingSphere();var p=a.geometry.vertices[1].clone().add(a.geometry.vertices[0]).multiplyScalar(.5),m=a.geometry.vertices[0].distanceTo(a.geometry.vertices[1]).toFixed(2);s.position.copy(p),s.setText(m),s.scale.multiplyScalar(10)}}}function a(){if(c==u.PICKING){var e=d.activeMeasurement.spheres.pop(),t=d.activeMeasurement.edges.pop(),o=d.activeMeasurement.sphereLabels.pop(),i=d.activeMeasurement.edgeLabels.pop();d.sceneRoot.remove(e),d.sceneRoot.remove(t),d.sceneRoot.remove(o),d.sceneRoot.remove(i),d.measurements.push(d.activeMeasurement),d.activeMeasurement=void 0,c=u.DEFAULT}}function s(e){3===e.which&&a(e)}function l(){var e=new THREE.Vector3(d.mouse.x,d.mouse.y,.5),t=new THREE.Projector;t.unprojectVector(e,d.camera);var o=new THREE.Raycaster;o.params={PointCloud:{threshold:1}},o.ray.set(d.camera.position,e.sub(d.camera.position).normalize());var i=[];d.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});var r=o.intersectObjects(i,!0);if(r.length>0){var n=r[0];return n.point}return void 0}var d=this;this.scene=e,this.camera=t,this.domElement=o,this.mouse={x:0,y:0};var u={DEFAULT:0,PICKING:1},c=u.DEFAULT;this.activeMeasurement,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.domElement.addEventListener("dblclick",r,!1),this.domElement.addEventListener("mousemove",n,!1),this.domElement.addEventListener("mousedown",s,!1)},Potree.MeasuringTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.ProfileTool=function(e,t,o){THREE.Object3D.call(this);var i=new THREE.BoxGeometry(1,1,1,1,1,1),r=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.3});this.profileFrustum=new THREE.Mesh(i,r),this.add(this.profileFrustum),this.camera=new THREE.OrthographicCamera(-e/2,e/2,t/2,-t/2,1,1+o),this.add(this.camera),this.setDimension(e,t,o),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);var n=new THREE.Vector3(0,0,0),a=new THREE.Vector3(10,0,0);this.setCoordinates(n,a)},Potree.ProfileTool.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileTool.prototype.setDimension=function(e,t,o){this.profileFrustum.scale.set(e,t,o),this.width=e,this.height=t,this.depth=o,this.camera.left=-e/2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=-t/2,this.camera.updateProjectionMatrix()},Potree.ProfileTool.prototype.setOrientation=function(e){var t=this.position.clone();this.position.add(e),this.lookAt(t),this.position.copy(t),this.camera.position.copy(t.clone().add(e)),this.camera.lookAt(t)},Potree.ProfileTool.prototype.setCoordinates=function(e,t){var o=e.distanceTo(t);this.setDimension(o,this.height,this.depth);var i=(new THREE.Vector3).addVectors(e,t).multiplyScalar(.5),r=(new THREE.Vector3).subVectors(t,e),n=new THREE.Vector3(r.z,0,-r.x);this.position.set(0,0,0),this.lookAt(n),this.position.copy(i),this.start=e,this.end=t},Potree.ProfileTool.prototype.render=function(e,t){this.camera.matrixWorld.copy(this.matrixWorld),t.traverse(function(e){e instanceof Potree.PointCloudOctree&&(e.material.oldSize=e.material.size,e.material.size=0)}),e.render(t,this.camera,this.rtProfile,!0),t.traverse(function(e){e instanceof Potree.PointCloudOctree&&(e.material.size=e.material.oldSize)})},Potree.TranslationTool=function(e){THREE.Object3D.call(this);var t=this;this.camera=e,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 e=t.createArrow(t.parts.ARROW_X,t.parts.ARROW_X.color);e.rotation.z=-Math.PI/2;var o=t.createArrow(t.parts.ARROW_Y,t.parts.ARROW_Y.color),i=t.createArrow(t.parts.ARROW_Z,t.parts.ARROW_Z.color);i.rotation.x=-Math.PI/2,t.add(e),t.add(o),t.add(i);var r=t.createBox(new THREE.Color(16776960));r.scale.z=.02,r.position.set(.5,.5,0);var n=t.createBox(new THREE.Color(16711935));n.scale.y=.02,n.position.set(.5,0,-.5);var a=t.createBox(new THREE.Color(65535));a.scale.x=.02,a.position.set(0,.5,-.5),t.add(r),t.add(n),t.add(a),t.parts.ARROW_X.object=e,t.parts.ARROW_Y.object=o,t.parts.ARROW_Z.object=i,t.scale.multiplyScalar(5)},this.createBox=function(e){var t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshBasicMaterial({color:e,transparent:!0,opacity:.5}),i=new THREE.Mesh(t,o);return i},this.createArrow=function(e,t){var o=new THREE.MeshBasicMaterial({color:t}),i=new THREE.CylinderGeometry(.1,.1,3,10,1,!1),r=o,n=new THREE.Mesh(i,r);n.position.y=1.5;var a=new THREE.CylinderGeometry(0,.3,1,10,1,!1),s=o,l=new THREE.Mesh(a,s);l.position.y=3;var d=new THREE.Object3D;return d.add(n),d.add(l),d.partID=e,d.material=o,d},this.setHighlighted=function(e){return void 0===e?void(t.highlighted&&(t.highlighted.object.material.color=t.highlighted.color,t.highlighted=void 0)):(void 0!==t.highlighted&&t.highlighted!==e&&(t.highlighted.object.material.color=t.highlighted.color),t.highlighted=e,void(e.object.material.color=new THREE.Color(16776960)))},this.getHoveredObject=function(e){var o=new THREE.Vector3(e.x,e.y,.5),i=new THREE.Projector;i.unprojectVector(o,t.camera);var r=new THREE.Raycaster;r.ray.set(t.camera.position,o.sub(t.camera.position).normalize());var n=r.intersectObject(t,!0);if(0===n.length)return void t.setHighlighted(void 0);var a=n[0],s=a.object.parent.partID;return s},this.onMouseMove=function(e){var o=e.normalizedPosition;if(t.state===t.STATE.DEFAULT)t.setHighlighted(t.getHoveredObject(o));else if(t.state===t.STATE.TRANSLATE_X||t.state===t.STATE.TRANSLATE_Y||t.state===t.STATE.TRANSLATE_Z){var i=t.start.lineStart.clone(),r=t.start.lineEnd.clone().sub(t.start.lineStart);r.normalize();var n=new THREE.Vector3(o.x,o.y),a=(new THREE.Vector3).subVectors(n,i).dot(r),s=r.clone().multiplyScalar(a).add(i),l=new THREE.Projector;l.unprojectVector(s,t.camera);var d=s.clone().sub(t.position);t.position.copy(s);for(var u=0;u=r?i.pointsCount:i.pointsCount/r,s=function(){var e=o.readData(1e6,0,r);return e.then(function(e){return t.push(new LASDecoder(e.buffer,i.pointsFormatId,i.pointsStructSize,e.count,i.scale,i.offset,i.mins,i.maxs)),n+=e.count,LasLazLoader.progressCB(n/a),e.hasMoreData?s():(i.totalRead=n,i.versionAsString=o.versionAsString,i.isCompressed=o.isCompressed,[o,i,t])})};return s()}).then(function(e){var t=e[0];return LasLazLoader.progressCB(1),t.close().then(function(){return t.isOpen=!1,Promise.delay(200).cancellable()}).then(function(){return e.slice(1)})}).catch(Promise.CancellationError,function(e){if(o.isOpen)return o.close().then(function(){throw o.isOpen=!1,e});throw e})},Potree.PointCloudRGBMaterial=function(e){e=e||{};var t={},o={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10},minSize:{type:"f",value:2}},i=e.size||1,r=e.minSize||2;this.setValues({uniforms:o,attributes:t,vertexShader:Potree.PointCloudRGBMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:i,minSize:r,alphaTest:.9})},Potree.PointCloudRGBMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudRGBMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudRGBMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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.PointCloudRGBInterpolationMaterial=function(e){e=e||{};var t,o,i={},r={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10},minSize:{type:"f",value:2},blendDepth:{type:"f",value:.01}},n=e.size||1,a=e.minSize||2,s=renderer.context.getExtension("EXT_frag_depth");s?(t=Potree.PointCloudRGBInterpolationMaterial.vs_points.join("\n"),o=Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb.join("\n")):(t=Potree.PointCloudRGBMaterial.vs_points.join("\n"),o=Potree.PointCloudRGBMaterial.fs_points_rgb.join("\n")),this.setValues({uniforms:r,attributes:i,vertexShader:t,fragmentShader:o,vertexColors:THREE.VertexColors,size:n,minSize:a,alphaTest:.9})},Potree.PointCloudRGBInterpolationMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Object.defineProperty(Potree.PointCloudRGBInterpolationMaterial.prototype,"blendDepth",{get:function(){return this.uniforms.blendDepth.value},set:function(e){this.uniforms.blendDepth.value=e}}),Potree.PointCloudRGBInterpolationMaterial.vs_points=[" "," "," ","uniform float size; ","uniform float minSize; ","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(minSize, gl_PointSize); "," gl_Position = projectionMatrix * mvPosition; ","} "],Potree.PointCloudRGBInterpolationMaterial.fs_points_rgb=["#extension GL_EXT_frag_depth : enable ","varying vec3 vColor; ","uniform float blendDepth; "," "," ","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); "," gl_FragDepthEXT = gl_FragCoord.z + blendDepth*(1.0-pow(c, 1.0)) * gl_FragCoord.w ; "," "," //float dist = gl_FragCoord.z / gl_FragCoord.w; "," //float fog = clamp(dist / 2000.0, 0.0, 1.0); "," //fog = min(fog, 0.6); "," //gl_FragColor = gl_FragColor * (1.0-fog) + vec4(170.0, 180.0, 190, 1.0) * fog / 256.0; "," //gl_FragColor.a = 1.0; ","} "],Potree.PointCloudIntensityMaterial=function(e){e=e||{};var t=e.size||1,o=e.minSize||2;this.min=e.min||0,this.max=e.max||1;var i={intensity:{type:"f",value:[]}},r={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},minSize:{type:"f",value:2},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max}};this.setValues({uniforms:r,attributes:i,vertexShader:Potree.PointCloudIntensityMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudIntensityMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,minSize:o,alphaTest:.9})},Potree.PointCloudIntensityMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudIntensityMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudIntensityMaterial.vs_points=["attribute float intensity; ","uniform float size; ","uniform float minSize; ","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 * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = max(minSize, 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(e){e=e||{};var t=e.size||1,o=e.minSize||2;this.min=e.min||0,this.max=e.max||1;var i=Potree.PointCloudHeightMaterial.generateGradient(),r={},n={uCol:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:1},minSize:{type:"f",value:2},uMin:{type:"f",value:this.min},uMax:{type:"f",value:this.max},gradient:{type:"t",value:i}};this.setValues({uniforms:n,attributes:r,vertexShader:Potree.PointCloudHeightMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudHeightMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,minSize:o,alphaTest:.9})},Potree.PointCloudHeightMaterial.generateGradient=function(){var e=64;canvas=document.createElement("canvas"),canvas.width=e,canvas.height=e;var t=canvas.getContext("2d");t.rect(0,0,e,e);var o=t.createLinearGradient(0,0,e,e);o.addColorStop(0,"blue"),o.addColorStop(.2,"aqua"),o.addColorStop(.4,"green"),o.addColorStop(.6,"yellow"),o.addColorStop(.8,"orange"),o.addColorStop(1,"red"),t.fillStyle=o,t.fill();var i=new THREE.Texture(canvas);return i.needsUpdate=!0,textureImage=i.image,i},Potree.PointCloudHeightMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudHeightMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Potree.PointCloudHeightMaterial.prototype.setBoundingBox=function(e){this.min=e.min.y,this.max=e.max.y,this.uniforms.uMin.value=this.min,this.uniforms.uMax.value=this.max},Potree.PointCloudHeightMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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(e){e=e||{};var t=e.color||(new THREE.Color).setRGB(1,0,0),o=e.size||1,i=e.minSize||2,r={},n={uCol:{type:"c",value:t},size:{type:"f",value:1},minSize:{type:"f",value:2}};this.setValues({uniforms:n,attributes:r,vertexShader:Potree.PointCloudColorMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudColorMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:o,minSize:i,alphaTest:.9})},Potree.PointCloudColorMaterial.prototype=new THREE.ShaderMaterial,Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Object.defineProperty(Potree.PointCloudColorMaterial.prototype,"color",{get:function(){return this.uniforms.uCol.value},set:function(e){this.uniforms.uCol.value.copy(e)}}),Potree.PointCloudColorMaterial.vs_points=["uniform float size; ","uniform float minSize; ","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(minSize, 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(e,t){function o(e){l.enabled!==!1&&(e.preventDefault(),0===e.button?(x=g.ROTATE,d.set(e.clientX,e.clientY)):2===e.button&&(x=g.PAN,h.set(e.clientX,e.clientY)),l.domElement.addEventListener("mousemove",i,!1),l.domElement.addEventListener("mouseup",r,!1),l.dispatchEvent(R))}function i(e){if(l.enabled!==!1){e.preventDefault();var t=l.domElement===document?l.domElement.body:l.domElement;x===g.ROTATE?(u.set(e.clientX,e.clientY),c.subVectors(u,d),l.rotateLeft(2*Math.PI*c.x/t.clientWidth*l.rotateSpeed),l.rotateUp(2*Math.PI*c.y/t.clientHeight*l.rotateSpeed),d.copy(u)):x===g.PAN&&(p.set(e.clientX,e.clientY),m.subVectors(p,h),m.multiplyScalar(5e-4).multiplyScalar(l.moveSpeed),l.pan(m.x,m.y),h.copy(p))}}function r(){l.enabled!==!1&&(l.domElement.removeEventListener("mousemove",i,!1),l.domElement.removeEventListener("mouseup",r,!1),l.dispatchEvent(w),x=g.NONE)}function n(e){if(l.enabled!==!1&&l.noZoom!==!0){e.preventDefault();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),l.moveSpeed+=.001*l.moveSpeed*t,l.moveSpeed=Math.max(.1,l.moveSpeed),l.dispatchEvent(R),l.dispatchEvent(w)}}function a(e){if(l.enabled!==!1)switch(e.keyCode){case l.keys.UP:l.moveForward=!0;break;case l.keys.BOTTOM:l.moveBackward=!0;break;case l.keys.LEFT:l.moveLeft=!0;break;case l.keys.RIGHT:l.moveRight=!0;break;case l.keys.W:l.moveForward=!0;break;case l.keys.S:l.moveBackward=!0;break;case l.keys.A:l.moveLeft=!0;break;case l.keys.D:l.moveRight=!0}}function s(e){switch(e.keyCode){case l.keys.W:l.moveForward=!1;break;case l.keys.S:l.moveBackward=!1;break;case l.keys.A:l.moveLeft=!1;break;case l.keys.D:l.moveRight=!1;break;case l.keys.UP:l.moveForward=!1;break;case l.keys.BOTTOM:l.moveBackward=!1;break;case l.keys.LEFT:l.moveLeft=!1;break;case l.keys.RIGHT:l.moveRight=!1}}this.object=e,this.domElement=void 0!==t?t: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 l=this,d=new THREE.Vector2,u=new THREE.Vector2,c=new THREE.Vector2,h=new THREE.Vector2,p=new THREE.Vector2,m=new THREE.Vector2,E=new THREE.Vector3,f=(new THREE.Vector3,0),v=0,T=1,P=new THREE.Vector3,y=new THREE.Vector3,g={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},x=g.NONE;this.position0=this.object.position.clone();var b={type:"change"},R={type:"start"},w={type:"end"};this.rotateLeft=function(e){v-=e},this.rotateUp=function(e){f-=e},this.panLeft=function(e){var t=this.object.matrix.elements;E.set(t[0],t[1],t[2]),E.multiplyScalar(-e),P.add(E)},this.panUp=function(e){var t=this.object.matrix.elements;E.set(t[4],t[5],t[6]),E.multiplyScalar(e),P.add(E)},this.panForward=function(e){var t=this.object.matrix.elements;E.set(t[8],t[9],t[10]),E.multiplyScalar(e),P.add(E)},this.pan=function(e,t){var o=l.domElement===document?l.domElement.body:l.domElement;if(void 0!==l.object.fov){var i=l.object.position,r=i.clone(),n=r.length();n*=Math.tan(l.object.fov/2*Math.PI/180),l.panLeft(2*e*n/o.clientHeight),l.panUp(2*t*n/o.clientHeight)}else void 0!==l.object.top?(l.panLeft(e*(l.object.right-l.object.left)/o.clientWidth),l.panUp(t*(l.object.top-l.object.bottom)/o.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(e){var t=this.object.position;if(void 0!==e&&(this.moveRight&&this.panLeft(-e*this.moveSpeed),this.moveLeft&&this.panLeft(e*this.moveSpeed),this.moveForward&&this.panForward(-e*this.moveSpeed),this.moveBackward&&this.panForward(e*this.moveSpeed)),!P.equals(new THREE.Vector3(0,0,0))){var o={type:"move",translation:P.clone()};this.dispatchEvent(o)}t.add(P),this.object.updateMatrix();var i=(new THREE.Matrix4).makeRotationY(v),r=(new THREE.Matrix4).multiplyMatrices(i,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=f,v=0,f=0,T=1,P.set(0,0,0),y.distanceTo(this.object.position)>0&&(this.dispatchEvent(b),y.copy(this.object.position))},this.reset=function(){x=g.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",n,!1),this.domElement.addEventListener("DOMMouseScroll",n,!1),window.addEventListener("keydown",a,!1),window.addEventListener("keyup",s,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(e){return null==this.items[e.id]},LRU.prototype.touch=function(e){var t;null==this.items[e.id]?(t=new LRUItem(e),t.previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):(t=this.items[e.id],null===t.previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null===t.next||(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))},LRU.prototype.remove=function(){if(null===this.first)return null;var e=this.first;return null!==e.next?(this.first=e.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[e.node.id],this.elements--,this.numPoints-=e.node.numPoints,e.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var e=this.first;return e.node},LRU.prototype.toString=function(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.boundingBox=e.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileRequest=function(e,t,o,i,r){this.start=e,this.end=t,this.width=o,this.depth=i,this.callback=r,this.loadQueue=[];var n=((new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),(new THREE.Vector3).subVectors(t,e).length(),(new THREE.Vector3).subVectors(t,e).normalize()),a=new THREE.Vector3(0,1,0),s=(new THREE.Vector3).crossVectors(n,a).normalize(),l=s;this.plane=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,e)},Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.root.boundingBox,this.material=t,this.visiblePointsTarget=2e6,this.level=0,this.position.sub(e.offset),this.updateMatrix(),this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.loadQueue=[],this.visibleBounds=new THREE.Box3,this.profileRequests=[];var o=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(o)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(e){this.numVisibleNodes=0,this.numVisiblePoints=0,this.loadQueue=[],e.updateMatrixWorld();var t=new THREE.Frustum,o=e.matrixWorldInverse,i=this.matrixWorld,r=e.projectionMatrix,n=(new THREE.Matrix4).multiply(r).multiply(o).multiply(i); +t.setFromMatrix(n);for(var a=e.matrixWorld,s=(new THREE.Matrix4).getInverse(i),l=(new THREE.Matrix4).multiply(s).multiply(a),d=(new THREE.Vector3).setFromMatrixPosition(l),u=(new THREE.Ray(e.position,new THREE.Vector3(0,0,-1).applyQuaternion(e.quaternion)),0);u0;){var E=m.shift();if(E instanceof THREE.Mesh||E instanceof THREE.Line)E.visible=!0;else{var f=E.boundingBox,v=f.center().distanceTo(d),T=.5*f.size().length(),P=Math.pow(T,1)/v,y=t.intersectsBox(f),g=!0;if(E.level>0){var g=P>=1/this.LOD;g||p.push({node:E,lod:P})}var x=y&&g;if(E.visible=x,E.insideFrustum=y,E.inRange=g,E.matrixWorld.multiplyMatrices(E.parent.matrixWorld,E.matrix),x)if(x&&this.showBoundingBox&&E instanceof THREE.PointCloud){if(void 0===E.boundingBoxNode&&void 0!==E.boundingBox){var b=new THREE.BoxHelper(E);E.add(b),E.boundingBoxNode=b}}else this.showBoundingBox||void 0!==E.boundingBoxNode&&(E.remove(E.boundingBoxNode),E.boundingBoxNode=void 0);else this.hideDescendants(E);if(x){if(E instanceof THREE.PointCloud)this.numVisibleNodes++,this.numVisiblePoints+=E.numPoints,Potree.PointCloudOctree.lru.touch(E),E.material=this.material,h.push({node:E,lod:P});else if(E instanceof Potree.PointCloudOctreeProxyNode){var R=E.geometryNode;R.loaded===!0?this.replaceProxy(E):this.loadQueue.push({node:E,lod:P})}for(var u=0;u0;){var E=m.shift();if(E instanceof Potree.PointCloudOctreeProxyNode){var f=Potree.utils.computeTransformedBoundingBox(E.boundingBox,E.matrixWorld),H=f.getBoundingSphere();Math.abs(w.distanceToPoint(H.center))0&&h.length>0){p.sort(function(e,t){return t.lod-e.lod}),h.sort(function(e,t){return e.lod-t.lod});var M=1/h[0].lod,S=Math.min(p.length-1,4),z=1/p[S].lod,L=Math.max(M,z);this.LOD=L}else this.numVisiblePoints>1.1*this.visiblePointsTarget&&(this.LOD*=.95);for(var B=[],u=0;u0){console.log("loading: "+G.loadQueue[0].geometryNode.name);var E=G.loadQueue[0],R=E.geometryNode;if(R.loaded===!0&&void 0!==E.parent){var _=this.replaceProxy(E);_.updateMatrixWorld(),_.matrixWorld.multiplyMatrices(_.parent.matrixWorld,_.matrix)}else E.geometryNode.load()}else{var j=this.getProfile(G.start,G.end,G.width,G.depth);G.callback({type:"finished",points:j}),D.push(G)}}for(var u=0;u-1&&this.profileRequests.splice(k,1)}if(this.loadQueue.length>0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.lod-e.lod});for(var u=0;un;n++)if(void 0!==t.children[n]){var a=t.children[n],s=new Potree.PointCloudOctreeProxyNode(a);i.add(s)}return i}},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o0;){var e=t.shift();e.visible=!1;for(var o=0;o0;){var E=n.shift(),f=0;if(E instanceof THREE.PointCloud)for(var v=E.geometry,T=v.attributes.position,P=T.array,y=T.length/T.itemSize,g=0;y>g;g++){var x=new THREE.Vector3(P[3*g],P[3*g+1],P[3*g+2]);x.applyMatrix4(this.matrixWorld);var b=Math.abs(h.distanceToPoint(x)),R=Math.abs(p.distanceToPoint(x));o/2>b&&s/2>R&&(m.push(x),f++)}if(E==this||E.levelt)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var r=0;r5)){this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++;var e=this.pcoGeometry.pointAttributes;if("LAS"===e||"LAZ"===e){var t=this.pcoGeometry.octreeDir+"/"+this.name+"."+e.toLowerCase();nodesLoadTimes[t]={},nodesLoadTimes[t].start=(new Date).getTime(),LasLazLoader.load(t,new Potree.LasLazBatcher(this,t))}else if("POT"===e){var o=function(e,t){var o=new DataView(t,0,4),i=o.getUint32(0,!0),r=4+i,n=t.slice(4,4+i),a=String.fromCharCode.apply(null,new Uint8Array(n));a=JSON.parse(a),console.log(a);for(var s=a.attributes[0].scale,l=a.attributes[0].offset,d=a.attributes[0].encoding,u=new THREE.Vector3(s[0],s[1],s[2]),c=new THREE.Vector3(l[0],l[1],l[2]),h=d.min,p=(d.max,d.bits),m=t.slice(r,r+t.byteLength-r),E=new BitReader(m),f=E.read(32),v=E.read(32),T=E.read(32),P=E.read(8),g=E.read(8),b=E.read(8),R=new THREE.BufferGeometry,w=a.pointcount,C=new Float32Array(3*w),H=new Float32Array(3*w),A=(new THREE.Color,0);Au;u++)n[3*u+0]=l[4*u+0]+e.pcoGeometry.offset.x,n[3*u+1]=l[4*u+1]+e.pcoGeometry.offset.y,n[3*u+2]=l[4*u+2]+e.pcoGeometry.offset.z,s.setRGB(d[16*u+12],d[16*u+13],d[16*u+14]),a[3*u+0]=s.r/255,a[3*u+1]=s.g/255,a[3*u+2]=s.b/255;i.addAttribute("position",new THREE.BufferAttribute(n,3)),i.addAttribute("color",new THREE.BufferAttribute(a,3)),i.boundingBox=e.boundingBox,e.geometry=i,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,nodesLoadTimes[t].end=(new Date).getTime();nodesLoadTimes[t].end-nodesLoadTimes[t].start};nodesLoadTimes[t]={},nodesLoadTimes[t].start=(new Date).getTime(),Potree.BinaryNodeLoader.load(this,"",o)}}},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(e,t,o){var i=e.pcoGeometry.octreeDir+"/"+e.name;void 0!==t&&t.length>0&&(i+="."+t);var r=new XMLHttpRequest;r.open("GET",i,!0),r.responseType="arraybuffer",r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status||0===r.status){var t=r.response;o(e,t)}else console.log("Failed to load file! HTTP status: "+r.status+", file: "+i)};try{r.send(null)}catch(n){console.log("fehler beim laden der punktwolke: "+n)}},Potree.LasLazBatcher=function(e,t){this.push=function(o){var i=Potree.workers.lasdecoder.getWorker(),r=new THREE.Vector3(o.mins[0],o.mins[1],o.mins[2]),n=new THREE.Vector3(o.maxs[0],o.maxs[1],o.maxs[2]);r.add(e.pcoGeometry.offset),n.add(e.pcoGeometry.offset),i.onmessage=function(a){for(var s=new THREE.BufferGeometry,l=o.pointsCount,d=a.data.position,u=a.data.color,c=a.data.intensity,h=new Uint8Array(a.data.classification),p=new Float32Array(h.byteLength),m=new THREE.Box3,E=new Float32Array(d),f=0;l>f;f++)p[f]=h[f],m.expandByPoint(new THREE.Vector3(E[3*f+0],E[3*f+1],E[3*f+2]));s.addAttribute("position",new THREE.BufferAttribute(new Float32Array(d),3)),s.addAttribute("color",new THREE.BufferAttribute(new Float32Array(u),3)),s.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(c),1)),s.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(p),1)),s.boundingBox=new THREE.Box3(r,n),e.boundingBox=s.boundingBox,e.geometry=s,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,nodesLoadTimes[t].end=(new Date).getTime();nodesLoadTimes[t].end-nodesLoadTimes[t].start;Potree.workers.lasdecoder.returnWorker(i)};var a={buffer:o.arrayb,numPoints:o.pointsCount,pointSize:o.pointSize,pointFormatID:2,scale:o.scale,offset:o.offset,mins:[e.pcoGeometry.boundingBox.min.x,e.pcoGeometry.boundingBox.min.y,e.pcoGeometry.boundingBox.min.z],maxs:[e.pcoGeometry.boundingBox.max.x,e.pcoGeometry.boundingBox.max.y,e.pcoGeometry.boundingBox.max.z],bbOffset:[e.pcoGeometry.offset.x,e.pcoGeometry.offset.y,e.pcoGeometry.offset.z]};i.postMessage(a,[a.buffer])}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),200!==t.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(e,t){var o=[new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.max.z).applyMatrix4(t)],i=new THREE.Box3;return i.setFromPoints(o),i},Potree.utils.addCommas=function(e){e+="",x=e.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var t=/(\d+)(\d{3})/;t.test(x1);)x1=x1.replace(t,"$1,$2");return x1+x2},Potree.utils.createWorker=function(e){var t=new Blob([e],{type:"application/javascript"}),o=new Worker(URL.createObjectURL(t));return o},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),o=new THREE.Scene,i=".jpg",r=[e+"px"+i,e+"nx"+i,e+"py"+i,e+"ny"+i,e+"pz"+i,e+"nz"+i],n=THREE.ImageUtils.loadTextureCube(r,new THREE.CubeRefractionMapping),a=new THREE.MeshBasicMaterial({color:16777215,envMap:n,refractionRatio:.95}),s=THREE.ShaderLib.cube;s.uniforms.tCube.value=n;var a=new THREE.ShaderMaterial({fragmentShader:s.fragmentShader,vertexShader:s.vertexShader,uniforms:s.uniforms,depthWrite:!1,side:THREE.BackSide}),l=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),a);return o.add(l),{camera:t,scene:o}},Potree.utils.createGrid=function(e,t,o,i){for(var r=new THREE.LineBasicMaterial({color:i||8947848}),n=new THREE.Geometry,a=0;t>=a;a++)n.vertices.push(new THREE.Vector3(-(o*e)/2,0,a*o-o*t/2)),n.vertices.push(new THREE.Vector3(+(o*e)/2,0,a*o-o*t/2));for(var a=0;e>=a;a++)n.vertices.push(new THREE.Vector3(a*o-o*e/2,0,-(o*t)/2)),n.vertices.push(new THREE.Vector3(a*o-o*e/2,0,+(o*t)/2));var s=new THREE.Line(n,r,THREE.LinePieces);return s.receiveShadow=!0,s},Potree.TextSprite=function(e){var t=new THREE.Texture,o=new THREE.SpriteMaterial({map:t,useScreenCoordinates:!1});THREE.Sprite.call(this,o),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(e)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(e){this.text=e,this.update()},Potree.TextSprite.prototype.setBorderColor=function(e){this.borderColor=e,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(e){this.backgroundColor=e,this.update()},Potree.TextSprite.prototype.update=function(){var e=document.createElement("canvas"),t=e.getContext("2d");t.font="Bold "+this.fontsize+"px "+this.fontface;var o=t.measureText(this.text),i=o.width,r=i+2*this.borderThickness,n=1.4*this.fontsize+2*this.borderThickness,e=document.createElement("canvas"),t=e.getContext("2d");t.canvas.width=r,t.canvas.height=n,t.font="Bold "+this.fontsize+"px "+this.fontface,t.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",t.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",t.lineWidth=this.borderThickness,this.roundRect(t,this.borderThickness/2,this.borderThickness/2,i+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),t.strokeStyle="rgba(0, 0, 0, 1.0)",t.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),t.fillStyle="rgba(255, 255, 255, 1.0)",t.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var a=new THREE.Texture(e);a.needsUpdate=!0,this.material.map=a,this.scale.set(.01*r,.01*n,1)},Potree.TextSprite.prototype.roundRect=function(e,t,o,i,r,n){e.beginPath(),e.moveTo(t+n,o),e.lineTo(t+i-n,o),e.quadraticCurveTo(t+i,o,t+i,o+n),e.lineTo(t+i,o+r-n),e.quadraticCurveTo(t+i,o+r,t+i-n,o+r),e.lineTo(t+n,o+r),e.quadraticCurveTo(t,o+r,t,o+r-n),e.lineTo(t,o+n),e.quadraticCurveTo(t,o,t+n,o),e.closePath(),e.fill(),e.stroke()},Potree.MeasuringTool=function(e,t,o){function i(){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[]}function r(e){var t=l();if(t){var o=t.clone(),r=new THREE.MeshNormalMaterial({shading:THREE.SmoothShading}),n=new THREE.SphereGeometry(.4,10,10),a=new THREE.Mesh(n,r);a.position.copy(t),d.sceneRoot.add(a);var s=new THREE.Mesh(n,r);s.position.copy(t),d.sceneRoot.add(s);var h=o.x.toFixed(2)+" / "+o.y.toFixed(2)+" / "+o.z.toFixed(2),p=new Potree.TextSprite(h);p.setBorderColor({r:0,g:255,b:0,a:1}),p.material.depthTest=!1,p.material.opacity=0,p.position.copy(t),p.position.y+=.5,d.sceneRoot.add(p);var m=new Potree.TextSprite(h);m.setBorderColor({r:0,g:255,b:0,a:1}),m.material.depthTest=!1,m.material.opacity=0,m.position.copy(t),m.position.y+=.5,d.sceneRoot.add(m);var E=new THREE.Color(16711680),f=new THREE.Geometry;f.vertices.push(t.clone(),t.clone()),f.colors.push(E,E,E);var v=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});v.depthTest=!1,sConnection=new THREE.Line(f,v),d.sceneRoot.add(sConnection);var T=new Potree.TextSprite(0);T.setBorderColor({r:0,g:255,b:0,a:0}),T.setBackgroundColor({r:0,g:255,b:0,a:0}),T.material.depthTest=!1,T.position.copy(t),T.position.y+=.5,d.sceneRoot.add(T),c===u.DEFAULT?(c=u.PICKING,d.activeMeasurement=new i,d.activeMeasurement.spheres.push(a)):c===u.PICKING,d.activeMeasurement.points.push(t),d.activeMeasurement.spheres.push(s),d.activeMeasurement.sphereLabels.push(p),d.activeMeasurement.sphereLabels.push(m),d.activeMeasurement.edges.push(sConnection),d.activeMeasurement.edgeLabels.push(T);var e={type:"newpoint",position:o.clone()};d.dispatchEvent(e)}}function n(e){if(d.mouse.x=e.clientX/d.domElement.clientWidth*2-1,d.mouse.y=2*-(e.clientY/d.domElement.clientHeight)+1,c==u.PICKING&&d.activeMeasurement){var t=l();if(t){var o=t.clone(),i=d.activeMeasurement.spheres.length,r=d.activeMeasurement.spheres[i-1],n=d.activeMeasurement.sphereLabels[i-1],a=d.activeMeasurement.edges[i-2],s=d.activeMeasurement.edgeLabels[i-2],h=o.x.toFixed(2)+" / "+o.y.toFixed(2)+" / "+o.z.toFixed(2);n.setText(h),r.position.copy(t),n.position.copy(t),n.position.y+=.5,a.geometry.vertices[1].copy(t),a.geometry.verticesNeedUpdate=!0,a.geometry.computeBoundingSphere();var p=a.geometry.vertices[1].clone().add(a.geometry.vertices[0]).multiplyScalar(.5),m=a.geometry.vertices[0].distanceTo(a.geometry.vertices[1]).toFixed(2);s.position.copy(p),s.setText(m),s.scale.multiplyScalar(10)}}}function a(){if(c==u.PICKING){var e=d.activeMeasurement.spheres.pop(),t=d.activeMeasurement.edges.pop(),o=d.activeMeasurement.sphereLabels.pop(),i=d.activeMeasurement.edgeLabels.pop();d.sceneRoot.remove(e),d.sceneRoot.remove(t),d.sceneRoot.remove(o),d.sceneRoot.remove(i),d.measurements.push(d.activeMeasurement),d.activeMeasurement=void 0,c=u.DEFAULT}}function s(e){3===e.which&&a(e)}function l(){var e=new THREE.Vector3(d.mouse.x,d.mouse.y,.5),t=new THREE.Projector;t.unprojectVector(e,d.camera);var o=new THREE.Raycaster;o.params={PointCloud:{threshold:1}},o.ray.set(d.camera.position,e.sub(d.camera.position).normalize());var i=[];d.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});var r=o.intersectObjects(i,!0);if(r.length>0){var n=r[0];return n.point}return void 0}var d=this;this.scene=e,this.camera=t,this.domElement=o,this.mouse={x:0,y:0};var u={DEFAULT:0,PICKING:1},c=u.DEFAULT;this.activeMeasurement,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.domElement.addEventListener("dblclick",r,!1),this.domElement.addEventListener("mousemove",n,!1),this.domElement.addEventListener("mousedown",s,!1)},Potree.MeasuringTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.ProfileTool=function(e,t,o){THREE.Object3D.call(this);var i=new THREE.BoxGeometry(1,1,1,1,1,1),r=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.3});this.profileFrustum=new THREE.Mesh(i,r),this.add(this.profileFrustum),this.camera=new THREE.OrthographicCamera(-e/2,e/2,t/2,-t/2,1,1+o),this.add(this.camera),this.setDimension(e,t,o),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);var n=new THREE.Vector3(0,0,0),a=new THREE.Vector3(10,0,0);this.setCoordinates(n,a)},Potree.ProfileTool.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileTool.prototype.setDimension=function(e,t,o){this.profileFrustum.scale.set(e,t,o),this.width=e,this.height=t,this.depth=o,this.camera.left=-e/2,this.camera.right=e/2,this.camera.top=t/2,this.camera.bottom=-t/2,this.camera.updateProjectionMatrix()},Potree.ProfileTool.prototype.setOrientation=function(e){var t=this.position.clone();this.position.add(e),this.lookAt(t),this.position.copy(t),this.camera.position.copy(t.clone().add(e)),this.camera.lookAt(t)},Potree.ProfileTool.prototype.setCoordinates=function(e,t){var o=e.distanceTo(t);this.setDimension(o,this.height,this.depth);var i=(new THREE.Vector3).addVectors(e,t).multiplyScalar(.5),r=(new THREE.Vector3).subVectors(t,e),n=new THREE.Vector3(r.z,0,-r.x);this.position.set(0,0,0),this.lookAt(n),this.position.copy(i),this.start=e,this.end=t},Potree.ProfileTool.prototype.render=function(e,t){this.camera.matrixWorld.copy(this.matrixWorld),t.traverse(function(e){e instanceof Potree.PointCloudOctree&&(e.material.oldSize=e.material.size,e.material.size=0)}),e.render(t,this.camera,this.rtProfile,!0),t.traverse(function(e){e instanceof Potree.PointCloudOctree&&(e.material.size=e.material.oldSize)})},Potree.TranslationTool=function(e){THREE.Object3D.call(this);var t=this;this.camera=e,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 e=t.createArrow(t.parts.ARROW_X,t.parts.ARROW_X.color);e.rotation.z=-Math.PI/2;var o=t.createArrow(t.parts.ARROW_Y,t.parts.ARROW_Y.color),i=t.createArrow(t.parts.ARROW_Z,t.parts.ARROW_Z.color);i.rotation.x=-Math.PI/2,t.add(e),t.add(o),t.add(i);var r=t.createBox(new THREE.Color(16776960));r.scale.z=.02,r.position.set(.5,.5,0);var n=t.createBox(new THREE.Color(16711935));n.scale.y=.02,n.position.set(.5,0,-.5);var a=t.createBox(new THREE.Color(65535));a.scale.x=.02,a.position.set(0,.5,-.5),t.add(r),t.add(n),t.add(a),t.parts.ARROW_X.object=e,t.parts.ARROW_Y.object=o,t.parts.ARROW_Z.object=i,t.scale.multiplyScalar(5)},this.createBox=function(e){var t=new THREE.BoxGeometry(1,1,1),o=new THREE.MeshBasicMaterial({color:e,transparent:!0,opacity:.5}),i=new THREE.Mesh(t,o);return i},this.createArrow=function(e,t){var o=new THREE.MeshBasicMaterial({color:t}),i=new THREE.CylinderGeometry(.1,.1,3,10,1,!1),r=o,n=new THREE.Mesh(i,r);n.position.y=1.5;var a=new THREE.CylinderGeometry(0,.3,1,10,1,!1),s=o,l=new THREE.Mesh(a,s);l.position.y=3;var d=new THREE.Object3D;return d.add(n),d.add(l),d.partID=e,d.material=o,d},this.setHighlighted=function(e){return void 0===e?void(t.highlighted&&(t.highlighted.object.material.color=t.highlighted.color,t.highlighted=void 0)):(void 0!==t.highlighted&&t.highlighted!==e&&(t.highlighted.object.material.color=t.highlighted.color),t.highlighted=e,void(e.object.material.color=new THREE.Color(16776960)))},this.getHoveredObject=function(e){var o=new THREE.Vector3(e.x,e.y,.5),i=new THREE.Projector;i.unprojectVector(o,t.camera);var r=new THREE.Raycaster;r.ray.set(t.camera.position,o.sub(t.camera.position).normalize());var n=r.intersectObject(t,!0);if(0===n.length)return void t.setHighlighted(void 0);var a=n[0],s=a.object.parent.partID;return s},this.onMouseMove=function(e){var o=e.normalizedPosition;if(t.state===t.STATE.DEFAULT)t.setHighlighted(t.getHoveredObject(o));else if(t.state===t.STATE.TRANSLATE_X||t.state===t.STATE.TRANSLATE_Y||t.state===t.STATE.TRANSLATE_Z){var i=t.start.lineStart.clone(),r=t.start.lineEnd.clone().sub(t.start.lineStart);r.normalize();var n=new THREE.Vector3(o.x,o.y),a=(new THREE.Vector3).subVectors(n,i).dot(r),s=r.clone().multiplyScalar(a).add(i),l=new THREE.Projector;l.unprojectVector(s,t.camera);var d=s.clone().sub(t.position);t.position.copy(s);for(var u=0;u