diff --git a/build/js/potree.js b/build/js/potree.js index ccacad99..db8c1f3a 100644 --- a/build/js/potree.js +++ b/build/js/potree.js @@ -7156,6 +7156,7 @@ Potree.MeasuringTool = function(scene, camera, renderer){ if(scope.activeMeasurement && state === STATE.INSERT){ scope.activeMeasurement.removeMarker(scope.activeMeasurement.points.length-1); scope.finishInsertion(); + event.stopImmediatePropagation(); } } diff --git a/build/js/potree.min.js b/build/js/potree.min.js index 0eacdae3..47ad216e 100644 --- a/build/js/potree.min.js +++ b/build/js/potree.min.js @@ -2,5 +2,5 @@ function Potree(){}function LRUItem(e){this.previous=null,this.next=null,this.no Potree.Shaders["normalize.vs"]=["","varying vec2 vUv;","","void main() {"," vUv = uv;",""," gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);","}"].join("\n"),Potree.Shaders["normalize.fs"]=["","#extension GL_EXT_frag_depth : enable","","uniform sampler2D depthMap;","uniform sampler2D texture;","","varying vec2 vUv;","","void main() {"," float depth = texture2D(depthMap, vUv).g; "," "," if(depth <= 0.0){"," discard;"," }"," "," vec4 color = texture2D(texture, vUv); "," color = color / color.w;"," "," gl_FragColor = vec4(color.xyz, 1.0); "," "," gl_FragDepthEXT = depth;","}"].join("\n"),Potree.Shaders["edl.vs"]=["","","varying vec2 vUv;","","void main() {"," vUv = uv;"," "," vec4 mvPosition = modelViewMatrix * vec4(position,1.0);",""," gl_Position = projectionMatrix * mvPosition;","}"].join("\n"),Potree.Shaders["edl.fs"]=["","// ","// adapted from the EDL shader code from Christian Boucheny in cloud compare:","// https://github.com/cloudcompare/trunk/tree/master/plugins/qEDL/shaders/EDL","//","","#define NEIGHBOUR_COUNT 8","","uniform mat4 projectionMatrix;","","uniform float screenWidth;","uniform float screenHeight;","uniform float near;","uniform float far;","uniform vec2 neighbours[NEIGHBOUR_COUNT];","uniform vec3 lightDir;","uniform float expScale;","uniform float edlScale;","uniform float radius;","uniform float opacity;","","//uniform sampler2D depthMap;","uniform sampler2D colorMap;","","varying vec2 vUv;","","/**"," * transform linear depth to [0,1] interval with 1 beeing closest to the camera."," */","float ztransform(float linearDepth){"," return 1.0 - (linearDepth - near) / (far - near);","}","","float expToLinear(float z){"," z = 2.0 * z - 1.0;"," float linear = (2.0 * near * far) / (far + near - z * (far - near));",""," return linear;","}","","// this actually only returns linear depth values if LOG_BIAS is 1.0","// lower values work out more nicely, though.","#define LOG_BIAS 0.01","float logToLinear(float z){"," return (pow((1.0 + LOG_BIAS * far), z) - 1.0) / LOG_BIAS;","}","","float obscurance(float z, float dist){"," return max(0.0, z) / dist;","}","","float computeObscurance(float linearDepth){"," vec4 P = vec4(0, 0, 1, -ztransform(linearDepth));"," vec2 uvRadius = radius / vec2(screenWidth, screenHeight);"," "," float sum = 0.0;"," "," for(int c = 0; c < NEIGHBOUR_COUNT; c++){"," vec2 N_rel_pos = uvRadius * neighbours[c];"," vec2 N_abs_pos = vUv + N_rel_pos;"," "," float neighbourDepth = logToLinear(texture2D(colorMap, N_abs_pos).a);"," "," if(neighbourDepth != 0.0){"," float Zn = ztransform(neighbourDepth);"," float Znp = dot( vec4( N_rel_pos, Zn, 1.0), P );"," "," sum += obscurance( Znp, 0.05 * linearDepth );"," }"," }"," "," return sum;","}","","void main(){"," float linearDepth = logToLinear(texture2D(colorMap, vUv).a);"," "," float f = computeObscurance(linearDepth);"," f = exp(-expScale * edlScale * f);"," "," vec4 color = texture2D(colorMap, vUv);"," if(color.a == 0.0 && f >= 1.0){"," discard;"," }"," "," gl_FragColor = vec4(color.rgb * f, opacity);","}",""].join("\n"),Potree.Shaders["blur.vs"]=["","varying vec2 vUv;","","void main() {"," vUv = uv;",""," gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0);","}"].join("\n"),Potree.Shaders["blur.fs"]=["","uniform mat4 projectionMatrix;","","uniform float screenWidth;","uniform float screenHeight;","uniform float near;","uniform float far;","","uniform sampler2D map;","","varying vec2 vUv;","","void main() {",""," float dx = 1.0 / screenWidth;"," float dy = 1.0 / screenHeight;",""," vec3 color = vec3(0.0, 0.0, 0.0);"," color += texture2D(map, vUv + vec2(-dx, -dy)).rgb;"," color += texture2D(map, vUv + vec2( 0, -dy)).rgb;"," color += texture2D(map, vUv + vec2(+dx, -dy)).rgb;"," color += texture2D(map, vUv + vec2(-dx, 0)).rgb;"," color += texture2D(map, vUv + vec2( 0, 0)).rgb;"," color += texture2D(map, vUv + vec2(+dx, 0)).rgb;"," color += texture2D(map, vUv + vec2(-dx, dy)).rgb;"," color += texture2D(map, vUv + vec2( 0, dy)).rgb;"," color += texture2D(map, vUv + vec2(+dx, dy)).rgb;"," "," color = color / 9.0;"," "," gl_FragColor = vec4(color, 1.0);"," "," ","}"].join("\n"),THREE.PerspectiveCamera.prototype.zoomTo=function(e,t){if(e.geometry||e.boundingSphere||e.boundingBox){e.geometry&&null===e.geometry.boundingSphere&&e.geometry.computeBoundingSphere(),e.updateMatrixWorld();var i;i=e.boundingSphere?e.boundingSphere:e.geometry&&e.geometry.boundingSphere?e.geometry.boundingSphere:e.boundingBox.getBoundingSphere();var o=t||1;i=i.clone().applyMatrix4(e.matrixWorld);var n=i.radius,r=this.fov*Math.PI/180;this.aspect<1&&(r*=this.aspect);var s=Math.abs(n/Math.sin(r/2))*o,a=this.getWorldDirection().multiplyScalar(-s);this.position.copy(i.center.clone().add(a))}},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 i=-(this.origin.dot(e.normal)+e.constant)/t;return i},Potree.POCLoader=function(){},Potree.POCLoader.load=function(e,t){try{var i=new Potree.PointCloudOctreeGeometry;i.url=e;var o=new XMLHttpRequest;o.open("GET",e,!0),o.onreadystatechange=function(){if(4===o.readyState&&(200===o.status||0===o.status)){var n=JSON.parse(o.responseText),r=new Potree.Version(n.version);0===n.octreeDir.indexOf("http")?i.octreeDir=n.octreeDir:i.octreeDir=e+"/../"+n.octreeDir,i.spacing=n.spacing,i.hierarchyStepSize=n.hierarchyStepSize,i.pointAttributes=n.pointAttributes;var s=new THREE.Vector3(n.boundingBox.lx,n.boundingBox.ly,n.boundingBox.lz),a=new THREE.Vector3(n.boundingBox.ux,n.boundingBox.uy,n.boundingBox.uz),l=new THREE.Box3(s,a),d=l.clone();n.tightBoundingBox&&(d.min.copy(new THREE.Vector3(n.tightBoundingBox.lx,n.tightBoundingBox.ly,n.tightBoundingBox.lz)),d.max.copy(new THREE.Vector3(n.tightBoundingBox.ux,n.tightBoundingBox.uy,n.tightBoundingBox.uz)));var c=new THREE.Vector3(0,0,0);c.set(-s.x,-s.y,-s.z),l.min.add(c),l.max.add(c),d.min.add(c),d.max.add(c),i.boundingBox=l,i.tightBoundingBox=d,i.boundingSphere=l.getBoundingSphere(),i.tightBoundingSphere=d.getBoundingSphere(),i.offset=c,"LAS"===n.pointAttributes?i.loader=new Potree.LasLazLoader(n.version):"LAZ"===n.pointAttributes?i.loader=new Potree.LasLazLoader(n.version):(i.loader=new Potree.BinaryLoader(n.version,l,n.scale),i.pointAttributes=new Potree.PointAttributes(i.pointAttributes));var u={},h="r",p=new Potree.PointCloudOctreeGeometryNode(h,i,l);if(p.level=0,p.hasChildren=!0,r.upTo("1.5")?p.numPoints=n.hierarchy[0][1]:p.numPoints=0,i.root=p,i.root.load(),u[h]=p,r.upTo("1.4"))for(var m=1;m=n?i.pointsCount:i.pointsCount/n,a=function(){var e=t.readData(1e6,0,n);return e.then(function(e){return o.push(new LASDecoder(e.buffer,i.pointsFormatId,i.pointsStructSize,e.count,i.scale,i.offset,i.mins,i.maxs)),r+=e.count,Potree.LasLazLoader.progressCB(r/s),e.hasMoreData?a():(i.totalRead=r,i.versionAsString=t.versionAsString,i.isCompressed=t.isCompressed,[t,i,o])})};return a()}).then(function(e){var t=e[0];return Potree.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(i.isOpen)return i.close().then(function(){throw i.isOpen=!1,e});throw e})},Potree.LasLazLoader.prototype.handle=function(e,t){},Potree.LasLazBatcher=function(e){this.push=function(t){var i=Potree.workers.lasdecoder.getWorker(),o=new THREE.Vector3(t.mins[0],t.mins[1],t.mins[2]),n=new THREE.Vector3(t.maxs[0],t.maxs[1],t.maxs[2]);o.add(e.pcoGeometry.offset),n.add(e.pcoGeometry.offset),i.onmessage=function(r){for(var s=new THREE.BufferGeometry,a=t.pointsCount,l=r.data.position,d=r.data.color,c=r.data.intensity,u=new Uint8Array(r.data.classification),h=new Float32Array(u.byteLength),p=new Uint8Array(r.data.returnNumber),m=new Uint8Array(r.data.numberOfReturns),f=new Float32Array(p.byteLength),v=new Float32Array(m.byteLength),g=new Uint16Array(r.data.pointSourceID),E=new Float32Array(g.length),y=new ArrayBuffer(4*a),b=new Uint32Array(y),T=new THREE.Box3,R=new Float32Array(l),P=0;a>P;P++)h[P]=u[P],f[P]=p[P],v[P]=m[P],E[P]=g[P],b[P]=P,T.expandByPoint(new THREE.Vector3(R[3*P+0],R[3*P+1],R[3*P+2]));s.addAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),s.addAttribute("color",new THREE.BufferAttribute(new Float32Array(d),3)),s.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(c),1)),s.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(h),1)),s.addAttribute("returnNumber",new THREE.BufferAttribute(new Float32Array(f),1)),s.addAttribute("numberOfReturns",new THREE.BufferAttribute(new Float32Array(v),1)),s.addAttribute("pointSourceID",new THREE.BufferAttribute(new Float32Array(E),1)),s.addAttribute("indices",new THREE.BufferAttribute(y,1)),s.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(3*a),3));var C=new THREE.Box3((new THREE.Vector3).fromArray(r.data.tightBoundingBox.min),(new THREE.Vector3).fromArray(r.data.tightBoundingBox.max));s.boundingBox=new THREE.Box3(o,n),e.tightBoundingBox=C,e.geometry=s,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,Potree.workers.lasdecoder.returnWorker(i)};var r={buffer:t.arrayb,numPoints:t.pointsCount,pointSize:t.pointSize,pointFormatID:2,scale:t.scale,offset:t.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(r,[r.buffer])}},Potree.Gradients={RAINBOW:[[0,new THREE.Color(.278,0,.714)],[1/6,new THREE.Color(0,0,1)],[2/6,new THREE.Color(0,1,1)],[.5,new THREE.Color(0,1,0)],[4/6,new THREE.Color(1,1,0)],[5/6,new THREE.Color(1,.64,0)],[1,new THREE.Color(1,0,0)]],GRAYSCALE:[[0,new THREE.Color(0,0,0)],[1,new THREE.Color(1,1,1)]]},Potree.Classification={DEFAULT:{0:new THREE.Vector4(.5,.5,.5,1),1:new THREE.Vector4(.5,.5,.5,1),2:new THREE.Vector4(.63,.32,.18,1),3:new THREE.Vector4(0,1,0,1),4:new THREE.Vector4(0,.8,0,1),5:new THREE.Vector4(0,.6,0,1),6:new THREE.Vector4(1,.66,0,1),7:new THREE.Vector4(1,0,1,1),8:new THREE.Vector4(1,0,0,1),9:new THREE.Vector4(0,0,1,1),12:new THREE.Vector4(1,1,0,1),DEFAULT:new THREE.Vector4(.3,.6,.6,1)}},Potree.PointSizeType={FIXED:0,ATTENUATED:1,ADAPTIVE:2},Potree.PointShape={SQUARE:0,CIRCLE:1},Potree.PointColorType={RGB:0,COLOR:1,DEPTH:2,HEIGHT:3,INTENSITY:4,INTENSITY_GRADIENT:5,TREE_DEPTH:6,POINT_INDEX:7,CLASSIFICATION:8,RETURN_NUMBER:9,SOURCE:10,NORMAL:11,PHONG:12},Potree.ClipMode={DISABLED:0,CLIP_OUTSIDE:1,HIGHLIGHT_INSIDE:2},Potree.TreeType={OCTREE:0,KDTREE:1},Potree.PointCloudMaterial=function(e){THREE.Material.call(this),e=e||{};var t=new THREE.Color(16777215),i=THREE.ImageUtils.generateDataTexture(2048,1,t);i.magFilter=THREE.NearestFilter,this.visibleNodesTexture=i;var o=e.size||1,n=e.minSize||1,r=e.maxSize||50,s=e.treeType||Potree.TreeType.OCTREE,a=1;this._pointSizeType=Potree.PointSizeType.ATTENUATED,this._pointShape=Potree.PointShape.SQUARE,this._interpolate=!1,this._pointColorType=Potree.PointColorType.RGB,this._useClipBox=!1,this.numClipBoxes=0,this._clipMode=Potree.ClipMode.DISABLED,this._weighted=!1,this._depthMap=null,this._gradient=Potree.Gradients.RAINBOW,this._classification=Potree.Classification.DEFAULT,this.gradientTexture=Potree.PointCloudMaterial.generateGradientTexture(this._gradient),this.classificationTexture=Potree.PointCloudMaterial.generateClassificationTexture(this._classification),this.lights=!0,this._treeType=s,this._useLogarithmicDepthBuffer=!1,this._useEDL=!1;var l={},d={spacing:{type:"f",value:1},fov:{type:"f",value:1},screenWidth:{type:"f",value:1},screenHeight:{type:"f",value:1},near:{type:"f",value:.1},far:{type:"f",value:1},uColor:{type:"c",value:new THREE.Color(16777215)},opacity:{type:"f",value:1},size:{type:"f",value:10},minSize:{type:"f",value:2},maxSize:{type:"f",value:2},octreeSize:{type:"f",value:0},bbSize:{type:"fv",value:[0,0,0]},heightMin:{type:"f",value:0},heightMax:{type:"f",value:1},intensityMin:{type:"f",value:0},intensityMax:{type:"f",value:1},clipBoxCount:{type:"f",value:0},visibleNodes:{type:"t",value:this.visibleNodesTexture},pcIndex:{type:"f",value:0},gradient:{type:"t",value:this.gradientTexture},classificationLUT:{type:"t",value:this.classificationTexture},clipBoxes:{type:"Matrix4fv",value:[]},depthMap:{type:"t",value:null},diffuse:{type:"fv",value:[1,1,1]},ambient:{type:"fv",value:[.1,.1,.1]},ambientLightColor:{type:"fv",value:[1,1,1]},directionalLightColor:{type:"fv",value:null},directionalLightDirection:{type:"fv",value:null},pointLightColor:{type:"fv",value:null},pointLightPosition:{type:"fv",value:null},pointLightDistance:{type:"fv1",value:null},pointLightDecay:{type:"fv1",value:null},spotLightColor:{type:"fv",value:null},spotLightPosition:{type:"fv",value:null},spotLightDistance:{type:"fv1",value:null},spotLightDecay:{type:"fv1",value:null},spotLightDirection:{type:"fv",value:null},spotLightAngleCos:{type:"fv1",value:null},spotLightExponent:{type:"fv1",value:null},hemisphereLightSkyColor:{type:"fv",value:null},hemisphereLightGroundColor:{type:"fv",value:null},hemisphereLightDirection:{type:"fv",value:null}};this.defaultAttributeValues.normal=[0,0,0],this.defaultAttributeValues.classification=[0,0,0],this.setValues({uniforms:d,attributes:l,vertexShader:this.getDefines()+Potree.Shaders["pointcloud.vs"],fragmentShader:this.getDefines()+Potree.Shaders["pointcloud.fs"],vertexColors:THREE.VertexColors,size:o,minSize:n,maxSize:r,nodeSize:a,pcIndex:0,alphaTest:.9})},Potree.PointCloudMaterial.prototype=new THREE.ShaderMaterial,Potree.PointCloudMaterial.prototype.updateShaderSource=function(){var e={};this.pointColorType===Potree.PointColorType.INTENSITY||this.pointColorType===Potree.PointColorType.INTENSITY_GRADIENT?e.intensity={type:"f",value:[]}:this.pointColorType===Potree.PointColorType.CLASSIFICATION||(this.pointColorType===Potree.PointColorType.RETURN_NUMBER?(e.returnNumber={type:"f",value:[]},e.numberOfReturns={type:"f",value:[]}):this.pointColorType===Potree.PointColorType.SOURCE?e.pointSourceID={type:"f",value:[]}:(this.pointColorType===Potree.PointColorType.NORMAL||this.pointColorType===Potree.PointColorType.PHONG)&&(e.normal={type:"f",value:[]})),e.classification={type:"f",value:0};var t=this.getDefines()+Potree.Shaders["pointcloud.vs"],i=this.getDefines()+Potree.Shaders["pointcloud.fs"];this.setValues({attributes:e,vertexShader:t,fragmentShader:i}),this.depthMap&&(this.uniforms.depthMap.value=this.depthMap,this.setValues({depthMap:this.depthMap})),1===this.opacity?this.setValues({blending:THREE.NoBlending,transparent:!1,depthTest:!0,depthWrite:!0}):this.setValues({blending:THREE.AdditiveBlending,transparent:!0,depthTest:!1,depthWrite:!0}),this.weighted&&this.setValues({blending:THREE.AdditiveBlending,transparent:!0,depthTest:!0,depthWrite:!1}),this.needsUpdate=!0},Potree.PointCloudMaterial.prototype.getDefines=function(){var e="";return this.pointSizeType===Potree.PointSizeType.FIXED?e+="#define fixed_point_size\n":this.pointSizeType===Potree.PointSizeType.ATTENUATED?e+="#define attenuated_point_size\n":this.pointSizeType===Potree.PointSizeType.ADAPTIVE&&(e+="#define adaptive_point_size\n"),this.pointShape===Potree.PointShape.SQUARE?e+="#define square_point_shape\n":this.pointShape===Potree.PointShape.CIRCLE&&(e+="#define circle_point_shape\n"),this._interpolate&&(e+="#define use_interpolation\n"),this._useLogarithmicDepthBuffer&&(e+="#define use_logarithmic_depth_buffer\n"),this._useEDL&&(e+="#define use_edl\n"),this._pointColorType===Potree.PointColorType.RGB?e+="#define color_type_rgb\n":this._pointColorType===Potree.PointColorType.COLOR?e+="#define color_type_color\n":this._pointColorType===Potree.PointColorType.DEPTH?e+="#define color_type_depth\n":this._pointColorType===Potree.PointColorType.HEIGHT?e+="#define color_type_height\n":this._pointColorType===Potree.PointColorType.INTENSITY?e+="#define color_type_intensity\n":this._pointColorType===Potree.PointColorType.INTENSITY_GRADIENT?e+="#define color_type_intensity_gradient\n":this._pointColorType===Potree.PointColorType.TREE_DEPTH?e+="#define color_type_tree_depth\n":this._pointColorType===Potree.PointColorType.POINT_INDEX?e+="#define color_type_point_index\n":this._pointColorType===Potree.PointColorType.CLASSIFICATION?e+="#define color_type_classification\n":this._pointColorType===Potree.PointColorType.RETURN_NUMBER?e+="#define color_type_return_number\n":this._pointColorType===Potree.PointColorType.SOURCE?e+="#define color_type_source\n":this._pointColorType===Potree.PointColorType.NORMAL?e+="#define color_type_normal\n":this._pointColorType===Potree.PointColorType.PHONG&&(e+="#define color_type_phong\n"),this.clipMode===Potree.ClipMode.DISABLED?e+="#define clip_disabled\n":this.clipMode===Potree.ClipMode.CLIP_OUTSIDE?e+="#define clip_outside\n":this.clipMode===Potree.ClipMode.HIGHLIGHT_INSIDE&&(e+="#define clip_highlight_inside\n"),this._treeType===Potree.TreeType.OCTREE?e+="#define tree_type_octree\n":this._treeType===Potree.TreeType.KDTREE&&(e+="#define tree_type_kdtree\n"),this.weighted&&(e+="#define weighted_splats\n"),this.numClipBoxes>0&&(e+="#define use_clip_box\n"),e},Potree.PointCloudMaterial.prototype.setClipBoxes=function(e){if(e){this.clipBoxes=e;var t=this.numClipBoxes!=e.length&&(0===e.length||0===this.numClipBoxes);this.numClipBoxes=e.length,this.uniforms.clipBoxCount.value=this.numClipBoxes,t&&this.updateShaderSource(),this.uniforms.clipBoxes.value=new Float32Array(16*this.numClipBoxes);for(var i=0;ir;r++)for(var s=0;i>s;s++){var a,l=r+t*s;a=e[r]?e[r]:e.DEFAULT,n[4*l+0]=255*a.x,n[4*l+1]=255*a.y,n[4*l+2]=255*a.z,n[4*l+3]=255*a.w}var d=new THREE.DataTexture(n,t,i,THREE.RGBAFormat);return d.magFilter=THREE.NearestFilter,d.needsUpdate=!0,d},Potree.EyeDomeLightingMaterial=function(e){THREE.Material.call(this),e=e||{};for(var t=8,i=new Float32Array(2*t),o=0;t>o;o++)i[2*o+0]=Math.cos(2*o*Math.PI/t),i[2*o+1]=Math.sin(2*o*Math.PI/t);var n=new THREE.Vector3(0,0,1).normalize(),r={screenWidth:{type:"f",value:0},screenHeight:{type:"f",value:0},near:{type:"f",value:0},far:{type:"f",value:0},expScale:{type:"f",value:100},edlScale:{type:"f",value:1},radius:{type:"f",value:3},lightDir:{type:"v3",value:n},neighbours:{type:"2fv",value:i},depthMap:{type:"t",value:null},colorMap:{type:"t",value:null},opacity:{type:"f",value:1}};this.setValues({uniforms:r,vertexShader:Potree.Shaders["edl.vs"],fragmentShader:Potree.Shaders["edl.fs"]})},Potree.EyeDomeLightingMaterial.prototype=new THREE.ShaderMaterial,Potree.BlurMaterial=function(e){THREE.Material.call(this),e=e||{};var t={near:{type:"f",value:0},far:{type:"f",value:0},screenWidth:{type:"f",value:0},screenHeight:{type:"f",value:0},map:{type:"t",value:null}};this.setValues({uniforms:t,vertexShader:Potree.Shaders["blur.vs"],fragmentShader:Potree.Shaders["blur.fs"]})},Potree.BlurMaterial.prototype=new THREE.ShaderMaterial,THREE.FirstPersonControls=function(e,t){function i(e){l.enabled!==!1&&(e.preventDefault(),0===e.button?(R=T.ROTATE,d.set(e.clientX,e.clientY)):2===e.button&&(R=T.PAN,h.set(e.clientX,e.clientY)),l.domElement.addEventListener("mousemove",o,!1),l.domElement.addEventListener("mouseup",n,!1),l.dispatchEvent(C))}function o(e){if(l.enabled!==!1){e.preventDefault();var t=l.domElement===document?l.domElement.body:l.domElement;R===T.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)):R===T.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 n(){l.enabled!==!1&&(l.domElement.removeEventListener("mousemove",o,!1),l.domElement.removeEventListener("mouseup",n,!1),l.dispatchEvent(x),R=T.NONE)}function r(e){if(l.enabled!==!1&&l.noZoom!==!0){e.preventDefault();var t=e.detail<0||e.wheelDelta>0?1:-1;l.moveSpeed+=.1*l.moveSpeed*t,l.moveSpeed=Math.max(.1,l.moveSpeed),l.dispatchEvent(C),l.dispatchEvent(x)}}function s(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 a(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,f=new THREE.Vector3,v=(new THREE.Vector3,0),g=0,E=1,y=new THREE.Vector3,b=new THREE.Vector3,T={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},R=T.NONE;this.position0=this.object.position.clone();var P={type:"change"},C={type:"start"},x={type:"end"};this.rotateLeft=function(e){g-=e},this.rotateUp=function(e){v-=e},this.panLeft=function(e){var t=this.object.matrix.elements;f.set(t[0],t[1],t[2]),f.multiplyScalar(-e),y.add(f)},this.panUp=function(e){var t=this.object.matrix.elements;f.set(t[4],t[5],t[6]),f.multiplyScalar(e),y.add(f)},this.panForward=function(e){var t=this.object.matrix.elements;f.set(t[8],t[9],t[10]),f.multiplyScalar(e),y.add(f)},this.pan=function(e,t){var i=l.domElement===document?l.domElement.body:l.domElement;if(void 0!==l.object.fov){var o=l.object.position,n=o.clone(),r=n.length();r*=Math.tan(l.object.fov/2*Math.PI/180),l.panLeft(2*e*r/i.clientHeight),l.panUp(2*t*r/i.clientHeight)}else void 0!==l.object.top?(l.panLeft(e*(l.object.right-l.object.left)/i.clientWidth),l.panUp(t*(l.object.top-l.object.bottom)/i.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(e){this.object.rotation.order="ZYX";var t=this.object;this.object=new THREE.Object3D,this.object.position.copy(t.position),this.object.rotation.copy(t.rotation),this.object.updateMatrix(),this.object.updateMatrixWorld();var i=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)),!y.equals(new THREE.Vector3(0,0,0))){var o={type:"move",translation:y.clone()};this.dispatchEvent(o)}if(i.add(y),0!==g||0!==v){var o={type:"rotate",thetaDelta:g,phiDelta:v};this.dispatchEvent(o)}this.object.updateMatrix();var n=(new THREE.Matrix4).makeRotationY(g),r=(new THREE.Matrix4).multiplyMatrices(n,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=v,this.object.updateMatrixWorld();var s={type:"proposeTransform",oldPosition:t.position,newPosition:this.object.position,objections:0,counterProposals:[]};if(this.dispatchEvent(s),s.objections>0&&s.counterProposals.length>0){var a=s.counterProposals;this.object.position.copy(a[0]),s.objections=0,s.counterProposals=[]}s.objections>0||t.position.copy(this.object.position),t.rotation.copy(this.object.rotation),this.object=t,g=0,v=0,E=1,y.set(0,0,0),b.distanceTo(this.object.position)>0&&(this.dispatchEvent(P),b.copy(this.object.position))},this.reset=function(){R=T.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",i,!1),this.domElement.addEventListener("mousewheel",r,!1),this.domElement.addEventListener("DOMMouseScroll",r,!1),window.addEventListener("keydown",s,!1),window.addEventListener("keyup",a,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.OrbitControls=function(e,t){function i(){return 2*Math.PI/60/60*h.autoRotateSpeed}function o(){return Math.pow(.95,h.zoomSpeed)}function n(e){if(h.enabled!==!1){if(e.preventDefault(),0===e.button){if(h.noRotate===!0)return;V=A.ROTATE,m.set(e.clientX,e.clientY)}else if(1===e.button){if(h.noZoom===!0)return;V=A.DOLLY,R.set(e.clientX,e.clientY)}else if(2===e.button){if(h.noPan===!0)return;V=A.PAN,g.set(e.clientX,e.clientY)}h.domElement.addEventListener("mousemove",r,!1),h.domElement.addEventListener("mouseup",s,!1),h.dispatchEvent(M)}}function r(e){if(h.enabled!==!1){e.preventDefault();var t=h.domElement===document?h.domElement.body:h.domElement;if(V===A.ROTATE){if(h.noRotate===!0)return;f.set(e.clientX,e.clientY),v.subVectors(f,m),h.rotateLeft(2*Math.PI*v.x/t.clientWidth*h.rotateSpeed),h.rotateUp(2*Math.PI*v.y/t.clientHeight*h.rotateSpeed),m.copy(f)}else if(V===A.DOLLY){if(h.noZoom===!0)return;P.set(e.clientX,e.clientY),C.subVectors(P,R),C.y>0?h.dollyIn():h.dollyOut(),R.copy(P)}else if(V===A.PAN){if(h.noPan===!0)return;E.set(e.clientX,e.clientY),y.subVectors(E,g),h.pan(y.x,y.y),g.copy(E)}}}function s(){h.enabled!==!1&&(h.domElement.removeEventListener("mousemove",r,!1),h.domElement.removeEventListener("mouseup",s,!1),h.dispatchEvent(L),V=A.NONE)}function a(e){if(h.enabled!==!1&&h.noZoom!==!0){e.preventDefault();var t=0;void 0!==e.wheelDelta?t=e.wheelDelta:void 0!==e.detail&&(t=-e.detail),t>0?h.dollyOut():h.dollyIn(),h.dispatchEvent(M),h.dispatchEvent(L)}}function l(e){if(h.enabled!==!1&&h.noKeys!==!0&&h.noPan!==!0)switch(e.keyCode){case h.keys.UP:h.pan(0,h.keyPanSpeed);break;case h.keys.BOTTOM:h.pan(0,-h.keyPanSpeed);break;case h.keys.LEFT:h.pan(h.keyPanSpeed,0);break;case h.keys.RIGHT:h.pan(-h.keyPanSpeed,0)}}function d(e){if(h.enabled!==!1){switch(e.touches.length){case 1:if(h.noRotate===!0)return;V=A.TOUCH_ROTATE,m.set(e.touches[0].pageX,e.touches[0].pageY);break;case 2:if(h.noZoom===!0)return;V=A.TOUCH_DOLLY;var t=e.touches[0].pageX-e.touches[1].pageX,i=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+i*i);R.set(0,o);break;case 3:if(h.noPan===!0)return;V=A.TOUCH_PAN,g.set(e.touches[0].pageX,e.touches[0].pageY);break;default:V=A.NONE}h.dispatchEvent(M)}}function c(e){if(h.enabled!==!1){e.preventDefault(),e.stopPropagation();var t=h.domElement===document?h.domElement.body:h.domElement;switch(e.touches.length){case 1:if(h.noRotate===!0)return;if(V!==A.TOUCH_ROTATE)return;f.set(e.touches[0].pageX,e.touches[0].pageY),v.subVectors(f,m),h.rotateLeft(2*Math.PI*v.x/t.clientWidth*h.rotateSpeed),h.rotateUp(2*Math.PI*v.y/t.clientHeight*h.rotateSpeed),m.copy(f);break;case 2:if(h.noZoom===!0)return;if(V!==A.TOUCH_DOLLY)return;var i=e.touches[0].pageX-e.touches[1].pageX,o=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(i*i+o*o);P.set(0,n),C.subVectors(P,R);var r=t.clientWidth,s=t.clientHeight,a=Math.sqrt(r*r+s*s),l=C.y/a;C.y>0?h.dollyOut(1-l):h.dollyIn(1+l),R.copy(P);break;case 3:if(h.noPan===!0)return;if(V!==A.TOUCH_PAN)return;E.set(e.touches[0].pageX,e.touches[0].pageY),y.subVectors(E,g),h.pan(y.x,y.y),g.copy(E);break;default:V=A.NONE}}}function u(){h.enabled!==!1&&(h.dispatchEvent(L),V=A.NONE)}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new THREE.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.fadeFactor=10,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40};var h=this,p=1e-6,m=new THREE.Vector2,f=new THREE.Vector2,v=new THREE.Vector2,g=new THREE.Vector2,E=new THREE.Vector2,y=new THREE.Vector2,b=new THREE.Vector3,T=new THREE.Vector3,R=new THREE.Vector2,P=new THREE.Vector2,C=new THREE.Vector2,x=0,w=0,H=1,S=new THREE.Vector3,B=new THREE.Vector3,A={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},V=A.NONE;this.target0=this.target.clone(),this.position0=this.object.position.clone();var I={type:"change"},M={type:"start"},L={type:"end"};this.rotateLeft=function(e){void 0===e&&(e=i()),w-=e},this.rotateUp=function(e){void 0===e&&(e=i()),x-=e},this.panLeft=function(e){var t=this.object.matrix.elements;b.set(t[0],t[1],t[2]),b.multiplyScalar(-e),S.add(b)},this.panUp=function(e){var t=this.object.matrix.elements;b.set(t[4],t[5],t[6]),b.multiplyScalar(e),S.add(b)},this.pan=function(e,t){var i=h.domElement===document?h.domElement.body:h.domElement;if(void 0!==h.object.fov){var o=h.object.position,n=o.clone().sub(h.target),r=n.length();r*=Math.tan(h.object.fov/2*Math.PI/180),h.panLeft(2*e*r/i.clientHeight),h.panUp(2*t*r/i.clientHeight)}else void 0!==h.object.top?(h.panLeft(e*(h.object.right-h.object.left)/i.clientWidth),h.panUp(t*(h.object.top-h.object.bottom)/i.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(e){void 0===e&&(e=o()),H/=e},this.dollyOut=function(e){void 0===e&&(e=o()),H*=e},this.update=function(e){var t=this.object.position.clone();T.copy(t).sub(this.target);var o=Math.atan2(T.x,T.z),n=Math.atan2(Math.sqrt(T.x*T.x+T.z*T.z),T.y);this.autoRotate&&this.rotateLeft(i());var r=Math.min(1,this.fadeFactor*e);o+=r*w,n+=r*x,n=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,n)),n=Math.max(p,Math.min(Math.PI-p,n));var s=T.length();s+=(H-1)*s*r,s=Math.max(this.minDistance,Math.min(this.maxDistance,s)),this.target.add(S.clone().multiplyScalar(r)),T.x=s*Math.sin(n)*Math.sin(o),T.y=s*Math.cos(n),T.z=s*Math.sin(n)*Math.cos(o),t.copy(this.target).add(T);var a={type:"proposeTransform",oldPosition:this.object.position,newPosition:t,objections:0,counterProposals:[]};if(this.dispatchEvent(a),a.objections>0&&a.counterProposals.length>0){var l=a.counterProposals;t.copy(l[0]),a.objections=0,a.counterProposals=[]}if(a.objections>0)w=0,x=0,H=1,S.set(0,0,0);else{this.object.position.copy(t),this.object.lookAt(this.target);var d=Math.max(0,1-this.fadeFactor*e);w*=d,x*=d,H=1+(H-1)*d,S.multiplyScalar(d)}B.distanceTo(this.object.position)>0&&(this.dispatchEvent(I),B.copy(this.object.position))},this.reset=function(){V=A.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.update()},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",n,!1),this.domElement.addEventListener("mousewheel",a,!1),this.domElement.addEventListener("DOMMouseScroll",a,!1),this.domElement.addEventListener("touchstart",d,!1),this.domElement.addEventListener("touchend",u,!1),this.domElement.addEventListener("touchmove",c,!1),window.addEventListener("keydown",l,!1)},Potree.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.EarthControls=function(e,t,i){function o(e){if(a.enabled!==!1){e.preventDefault();var t=a.domElement.getBoundingClientRect(),i={x:(e.clientX-t.left)/a.domElement.clientWidth*2-1,y:2*-((e.clientY-t.top)/a.domElement.clientHeight)+1},o=getMousePointCloudIntersection(i,a.camera,a.renderer,a.pointclouds);if(o){var s=(new THREE.Plane).setFromNormalAndCoplanarPoint(new THREE.Vector3(0,1,0),o),h=new THREE.Vector3(i.x,i.y,.5);h.unproject(a.camera);var p=h.sub(a.camera.position).normalize(),m=new THREE.Ray(a.camera.position,p);v=m.intersectPlane(s),f=a.camera.clone(),f.rotation.copy(a.camera.rotation),c.set(e.clientX-t.left,e.clientY-t.top),u.set(e.clientX-t.left,e.clientY-t.top),a.scene.add(a.pivotNode),a.pivotNode.position.copy(v),0===e.button?d=l.DRAG:2===e.button&&(d=l.ROTATE),a.domElement.addEventListener("mousemove",n,!1),a.domElement.addEventListener("mouseup",r,!1)}}}function n(e){if(a.enabled!==!1){e.preventDefault();var t=a.domElement.getBoundingClientRect();a.domElement===document?a.domElement.body:a.domElement;m.set(e.clientX-t.left-u.x,e.clientY-t.top-u.y),u.set(e.clientX-t.left,e.clientY-t.top)}}function r(){a.enabled!==!1&&(a.domElement.removeEventListener("mousemove",n,!1),a.domElement.removeEventListener("mouseup",r,!1),d=l.NONE,a.scene.remove(a.pivotNode))}function s(e){if(a.enabled!==!1&&a.noZoom!==!0){e.preventDefault();var t=a.domElement.getBoundingClientRect(),i=e.detail<0||e.wheelDelta>0?1:-1,o={x:(e.clientX-t.left)/a.domElement.clientWidth*2-1,y:2*-((e.clientY-t.top)/a.domElement.clientHeight)+1},n=getMousePointCloudIntersection(o,a.camera,a.renderer,a.pointclouds);if(n){var r=n.distanceTo(a.camera.position),s=(new THREE.Vector3).subVectors(n,a.camera.position).normalize();a.camera.position.add(s.multiplyScalar(.1*r*i))}}}this.camera=e,this.renderer=t,this.pointclouds=[],this.domElement=t.domElement,this.scene=i,this.enabled=!0;var a=this,l={NONE:-1,DRAG:0,ROTATE:1},d=l.NONE,c=new THREE.Vector2,u=new THREE.Vector2,h=new THREE.SphereGeometry(1,32,32),p=new THREE.MeshNormalMaterial({shading:THREE.SmoothShading,transparent:!0,opacity:.5});this.pivotNode=new THREE.Mesh(h,p);var m=new THREE.Vector2,f=null,v=null;this.minAngle=10/180*Math.PI,this.maxAngle=70/180*Math.PI,this.update=function(e){this.camera.position;this.camera.updateMatrixWorld();var t=new THREE.Object3D;if(t.position.copy(this.camera.position),t.rotation.copy(this.camera.rotation),t.updateMatrix(),t.updateMatrixWorld(),v){if(d===l.DRAG){var i=(new THREE.Plane).setFromNormalAndCoplanarPoint(new THREE.Vector3(0,1,0),v),o={x:u.x/this.domElement.clientWidth*2-1,y:2*-(u.y/this.domElement.clientHeight)+1},n=new THREE.Vector3(o.x,o.y,.5);n.unproject(f);var r=n.sub(f.position).normalize(),s=new THREE.Ray(f.position,r),a=s.distanceToPlane(i);if(a>0){var c=(new THREE.Vector3).subVectors(v,r.clone().multiplyScalar(a));t.position.copy(c)}}else if(d===l.ROTATE){var h=m.clone().multiplyScalar(e);h.x*=.3,h.y*=.2;var p=new THREE.Object3D,g=new THREE.Object3D;p.add(g),p.position.copy(v),g.position.copy(this.camera.position).sub(v),g.rotation.copy(this.camera.rotation),p.rotation.y+=-h.x;var r=this.camera.getWorldDirection(),E=new THREE.Vector3(0,1,0),y=(new THREE.Vector3).crossVectors(E,r),b=g.position.clone();b.y=0,b.normalize();var T=b.dot(g.position.clone().normalize()),R=Math.acos(T);g.position.y<0&&(R=-R);var P=0;P=h.y>0?h.y-Math.max(0,this.minAngle-(R-h.y)):h.y+Math.max(0,R-h.y-this.maxAngle),p.rotateOnAxis(y,-P),p.updateMatrixWorld(),t.position.copy(g.getWorldPosition()),t.quaternion.copy(g.getWorldQuaternion())}var C={type:"proposeTransform",oldPosition:this.camera.position,newPosition:t.position,objections:0};this.dispatchEvent(C),C.objections>0||(this.camera.position.copy(t.position),this.camera.rotation.copy(t.rotation));var x=this.pivotNode.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse),w=Math.abs(x.z/30),H=this.pivotNode.scale.length();this.pivotNode.scale.multiplyScalar(w/H)}m.set(0,0)},this.reset=function(){d=l.NONE,this.camera.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",s,!1),this.domElement.addEventListener("DOMMouseScroll",s,!1)},THREE.EarthControls.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){if(e.loaded){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(e){var t=this.items[e.id];t&&(1===this.elements?(this.first=null,this.last=null):(t.previous||(this.first=t.next,this.first.previous=null),t.next||(this.last=t.previous,this.last.next=null),t.previous&&t.next&&(t.previous.next=t.next,t.next.previous=t.previous)),delete this.items[e.id],this.elements--,this.numPoints-=e.numPoints)},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()+")"},LRU.prototype.freeMemory=function(){if(!(this.elements<=1))for(;this.numPoints>Potree.pointLoadLimit;){var e=this.first,t=e.node;this.disposeDescendants(t)}},LRU.prototype.disposeDescendants=function(e){var t=[];for(t.push(e);t.length>0;){var i=t.pop();i.dispose(),this.remove(i);for(var o in i.children)if(i.children.hasOwnProperty(o)){var n=i.children[o];n.loaded&&t.push(i.children[o])}}},Potree.Annotation=function(e,t){var i=this;Potree.Annotation.counter++,this.viewer=e,this.ordinal=t.ordinal||Potree.Annotation.counter,this.title=t.title||"No Title",this.description=t.description||"",this.scene=t.scene||null,this.position=t.position||new THREE.Vector3(0,0,0),this.cameraPosition=t.cameraPosition,this.cameraTarget=t.cameraTarget||this.position,this.view=t.view||null,this.keepOpen=!1,this.domElement=document.createElement("div"),this.domElement.style.position="fixed",this.domElement.style.opacity="0.5",this.domElement.className="annotation",this.elOrdinal=document.createElement("div"),this.elOrdinal.style.position="absolute",this.elOrdinal.style.width="1.5em",this.elOrdinal.style.height="1.5em",this.elOrdinal.style.color="white",this.elOrdinal.style.backgroundColor="black",this.elOrdinal.style.borderRadius="1.5em",this.elOrdinal.style.fontSize="1em",this.elOrdinal.style.opacity="1",this.elOrdinal.style.zIndex="100",this.domElement.appendChild(this.elOrdinal),this.elOrdinal.onmouseenter=function(){},this.elOrdinal.onmouseleave=function(){},this.elOrdinal.onclick=function(){i.moveHere(i.viewer.camera)},this.domElement.onmouseleave=function(){},this.elOrdinalText=document.createElement("span"),this.elOrdinalText.style.display="inline-block",this.elOrdinalText.style.verticalAlign="middle",this.elOrdinalText.style.lineHeight="1.5em",this.elOrdinalText.style.textAlign="center",this.elOrdinalText.style.width="100%",this.elOrdinalText.style.fontFamily="Arial",this.elOrdinalText.style.cursor="default",this.elOrdinalText.innerHTML=this.ordinal,this.elOrdinalText.userSelect="none",this.elOrdinal.appendChild(this.elOrdinalText),this.elButtons=document.createElement("div"),this.elButtons.style.position="absolute",this.elButtons.style.display="block",this.elButtons.style.height="1.5em",this.elButtons.style.backgroundColor="#333333",this.elButtons.style.zIndex="50",this.elButtons.style.borderRadius="1.5em 1.5em 1.5em 1.5em",this.elButtons.style.cursor="default",this.elButtons.style.padding="0.0em 0.0em 0em 1.5em",this.elButtons.style.whiteSpace="nowrap",this.domElement.appendChild(this.elButtons),this.description&&(this.elButtonsInfo=document.createElement("img"),this.elButtonsInfo.src="../resources/icons/info_32x32.png",this.elButtonsInfo.style.width="1.5em",this.elButtonsInfo.style.padding="0em 0em 0em 0.2em",this.elButtons.appendChild(this.elButtonsInfo),this.elButtonsInfo.onclick=function(){i.openDescriptionWindow()}),this.scene&&(this.elButtonsScene=document.createElement("img"),this.elButtonsScene.src="../resources/icons/goto_32x32.png",this.elButtonsScene.style.width="1.5em",this.elButtonsScene.style.padding="0em 0em 0em 0.2em",this.elButtonsScene.onclick=function(){loadScene(i.scene)},this.elButtons.appendChild(this.elButtonsScene)),this.domElement.onmouseenter=function(){i.domElement.style.opacity="0.8"},this.domElement.onmouseleave=function(){i.domElement.style.opacity="0.5"},this.openBar=function(){i.elOrdinal.style.opacity=.8,i.elButtons.style.display="block"},this.closeBar=function(){this.keepOpen||(i.elOrdinal.style.opacity=.5,i.elButtons.style.display="none")},this.openDescriptionWindow=function(){this.elDescription?this.elDescription.style.display="block":(this.elDescription=document.createElement("div"),this.elDescription.className="description",this.elDescriptionHeader=document.createElement("div"),this.elDescriptionHeader.className="description-header",this.elDescription.appendChild(this.elDescriptionHeader),this.elDescriptionTitle=document.createElement("span"),this.elDescriptionTitle.className="description-title",this.elDescriptionTitle.innerHTML=i.title,this.elDescriptionHeader.appendChild(this.elDescriptionTitle),this.elDescriptionButtons=document.createElement("span"),this.elDescriptionButtons.className="description-buttons",this.elDescriptionHeader.appendChild(this.elDescriptionButtons),this.elDescriptionClose=document.createElement("img"),this.elDescriptionClose.src="../resources/icons/close_32x32_black.png",this.elDescriptionClose.onmouseenter=function(){this.src="../resources/icons/close_32x32_black_shadow.png"},this.elDescriptionClose.onmouseleave=function(){this.src="../resources/icons/close_32x32_black.png"},this.elDescriptionClose.style.height="1.5em",this.elDescriptionClose.onclick=function(){i.elDescription.style.display="none"},this.elDescriptionButtons.appendChild(this.elDescriptionClose),this.elDescriptionContent=document.createElement("div"),this.elDescriptionContent.className="description-content",this.elDescriptionContent.innerHTML=this.description,this.elDescription.appendChild(this.elDescriptionContent),document.body.appendChild(this.elDescription))},this.moveHere=function(e){var t=800,o=TWEEN.Easing.Quartic.Out,n=new TWEEN.Tween(e.position).to(i.cameraPosition,t);n.easing(o),n.start();var r=e.position.distanceTo(i.cameraTarget),s=(new THREE.Vector3).addVectors(e.position,e.getWorldDirection().clone().multiplyScalar(r)),n=new TWEEN.Tween(s).to(i.cameraTarget,t);n.easing(o),n.onUpdate(function(){e.lookAt(s),i.viewer.orbitControls.target.copy(s)}),n.onComplete(function(){e.lookAt(s),i.viewer.orbitControls.target.copy(s)}),n.start()},this.dispose=function(){if(this.descriptionDialog){var e="annotation_description_"+i.ordinal;$("#"+e).dialog("destroy")}this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),this.elDescription&&this.elDescription.parentElement&&this.elDescription.parentElement.removeChild(this.elDescription)}},Potree.Annotation.counter=0,Potree.ProfileData=function(e){this.profile=e,this.segments=[],this.boundingBox=new THREE.Box3,this.projectedBoundingBox=new THREE.Box2;for(var t=new THREE.Vector3,i=0;i0&&(l=-l),function(e){var t=(new THREE.Matrix4).makeTranslation(-o.x,0,-o.z),i=(new THREE.Matrix4).makeRotationY(-l),n=(new THREE.Matrix4).makeTranslation(r.x,0,0),s=e.clone();return s.applyMatrix4(t),s.applyMatrix4(i),s.applyMatrix4(n),s}}(o,n,t.clone()),m={start:o,end:n,cutPlane:u,halfPlane:h,length:s,points:null,project:p};this.segments.push(m),t.x+=new THREE.Vector3(o.x,0,o.z).distanceTo(new THREE.Vector3(n.x,0,n.z)),t.y+=n.y-o.y}this.projectedBoundingBox.min.x=0,this.projectedBoundingBox.min.y=Number.POSITIVE_INFINITY,this.projectedBoundingBox.max.x=t.x,this.projectedBoundingBox.max.y=Number.NEGATIVE_INFINITY,this.size=function(){for(var e=0,t=0;to;o++){var n=t.children[o];n&&e.nodeIntersectsProfile(n,this.profile)&&i.push(n)}for(;i.length>0;){var t=i.pop(),r=t.boundingSphere.radius;if(this.priorityQueue.push({node:t,weight:r}),t.levelo;o++){var n=t.children[o];n&&e.nodeIntersectsProfile(n,this.profile)&&i.push(n)}}},this.update=function(){for(var t=[],i=0;i0&&(this.getPointsInsideProfile(t,this.temporaryResult),this.temporaryResult.size()>100&&(this.pointsServed+=this.temporaryResult.size(),o.onProgress({request:this,points:this.temporaryResult}),this.temporaryResult=new Potree.ProfileData(this.profile))),0===this.priorityQueue.size()){this.temporaryResult.size()>0&&(this.pointsServed+=this.temporaryResult.size(),o.onProgress({request:this,points:this.temporaryResult}),this.temporaryResult=new Potree.ProfileData(this.profile)),o.onFinish({request:this});var s=e.profileRequests.indexOf(this);s>=0&&e.profileRequests.splice(s,1)}},this.getPointsInsideProfile=function(i,o){for(var n=0;np;p++){var m=new THREE.Vector3(c[3*p],c[3*p+1],c[3*p+2]);m.applyMatrix4(e.matrixWorld);var f=Math.abs(r.cutPlane.distanceToPoint(m)),v=Math.abs(r.halfPlane.distanceToPoint(m));if(f0&&(o.boundingBox.expandByPoint(r.points.boundingBox.min),o.boundingBox.expandByPoint(r.points.boundingBox.max),o.projectedBoundingBox.expandByPoint(new THREE.Vector2(0,o.boundingBox.min.y)),o.projectedBoundingBox.expandByPoint(new THREE.Vector2(0,o.boundingBox.max.y)))}},this.cancel=function(){o.onCancel(),this.priorityQueue=new BinaryHeap(function(e){return 1/e.weight});var t=e.profileRequests.indexOf(this);t>=0&&e.profileRequests.splice(t,1)},this.initialize()},Potree.PointCloudOctreeNode=function(){this.children={},this.sceneNode=null,this.octree=null},Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.tightBoundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.material=t||new Potree.PointCloudMaterial,this.visiblePointsTarget=2e6,this.minimumNodePixelSize=150,this.level=0,this.position.sub(e.offset),this.updateMatrix(),this.showBoundingBox=!1,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleBounds=new THREE.Box3,this.visibleNodes=[],this.visibleGeometry=[],this.pickTarget=null,this.generateDEM=!1,this.profileRequests=[],this.root=this.pcoGeometry.root},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.updateVisibility=function(e,t){this.numVisibleNodes=0,this.numVisiblePoints=0,e.updateMatrixWorld();var i=new THREE.Frustum,o=e.matrixWorldInverse,n=this.matrixWorld,r=e.projectionMatrix,s=(new THREE.Matrix4).multiply(r).multiply(o).multiply(n);i.setFromMatrix(s);var a=e.matrixWorld,l=(new THREE.Matrix4).getInverse(n),d=(new THREE.Matrix4).multiply(l).multiply(a),c=(new THREE.Vector3).setFromMatrixPosition(d),u=new BinaryHeap(function(e){return 1/e.weight});u.push({ node:this.root,weight:1});var h=[],p=[],m=[];this.root instanceof Potree.PointCloudOctreeNode&&this.hideDescendants(this.root.sceneNode);for(var f=0;f0;){var v=u.pop(),g=v.node,E=v.parent,y=g.boundingBox,b=i.intersectsBox(y),T=b;if(T=T&&!(this.numVisiblePoints+g.numPoints>this.visiblePointsTarget)){if(this.numVisibleNodes++,this.numVisiblePoints+=g.numPoints,g instanceof Potree.PointCloudOctreeGeometryNode){var R=g,P=R.geometry;if(("undefined"==typeof E||E instanceof Potree.PointCloudOctreeNode)&&R.loaded){var C=new Potree.PointCloudOctreeNode,x=new THREE.PointCloud(P,this.material);x.visible=!1,C.octree=this,C.name=R.name,C.level=R.level,C.numPoints=R.numPoints,C.boundingBox=P.boundingBox,C.tightBoundingBox=P.tightBoundingBox,C.boundingSphere=C.boundingBox.getBoundingSphere(),C.geometryNode=R,C.parent=E,C.children={};for(var w in R.children)C.children[w]=R.children[w];if(x.boundingBox=C.boundingBox,x.boundingSphere=C.boundingSphere,x.numPoints=C.numPoints,x.level=C.level,C.sceneNode=x,"undefined"==typeof g.parent)this.root=C,this.add(C.sceneNode),x.matrixWorld.multiplyMatrices(this.matrixWorld,x.matrix);else{var H=parseInt(C.name[C.name.length-1]);E.sceneNode.add(x),E.children[H]=C,x.matrixWorld.multiplyMatrices(E.sceneNode.matrixWorld,x.matrix)}var S=function(e,t,i){return function(){var o=parseInt(t.name[t.name.length-1]);e.sceneNode.remove(t.sceneNode),e.children[o]=i}}(E,C,g);C.geometryNode.oneTimeDisposeHandlers.push(S),g=C}R.loaded||(m.push(g),p.push(g))}if(g instanceof Potree.PointCloudOctreeNode){if(Potree.PointCloudOctree.lru.touch(g.geometryNode),g.sceneNode.visible=!0,g.sceneNode.material=this.material,h.push(g),p.push(g.geometryNode),g.parent?g.sceneNode.matrixWorld.multiplyMatrices(g.parent.sceneNode.matrixWorld,g.sceneNode.matrix):g.sceneNode.matrixWorld.multiplyMatrices(this.matrixWorld,g.sceneNode.matrix),this.showBoundingBox&&!g.boundingBoxNode){var B=new THREE.BoxHelper(g.sceneNode);this.add(B),this.boundingBoxNodes.push(B),g.boundingBoxNode=B,g.boundingBoxNode.matrixWorld.copy(g.sceneNode.matrixWorld)}else this.showBoundingBox?(g.boundingBoxNode.visible=!0,g.boundingBoxNode.matrixWorld.copy(g.sceneNode.matrixWorld)):!this.showBoundingBox&&g.boundingBoxNode&&(g.boundingBoxNode.visible=!1);this.generateDEM&&g.level<=2&&(g.dem||(g.dem=this.createDEM(g)))}for(var f=0;8>f;f++)if(g.children[f]){var A=g.children[f],V=A.boundingSphere,I=V.center.distanceTo(c),M=V.radius,L=e.fov/2*Math.PI/180,W=1/Math.tan(L)*M/Math.sqrt(I*I-M*M),G=t.domElement.clientHeight*W;if(!(GI-M&&(N=Number.MAX_VALUE),u.push({node:A,parent:g,weight:N})}}}}this.visibleNodes=h,this.visibleGeometry=p;for(var f=0;fi?-1:i>o?1:0};t.sort(n);for(var r=0;rl;l++){var d=s.children[l];d instanceof Potree.PointCloudOctreeNode&&d.sceneNode.visible&&t.indexOf(d)>=0&&a.push(d)}a.sort(function(e,t){return e.namet.name?1:0}),o[3*r+0]=0,o[3*r+1]=0,o[3*r+2]=0;for(var l=0;l0;){var e=t.shift();e.visible=!1;for(var i=0;i0&&(c=-c),function(e){var t=(new THREE.Matrix4).makeTranslation(-n.x,-a.min.y,-n.z),i=(new THREE.Matrix4).makeRotationY(-c),o=(new THREE.Matrix4).makeTranslation(s.x,0,0),r=e.clone();return r.applyMatrix4(t),r.applyMatrix4(i),r.applyMatrix4(o),r}}(s,a,c.clone(),n.boundingBox.clone());d.project=u,c.x+=new THREE.Vector3(s.x,0,s.z).distanceTo(new THREE.Vector3(a.x,0,a.z)),c.y+=a.y-s.y}return n.projectedBoundingBox.min.x=0,n.projectedBoundingBox.min.y=n.boundingBox.min.y,n.projectedBoundingBox.max.x=c.x,n.projectedBoundingBox.max.y=n.boundingBox.max.y,n},Potree.PointCloudOctree.prototype.getProfile=function(e,t,i,o,n){if(void 0===n){var r=[];r.push(this);for(var s=(new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),a=(new THREE.Vector3).subVectors(t,e).length(),l=(new THREE.Vector3).subVectors(t,e).normalize(),d=new THREE.Vector3(0,1,0),c=(new THREE.Vector3).crossVectors(l,d).normalize(),u=c,h=(new THREE.Plane).setFromNormalAndCoplanarPoint(u,e),p=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,s),m=null,f=new THREE.Box3;r.length>0;){var v=r.shift(),g=0;if(v instanceof THREE.PointCloud){var E=v.geometry,y=E.attributes.position,b=y.array,T=v.numPoints;if(!m){m={};for(var R in E.attributes)E.attributes.hasOwnProperty(R)&&("indices"===R||(m[R]=[]))}for(var P=0;T>P;P++){var C=new THREE.Vector3(b[3*P],b[3*P+1],b[3*P+2]);C.applyMatrix4(this.matrixWorld);var x=Math.abs(h.distanceToPoint(C)),w=Math.abs(p.distanceToPoint(C));if(i/2>x&&a/2>w){f.expandByPoint(C);for(var R in E.attributes)if(E.attributes.hasOwnProperty(R))if("position"===R)m[R].push(C);else if("indices"===R);else{var H=E.attributes[R];if(1===H.itemSize)m[R].push(H.array[P+B]);else{for(var S=[],B=0;B0&&(s=-s),function(e){var t=(new THREE.Matrix4).makeTranslation(-i.x,-i.y,-i.z),o=(new THREE.Matrix4).makeRotationY(-s),n=e.clone();return n.applyMatrix4(t),n.applyMatrix4(o),n}}(e,t);return m.project=I,m.boundingBox=f,m}var M=new Potree.ProfileRequest(e,t,i,o,n);this.profileRequests.push(M)},Potree.PointCloudOctree.prototype.getVisibleExtent=function(){return this.visibleBounds.applyMatrix4(this.matrixWorld)},Potree.PointCloudOctree.prototype.pick=function(e,t,i,o){var o=o||{},n=o.pickWindowSize||17,r=this.nodesOnRay(this.visibleNodes,i);if(0===r.length)return null;var s=Math.ceil(e.domElement.clientWidth),a=Math.ceil(e.domElement.clientHeight),l=(new THREE.Vector3).addVectors(t.position,i.direction).project(t);l.addScalar(1).multiplyScalar(.5),l.x*=s,l.y*=a,this.pickTarget?(this.pickTarget.width!=s||this.pickTarget.height!=a)&&(this.pickTarget.dispose(),this.pickTarget=new THREE.WebGLRenderTarget(1,1,{minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat})):this.pickTarget=new THREE.WebGLRenderTarget(1,1,{minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),this.pickTarget.setSize(s,a),this.pickMaterial||(this.pickMaterial=new Potree.PointCloudMaterial,this.pickMaterial.pointColorType=Potree.PointColorType.POINT_INDEX),this.pickMaterial.pointSizeType=this.material.pointSizeType,this.pickMaterial.size=this.material.size,this.pickMaterial.pointShape=this.material.pointShape,this.pickMaterial.interpolate=this.material.interpolate,this.pickMaterial.minSize=this.material.minSize,this.pickMaterial.maxSize=this.material.maxSize,this.pickMaterial.classification=this.material.classification,this.updateMaterial(this.pickMaterial,r,t,e);var d=e.context;d.enable(d.SCISSOR_TEST),d.scissor(l.x-(n-1)/2,l.y-(n-1)/2,n,n),d.disable(d.SCISSOR_TEST);var c=this.pickMaterial;e.setRenderTarget(this.pickTarget),e.state.setDepthTest(c.depthTest),e.state.setDepthWrite(c.depthWrite),e.state.setBlending(THREE.NoBlending),e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),r.length>0&&r.push(r[0]);for(var u=0;uP;P++)for(var C=0;n>C;C++){var x=P+C*n,w=Math.pow(P-(n-1)/2,2)+Math.pow(C-(n-1)/2,2),H=y[4*x+3];y[4*x+3]=0;var S=b[x];(0!==S||0!==H)&&T>w&&(R={pIndex:S,pcIndex:H},T=w)}if(R){var B={},A=r[R.pcIndex].sceneNode,V=A.geometry.attributes;for(var I in V)if(V.hasOwnProperty(I)){var M=A.geometry.attributes[I];if("position"===I){var L=A.geometry.attributes.position.array,W=L[3*R.pIndex+0],G=L[3*R.pIndex+1],N=L[3*R.pIndex+2],D=new THREE.Vector3(W,G,N);D.applyMatrix4(this.matrixWorld),B[I]=D}else if("indices"===I);else if(1===M.itemSize)B[I]=M.array[u+X];else{for(var O=[],X=0;Xu;u++){var h=s[3*u+0],p=s[3*u+1],m=s[3*u+2],f=new THREE.Vector3(h,p,m).applyMatrix4(o),v=parseInt(a*(f.x-n.min.x)/r.x),g=parseInt(a*(f.z-n.min.z)/r.z);v=Math.min(v,a-1),g=Math.min(g,a-1);var E=v+g*a;l[E]||(l[E]=[]),l[E].push(f.y)}for(var u=0;u.5&&r.x.5&&r.y0;){var r=n.shift(),s=r.dem,a=(s.demSize,s.boundingBox2D);a.containsPoint(t);if(a.containsPoint(t)){var l=i(s);if(o?null!=l&&l>0&&(o=l):o=l,r.level<=2)for(var d=0;ds;s++)for(var a=0;i>a;a++){var l=s/t,d=a/i,c=l*e.size().x+e.min.x,u=d*e.size().z+e.min.z,h=this.getDEMHeight(new THREE.Vector3(c,0,u));h||(h=0),n[r+0]=c,n[r+1]=h,n[r+2]=u,r+=3}o.addAttribute("position",new THREE.BufferAttribute(n,3));var p=new THREE.PointCloudMaterial({size:20,color:65280}),m=new THREE.PointCloud(o,p);scene.add(m)},Object.defineProperty(Potree.PointCloudOctree.prototype,"progress",{get:function(){return this.visibleNodes.length/this.visibleGeometry.length}});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,this.hierarchyStepSize=-1,this.loader=null},Potree.PointCloudOctreeGeometryNode=function(e,t,i){this.id=Potree.PointCloudOctreeGeometryNode.IDCount++,this.name=e,this.index=parseInt(e.charAt(e.length-1)),this.pcoGeometry=t,this.geometry=null,this.boundingBox=i,this.boundingSphere=i.getBoundingSphere(),this.children={},this.numPoints=0,this.level=null,this.loaded=!1,this.oneTimeDisposeHandlers=[]},Potree.PointCloudOctreeGeometryNode.IDCount=0,Potree.PointCloudOctreeGeometryNode.prototype.getURL=function(){var e="",t=this.pcoGeometry.loader.version;return t.equalOrHigher("1.5")?e=this.pcoGeometry.octreeDir+"/"+this.getHierarchyPath()+"/"+this.name:t.equalOrHigher("1.4")?e=this.pcoGeometry.octreeDir+"/"+this.name:t.upTo("1.3")&&(e=this.pcoGeometry.octreeDir+"/"+this.name),e},Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath=function(){for(var e="r/",t=this.pcoGeometry.hierarchyStepSize,i=this.name.substr(1),o=Math.floor(i.length/t),n=0;o>n;n++)e+=i.substr(n*t,t)+"/";return e=e.slice(0,-1)},Potree.PointCloudOctreeGeometryNode.prototype.addChild=function(e){this.children[e.index]=e,e.parent=this},Potree.PointCloudOctreeGeometryNode.prototype.load=function(){this.loading===!0||this.loaded===!0||this.pcoGeometry.numNodesLoading>3||(this.loading=!0,this.pcoGeometry.numNodesLoading++,this.pcoGeometry.loader.version.equalOrHigher("1.5")&&this.level%this.pcoGeometry.hierarchyStepSize===0&&this.hasChildren?this.loadHierachyThenPoints():this.loadPoints())},Potree.PointCloudOctreeGeometryNode.prototype.loadPoints=function(){this.pcoGeometry.loader.load(this)},Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints=function(){var e=this,t=function(e,t){var i=(t.byteLength/5,new DataView(t)),o=[],n=i.getUint8(0),r=i.getUint32(1,!0);e.numPoints=r,o.push({children:n,numPoints:r,name:e.name});for(var s=[],a=5;o.length>0;){for(var l=o.shift(),d=1,c=0;8>c;c++){if(0!==(l.children&d)){var u=l.name+c,h=i.getUint8(a),p=i.getUint32(a+1,!0);o.push({children:h,numPoints:p,name:u}),s.push({children:h,numPoints:p,name:u}),a+=5}d=2*d}if(a===t.byteLength)break}var m={};m[e.name]=e;for(var f=e.pcoGeometry,c=0;c0,y.addChild(R),m[v]=R}e.loadPoints()};if(e.level%e.pcoGeometry.hierarchyStepSize===0){var i=e.pcoGeometry.octreeDir+"/"+e.getHierarchyPath()+"/"+e.name+".hrc",o=new XMLHttpRequest;o.open("GET",i,!0),o.responseType="arraybuffer",o.overrideMimeType("text/plain; charset=x-user-defined"),o.onreadystatechange=function(){if(4===o.readyState)if(200===o.status||0===o.status){var i=o.response;t(e,i)}else console.log("Failed to load file! HTTP status: "+o.status+", file: "+url)};try{o.send(null)}catch(n){console.log("fehler beim laden der punktwolke: "+n)}}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){if(this.geometry&&null!=this.parent){this.geometry.dispose(),this.geometry=null,this.loaded=!1;for(var e=0;e1?"."+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"}),i=new Worker(URL.createObjectURL(t));return i},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),i=new THREE.Scene,o=".jpg",n=[e+"px"+o,e+"nx"+o,e+"py"+o,e+"ny"+o,e+"pz"+o,e+"nz"+o],r=THREE.ImageUtils.loadTextureCube(n,THREE.CubeRefractionMapping),s={uniforms:{tCube:{type:"t",value:r},tFlip:{type:"f",value:-1}},vertexShader:THREE.ShaderLib.cube.vertexShader,fragmentShader:THREE.ShaderLib.cube.fragmentShader},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 i.add(l),{camera:t,scene:i}},Potree.utils.createGrid=function(e,t,i,o){for(var n=new THREE.LineBasicMaterial({color:o||8947848}),r=new THREE.Geometry,s=0;t>=s;s++)r.vertices.push(new THREE.Vector3(-(i*e)/2,0,s*i-i*t/2)),r.vertices.push(new THREE.Vector3(+(i*e)/2,0,s*i-i*t/2));for(var s=0;e>=s;s++)r.vertices.push(new THREE.Vector3(s*i-i*e/2,0,-(i*t)/2)),r.vertices.push(new THREE.Vector3(s*i-i*e/2,0,+(i*t)/2));var a=new THREE.Line(r,n,THREE.LinePieces);return a.receiveShadow=!0,a},Potree.utils.createBackgroundTexture=function(e,t){function i(e,t){return 1/(2*Math.PI)*Math.exp(-(e*e+t*t)/2)}var o=THREE.ImageUtils.generateDataTexture(e,t,new THREE.Color);o.magFilter=THREE.NearestFilter;for(var n=o.image.data,r=[1,1.5,1.7],s=i(0,0),a=0;e>a;a++)for(var l=0;t>l;l++){var d=2*(a/e)-1,c=2*(l/t)-1,u=a+e*l,h=i(2*d,2*c)/s,p=(Math.random()+Math.random()+Math.random())/3;p=(.5*h+.5)*p*.03,p=.4*p,n[3*u+0]=255*(h/15+.05+p)*r[0],n[3*u+1]=255*(h/15+.05+p)*r[1],n[3*u+2]=255*(h/15+.05+p)*r[2]}return o},Potree.utils.topView=function(e,t){e.position.set(0,1,0),e.rotation.set(-Math.PI/2,0,0),e.zoomTo(t,1)},Potree.utils.frontView=function(e,t){e.position.set(0,0,1),e.rotation.set(0,0,0),e.zoomTo(t,1)},Potree.utils.leftView=function(e,t){e.position.set(-1,0,0),e.rotation.set(0,-Math.PI/2,0),e.zoomTo(t,1)},Potree.utils.rightView=function(e,t){e.position.set(1,0,0),e.rotation.set(0,Math.PI/2,0),e.zoomTo(t,1)},Potree.utils.frustumSphereIntersection=function(e,t){for(var i=e.planes,o=t.center,n=-t.radius,r=Number.MAX_VALUE,s=0;6>s;s++){var a=i[s].distanceToPoint(o);if(n>a)return 0;r=Math.min(r,a)}return r>=t.radius?2:1},Potree.utils.screenPass=new function(){this.screenScene=new THREE.Scene,this.screenQuad=new THREE.Mesh(new THREE.PlaneBufferGeometry(2,2,0)),this.screenQuad.material.depthTest=!0,this.screenQuad.material.depthWrite=!0,this.screenQuad.material.transparent=!0,this.screenScene.add(this.screenQuad),this.camera=new THREE.Camera,this.render=function(e,t,i){this.screenQuad.material=t,void 0===typeof i?e.render(this.screenScene,this.camera):e.render(this.screenScene,this.camera,i)}},Potree.Features=function(){var e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");if(null===t)return null;var i,o=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT),n=t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.MEDIUM_FLOAT),r=(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.LOW_FLOAT),t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT)),s=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.MEDIUM_FLOAT),a=(t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.LOW_FLOAT),o.precision>0&&r.precision>0),l=n.precision>0&&s.precision>0;return i=a?"highp":l?"mediump":"lowp",{SHADER_INTERPOLATION:{isSupported:function(){var e=!0;return e=e&&t.getExtension("EXT_frag_depth"),e=e&&t.getParameter(t.MAX_VARYING_VECTORS)>=8}},SHADER_SPLATS:{isSupported:function(){var e=!0;return e=e&&t.getExtension("EXT_frag_depth"),e=e&&t.getExtension("OES_texture_float"),e=e&&t.getParameter(t.MAX_VARYING_VECTORS)>=8}},SHADER_EDL:{isSupported:function(){var e=!0;return e=e&&t.getExtension("EXT_frag_depth"),e=e&&t.getExtension("OES_texture_float"),e=e&&t.getParameter(t.MAX_VARYING_VECTORS)>=8}},precision:i}}(),Potree.TextSprite=function(e){THREE.Object3D.call(this);var t=new THREE.Texture;t.minFilter=THREE.LinearFilter,t.magFilter=THREE.LinearFilter;var i=new THREE.SpriteMaterial({map:t,useScreenCoordinates:!1,depthTest:!1,depthWrite:!1});this.material=i,this.sprite=new THREE.Sprite(i),this.add(this.sprite),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.textColor={r:255,g:255,b:255,a:1},this.text="",this.setText(e)},Potree.TextSprite.prototype=new THREE.Object3D,Potree.TextSprite.prototype.setText=function(e){this.text=e,this.update()},Potree.TextSprite.prototype.setTextColor=function(e){this.textColor=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 i=t.measureText(this.text),o=i.width,n=o+2*this.borderThickness,r=1.4*this.fontsize+2*this.borderThickness,e=document.createElement("canvas"),t=e.getContext("2d");t.canvas.width=n,t.canvas.height=r,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,o+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("+this.textColor.r+","+this.textColor.g+","+this.textColor.b+","+this.textColor.a+")",t.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var s=new THREE.Texture(e);s.minFilter=THREE.LinearFilter,s.magFilter=THREE.LinearFilter,s.needsUpdate=!0,this.sprite.material.map=s,this.sprite.scale.set(.01*n,.01*r,1)},Potree.TextSprite.prototype.roundRect=function(e,t,i,o,n,r){e.beginPath(),e.moveTo(t+r,i),e.lineTo(t+o-r,i),e.quadraticCurveTo(t+o,i,t+o,i+r),e.lineTo(t+o,i+n-r),e.quadraticCurveTo(t+o,i+n,t+o-r,i+n),e.lineTo(t+r,i+n),e.quadraticCurveTo(t,i+n,t,i+n-r),e.lineTo(t,i+r),e.quadraticCurveTo(t,i,t+r,i),e.closePath(),e.fill(),e.stroke()},Potree.Version=function(e){this.version=e;var t=-1===e.indexOf(".")?e.length:e.indexOf(".");this.versionMajor=parseInt(e.substr(0,t)),this.versionMinor=parseInt(e.substr(t+1)),0===this.versionMinor.length&&(this.versionMinor=0)},Potree.Version.prototype.newerThan=function(e){var t=new Potree.Version(e);return this.versionMajor>t.versionMajor?!0:this.versionMajor===t.versionMajor&&this.versionMinor>t.versionMinor?!0:!1},Potree.Version.prototype.equalOrHigher=function(e){var t=new Potree.Version(e);return this.versionMajor>t.versionMajor?!0:this.versionMajor===t.versionMajor&&this.versionMinor>=t.versionMinor?!0:!1},Potree.Version.prototype.upTo=function(e){return!this.newerThan(e)},Potree.Measure=function(){var e=this;THREE.Object3D.call(this),this.points=[],this._showDistances=!0,this._showArea=!0,this._closed=!0,this.maxMarkers=Number.MAX_SAFE_INTEGER,this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[],this.angleLabels=[],this.areaLabel=new Potree.TextSprite(""),this.areaLabel.setBorderColor({r:0,g:255,b:0,a:0}),this.areaLabel.setBackgroundColor({r:0,g:255,b:0,a:0}),this.areaLabel.setTextColor({r:180,g:220,b:180,a:1}),this.areaLabel.material.depthTest=!1,this.areaLabel.material.opacity=1,this.add(this.areaLabel);var t=new THREE.SphereGeometry(.4,10,10);this.color=new THREE.Color(16711680);var i=function(){var t=new THREE.MeshLambertMaterial({shading:THREE.SmoothShading,color:e.color,ambient:11184810,depthTest:!1,depthWrite:!1});return t},o=function(e){e.target.material.emissive.setHex(8947848)},n=function(e){e.target.material.emissive.setHex(0)},r=function(t){var i=t.tool,o=(i.dragstart,i.mouse,i.getMousePointCloudIntersection());if(o){var n=e.spheres.indexOf(i.dragstart.object);e.setPosition(n,o)}t.event.stopImmediatePropagation()},s=function(e){};this.addMarker=function(e){this.points.push(e);var a=new THREE.Mesh(t,i());a.addEventListener("move",o),a.addEventListener("leave",n),a.addEventListener("drag",r),a.addEventListener("drop",s),this.add(a),this.spheres.push(a);var l=new THREE.Geometry;l.vertices.push(new THREE.Vector3,new THREE.Vector3),l.colors.push(this.color,this.color,this.color);var d=new THREE.LineBasicMaterial({linewidth:1});d.depthTest=!1;var c=new THREE.Line(l,d);c.visible=!0,this.add(c),this.edges.push(c);var u=new Potree.TextSprite(0);u.setBorderColor({r:0,g:255,b:0,a:0}),u.setBackgroundColor({r:0,g:255,b:0,a:0}),u.material.depthTest=!1,u.visible=!1,this.edgeLabels.push(u),this.add(u);var h=new Potree.TextSprite;h.setBorderColor({r:0,g:255,b:0,a:0}),h.setBackgroundColor({r:0,g:255,b:0,a:0}),h.material.depthTest=!1,h.material.opacity=1,h.visible=!1,this.angleLabels.push(h),this.add(h);var p={type:"marker_added",measurement:this};this.dispatchEvent(p),this.setPosition(this.points.length-1,e)},this.removeMarker=function(e){this.points.splice(e,1),this.remove(this.spheres[e]);var t=0===e?0:e-1;this.remove(this.edges[t]),this.edges.splice(t,1),this.remove(this.edgeLabels[t]),this.edgeLabels.splice(t,1),this.spheres.splice(e,1),this.update()},this.setPosition=function(e,t){var i=this.points[e];i.copy(t);var o={type:"marker_moved",measure:this,index:e,position:t.clone()};this.dispatchEvent(o),this.update()},this.getArea=function(){for(var e=0,t=this.points.length-1,i=0;i=n;n++){var t=this.points[n];o.add(t)}o.divideScalar(this.points.length);for(var n=0;i>=n;n++){var r=n,s=n+1>i?0:n+1,a=0===n?i:n-1,t=this.points[r],l=this.points[s],d=this.points[a],c=this.spheres[r];c.position.copy(t),c.material.color=e.color;var u=this.edges[r];u.material.color=this.color,u.geometry.vertices[0].copy(t),u.geometry.vertices[1].copy(l),u.geometry.verticesNeedUpdate=!0,u.geometry.computeBoundingSphere(),u.visible=i>r||this.closed;var h=this.edgeLabels[n],p=(new THREE.Vector3).add(t);p.add(l),p=p.multiplyScalar(.5);var m=t.distanceTo(l);h.position.copy(p),h.setText(m.toFixed(2)),h.visible=this.showDistances&&(i>r||this.closed)&&this.points.length>=2&&m>0;var f=this.angleLabels[n],v=this.getAngleBetweenLines(t,d,l),g=l.clone().sub(d);g.multiplyScalar(.5),g=d.clone().add(g).sub(t).normalize();var E=Math.min(t.distanceTo(d),t.distanceTo(l));E/=9;var y=t.clone().add(g.multiplyScalar(E));f.position.copy(y);var b=Potree.utils.addCommas((v*(180/Math.PI)).toFixed(1))+"°";f.setText(b),f.visible=this.showAngles&&(i>r||this.closed)&&this.points.length>=3&&v>0}this.areaLabel.position.copy(o),this.areaLabel.visible=this.showArea&&this.points.length>=3;var b=Potree.utils.addCommas(this.getArea().toFixed(1))+"²";this.areaLabel.setText(b)}},this.raycast=function(e,t){for(var i=0;ic.activeMeasurement.maxMarkers&&c.finishInsertion()}}}function n(e){var t=c.domElement.getBoundingClientRect();if(c.mouse.x=(e.clientX-t.left)/c.domElement.clientWidth*2-1,c.mouse.y=2*-((e.clientY-t.top)/c.domElement.clientHeight)+1,c.dragstart){var i={type:"drag",event:e,tool:c};c.dragstart.object.dispatchEvent(i)}else if(h==u.INSERT&&c.activeMeasurement){var o=c.getMousePointCloudIntersection();if(o){var n=c.activeMeasurement.points.length-1;c.activeMeasurement.setPosition(n,o)}}else{var o=d();o?(o.object.dispatchEvent({type:"move",target:o.object,event:e}),c.hoveredElement&&c.hoveredElement!==o.object&&c.hoveredElement.dispatchEvent({type:"leave",target:c.hoveredElement,event:e}),c.hoveredElement=o.object):(c.hoveredElement&&c.hoveredElement.dispatchEvent({type:"leave",target:c.hoveredElement,event:e}),c.hoveredElement=null)}}function r(e){h==u.INSERT&&c.finishInsertion()}function s(e){if(1===e.which){h!==u.DEFAULT&&e.stopImmediatePropagation();var t=d();t&&(c.dragstart={object:t.object,sceneClickPos:t.point,sceneStartPos:c.sceneRoot.position.clone(),mousePos:{x:c.mouse.x,y:c.mouse.y}},e.stopImmediatePropagation())}else 3===e.which&&r(e)}function a(e){window.getSelection?window.getSelection().removeAllRanges():document.selection&&document.selection.empty(),c.activeMeasurement&&h===u.INSERT&&(c.activeMeasurement.removeMarker(c.activeMeasurement.points.length-1),c.finishInsertion())}function l(e){c.dragstart&&(c.dragstart.object.dispatchEvent({type:"drop",event:e}),c.dragstart=null)}function d(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=new THREE.Raycaster;t.ray.set(c.camera.position,e.sub(c.camera.position).normalize());for(var i=[],o=0;o0?s[0]:!1}var c=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0};var u={DEFAULT:0,INSERT:1},h=u.DEFAULT;this.activeMeasurement=null,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.light=new THREE.DirectionalLight(16777215,1),this.light.position.set(0,0,10),this.light.lookAt(new THREE.Vector3(0,0,0)),this.sceneMeasurement.add(this.light),this.hoveredElement=null,this.getState=function(){return h},this.getMousePointCloudIntersection=function(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null},this.startInsertion=function(e){h=u.INSERT;var e=e||{},t="undefined"!=typeof e.showDistances?e.showDistances:!0,i="undefined"!=typeof e.showArea?e.showArea:!1,o="undefined"!=typeof e.showAngles?e.showAngles:!1,n="undefined"!=typeof e.closed?e.closed:!1,r=e.maxMarkers||Number.MAX_SAFE_INTEGER,s=new Potree.Measure;s.showDistances=t,s.showArea=i,s.showAngles=o,s.closed=n,s.maxMarkers=r,this.addMeasurement(s),s.addMarker(new THREE.Vector3(0,0,0)),this.activeMeasurement=s},this.finishInsertion=function(){this.activeMeasurement.removeMarker(this.activeMeasurement.points.length-1);var e={type:"insertion_finished",measurement:this.activeMeasurement};this.dispatchEvent(e),this.activeMeasurement=null,h=u.DEFAULT},this.addMeasurement=function(e){this.sceneMeasurement.add(e),this.measurements.push(e),this.dispatchEvent({type:"measurement_added",measurement:e}),e.addEventListener("marker_added",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_removed",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_moved",function(e){c.dispatchEvent(e)})},this.removeMeasurement=function(e){this.sceneMeasurement.remove(e);var t=this.measurements.indexOf(e);t>=0&&this.measurements.splice(t,1)},this.reset=function(){for(var e=this.measurements.length-1;e>=0;e--){var t=this.measurements[e];this.removeMeasurement(t)}},this.update=function(){for(var e=[],t=0;t1){var d=new THREE.Geometry;d.vertices.push(new THREE.Vector3,new THREE.Vector3),d.colors.push(i,i,i);var c=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linewidth:2,transparent:!0,opacity:.4});c.depthTest=!1;var u=new THREE.Line(d,c);u.visible=!1,this.add(u),this.edges.push(u);var h=new THREE.BoxGeometry(1,1,1),p=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.2}),m=new THREE.Mesh(h,p);m.visible=!1,this.add(m),this.boxes.push(m)}var f={type:"marker_added",profile:this};this.dispatchEvent(f),this.setPosition(this.points.length-1,e)},this.removeMarker=function(e){this.points.splice(e,1),this.remove(this.spheres[e]);var t=0===e?0:e-1;this.remove(this.edges[t]),this.edges.splice(t,1),this.remove(this.boxes[t]),this.boxes.splice(t,1),this.spheres.splice(e,1),this.update();var i={type:"marker_removed",profile:this};this.dispatchEvent(i)},this.getArea=function(){for(var e=0,t=this.points.length-1,i=0;i=r;r++){var e=this.points[r],s=this.spheres[r],a=0===r?n:r-1,l=r===n?0:r+1,d=this.points[a],c=this.points[l],u=this.edges[a],h=this.edges[r],p=this.boxes[a];this.boxes[r],e.distanceTo(d),e.distanceTo(c),(new THREE.Vector3).addVectors(d,e).multiplyScalar(.5),(new THREE.Vector3).addVectors(e,c).multiplyScalar(.5);if(s.position.copy(e),this._modifiable?s.visible=!0:s.visible=!1,u&&(u.geometry.vertices[1].copy(e),u.geometry.verticesNeedUpdate=!0,u.geometry.computeBoundingSphere()),h&&(h.geometry.vertices[0].copy(e),h.geometry.verticesNeedUpdate=!0,h.geometry.computeBoundingSphere()),p){var m=d,f=e,v=m.clone().setY(0).distanceTo(f.clone().setY(0));p.scale.set(v,this.height,this.width);var g=(new THREE.Vector3).addVectors(m,f).multiplyScalar(.5),E=(new THREE.Vector3).subVectors(f,m),y=new THREE.Vector3(E.z,0,-E.x);p.position.set(0,0,0),p.lookAt(y),p.position.copy(g)}o.add(e),t.min(e),i.max(e)}o.multiplyScalar(1/this.points.length);for(var r=0;r0?i[0]:!1}var c=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0};var u={DEFAULT:0,INSERT:1},h=u.DEFAULT;new THREE.SphereGeometry(.4,10,10);this.activeProfile=null,this.profiles=[],this.sceneProfile=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneProfile.add(this.sceneRoot),this.light=new THREE.DirectionalLight(16777215,1),this.light.position.set(0,0,10),this.light.lookAt(new THREE.Vector3(0,0,0)),this.sceneProfile.add(this.light),this.hoveredElement=null,this.getMousePointCloudIntersection=function(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null},this.startInsertion=function(e){h=u.INSERT;var e=e||{},t=e.clip||!1,i=e.width||1;return this.activeProfile=new Potree.HeightProfile,this.activeProfile.clip=t,this.activeProfile.setWidth(i),this.addProfile(this.activeProfile),this.activeProfile.addMarker(new THREE.Vector3(0,0,0)),this.activeProfile},this.finishInsertion=function(){this.activeProfile.removeMarker(this.activeProfile.points.length-1);var e={type:"insertion_finished",profile:this.activeProfile};this.dispatchEvent(e),this.activeProfile=null,h=u.DEFAULT},this.addProfile=function(e){this.profiles.push(e),this.sceneProfile.add(e),e.update(),this.dispatchEvent({type:"profile_added",profile:e}),e.addEventListener("marker_added",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_removed",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_moved",function(e){c.dispatchEvent(e)})},this.removeProfile=function(e){this.sceneProfile.remove(e);var t=this.profiles.indexOf(e);t>=0&&this.profiles.splice(t,1),this.dispatchEvent({type:"profile_removed",profile:e})},this.reset=function(){for(var e=this.profiles.length-1;e>=0;e--){var t=this.profiles[e];this.removeProfile(t)}},this.update=function(){for(var e=0;e0?o[0]:!1}}var a=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0},this.dragstart=null,this.sceneTransformation=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneTransformation.add(this.sceneRoot),this.sceneRotation=new THREE.Scene,this.translationNode=new THREE.Object3D,this.rotationNode=new THREE.Object3D,this.scaleNode=new THREE.Object3D,this.sceneRoot.add(this.translationNode),this.sceneRoot.add(this.rotationNode),this.sceneRoot.add(this.scaleNode),this.sceneRoot.visible=!1,this.hoveredElement=null,this.STATE={DEFAULT:0,TRANSLATE_X:1,TRANSLATE_Y:2,TRANSLATE_Z:3,SCALE_X:1,SCALE_Y:2,SCALE_Z:3},this.parts={ARROW_X:{name:"arrow_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.TRANSLATE_X},ARROW_Z:{name:"arrow_z",object:void 0,color:new THREE.Color(255),state:this.STATE.TRANSLATE_Z},ARROW_Y:{name:"arrow_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.TRANSLATE_Y},SCALE_X:{name:"scale_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.SCALE_X},SCALE_Z:{name:"scale_z",object:void 0,color:new THREE.Color(255),state:this.STATE.SCALE_Z},SCALE_Y:{name:"scale_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.SCALE_Y},ROTATE_X:{name:"rotate_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.ROTATE_X},ROTATE_Z:{name:"rotate_z",object:void 0,color:new THREE.Color(255),state:this.STATE.ROTATE_Z},ROTATE_Y:{name:"rotate_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.ROTATE_Y}},this.buildTranslationNode=function(){var e=a.createArrow(a.parts.ARROW_X,a.parts.ARROW_X.color);e.rotation.z=-Math.PI/2;var t=a.createArrow(a.parts.ARROW_Y,a.parts.ARROW_Y.color),i=a.createArrow(a.parts.ARROW_Z,a.parts.ARROW_Z.color);i.rotation.x=-Math.PI/2,this.translationNode.add(e),this.translationNode.add(t),this.translationNode.add(i)},this.buildScaleNode=function(){var e=this.createScaleHandle(a.parts.SCALE_X,16711680);e.rotation.z=-Math.PI/2;var t=this.createScaleHandle(a.parts.SCALE_Y,65280),i=this.createScaleHandle(a.parts.SCALE_Z,255);i.rotation.x=-Math.PI/2,this.scaleNode.add(e),this.scaleNode.add(t),this.scaleNode.add(i)},this.buildRotationNode=function(){var e=this.createRotationCircle(a.parts.ROTATE_X,16711680);e.rotation.y=-Math.PI/2;var t=this.createRotationCircle(a.parts.ROTATE_Y,65280),i=this.createRotationCircle(a.parts.ROTATE_Z,255);t.rotation.x=-Math.PI/2,this.rotationNode.add(e),this.rotationNode.add(t),this.rotationNode.add(i);var o=new THREE.SphereGeometry(2.9,24,24),n=new THREE.Mesh(o,new THREE.MeshBasicMaterial({color:11184810,transparent:!0,opacity:.4}));this.sceneRotation.add(n);var r=function(e){n.material.color.setHex(5592405)},s=function(e){n.material.color.setHex(11184810)},l=function(e){e.event.stopImmediatePropagation();for(var t=new THREE.Vector3(a.dragstart.mousePos.x,a.dragstart.mousePos.y,.1),i=new THREE.Vector3(a.mouse.x,a.mouse.y,.1),o=(new THREE.Vector3).subVectors(i,t),n=t.clone().unproject(a.camera),r=i.clone().unproject(a.camera),s=(new THREE.Vector3).subVectors(r,n),l=s.clone().normalize(),d=(new THREE.Vector3).subVectors(a.camera.position,n).normalize(),c=d.clone().cross(l),u=6*o.length(),h=0;h=n;n++){var r=2*Math.PI*n/o,s=3*Math.cos(r),l=3*Math.sin(r);i.push(new THREE.Vector3(s,l,0))}for(var d=new THREE.Geometry,n=0;nt;t++)n.label.children[t].updateMatrixWorld(!0)},this.setDimension=function(e,t,i){this.dimension.set(e,t,i),this.box.scale.set(e,t,i),this.frame.scale.set(e,t,i)},this.volume=function(){return Math.abs(this.scale.x*this.scale.y*this.scale.z)},this.update=function(){this.boundingBox=this.box.geometry.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this._clip?(this.box.visible=!1,this.label.visible=!1):(this.box.visible=!0,this.label.visible=!0)},this.raycast=function(e,t){var i=[];if(this.box.raycast(e,i),i.length>0){var o=i[0];t.push({distance:o.distance,object:this,point:o.point.clone()})}},this.update()},Potree.Volume.prototype=Object.create(THREE.Object3D.prototype),Object.defineProperty(Potree.Volume.prototype,"clip",{get:function(){return this._clip},set:function(e){this._clip=e,this.update()}}),Object.defineProperty(Potree.Volume.prototype,"modifiable",{get:function(){return this._modifiable},set:function(e){this._modifiable=e,this.update()}}),Potree.VolumeTool=function(e,t,i,o){function n(e){var t=c.domElement.getBoundingClientRect();c.mouse.x=(e.clientX-t.left)/c.domElement.clientWidth*2-1,c.mouse.y=2*-((e.clientY-t.top)/c.domElement.clientHeight)+1}function r(e){}function s(e){if(h!==u.DEFAULT&&e.stopImmediatePropagation(),h===u.INSERT_VOLUME)c.finishInsertion();else if(1===e.which){var t=l();t&&t.object.modifiable&&c.transformationTool.setTargets([t.object])}3===e.which}function a(e){return e.preventDefault(), -!1}function l(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=new THREE.Raycaster;t.ray.set(c.camera.position,e.sub(c.camera.position).normalize());for(var i=[],o=0;o0?r[0]:!1}function d(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null}var c=this;this.enabled=!1,this.scene=e,this.sceneVolume=new THREE.Scene,this.camera=t,this.renderer=i,this.transformationTool=o,this.domElement=this.renderer.domElement,this.mouse={x:0,y:0},this.volumes=[];var u={DEFAULT:0,INSERT_VOLUME:1},h=u.DEFAULT;this.update=function(e){if(h===u.INSERT_VOLUME){var t=d();if(t){this.activeVolume.position.copy(t);var i=this.activeVolume.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse),o=(new THREE.Vector4(i.x,i.y,i.z).applyMatrix4(this.camera.projectionMatrix),Math.abs(i.z/10));this.activeVolume.scale.set(o,o,o)}}for(var n=[],r=0;r=0&&this.volumes.splice(t,1)},this.reset=function(){for(var e=this.volumes.length-1;e>=0;e--){var t=this.volumes[e];this.removeVolume(t)}},this.render=function(e){c.renderer.render(this.sceneVolume,this.camera,e)},this.domElement.addEventListener("click",r,!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mousemove",n,!1),this.domElement.addEventListener("contextmenu",a,!1)},Potree.VolumeTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.PointCloudArena4DProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.pcoGeometry=e,this.boundingBox=e.boundingBox,this.boundingSphere=e.boundingSphere,this.number=e.name,this.numPoints=e.numPoints,this.level=e.level},Potree.PointCloudArena4DProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudArena4D=function(e){THREE.Object3D.call(this),this.root=null,this.visiblePointsTarget=2e6,this.minimumNodePixelSize=150,this.position.sub(e.offset),this.updateMatrix(),this.numVisibleNodes=0,this.numVisiblePoints=0,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleNodes=[],this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.boundingBox,this.boundingSphere=this.pcoGeometry.boundingSphere,this.material=new Potree.PointCloudMaterial({vertexColors:THREE.VertexColors,size:.05,treeType:Potree.TreeType.KDTREE}),this.material.sizeType=Potree.PointSizeType.ATTENUATED,this.material.size=.05,this.pickTarget,this.pickMaterial,this.updateMatrixWorld()},Potree.PointCloudArena4D.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudArena4D.prototype.updateMaterial=function(e,t){this.material.fov=e.fov*(Math.PI/180),this.material.screenWidth=t.domElement.clientWidth,this.material.screenHeight=t.domElement.clientHeight,this.material.spacing=this.pcoGeometry.spacing,this.material.near=e.near,this.material.far=e.far,this.maxLevel>this.material.levels&&(this.material.levels=this.maxLevel+2),this.material.minSize=3;var i=this.boundingBox.size();this.material.bbSize=[i.x,i.y,i.z]},Potree.PointCloudArena4D.prototype.hideDescendants=function(e){for(var t=[],i=0;i0;){var e=t.shift();e.visible=!1,e.boundingBoxNode&&(e.boundingBoxNode.visible=!1);for(var i=0;i0;){var v=f.shift(),g=v.node,E=v.weight;g.matrixWorld.multiplyMatrices(this.matrixWorld,g.matrix);var y=g.boundingBox.clone(),b=s.intersectsBox(y),T=b;if(g.visible=T,T){var R=0;if(8===R&&dbgFullyInside++,g instanceof Potree.PointCloudArena4DProxyNode){var P=g.geometryNode;P.loaded===!0?this.replaceProxy(g):this.loadQueue.push(v)}else if(g instanceof THREE.PointCloud){if(this.numVisiblePoints+g.pcoGeometry.numPoints>this.visiblePointsTarget)break;if(this.numVisibleNodes++,this.numVisiblePoints+=g.pcoGeometry.numPoints,this.visibleNodes.push({node:g,weight:E}),this.showBoundingBox&&!g.boundingBoxNode){var C=new THREE.BoxHelper(g);this.add(C),this.boundingBoxNodes.push(C),g.boundingBoxNode=C,g.boundingBoxNode.matrixWorld.copy(g.matrixWorld)}else this.showBoundingBox&&g.boundingBoxNode?g.boundingBoxNode.visible=!0:this.showBoundingBox||delete g.boundingBoxNode;for(var n=0;nH&&(A=Number.MAX_VALUE);var V=t.domElement.clientHeight*A;if(!(Vf[M].weight){var I=M;break}if(M==f.length-1){I=f.length;break}}f.splice(I,0,{node:x,weight:E})}}}}}}this.updateLoadQueue(),this.maxLevel=0;for(var n=0;n0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.weight-e.weight});for(var t=0;t0&&!(t.length>12);){var d=a.shift(),c=d.boundingBox.clone();c.max.sub(c.min),c.min.sub(c.min);var u=i.intersectsBox(c),h=u;if(h){if(l+d.numPoints>this.visiblePointsTarget)break;l+=d.numPoints,t.push(d),d.loaded&&(d.left&&a.push(d.left),d.right&&a.push(d.right))}}return t},Potree.PointCloudArena4D.prototype.nodesOnRay=function(e,t){for(var i=[],o=t.clone(),n=0;n0&&r.push(r[0]);for(var u=0;uP;P++)for(var C=0;n>C;C++){var x=P+C*n,w=Math.pow(P-(n-1)/2,2)+Math.pow(C-(n-1)/2,2),H=y[4*x+3];y[4*x+3]=0;var S=b[x];(0!==S||0!==H)&&T>w&&(R={pIndex:S,pcIndex:H},T=w)}if(R){var B={},A=r[R.pcIndex],V=A.geometry.attributes;for(var I in V)if(V.hasOwnProperty(I)){var M=A.geometry.attributes[I];if("position"===I){var L=A.geometry.attributes.position.array,W=L[3*R.pIndex+0],G=L[3*R.pIndex+1],N=L[3*R.pIndex+2],D=new THREE.Vector3(W,G,N);D.applyMatrix4(this.matrixWorld),B[I]=D}else if("indices"===I);else if(1===M.itemSize)B[I]=M.array[u+X];else{for(var O=[],X=0;Xn?-1:n>r?1:0};t.sort(n);for(var r=[],s=0;s0&&(l+=1,d=r.indexOf(a.pcoGeometry.left.number)-s),a.pcoGeometry.right&&r.indexOf(a.pcoGeometry.right.number)>0&&(l+=2,d=0===d?r.indexOf(a.pcoGeometry.right.number)-s:d),"X"===a.pcoGeometry.split?c=1:"Y"===a.pcoGeometry.split?c=2:"Z"===a.pcoGeometry.split&&(c=4),o[3*s+0]=l,o[3*s+1]=d,o[3*s+2]=c}i.needsUpdate=!0}},Object.defineProperty(Potree.PointCloudArena4D.prototype,"progress",{get:function(){return this.pcoGeometry.root?Potree.PointCloudArena4DGeometryNode.nodesLoading>0?0:1:0}}),Potree.PointCloudArena4DGeometryNode=function(){this.left=null,this.right=null,this.boundingBox=null,this.number=null,this.pcoGeometry=null,this.loaded=!1,this.numPoints=0,this.level=0},Potree.PointCloudArena4DGeometryNode.nodesLoading=0,Potree.PointCloudArena4DGeometryNode.prototype.load=function(){if(!(this.loaded||this.loading||Potree.PointCloudArena4DGeometryNode.nodesLoading>=5)){Potree.PointCloudArena4DGeometryNode.nodesLoading++;var e=this.pcoGeometry.url+"?node="+this.number,t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer";var i=this;t.onreadystatechange=function(){if(4===t.readyState&&200===t.status){for(var e=t.response,o=new DataView(e),n=e.byteLength/17,r=new Float32Array(3*n),s=new Float32Array(3*n),a=new Uint32Array(n),l=0;n>l;l++){var d=o.getFloat32(17*l+0,!0)+i.boundingBox.min.x,c=o.getFloat32(17*l+4,!0)+i.boundingBox.min.y,u=o.getFloat32(17*l+8,!0)+i.boundingBox.min.z,h=o.getUint8(17*l+12,!0)/256,p=o.getUint8(17*l+13,!0)/256,m=o.getUint8(17*l+14,!0)/256;r[3*l+0]=d,r[3*l+1]=c,r[3*l+2]=u,s[3*l+0]=h,s[3*l+1]=p,s[3*l+2]=m,a[l]=l}var f=new THREE.BufferGeometry;f.addAttribute("position",new THREE.BufferAttribute(r,3)),f.addAttribute("color",new THREE.BufferAttribute(s,3)),f.addAttribute("indices",new THREE.BufferAttribute(a,1)),f.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(3*n),3)),i.geometry=f,i.loaded=!0,Potree.PointCloudArena4DGeometryNode.nodesLoading--,f.boundingBox=i.boundingBox,f.boundingSphere=i.boundingSphere,i.numPoints=n}},t.send(null)}},Potree.PointCloudArena4DGeometry=function(){this.numPoints=0,this.version=0,this.boundingBox=null,this.numNodes=0,this.name=null,this.provider=null,this.url=null,this.root=null,this.levels=0,this._spacing=null,this.pointAttributes=new Potree.PointAttributes(["POSITION_CARTESIAN","COLOR_PACKED"])},Potree.PointCloudArena4DGeometry.load=function(e,t){var i=new XMLHttpRequest;i.open("GET",e+"?info",!0),i.onreadystatechange=function(){try{if(4===i.readyState&&200===i.status){var o=JSON.parse(i.responseText),n=new Potree.PointCloudArena4DGeometry;n.url=e,n.name=o.Name,n.provider=o.Provider,n.numNodes=o.Nodes,n.numPoints=o.Points,n.version=o.Version,n.boundingBox=new THREE.Box3((new THREE.Vector3).fromArray(o.BoundingBox.slice(0,3)),(new THREE.Vector3).fromArray(o.BoundingBox.slice(3,6))),o.Spacing&&(n.spacing=o.Spacing);var r=n.boundingBox.min.clone().multiplyScalar(-1);n.boundingBox.min.add(r),n.boundingBox.max.add(r),n.offset=r;var s=n.boundingBox.center(),a=n.boundingBox.size().length()/2;n.boundingSphere=new THREE.Sphere(s,a),n.loadHierarchy(),t(n)}else 4===i.readyState&&t(null)}catch(l){console.error(l.message),t(null)}},i.send(null)},Potree.PointCloudArena4DGeometry.prototype.loadHierarchy=function(){var e=this.url+"?tree",t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer";var i=this;t.onreadystatechange=function(){if(4===t.readyState&&200===t.status){for(var e=t.response,o=e.byteLength/3,n=new DataView(e),r=[],s=null,a=0,l=((new Date).getTime(),0);o>l;l++){var d=n.getUint8(3*l+0,!0),c=(n.getUint16(3*l+1,!0),(1&d)>0),u=(2&d)>0,h=(4&d)>0,p=(8&d)>0,m=(16&d)>0,f=null;h?f="X":p&&(f="Y"),m&&(f="Z");var v=new Potree.PointCloudArena4DGeometryNode;if(v.hasLeft=c,v.hasRight=u,v.split=f,v.isLeaf=!c&&!u,v.number=l,v.left=null,v.right=null,v.pcoGeometry=i,v.level=r.length,a=Math.max(a,v.level),r.length>0){var g=r[r.length-1];v.boundingBox=g.boundingBox.clone();var E=g.boundingBox.size();if(g.hasLeft&&!g.left){g.left=v,"X"===g.split?v.boundingBox.max.x=v.boundingBox.min.x+E.x/2:"Y"===g.split?v.boundingBox.max.y=v.boundingBox.min.y+E.y/2:"Z"===g.split&&(v.boundingBox.max.z=v.boundingBox.min.z+E.z/2);var y=v.boundingBox.center(),b=v.boundingBox.size().length()/2;v.boundingSphere=new THREE.Sphere(y,b)}else{g.right=v,"X"===g.split?v.boundingBox.min.x=v.boundingBox.min.x+E.x/2:"Y"===g.split?v.boundingBox.min.y=v.boundingBox.min.y+E.y/2:"Z"===g.split&&(v.boundingBox.min.z=v.boundingBox.min.z+E.z/2);var y=v.boundingBox.center(),b=v.boundingBox.size().length()/2;v.boundingSphere=new THREE.Sphere(y,b)}}else{s=v,s.boundingBox=i.boundingBox.clone();var y=s.boundingBox.center(),b=s.boundingBox.size().length()/2;s.boundingSphere=new THREE.Sphere(y,b)}var T=v.boundingBox.size();if(v.spacing=(T.x+T.y+T.z)/3/75,r.push(v),v.isLeaf)for(var R=!1;!R&&r.length>0;){r.pop();var P=r[r.length-1];R=r.length>0&&P.hasRight&&null==P.right}}(new Date).getTime();i.root=s,i.levels=a}},t.send(null)},Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype,"spacing",{get:function(){return this._spacing?this._spacing:this.root?this.root.spacing:void 0},set:function(e){this._spacing=e}}); \ No newline at end of file +}t.sort(function(e,t){return e.distance-t.distance})}},Potree.Measure.prototype=Object.create(THREE.Object3D.prototype),Object.defineProperty(Potree.Measure.prototype,"showArea",{get:function(){return this._showArea},set:function(e){this._showArea=e,this.update()}}),Object.defineProperty(Potree.Measure.prototype,"closed",{get:function(){return this._closed},set:function(e){this._closed=e,this.update()}}),Object.defineProperty(Potree.Measure.prototype,"showDistances",{get:function(){return this._showDistances},set:function(e){this._showDistances=e,this.update()}}),Potree.MeasuringTool=function(e,t,i){function o(e){if(h===u.INSERT){var t=c.getMousePointCloudIntersection();if(t){var i=t.clone();c.activeMeasurement.addMarker(i);var e={type:"newpoint",position:i.clone()};c.dispatchEvent(e),c.activeMeasurement.points.length>c.activeMeasurement.maxMarkers&&c.finishInsertion()}}}function n(e){var t=c.domElement.getBoundingClientRect();if(c.mouse.x=(e.clientX-t.left)/c.domElement.clientWidth*2-1,c.mouse.y=2*-((e.clientY-t.top)/c.domElement.clientHeight)+1,c.dragstart){var i={type:"drag",event:e,tool:c};c.dragstart.object.dispatchEvent(i)}else if(h==u.INSERT&&c.activeMeasurement){var o=c.getMousePointCloudIntersection();if(o){var n=c.activeMeasurement.points.length-1;c.activeMeasurement.setPosition(n,o)}}else{var o=d();o?(o.object.dispatchEvent({type:"move",target:o.object,event:e}),c.hoveredElement&&c.hoveredElement!==o.object&&c.hoveredElement.dispatchEvent({type:"leave",target:c.hoveredElement,event:e}),c.hoveredElement=o.object):(c.hoveredElement&&c.hoveredElement.dispatchEvent({type:"leave",target:c.hoveredElement,event:e}),c.hoveredElement=null)}}function r(e){h==u.INSERT&&c.finishInsertion()}function s(e){if(1===e.which){h!==u.DEFAULT&&e.stopImmediatePropagation();var t=d();t&&(c.dragstart={object:t.object,sceneClickPos:t.point,sceneStartPos:c.sceneRoot.position.clone(),mousePos:{x:c.mouse.x,y:c.mouse.y}},e.stopImmediatePropagation())}else 3===e.which&&r(e)}function a(e){window.getSelection?window.getSelection().removeAllRanges():document.selection&&document.selection.empty(),c.activeMeasurement&&h===u.INSERT&&(c.activeMeasurement.removeMarker(c.activeMeasurement.points.length-1),c.finishInsertion(),e.stopImmediatePropagation())}function l(e){c.dragstart&&(c.dragstart.object.dispatchEvent({type:"drop",event:e}),c.dragstart=null)}function d(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=new THREE.Raycaster;t.ray.set(c.camera.position,e.sub(c.camera.position).normalize());for(var i=[],o=0;o0?s[0]:!1}var c=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0};var u={DEFAULT:0,INSERT:1},h=u.DEFAULT;this.activeMeasurement=null,this.measurements=[],this.sceneMeasurement=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneMeasurement.add(this.sceneRoot),this.light=new THREE.DirectionalLight(16777215,1),this.light.position.set(0,0,10),this.light.lookAt(new THREE.Vector3(0,0,0)),this.sceneMeasurement.add(this.light),this.hoveredElement=null,this.getState=function(){return h},this.getMousePointCloudIntersection=function(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null},this.startInsertion=function(e){h=u.INSERT;var e=e||{},t="undefined"!=typeof e.showDistances?e.showDistances:!0,i="undefined"!=typeof e.showArea?e.showArea:!1,o="undefined"!=typeof e.showAngles?e.showAngles:!1,n="undefined"!=typeof e.closed?e.closed:!1,r=e.maxMarkers||Number.MAX_SAFE_INTEGER,s=new Potree.Measure;s.showDistances=t,s.showArea=i,s.showAngles=o,s.closed=n,s.maxMarkers=r,this.addMeasurement(s),s.addMarker(new THREE.Vector3(0,0,0)),this.activeMeasurement=s},this.finishInsertion=function(){this.activeMeasurement.removeMarker(this.activeMeasurement.points.length-1);var e={type:"insertion_finished",measurement:this.activeMeasurement};this.dispatchEvent(e),this.activeMeasurement=null,h=u.DEFAULT},this.addMeasurement=function(e){this.sceneMeasurement.add(e),this.measurements.push(e),this.dispatchEvent({type:"measurement_added",measurement:e}),e.addEventListener("marker_added",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_removed",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_moved",function(e){c.dispatchEvent(e)})},this.removeMeasurement=function(e){this.sceneMeasurement.remove(e);var t=this.measurements.indexOf(e);t>=0&&this.measurements.splice(t,1)},this.reset=function(){for(var e=this.measurements.length-1;e>=0;e--){var t=this.measurements[e];this.removeMeasurement(t)}},this.update=function(){for(var e=[],t=0;t1){var d=new THREE.Geometry;d.vertices.push(new THREE.Vector3,new THREE.Vector3),d.colors.push(i,i,i);var c=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linewidth:2,transparent:!0,opacity:.4});c.depthTest=!1;var u=new THREE.Line(d,c);u.visible=!1,this.add(u),this.edges.push(u);var h=new THREE.BoxGeometry(1,1,1),p=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.2}),m=new THREE.Mesh(h,p);m.visible=!1,this.add(m),this.boxes.push(m)}var f={type:"marker_added",profile:this};this.dispatchEvent(f),this.setPosition(this.points.length-1,e)},this.removeMarker=function(e){this.points.splice(e,1),this.remove(this.spheres[e]);var t=0===e?0:e-1;this.remove(this.edges[t]),this.edges.splice(t,1),this.remove(this.boxes[t]),this.boxes.splice(t,1),this.spheres.splice(e,1),this.update();var i={type:"marker_removed",profile:this};this.dispatchEvent(i)},this.getArea=function(){for(var e=0,t=this.points.length-1,i=0;i=r;r++){var e=this.points[r],s=this.spheres[r],a=0===r?n:r-1,l=r===n?0:r+1,d=this.points[a],c=this.points[l],u=this.edges[a],h=this.edges[r],p=this.boxes[a];this.boxes[r],e.distanceTo(d),e.distanceTo(c),(new THREE.Vector3).addVectors(d,e).multiplyScalar(.5),(new THREE.Vector3).addVectors(e,c).multiplyScalar(.5);if(s.position.copy(e),this._modifiable?s.visible=!0:s.visible=!1,u&&(u.geometry.vertices[1].copy(e),u.geometry.verticesNeedUpdate=!0,u.geometry.computeBoundingSphere()),h&&(h.geometry.vertices[0].copy(e),h.geometry.verticesNeedUpdate=!0,h.geometry.computeBoundingSphere()),p){var m=d,f=e,v=m.clone().setY(0).distanceTo(f.clone().setY(0));p.scale.set(v,this.height,this.width);var g=(new THREE.Vector3).addVectors(m,f).multiplyScalar(.5),E=(new THREE.Vector3).subVectors(f,m),y=new THREE.Vector3(E.z,0,-E.x);p.position.set(0,0,0),p.lookAt(y),p.position.copy(g)}o.add(e),t.min(e),i.max(e)}o.multiplyScalar(1/this.points.length);for(var r=0;r0?i[0]:!1}var c=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0};var u={DEFAULT:0,INSERT:1},h=u.DEFAULT;new THREE.SphereGeometry(.4,10,10);this.activeProfile=null,this.profiles=[],this.sceneProfile=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneProfile.add(this.sceneRoot),this.light=new THREE.DirectionalLight(16777215,1),this.light.position.set(0,0,10),this.light.lookAt(new THREE.Vector3(0,0,0)),this.sceneProfile.add(this.light),this.hoveredElement=null,this.getMousePointCloudIntersection=function(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null},this.startInsertion=function(e){h=u.INSERT;var e=e||{},t=e.clip||!1,i=e.width||1;return this.activeProfile=new Potree.HeightProfile,this.activeProfile.clip=t,this.activeProfile.setWidth(i),this.addProfile(this.activeProfile),this.activeProfile.addMarker(new THREE.Vector3(0,0,0)),this.activeProfile},this.finishInsertion=function(){this.activeProfile.removeMarker(this.activeProfile.points.length-1);var e={type:"insertion_finished",profile:this.activeProfile};this.dispatchEvent(e),this.activeProfile=null,h=u.DEFAULT},this.addProfile=function(e){this.profiles.push(e),this.sceneProfile.add(e),e.update(),this.dispatchEvent({type:"profile_added",profile:e}),e.addEventListener("marker_added",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_removed",function(e){c.dispatchEvent(e)}),e.addEventListener("marker_moved",function(e){c.dispatchEvent(e)})},this.removeProfile=function(e){this.sceneProfile.remove(e);var t=this.profiles.indexOf(e);t>=0&&this.profiles.splice(t,1),this.dispatchEvent({type:"profile_removed",profile:e})},this.reset=function(){for(var e=this.profiles.length-1;e>=0;e--){var t=this.profiles[e];this.removeProfile(t)}},this.update=function(){for(var e=0;e0?o[0]:!1}}var a=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=i,this.domElement=i.domElement,this.mouse={x:0,y:0},this.dragstart=null,this.sceneTransformation=new THREE.Scene,this.sceneRoot=new THREE.Object3D,this.sceneTransformation.add(this.sceneRoot),this.sceneRotation=new THREE.Scene,this.translationNode=new THREE.Object3D,this.rotationNode=new THREE.Object3D,this.scaleNode=new THREE.Object3D,this.sceneRoot.add(this.translationNode),this.sceneRoot.add(this.rotationNode),this.sceneRoot.add(this.scaleNode),this.sceneRoot.visible=!1,this.hoveredElement=null,this.STATE={DEFAULT:0,TRANSLATE_X:1,TRANSLATE_Y:2,TRANSLATE_Z:3,SCALE_X:1,SCALE_Y:2,SCALE_Z:3},this.parts={ARROW_X:{name:"arrow_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.TRANSLATE_X},ARROW_Z:{name:"arrow_z",object:void 0,color:new THREE.Color(255),state:this.STATE.TRANSLATE_Z},ARROW_Y:{name:"arrow_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.TRANSLATE_Y},SCALE_X:{name:"scale_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.SCALE_X},SCALE_Z:{name:"scale_z",object:void 0,color:new THREE.Color(255),state:this.STATE.SCALE_Z},SCALE_Y:{name:"scale_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.SCALE_Y},ROTATE_X:{name:"rotate_x",object:void 0,color:new THREE.Color(16711680),state:this.STATE.ROTATE_X},ROTATE_Z:{name:"rotate_z",object:void 0,color:new THREE.Color(255),state:this.STATE.ROTATE_Z},ROTATE_Y:{name:"rotate_y",object:void 0,color:new THREE.Color(65280),state:this.STATE.ROTATE_Y}},this.buildTranslationNode=function(){var e=a.createArrow(a.parts.ARROW_X,a.parts.ARROW_X.color);e.rotation.z=-Math.PI/2;var t=a.createArrow(a.parts.ARROW_Y,a.parts.ARROW_Y.color),i=a.createArrow(a.parts.ARROW_Z,a.parts.ARROW_Z.color);i.rotation.x=-Math.PI/2,this.translationNode.add(e),this.translationNode.add(t),this.translationNode.add(i)},this.buildScaleNode=function(){var e=this.createScaleHandle(a.parts.SCALE_X,16711680);e.rotation.z=-Math.PI/2;var t=this.createScaleHandle(a.parts.SCALE_Y,65280),i=this.createScaleHandle(a.parts.SCALE_Z,255);i.rotation.x=-Math.PI/2,this.scaleNode.add(e),this.scaleNode.add(t),this.scaleNode.add(i)},this.buildRotationNode=function(){var e=this.createRotationCircle(a.parts.ROTATE_X,16711680);e.rotation.y=-Math.PI/2;var t=this.createRotationCircle(a.parts.ROTATE_Y,65280),i=this.createRotationCircle(a.parts.ROTATE_Z,255);t.rotation.x=-Math.PI/2,this.rotationNode.add(e),this.rotationNode.add(t),this.rotationNode.add(i);var o=new THREE.SphereGeometry(2.9,24,24),n=new THREE.Mesh(o,new THREE.MeshBasicMaterial({color:11184810,transparent:!0,opacity:.4}));this.sceneRotation.add(n);var r=function(e){n.material.color.setHex(5592405)},s=function(e){n.material.color.setHex(11184810)},l=function(e){e.event.stopImmediatePropagation();for(var t=new THREE.Vector3(a.dragstart.mousePos.x,a.dragstart.mousePos.y,.1),i=new THREE.Vector3(a.mouse.x,a.mouse.y,.1),o=(new THREE.Vector3).subVectors(i,t),n=t.clone().unproject(a.camera),r=i.clone().unproject(a.camera),s=(new THREE.Vector3).subVectors(r,n),l=s.clone().normalize(),d=(new THREE.Vector3).subVectors(a.camera.position,n).normalize(),c=d.clone().cross(l),u=6*o.length(),h=0;h=n;n++){var r=2*Math.PI*n/o,s=3*Math.cos(r),l=3*Math.sin(r);i.push(new THREE.Vector3(s,l,0))}for(var d=new THREE.Geometry,n=0;nt;t++)n.label.children[t].updateMatrixWorld(!0)},this.setDimension=function(e,t,i){this.dimension.set(e,t,i),this.box.scale.set(e,t,i),this.frame.scale.set(e,t,i)},this.volume=function(){return Math.abs(this.scale.x*this.scale.y*this.scale.z)},this.update=function(){this.boundingBox=this.box.geometry.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this._clip?(this.box.visible=!1,this.label.visible=!1):(this.box.visible=!0,this.label.visible=!0)},this.raycast=function(e,t){var i=[];if(this.box.raycast(e,i),i.length>0){var o=i[0];t.push({distance:o.distance,object:this,point:o.point.clone()})}},this.update()},Potree.Volume.prototype=Object.create(THREE.Object3D.prototype),Object.defineProperty(Potree.Volume.prototype,"clip",{get:function(){return this._clip},set:function(e){this._clip=e,this.update()}}),Object.defineProperty(Potree.Volume.prototype,"modifiable",{get:function(){return this._modifiable},set:function(e){this._modifiable=e,this.update()}}),Potree.VolumeTool=function(e,t,i,o){function n(e){var t=c.domElement.getBoundingClientRect();c.mouse.x=(e.clientX-t.left)/c.domElement.clientWidth*2-1,c.mouse.y=2*-((e.clientY-t.top)/c.domElement.clientHeight)+1}function r(e){}function s(e){if(h!==u.DEFAULT&&e.stopImmediatePropagation(),h===u.INSERT_VOLUME)c.finishInsertion();else if(1===e.which){var t=l();t&&t.object.modifiable&&c.transformationTool.setTargets([t.object])}3===e.which; +}function a(e){return e.preventDefault(),!1}function l(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=new THREE.Raycaster;t.ray.set(c.camera.position,e.sub(c.camera.position).normalize());for(var i=[],o=0;o0?r[0]:!1}function d(){var e=new THREE.Vector3(c.mouse.x,c.mouse.y,.5);e.unproject(c.camera);var t=e.sub(c.camera.position).normalize(),i=new THREE.Ray(c.camera.position,t),o=[];c.scene.traverse(function(e){(e instanceof Potree.PointCloudOctree||e instanceof Potree.PointCloudArena4D)&&o.push(e)});for(var n=null,r=null,s=0;sd)&&(n=l,r=d)}}return n?n.position:null}var c=this;this.enabled=!1,this.scene=e,this.sceneVolume=new THREE.Scene,this.camera=t,this.renderer=i,this.transformationTool=o,this.domElement=this.renderer.domElement,this.mouse={x:0,y:0},this.volumes=[];var u={DEFAULT:0,INSERT_VOLUME:1},h=u.DEFAULT;this.update=function(e){if(h===u.INSERT_VOLUME){var t=d();if(t){this.activeVolume.position.copy(t);var i=this.activeVolume.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse),o=(new THREE.Vector4(i.x,i.y,i.z).applyMatrix4(this.camera.projectionMatrix),Math.abs(i.z/10));this.activeVolume.scale.set(o,o,o)}}for(var n=[],r=0;r=0&&this.volumes.splice(t,1)},this.reset=function(){for(var e=this.volumes.length-1;e>=0;e--){var t=this.volumes[e];this.removeVolume(t)}},this.render=function(e){c.renderer.render(this.sceneVolume,this.camera,e)},this.domElement.addEventListener("click",r,!1),this.domElement.addEventListener("mousedown",s,!1),this.domElement.addEventListener("mousemove",n,!1),this.domElement.addEventListener("contextmenu",a,!1)},Potree.VolumeTool.prototype=Object.create(THREE.EventDispatcher.prototype),Potree.PointCloudArena4DProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.pcoGeometry=e,this.boundingBox=e.boundingBox,this.boundingSphere=e.boundingSphere,this.number=e.name,this.numPoints=e.numPoints,this.level=e.level},Potree.PointCloudArena4DProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudArena4D=function(e){THREE.Object3D.call(this),this.root=null,this.visiblePointsTarget=2e6,this.minimumNodePixelSize=150,this.position.sub(e.offset),this.updateMatrix(),this.numVisibleNodes=0,this.numVisiblePoints=0,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleNodes=[],this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.boundingBox,this.boundingSphere=this.pcoGeometry.boundingSphere,this.material=new Potree.PointCloudMaterial({vertexColors:THREE.VertexColors,size:.05,treeType:Potree.TreeType.KDTREE}),this.material.sizeType=Potree.PointSizeType.ATTENUATED,this.material.size=.05,this.pickTarget,this.pickMaterial,this.updateMatrixWorld()},Potree.PointCloudArena4D.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudArena4D.prototype.updateMaterial=function(e,t){this.material.fov=e.fov*(Math.PI/180),this.material.screenWidth=t.domElement.clientWidth,this.material.screenHeight=t.domElement.clientHeight,this.material.spacing=this.pcoGeometry.spacing,this.material.near=e.near,this.material.far=e.far,this.maxLevel>this.material.levels&&(this.material.levels=this.maxLevel+2),this.material.minSize=3;var i=this.boundingBox.size();this.material.bbSize=[i.x,i.y,i.z]},Potree.PointCloudArena4D.prototype.hideDescendants=function(e){for(var t=[],i=0;i0;){var e=t.shift();e.visible=!1,e.boundingBoxNode&&(e.boundingBoxNode.visible=!1);for(var i=0;i0;){var v=f.shift(),g=v.node,E=v.weight;g.matrixWorld.multiplyMatrices(this.matrixWorld,g.matrix);var y=g.boundingBox.clone(),b=s.intersectsBox(y),T=b;if(g.visible=T,T){var R=0;if(8===R&&dbgFullyInside++,g instanceof Potree.PointCloudArena4DProxyNode){var P=g.geometryNode;P.loaded===!0?this.replaceProxy(g):this.loadQueue.push(v)}else if(g instanceof THREE.PointCloud){if(this.numVisiblePoints+g.pcoGeometry.numPoints>this.visiblePointsTarget)break;if(this.numVisibleNodes++,this.numVisiblePoints+=g.pcoGeometry.numPoints,this.visibleNodes.push({node:g,weight:E}),this.showBoundingBox&&!g.boundingBoxNode){var C=new THREE.BoxHelper(g);this.add(C),this.boundingBoxNodes.push(C),g.boundingBoxNode=C,g.boundingBoxNode.matrixWorld.copy(g.matrixWorld)}else this.showBoundingBox&&g.boundingBoxNode?g.boundingBoxNode.visible=!0:this.showBoundingBox||delete g.boundingBoxNode;for(var n=0;nH&&(A=Number.MAX_VALUE);var V=t.domElement.clientHeight*A;if(!(Vf[M].weight){var I=M;break}if(M==f.length-1){I=f.length;break}}f.splice(I,0,{node:x,weight:E})}}}}}}this.updateLoadQueue(),this.maxLevel=0;for(var n=0;n0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.weight-e.weight});for(var t=0;t0&&!(t.length>12);){var d=a.shift(),c=d.boundingBox.clone();c.max.sub(c.min),c.min.sub(c.min);var u=i.intersectsBox(c),h=u;if(h){if(l+d.numPoints>this.visiblePointsTarget)break;l+=d.numPoints,t.push(d),d.loaded&&(d.left&&a.push(d.left),d.right&&a.push(d.right))}}return t},Potree.PointCloudArena4D.prototype.nodesOnRay=function(e,t){for(var i=[],o=t.clone(),n=0;n0&&r.push(r[0]);for(var u=0;uP;P++)for(var C=0;n>C;C++){var x=P+C*n,w=Math.pow(P-(n-1)/2,2)+Math.pow(C-(n-1)/2,2),H=y[4*x+3];y[4*x+3]=0;var S=b[x];(0!==S||0!==H)&&T>w&&(R={pIndex:S,pcIndex:H},T=w)}if(R){var B={},A=r[R.pcIndex],V=A.geometry.attributes;for(var I in V)if(V.hasOwnProperty(I)){var M=A.geometry.attributes[I];if("position"===I){var L=A.geometry.attributes.position.array,W=L[3*R.pIndex+0],G=L[3*R.pIndex+1],N=L[3*R.pIndex+2],D=new THREE.Vector3(W,G,N);D.applyMatrix4(this.matrixWorld),B[I]=D}else if("indices"===I);else if(1===M.itemSize)B[I]=M.array[u+X];else{for(var O=[],X=0;Xn?-1:n>r?1:0};t.sort(n);for(var r=[],s=0;s0&&(l+=1,d=r.indexOf(a.pcoGeometry.left.number)-s),a.pcoGeometry.right&&r.indexOf(a.pcoGeometry.right.number)>0&&(l+=2,d=0===d?r.indexOf(a.pcoGeometry.right.number)-s:d),"X"===a.pcoGeometry.split?c=1:"Y"===a.pcoGeometry.split?c=2:"Z"===a.pcoGeometry.split&&(c=4),o[3*s+0]=l,o[3*s+1]=d,o[3*s+2]=c}i.needsUpdate=!0}},Object.defineProperty(Potree.PointCloudArena4D.prototype,"progress",{get:function(){return this.pcoGeometry.root?Potree.PointCloudArena4DGeometryNode.nodesLoading>0?0:1:0}}),Potree.PointCloudArena4DGeometryNode=function(){this.left=null,this.right=null,this.boundingBox=null,this.number=null,this.pcoGeometry=null,this.loaded=!1,this.numPoints=0,this.level=0},Potree.PointCloudArena4DGeometryNode.nodesLoading=0,Potree.PointCloudArena4DGeometryNode.prototype.load=function(){if(!(this.loaded||this.loading||Potree.PointCloudArena4DGeometryNode.nodesLoading>=5)){Potree.PointCloudArena4DGeometryNode.nodesLoading++;var e=this.pcoGeometry.url+"?node="+this.number,t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer";var i=this;t.onreadystatechange=function(){if(4===t.readyState&&200===t.status){for(var e=t.response,o=new DataView(e),n=e.byteLength/17,r=new Float32Array(3*n),s=new Float32Array(3*n),a=new Uint32Array(n),l=0;n>l;l++){var d=o.getFloat32(17*l+0,!0)+i.boundingBox.min.x,c=o.getFloat32(17*l+4,!0)+i.boundingBox.min.y,u=o.getFloat32(17*l+8,!0)+i.boundingBox.min.z,h=o.getUint8(17*l+12,!0)/256,p=o.getUint8(17*l+13,!0)/256,m=o.getUint8(17*l+14,!0)/256;r[3*l+0]=d,r[3*l+1]=c,r[3*l+2]=u,s[3*l+0]=h,s[3*l+1]=p,s[3*l+2]=m,a[l]=l}var f=new THREE.BufferGeometry;f.addAttribute("position",new THREE.BufferAttribute(r,3)),f.addAttribute("color",new THREE.BufferAttribute(s,3)),f.addAttribute("indices",new THREE.BufferAttribute(a,1)),f.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(3*n),3)),i.geometry=f,i.loaded=!0,Potree.PointCloudArena4DGeometryNode.nodesLoading--,f.boundingBox=i.boundingBox,f.boundingSphere=i.boundingSphere,i.numPoints=n}},t.send(null)}},Potree.PointCloudArena4DGeometry=function(){this.numPoints=0,this.version=0,this.boundingBox=null,this.numNodes=0,this.name=null,this.provider=null,this.url=null,this.root=null,this.levels=0,this._spacing=null,this.pointAttributes=new Potree.PointAttributes(["POSITION_CARTESIAN","COLOR_PACKED"])},Potree.PointCloudArena4DGeometry.load=function(e,t){var i=new XMLHttpRequest;i.open("GET",e+"?info",!0),i.onreadystatechange=function(){try{if(4===i.readyState&&200===i.status){var o=JSON.parse(i.responseText),n=new Potree.PointCloudArena4DGeometry;n.url=e,n.name=o.Name,n.provider=o.Provider,n.numNodes=o.Nodes,n.numPoints=o.Points,n.version=o.Version,n.boundingBox=new THREE.Box3((new THREE.Vector3).fromArray(o.BoundingBox.slice(0,3)),(new THREE.Vector3).fromArray(o.BoundingBox.slice(3,6))),o.Spacing&&(n.spacing=o.Spacing);var r=n.boundingBox.min.clone().multiplyScalar(-1);n.boundingBox.min.add(r),n.boundingBox.max.add(r),n.offset=r;var s=n.boundingBox.center(),a=n.boundingBox.size().length()/2;n.boundingSphere=new THREE.Sphere(s,a),n.loadHierarchy(),t(n)}else 4===i.readyState&&t(null)}catch(l){console.error(l.message),t(null)}},i.send(null)},Potree.PointCloudArena4DGeometry.prototype.loadHierarchy=function(){var e=this.url+"?tree",t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer";var i=this;t.onreadystatechange=function(){if(4===t.readyState&&200===t.status){for(var e=t.response,o=e.byteLength/3,n=new DataView(e),r=[],s=null,a=0,l=((new Date).getTime(),0);o>l;l++){var d=n.getUint8(3*l+0,!0),c=(n.getUint16(3*l+1,!0),(1&d)>0),u=(2&d)>0,h=(4&d)>0,p=(8&d)>0,m=(16&d)>0,f=null;h?f="X":p&&(f="Y"),m&&(f="Z");var v=new Potree.PointCloudArena4DGeometryNode;if(v.hasLeft=c,v.hasRight=u,v.split=f,v.isLeaf=!c&&!u,v.number=l,v.left=null,v.right=null,v.pcoGeometry=i,v.level=r.length,a=Math.max(a,v.level),r.length>0){var g=r[r.length-1];v.boundingBox=g.boundingBox.clone();var E=g.boundingBox.size();if(g.hasLeft&&!g.left){g.left=v,"X"===g.split?v.boundingBox.max.x=v.boundingBox.min.x+E.x/2:"Y"===g.split?v.boundingBox.max.y=v.boundingBox.min.y+E.y/2:"Z"===g.split&&(v.boundingBox.max.z=v.boundingBox.min.z+E.z/2);var y=v.boundingBox.center(),b=v.boundingBox.size().length()/2;v.boundingSphere=new THREE.Sphere(y,b)}else{g.right=v,"X"===g.split?v.boundingBox.min.x=v.boundingBox.min.x+E.x/2:"Y"===g.split?v.boundingBox.min.y=v.boundingBox.min.y+E.y/2:"Z"===g.split&&(v.boundingBox.min.z=v.boundingBox.min.z+E.z/2);var y=v.boundingBox.center(),b=v.boundingBox.size().length()/2;v.boundingSphere=new THREE.Sphere(y,b)}}else{s=v,s.boundingBox=i.boundingBox.clone();var y=s.boundingBox.center(),b=s.boundingBox.size().length()/2;s.boundingSphere=new THREE.Sphere(y,b)}var T=v.boundingBox.size();if(v.spacing=(T.x+T.y+T.z)/3/75,r.push(v),v.isLeaf)for(var R=!1;!R&&r.length>0;){r.pop();var P=r[r.length-1];R=r.length>0&&P.hasRight&&null==P.right}}(new Date).getTime();i.root=s,i.levels=a}},t.send(null)},Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype,"spacing",{get:function(){return this._spacing?this._spacing:this.root?this.root.spacing:void 0},set:function(e){this._spacing=e}}); \ No newline at end of file diff --git a/src/utils/MeasuringTool.js b/src/utils/MeasuringTool.js index 64dcf9ec..2d71dfe4 100644 --- a/src/utils/MeasuringTool.js +++ b/src/utils/MeasuringTool.js @@ -474,6 +474,7 @@ Potree.MeasuringTool = function(scene, camera, renderer){ if(scope.activeMeasurement && state === STATE.INSERT){ scope.activeMeasurement.removeMarker(scope.activeMeasurement.points.length-1); scope.finishInsertion(); + event.stopImmediatePropagation(); } } diff --git a/src/utils/ProfileTool.js b/src/utils/ProfileTool.js index 4673db7d..b11c882f 100644 --- a/src/utils/ProfileTool.js +++ b/src/utils/ProfileTool.js @@ -494,6 +494,7 @@ Potree.ProfileTool = function(scene, camera, renderer){ if(scope.activeProfile && state === STATE.INSERT){ scope.activeProfile.removeMarker(scope.activeProfile.points.length-1); scope.finishInsertion(); + event.stopImmediatePropagation(); } }