text: 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<e.length;o++){var i=e[o],r=new XMLHttpRequest;r.open("GET",i,!1),r.responseType="text",r.overrideMimeType("text/plain; charset=x-user-defined"),r.send(null),200===r.status&&(t+=r.responseText+"\n")}return new Potree.WorkerManager(t)},THREE.PerspectiveCamera.prototype.zoomTo=function(e,t){void 0===t&&(t=1),e.updateMatrixWorld(),this.updateMatrix(),this.updateMatrixWorld();var o=Potree.utils.computeTransformedBoundingBox(e.boundingBox,e.matrixWorld),i=new THREE.Vector3(0,0,-1).applyQuaternion(this.quaternion),r=o.center().sub(i),n=[new THREE.Vector3(o.min.x,o.min.y,o.min.z),new THREE.Vector3(o.min.x,o.min.y,o.min.z),new THREE.Vector3(o.max.x,o.min.y,o.min.z),new THREE.Vector3(o.min.x,o.max.y,o.min.z),new THREE.Vector3(o.min.x,o.min.y,o.max.z),new THREE.Vector3(o.min.x,o.max.y,o.max.z),new THREE.Vector3(o.max.x,o.max.y,o.min.z),new THREE.Vector3(o.max.x,o.min.y,o.max.z),new THREE.Vector3(o.max.x,o.max.y,o.max.z)],a=new THREE.Frustum;a.setFromMatrix((new THREE.Matrix4).multiplyMatrices(this.projectionMatrix,this.matrixWorldInverse));for(var s=Number.MIN_VALUE,l=0;l<n.length;l++){for(var d=n[l],c=Number.MIN_VALUE,u=0;u<a.planes.length-2;u++){var h=a.planes[u],p=new THREE.Ray(d,i),m=p.distanceToPlaneWithNegative(h);c=Math.max(c,m)}s=Math.max(s,c)}var E=i.clone().multiplyScalar(-s);E.multiplyScalar(t),r.add(E),this.position.copy(r)},THREE.Ray.prototype.distanceToPlaneWithNegative=function(e){var t=e.normal.dot(this.direction);if(0==t)return 0==e.distanceToPoint(this.origin)?0:null;var o=-(this.origin.dot(e.normal)+e.constant)/t;return o},POCLoader.load=function(e,t){var o=t||{},i=o.toOrigin||!1;try{var r=new Potree.PointCloudOctreeGeometry;r.url=e;var n=new XMLHttpRequest;if(n.open("GET",e,!1),n.send(null),200===n.status||0===n.status){var a=JSON.parse(n.responseText);r.octreeDir=Potree.utils.pathExists(a.octreeDir+"/r")?a.octreeDir:e+"/../"+a.octreeDir,r.spacing=a.spacing,r.pointAttributes=a.pointAttributes;var s=new THREE.Vector3(a.boundingBox.lx,a.boundingBox.ly,a.boundingBox.lz),l=new THREE.Vector3(a.boundingBox.ux,a.boundingBox.uy,a.boundingBox.uz),d=new THREE.Box3(s,l),c=new THREE.Vector3(0,0,0);i&&(c.set(-s.x,-s.y,-s.z),d.min.add(c),d.max.add(c)),r.boundingBox=d,r.offset=c;var u={},h="r",p=new Potree.PointCloudOctreeGeometryNode(h,r,d);p.level=0,p.numPoints=a.hierarchy[0][1],r.root=p,r.root.load(),u[h]=p;for(var m=1;m<a.hierarchy.length;m++){var h=a.hierarchy[m][0],E=a.hierarchy[m][1],v=parseInt(h.charAt(h.length-1)),f=h.substring(0,h.length-1),T=u[f],P=h.length-1,d=POCLoader.createChildAABB(T.boundingBox,v),y=new Potree.PointCloudOctreeGeometryNode(h,r,d);y.level=P,y.numPoints=E,T.addChild(y),u[h]=y}r.nodes=u}return r}catch(g){console.log("loading failed: '"+e+"'"),console.log(g)}},POCLoader.loadPointAttributes=function(e){for(var t=e.pointAttributes,o=new PointAttributes,i=0;i<t.length;i++){var r=PointAttribute[t[i]];o.add(r)}return o},POCLoader.createChildAABB=function(e,t){var o,i,o=(THREE.Vector3,e.min),i=e.max,r=(new THREE.Vector3).copy(i).sub(o).multiplyScalar(.5),n=new THREE.Vector3(r.x,0,0),a=new THREE.Vector3(0,r.y,0),s=new THREE.Vector3(0,0,r.z),l=o,d=(new THREE.Vector3).add(o).add(r);return 1===t?(o=(new THREE.Vector3).copy(l).add(s),i=(new THREE.Vector3).copy(d).add(s)):3===t?(o=(new THREE.Vector3).copy(l).add(s).add(a),i=(new THREE.Vector3).copy(d).add(s).add(a)):0===t?(o=l,i=d):2===t?(o=(new THREE.Vector3).copy(l).add(a),i=(new THREE.Vector3).copy(d).add(a)):5===t?(o=(new THREE.Vector3).copy(l).add(s).add(n),i=(new THREE.Vector3).copy(d).add(s).add(n)):7===t?(o=(new THREE.Vector3).copy(l).add(r),i=(new THREE.Vector3).copy(d).add(r)):4===t?(o=(new THREE.Vector3).copy(l).add(n),i=(new THREE.Vector3).copy(d).add(n)):6===t&&(o=(new THREE.Vector3).copy(l).add(n).add(a),i=(new THREE.Vector3).copy(d).add(n).add(a)),new THREE.Box3(o,i)},PointAttributeNames.POSITION_CARTESIAN=0,PointAttributeNames.COLOR_PACKED=1,PointAttributeNames.COLOR_FLOATS_1=2,PointAttributeNames.COLOR_FLOATS_255=3,PointAttributeNames.NORMAL_FLOATS=4,PointAttributeNames.FILLER=5;var PointAttributeTypes={DATA_TYPE_DOUBLE:{ordinal:0,size:8},DATA_TYPE_FLOAT:{ordinal:1,size:4},DATA_TYPE_INT8:{ordinal:2,size:1},DATA_TYPE_UINT8:{ordinal:3,size:1},DATA_TYPE_INT16:{ordinal:4,size:2},DATA_TYPE_UINT16:{ordinal:5,size:2},DATA_TYPE_INT32:{ordinal:6,size:4},DATA_TYPE_UINT32:{ordinal:7,size:4},DATA_TYPE_INT64:{ordinal:8,size:8},DATA_TYPE_UINT64:{ordinal:9,size:8}},i=0;for(var obj in PointAttributeTypes)PointAttributeTypes[i]=PointAttributeTypes[obj],i++;PointAttribute.POSITION_CARTESIAN=new PointAttribute(PointAttributeNames.POSITION_CARTESIAN,PointAttributeTypes.DATA_TYPE_FLOAT,3),PointAttribute.RGBA_PACKED=new PointAttribute(PointAttributeNames.COLOR_PACKED,PointAttributeTypes.DATA_TYPE_INT8,4),PointAttribute.COLOR_PACKED=PointAttribute.RGBA_PACKED,PointAttribute.RGB_PACKED=new PointAttribute(PointAttributeNames.COLOR_PACKED,PointAttributeTypes.DATA_TYPE_INT8,3),PointAttribute.NORMAL_FLOATS=new PointAttribute(PointAttributeNames.NORMAL_FLOATS,PointAttributeTypes.DATA_TYPE_FLOAT,3),PointAttribute.FILLER_1B=new PointAttribute(PointAttributeNames.FILLER,PointAttributeTypes.DATA_TYPE_UINT8,1),PointAttributes.prototype.add=function(e){this.attributes.push(e),this.byteSize+=e.byteSize,this.size++},PointAttributes.prototype.hasColors=function(){for(var e in this.attributes){var t=this.attributes[e];if(t.name===PointAttributeNames.COLOR_PACKED)return!0}return!1},PointAttributes.prototype.hasNormals=function(){for(var e in this.attributes){var t=this.attributes[e];if(t===PointAttribute.NORMAL_FLOATS)return!0}return!1},LasLazLoader.load=function(e,t){var o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.overrideMimeType("text/plain; charset=x-user-defined"),o.onreadystatechange=function(){if(4===o.readyState)if(200===o.status){var i=o.response;LasLazLoader.loadData(i,t)}else console.log("Failed to load file! HTTP status: "+o.status+", file: "+e)},o.send(null)},LasLazLoader.progressCB=function(){},LasLazLoader.loadData=function(e,t){var o=new LASFile(e);return Promise.resolve(o).cancellable().then(function(e){return e.open().then(function(){return e.isOpen=!0,e}).catch(Promise.CancellationError,function(t){return e.close().then(function(){throw t})})}).then(function(e){return e.getHeader().then(function(t){return[e,t]})}).then(function(e){var o=e[0],i=e[1],r=1,n=0,a=1>=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}},i=e.size||1;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,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}}),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.PointCloudRGBInterpolationMaterial=function(e){e=e||{};var t,o,i={},r={color:{type:"c",value:new THREE.Color(16777215)},size:{type:"f",value:10},blendDepth:{type:"f",value:.01}},n=e.size||1,a=renderer.context.getExtension("EXT_frag_depth");a?(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,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,"blendDepth",{get:function(){return this.uniforms.blendDepth.value},set:function(e){this.uniforms.blendDepth.value=e}}),Potree.PointCloudRGBInterpolationMaterial.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.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 ;                                                            ","}                                                            "],Potree.PointCloudIntensityMaterial=function(e){e=e||{};var t=e.size||1;this.min=e.min||0,this.max=e.max||1;var o={intensity:{type:"f",value:[]}},i={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:i,attributes:o,vertexShader:Potree.PointCloudIntensityMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudIntensityMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,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}}),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(e){e=e||{};var t=e.size||1;this.min=e.min||0,this.max=e.max||1;var o=Potree.PointCloudHeightMaterial.generateGradient(),i={},r={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:o}};this.setValues({uniforms:r,attributes:i,vertexShader:Potree.PointCloudHeightMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudHeightMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:t,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}}),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 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(e){e=e||{};var t=e.color||(new THREE.Color).setRGB(1,0,0),o=e.size||1,i={},r={uCol:{type:"c",value:t},size:{type:"f",value:1}};this.setValues({uniforms:r,attributes:i,vertexShader:Potree.PointCloudColorMaterial.vs_points.join("\n"),fragmentShader:Potree.PointCloudColorMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:o,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,"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 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(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?(c.set(e.clientX,e.clientY),u.subVectors(c,d),l.rotateLeft(2*Math.PI*u.x/t.clientWidth*l.rotateSpeed),l.rotateUp(2*Math.PI*u.y/t.clientHeight*l.rotateSpeed),d.copy(c)):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,c=new THREE.Vector2,u=new THREE.Vector2,h=new THREE.Vector2,p=new THREE.Vector2,m=new THREE.Vector2,E=new THREE.Vector3,v=(new THREE.Vector3,0),f=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){f-=e},this.rotateUp=function(e){v-=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(f),r=(new THREE.Matrix4).multiplyMatrices(i,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=v,f=0,v=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.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),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.maxVisibleNodes=2e3,this.maxVisiblePoints=2e7,this.level=0,this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.loadQueue=[];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);var a=e.matrixWorld,s=(new THREE.Matrix4).getInverse(i),l=(new THREE.Matrix4).multiply(s).multiply(a),d=(new THREE.Vector3).setFromMatrixPosition(l),c=(new THREE.Ray(e.position,new THREE.Vector3(0,0,-1).applyQuaternion(e.quaternion)),[]);for(c.push(this);c.length>0;){var u=c.shift();if(u instanceof THREE.Mesh||u instanceof THREE.Line)u.visible=!0;else{var h=u.boundingBox,p=h.center().distanceTo(d),m=.5*h.size().length(),E=!0;if(E=E&&t.intersectsBox(h),u.level>0&&(E=E&&Math.pow(m,.8)/p>1/this.LOD,E=E&&this.numVisiblePoints+u.numPoints<Potree.pointLoadLimit,E=E&&this.numVisibleNodes<=this.maxVisibleNodes,E=E&&this.numVisiblePoints<=this.maxVisiblePoints),u.visible=E,E){if(E&&this.showBoundingBox&&u instanceof THREE.PointCloud){if(void 0===u.boundingBoxNode&&void 0!==u.boundingBox){var v=new THREE.BoxHelper(u);u.add(v),u.boundingBoxNode=v}}else this.showBoundingBox||void 0!==u.boundingBoxNode&&(u.remove(u.boundingBoxNode),u.boundingBoxNode=void 0);if(u instanceof THREE.PointCloud)this.numVisibleNodes++,this.numVisiblePoints+=u.numPoints,Potree.PointCloudOctree.lru.touch(u),u.material=this.material;else if(u instanceof Potree.PointCloudOctreeProxyNode){var f=u.geometryNode;f.loaded===!0?this.replaceProxy(u):this.loadQueue.push({node:u,lod:Math.pow(m,.8)/p})}for(var T=0;T<u.children.length;T++)c.push(u.children[T])}else this.hideDescendants(u)}}if(this.loadQueue.length>0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.lod-e.lod});for(var T=0;T<Math.min(5,this.loadQueue.length);T++)this.loadQueue[T].node.geometryNode.load()}},Potree.PointCloudOctree.prototype.replaceProxy=function(e){var t=e.geometryNode;if(t.loaded===!0){var o=t.geometry,i=new THREE.PointCloud(o,this.material);i.name=e.name,i.level=e.level,i.numPoints=e.numPoints,i.boundingBox=o.boundingBox,i.pcoGeometry=t;var r=e.parent;r.remove(e),r.add(i);for(var n=0;8>n;n++)if(void 0!==t.children[n]){var a=t.children[n],s=new Potree.PointCloudOctreeProxyNode(a);i.add(s)}}},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o<e.children.length;o++){var i=e.children[o];i.visible&&t.push(i)}for(;t.length>0;){var e=t.shift();e.visible=!1;for(var o=0;o<e.children.length;o++){var i=e.children[o];i.visible&&t.push(i)}}},Potree.PointCloudOctree.prototype.moveToOrigin=function(){this.position.set(0,0,0),this.updateMatrixWorld();var e=this.boundingBox,t=this.matrixWorld,o=Potree.utils.computeTransformedBoundingBox(e,t);this.position.set(0,0,0).sub(o.center())},Potree.PointCloudOctree.prototype.moveToGroundPlane=function(){this.updateMatrixWorld();var e=this.boundingBox,t=this.matrixWorld,o=Potree.utils.computeTransformedBoundingBox(e,t);
  this.position.y+=-o.min.y},Potree.PointCloudOctree.prototype.getBoundingBoxWorld=function(){this.updateMatrixWorld();var e=this.boundingBox,t=this.matrixWorld,o=Potree.utils.computeTransformedBoundingBox(e,t);return o},Potree.PointCloudOctree.prototype.getProfile=function(e,t,o,i){var r=[];r.push(this);for(var n=(new THREE.Vector3).subVectors(t,e).normalize(),a=new THREE.Vector3(0,1,0),s=(new THREE.Vector3).crossVectors(n,a).normalize(),l=s,d=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,e),c=[];r.length>0;){var u=r.shift();if(console.log("traversing: "+u.name),u instanceof THREE.PointCloud)for(var h=u.geometry,p=h.attributes.position,m=p.array,E=p.length/p.itemSize,v=0;E>v;v++){var f=new THREE.Vector3(m[3*v],m[3*v+1],m[3*v+2]);f.applyMatrix4(this.matrixWorld);var T=Math.abs(d.distanceToPoint(f));o/2>T&&c.push(f)}if(u==this||u.level<i)for(var v=0;v<u.children.length;v++)r.push(u.children[v])}return console.log("points inside: "+c.length),c},Potree.PointCloudOctree.disposeLeastRecentlyUsed=function(e){var t=0;do{var o=this.lru.first.node,i=o.parent,r=(o.geometry,o.pcoGeometry),n=new Potree.PointCloudOctreeProxyNode(r),a=Potree.PointCloudOctree.disposeNode(o);if(t+=a.freed,i.add(n),0==a.numDeletedNodes)break}while(e>t)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var r=0;r<i.length;r++){var n=i[r];n instanceof THREE.PointCloud&&(t+=n.pcoGeometry.numPoints,n.pcoGeometry.dispose(),n.geometry.dispose(),Potree.PointCloudOctree.lru.remove(n),o++)}return Potree.PointCloudOctree.lru.remove(e),e.parent.remove(e),{freed:t,numDeletedNodes:o}};var nodesLoadTimes={};Potree.PointCloudOctreeGeometry=function(){Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.url=null,this.octreeDir=null,this.spacing=0,this.boundingBox=null,this.root=null,this.numNodesLoading=0,this.nodes=null,this.pointAttributes=null},Potree.PointCloudOctreeGeometryNode=function(e,t,o){this.name=e,this.index=parseInt(e.charAt(e.length-1)),this.pcoGeometry=t,this.boundingBox=o,this.children={},this.numPoints=0,this.level=null},Potree.PointCloudOctreeGeometryNode.prototype.addChild=function(e){this.children[e.index]=e,e.parent=this},Potree.PointCloudOctreeGeometryNode.prototype.load=function(){if(!(this.loading===!0||this.pcoGeometry.numNodesLoading>5)){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,c=new THREE.Vector3(s[0],s[1],s[2]),u=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),v=E.read(32),f=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);A<a.pointcount-1;A++)dx=E.read(p[0])+h[0],dy=E.read(p[1])+h[1],dz=E.read(p[2])+h[2],v+=dx,f+=dy,T+=dz,x=v*c.x+u.x,y=f*c.y+u.y,z=T*c.z+u.z,P=E.read(8),g=E.read(8),b=E.read(8),C[3*A+0]=x,C[3*A+1]=y,C[3*A+2]=z,H[3*A+0]=P/255,H[3*A+1]=g/255,H[3*A+2]=b/255;R.addAttribute("position",new THREE.BufferAttribute(C,3)),R.addAttribute("color",new THREE.BufferAttribute(H,3)),R.boundingBox=e.boundingBox,e.geometry=R,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--};Potree.BinaryNodeLoader.load(this,"pot",o)}else{var t=this.pcoGeometry.octreeDir+"/"+this.name;nodesLoadTimes[t]={},nodesLoadTimes[t].start=(new Date).getTime();var o=function(e,o){for(var i=new THREE.BufferGeometry,r=o.byteLength/16,n=new Float32Array(3*r),a=new Float32Array(3*r),s=new THREE.Color,l=new Float32Array(o),d=new Uint8Array(o),c=0;r>c;c++)n[3*c+0]=l[4*c+0]+e.pcoGeometry.offset.x,n[3*c+1]=l[4*c+1]+e.pcoGeometry.offset.y,n[3*c+2]=l[4*c+2]+e.pcoGeometry.offset.z,s.setRGB(d[16*c+12],d[16*c+13],d[16*c+14]),a[3*c+0]=s.r/255,a[3*c+1]=s.g/255,a[3*c+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,c=a.data.color,u=a.data.intensity,h=new Uint8Array(a.data.classification),p=new Float32Array(h.byteLength),m=new THREE.Box3,E=new Float32Array(d),v=0;l>v;v++)p[v]=h[v],m.expandByPoint(new THREE.Vector3(E[3*v+0],E[3*v+1],E[3*v+2]));s.addAttribute("position",new THREE.BufferAttribute(new Float32Array(d),3)),s.addAttribute("color",new THREE.BufferAttribute(new Float32Array(c),3)),s.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(u),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),v=new THREE.Geometry;v.vertices.push(t.clone(),t.clone()),v.colors.push(E,E,E);var f=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});f.depthTest=!1,sConnection=new THREE.Line(v,f),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),u===c.DEFAULT?(u=c.PICKING,d.activeMeasurement=new i,d.activeMeasurement.spheres.push(a)):u===c.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,u==c.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(u==c.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,u=c.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 c={DEFAULT:0,PICKING:1},u=c.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)},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.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 c=0;c<t.targets.length;c++){var u=t.targets[0];u.position.add(d)}e.signal.halt()}},this.onMouseDown=function(e){if(t.state===t.STATE.DEFAULT){var o=t.getHoveredObject(e.normalizedPosition,t.camera);if(o){t.state=o.state;var i,r=t.position.clone();t.state===t.STATE.TRANSLATE_X?(i=t.position.clone(),i.x+=2):t.state===t.STATE.TRANSLATE_Y?(i=t.position.clone(),i.y+=2):t.state===t.STATE.TRANSLATE_Z&&(i=t.position.clone(),i.z-=2);var n=new THREE.Projector;n.projectVector(r,t.camera),n.projectVector(i,t.camera),t.start={mouse:e.normalizedPosition,lineStart:r,lineEnd:i},e.signal.halt()}}},this.onMouseUp=function(){t.setHighlighted(),t.state=t.STATE.DEFAULT},this.setTargets=function(e){if(t.targets=e,0!==t.targets.length){var o=e[0].position.clone();t.position.copy(o)}},this.build()},Potree.TranslationTool.prototype=Object.create(THREE.Object3D.prototype);