From 0616d3f1b8f46ce4bc4a98f8e60b34127078cf79 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Tue, 30 Dec 2014 23:48:33 +0100 Subject: [PATCH] updated builds --- build/js/potree.js | 2 +- build/js/potree.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build/js/potree.js b/build/js/potree.js index b23d2575..944926b0 100644 --- a/build/js/potree.js +++ b/build/js/potree.js @@ -2285,7 +2285,7 @@ Potree.PointCloudOctree.prototype.update = function(camera, renderer){ this.material.fov = camera.fov * (Math.PI / 180); this.material.screenWidth = renderer.domElement.clientWidth; this.material.screenHeight = renderer.domElement.clientHeight; - this.material.spacing = pointcloud.pcoGeometry.spacing; + this.material.spacing = this.pcoGeometry.spacing; this.material.near = camera.near; this.material.far = camera.far; diff --git a/build/js/potree.min.js b/build/js/potree.min.js index 5b20a1ef..c4957637 100644 --- a/build/js/potree.min.js +++ b/build/js/potree.min.js @@ -1,4 +1,4 @@ function Potree(){}function POCLoader(){}function PointAttributeNames(){}function PointAttribute(e,t,o){this.name=e,this.type=t,this.numElements=o,this.byteSize=this.numElements*this.type.size}function PointAttributes(e){if(this.attributes=new Array,this.byteSize=0,this.size=0,null!=e)for(var t in e){var o=e[t];this.attributes.push(o),this.byteSize+=o.byteSize,this.size++}}function LRUItem(e){this.previous=null,this.next=null,this.node=e}function LRU(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}Potree.pointLoadLimit=5e7,Potree.workers={},Potree.WorkerManager=function(e){this.code=e,this.instances=[],this.createdInstances=0},Potree.WorkerManager.prototype.getWorker=function(){var e=this.instances.pop();return void 0===e&&(e=Potree.utils.createWorker(this.code),this.createdInstances++),e},Potree.WorkerManager.prototype.returnWorker=function(e){this.instances.push(e)},Potree.WorkerManager.fromUrls=function(e){for(var t="",o=0;ou;u++)this.version.newerThan("1.3")?(r[3*u+0]=c[4*u+0]*this.scale+e.boundingBox.min.x,r[3*u+1]=c[4*u+1]*this.scale+e.boundingBox.min.y,r[3*u+2]=c[4*u+2]*this.scale+e.boundingBox.min.z):(r[3*u+0]=l[4*u+0]+e.pcoGeometry.offset.x,r[3*u+1]=l[4*u+1]+e.pcoGeometry.offset.y,r[3*u+2]=l[4*u+2]+e.pcoGeometry.offset.z),a.setRGB(d[16*u+12],d[16*u+13],d[16*u+14]),n[3*u+0]=a.r/255,n[3*u+1]=a.g/255,n[3*u+2]=a.b/255,h[u]=u;o.addAttribute("position",new THREE.BufferAttribute(r,3)),o.addAttribute("color",new THREE.BufferAttribute(n,3)),o.addAttribute("indices",new THREE.BufferAttribute(s,1)),o.boundingBox=e.boundingBox,e.geometry=o,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--},Potree.LasLazLoader=function(e){this.version="string"==typeof e?new Potree.Version(e):e},Potree.LasLazLoader.prototype.load=function(e){if(!e.loaded){var t=e.pcoGeometry.pointAttributes,o=e.pcoGeometry.octreeDir+"/"+e.name+"."+t.toLowerCase(),i=this,r=new XMLHttpRequest;r.open("GET",o,!0),r.responseType="arraybuffer",r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status){var t=r.response;i.parse(e,t)}else console.log("Failed to load file! HTTP status: "+r.status+", file: "+o)},r.send(null)}},Potree.LasLazLoader.progressCB=function(){},Potree.LasLazLoader.prototype.parse=function(e,t){var o=new LASFile(t),i=new Potree.LasLazBatcher(e);return Promise.resolve(o).cancellable().then(function(e){return e.open().then(function(){return e.isOpen=!0,e}).catch(Promise.CancellationError,function(t){return e.close().then(function(){throw t})})}).then(function(e){return e.getHeader().then(function(t){return[e,t]})}).then(function(e){var t=e[0],o=e[1],r=1,n=0,s=1>=r?o.pointsCount:o.pointsCount/r,a=function(){var e=t.readData(1e6,0,r);return e.then(function(e){return i.push(new LASDecoder(e.buffer,o.pointsFormatId,o.pointsStructSize,e.count,o.scale,o.offset,o.mins,o.maxs)),n+=e.count,Potree.LasLazLoader.progressCB(n/s),e.hasMoreData?a():(o.totalRead=n,o.versionAsString=t.versionAsString,o.isCompressed=t.isCompressed,[t,o,i])})};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(o.isOpen)return o.close().then(function(){throw o.isOpen=!1,e});throw e})},Potree.LasLazLoader.prototype.handle=function(){},Potree.LasLazBatcher=function(e){this.push=function(t){var o=Potree.workers.lasdecoder.getWorker(),i=new THREE.Vector3(t.mins[0],t.mins[1],t.mins[2]),r=new THREE.Vector3(t.maxs[0],t.maxs[1],t.maxs[2]);i.add(e.pcoGeometry.offset),r.add(e.pcoGeometry.offset),o.onmessage=function(n){for(var s=new THREE.BufferGeometry,a=t.pointsCount,l=n.data.position,c=n.data.color,d=n.data.intensity,h=new Uint8Array(n.data.classification),u=new Float32Array(h.byteLength),p=new Uint8Array(n.data.returnNumber),m=new Float32Array(p.byteLength),v=new Uint16Array(n.data.pointSourceID),f=new Float32Array(v.length),E=new ArrayBuffer(4*a),y=new Uint32Array(E),g=new THREE.Box3,T=new Float32Array(l),b=0;a>b;b++)u[b]=h[b],m[b]=p[b],f[b]=v[b],y[b]=b,g.expandByPoint(new THREE.Vector3(T[3*b+0],T[3*b+1],T[3*b+2]));s.addAttribute("position",new THREE.BufferAttribute(new Float32Array(l),3)),s.addAttribute("color",new THREE.BufferAttribute(new Float32Array(c),3)),s.addAttribute("intensity",new THREE.BufferAttribute(new Float32Array(d),1)),s.addAttribute("classification",new THREE.BufferAttribute(new Float32Array(u),1)),s.addAttribute("returnNumber",new THREE.BufferAttribute(new Float32Array(m),1)),s.addAttribute("pointSourceID",new THREE.BufferAttribute(new Float32Array(f),1)),s.addAttribute("indices",new THREE.BufferAttribute(E,1)),s.boundingBox=new THREE.Box3(i,r),e.boundingBox=s.boundingBox,e.geometry=s,e.loaded=!0,e.loading=!1,e.pcoGeometry.numNodesLoading--,Potree.workers.lasdecoder.returnWorker(o)};var n={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]};o.postMessage(n,[n.buffer])}},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,OCTREE_DEPTH:6,POINT_INDEX:7,CLASSIFICATION:8,RETURN_NUMBER:9,SOURCE:10},Potree.ClipMode={DISABLED:0,CLIP_OUTSIDE:1,HIGHLIGHT_INSIDE:2},Potree.PointCloudMaterial=function(e){e=e||{};var t=new THREE.Color(0),o=THREE.ImageUtils.generateDataTexture(2048,1,t);o.magFilter=THREE.NearestFilter,this.visibleNodesTexture=o;var i=e.size||1,r=e.minSize||1,n=1;this._pointSizeType=Potree.PointSizeType.ATTENUATED,this._pointShape=Potree.PointShape.SQUARE,this._interpolate=!1,this._pointColorType=Potree.PointColorType.RGB,this._octreeLevels=6,this._useClipBox=!1,this.numClipBoxes=0,this._clipMode=Potree.ClipMode.DISABLED,this._weighted=!1,this._blendDepth=.1,this._depthMap,this.gradientTexture=Potree.PointCloudMaterial.generateGradient();var s={},a={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(16711680)},opacity:{type:"f",value:1},size:{type:"f",value:10},minSize:{type:"f",value:2},nodeSize:{type:"f",value:n},heightMin:{type:"f",value:0},heightMax:{type:"f",value:1},intensityMin:{type:"f",value:0},intensityMax:{type:"f",value:1},visibleNodes:{type:"t",value:this.visibleNodesTexture},pcIndex:{type:"f",value:0},gradient:{type:"t",value:this.gradientTexture},clipBoxes:{type:"Matrix4fv",value:[]},blendDepth:{type:"f",value:this._blendDepth},depthMap:{type:"t",value:null}};this.setValues({uniforms:a,attributes:s,vertexShader:this.getDefines()+Potree.PointCloudMaterial.vs_points.join("\n"),fragmentShader:this.getDefines()+Potree.PointCloudMaterial.fs_points_rgb.join("\n"),vertexColors:THREE.VertexColors,size:i,minSize:r,nodeSize:n,pcIndex:0,alphaTest:.9})},Potree.PointCloudMaterial.prototype=new THREE.RawShaderMaterial,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?e.classification={type:"f",value:[]}:this.pointColorType===Potree.PointColorType.RETURN_NUMBER?e.returnNumber={type:"f",value:[]}:this.pointColorType===Potree.PointColorType.SOURCE&&(e.pointSourceID={type:"f",value:[]}),this.setValues({attributes:e,vertexShader:this.getDefines()+Potree.PointCloudMaterial.vs_points.join("\n"),fragmentShader:this.getDefines()+Potree.PointCloudMaterial.fs_points_rgb.join("\n")}),this.depthMap&&(this.uniforms.depthMap.value=this.depthMap,this.setValues({depthMap:this.depthMap})),this.setValues(1===this.opacity?{blending:THREE.NoBlending,transparent:!1,depthTest:!0,depthWrite:!0}:{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",e+="#define octreeLevels "+Math.max(0,this._octreeLevels-2).toFixed(1)+"\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._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.OCTREE_DEPTH?e+="#define color_type_octree_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.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.weighted&&(e+="#define weighted_splats\n"),this.numClipBoxes>0&&(e+="#define use_clip_box\n",e+="#define clip_box_count "+this.numClipBoxes+"\n"),e},Potree.PointCloudMaterial.prototype.setClipBoxes=function(e){var t=e.length;this.numClipBoxes=t,this.uniforms.clipBoxes.value.length/16!==t&&(this.uniforms.clipBoxes.value=new Float32Array(16*t),this.updateShaderSource());for(var o=0;t>o;o++){var i=e[o];this.uniforms.clipBoxes.value.set(i.elements,16*o)}},Object.defineProperty(Potree.PointCloudMaterial.prototype,"spacing",{get:function(){return this.uniforms.spacing.value},set:function(e){this.uniforms.spacing.value!==e&&(this.uniforms.spacing.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"blendDepth",{get:function(){return this.uniforms.blendDepth.value},set:function(e){this.uniforms.blendDepth.value!==e&&(this.uniforms.blendDepth.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"useClipBox",{get:function(){return this._useClipBox},set:function(e){this._useClipBox!==e&&(this._useClipBox=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"weighted",{get:function(){return this._weighted},set:function(e){this._weighted!==e&&(this._weighted=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"fov",{get:function(){return this.uniforms.fov.value},set:function(e){this.uniforms.fov.value!==e&&(this.uniforms.fov.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"screenWidth",{get:function(){return this.uniforms.screenWidth.value},set:function(e){this.uniforms.screenWidth.value!==e&&(this.uniforms.screenWidth.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"screenHeight",{get:function(){return this.uniforms.screenHeight.value},set:function(e){this.uniforms.screenHeight.value!==e&&(this.uniforms.screenHeight.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"near",{get:function(){return this.uniforms.near.value},set:function(e){this.uniforms.near.value!==e&&(this.uniforms.near.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"far",{get:function(){return this.uniforms.far.value},set:function(e){this.uniforms.far.value!==e&&(this.uniforms.far.value=e)}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"opacity",{get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value!==e&&(this.uniforms.opacity.value=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"octreeLevels",{get:function(){return this._octreeLevels},set:function(e){this._octreeLevels!==e&&(this._octreeLevels=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"pointColorType",{get:function(){return this._pointColorType},set:function(e){this._pointColorType!==e&&(this._pointColorType=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"depthMap",{get:function(){return this._depthMap},set:function(e){this._depthMap!==e&&(this._depthMap=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"pointSizeType",{get:function(){return this._pointSizeType},set:function(e){this._pointSizeType!==e&&(this._pointSizeType=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"clipMode",{get:function(){return this._clipMode},set:function(e){this._clipMode!==e&&(this._clipMode=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"interpolate",{get:function(){return this._interpolate},set:function(e){this._interpolate!==e&&(this._interpolate=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"color",{get:function(){return this.uniforms.uColor.value},set:function(e){this.uniforms.uColor.value!==e&&(this.uniforms.uColor.value.copy(e),this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"pointShape",{get:function(){return this._pointShape},set:function(e){this._pointShape!==e&&(this._pointShape=e,this.updateShaderSource())}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"size",{get:function(){return this.uniforms.size.value},set:function(e){this.uniforms.size.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"minSize",{get:function(){return this.uniforms.minSize.value},set:function(e){this.uniforms.minSize.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"heightMin",{get:function(){return this.uniforms.heightMin.value},set:function(e){this.uniforms.heightMin.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"heightMax",{get:function(){return this.uniforms.heightMax.value},set:function(e){this.uniforms.heightMax.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"intensityMin",{get:function(){return this.uniforms.intensityMin.value},set:function(e){this.uniforms.intensityMin.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"intensityMax",{get:function(){return this.uniforms.intensityMax.value},set:function(e){this.uniforms.intensityMax.value=e}}),Object.defineProperty(Potree.PointCloudMaterial.prototype,"pcIndex",{get:function(){return this.uniforms.pcIndex.value},set:function(e){this.uniforms.pcIndex.value=e}}),Potree.PointCloudMaterial.generateGradient=function(){var e=64;canvas=document.createElement("canvas"),canvas.width=e,canvas.height=e;var t=canvas.getContext("2d");t.rect(0,0,e,e);var o=t.createLinearGradient(0,0,e,e);o.addColorStop(0,"#4700b6"),o.addColorStop(1/6,"blue"),o.addColorStop(2/6,"aqua"),o.addColorStop(.5,"green"),o.addColorStop(4/6,"yellow"),o.addColorStop(5/6,"orange"),o.addColorStop(1,"red"),t.fillStyle=o,t.fill();var i=new THREE.Texture(canvas);return i.needsUpdate=!0,textureImage=i.image,i},Potree.PointCloudMaterial.vs_points=["precision mediump float; ","precision mediump int; "," ","attribute vec3 position; ","attribute vec3 color; ","attribute float intensity; ","attribute float classification; ","attribute float returnNumber; ","attribute float pointSourceID; ","attribute vec4 indices; "," ","uniform mat4 modelMatrix; ","uniform mat4 modelViewMatrix; ","uniform mat4 projectionMatrix; ","uniform mat4 viewMatrix; ","uniform mat3 normalMatrix; ","uniform vec3 cameraPosition; ","uniform float screenWidth; ","uniform float screenHeight; ","uniform float fov; ","uniform float spacing; ","uniform float blendDepth; ","uniform float near; ","uniform float far; "," ","#if defined use_clip_box "," uniform mat4 clipBoxes[clip_box_count]; ","#endif "," "," ","uniform float heightMin; ","uniform float heightMax; ","uniform float intensityMin; ","uniform float intensityMax; ","uniform float size; ","uniform float minSize; ","uniform float nodeSize; ","uniform vec3 uColor; ","uniform float opacity; "," "," ","uniform sampler2D visibleNodes; ","uniform sampler2D gradient; ","uniform sampler2D depthMap; "," ","varying float vOpacity; ","varying vec3 vColor; ","varying float vDepth; ","varying float vLinearDepth; "," "," ","#if defined(adaptive_point_size) || defined(color_type_octree_depth) ","/** "," * number of 1-bits up to inclusive index position "," * number is treated as if it were an integer in the range 0-255 "," * "," */ ","float numberOfOnes(float number, float index){ "," float tmp = mod(number, pow(2.0, index + 1.0)); "," float numOnes = 0.0; "," for(float i = 0.0; i < 8.0; i++){ "," if(mod(tmp, 2.0) != 0.0){ "," numOnes++; "," } "," tmp = floor(tmp / 2.0); "," } "," return numOnes; ","} "," "," ","/** "," * checks whether the bit at index is 1 "," * number is treated as if it were an integer in the range 0-255 "," * "," */ ","bool isBitSet(float number, float index){ "," return mod(floor(number / pow(2.0, index)), 2.0) != 0.0; ","} "," "," ","/** "," * find the octree depth at the point position "," */ ","float getOctreeDepth(){ "," vec3 offset = vec3(0.0, 0.0, 0.0); "," float iOffset = 0.0; "," float depth = 0.0; "," for(float i = 0.0; i <= octreeLevels + 1.0; i++){ "," "," float nodeSizeAtLevel = nodeSize / pow(2.0, i); "," vec3 index3d = (position - offset) / nodeSizeAtLevel; "," index3d = floor(index3d + 0.5); "," float index = 4.0*index3d.x + 2.0*index3d.y + index3d.z; "," "," vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0)); "," float mask = value.r * 255.0; "," if(isBitSet(mask, index)){ "," // there are more visible child nodes at this position "," iOffset = iOffset + value.g * 255.0 + numberOfOnes(mask, index - 1.0); "," depth++; "," }else{ "," // no more visible child nodes at this position "," return depth; "," } "," offset = offset + (vec3(1.0, 1.0, 1.0) * nodeSizeAtLevel * 0.5) * index3d; "," } "," "," return depth; ","} "," ","#endif "," ","vec3 classificationColor(float classification){ "," vec3 color = vec3(0.0, 0.0, 0.0); "," float c = mod(classification, 16.0); "," if(c == 0.0){ "," color = vec3(0.5, 0.5, 0.5); "," }else if(c == 1.0){ "," color = vec3(0.5, 0.5, 0.5); "," }else if(c == 2.0){ "," color = vec3(0.63, 0.32, 0.18); "," }else if(c == 3.0){ "," color = vec3(0.0, 1.0, 0.0); "," }else if(c == 4.0){ "," color = vec3(0.0, 0.8, 0.0); "," }else if(c == 5.0){ "," color = vec3(0.0, 0.6, 0.0); "," }else if(c == 6.0){ "," color = vec3(1.0, 0.66, 0.0); "," }else if(c == 7.0){ "," color = vec3(1.0, 0, 1.0); "," }else if(c == 8.0){ "," color = vec3(1.0, 0, 0.0); "," }else if(c == 9.0){ "," color = vec3(0.0, 0.0, 1.0); "," }else if(c == 12.0){ "," color = vec3(1.0, 1.0, 0.0); "," }else{ "," color = vec3(0.3, 0.6, 0.6); "," } "," "," return color; ","} "," ","void main() { "," "," vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); "," gl_Position = projectionMatrix * mvPosition; "," //float pw = gl_Position.w; "," //float pd = gl_Position.z; "," //gl_Position = gl_Position / pw; "," //gl_Position.z = 2.0*((pw - near) / far)-1.0; "," vOpacity = opacity; "," vLinearDepth = -mvPosition.z; "," vDepth = mvPosition.z / gl_Position.w; "," "," // COLOR TYPES "," "," #ifdef color_type_rgb "," vColor = color; "," #elif defined color_type_height "," vec4 world = modelMatrix * vec4( position, 1.0 ); "," float w = (world.y - heightMin) / (heightMax-heightMin); "," "," vColor = texture2D(gradient, vec2(w,1.0-w)).rgb; "," #elif defined color_type_depth "," float d = -mvPosition.z ; "," vColor = vec3(d, vDepth, 0.0); "," #elif defined color_type_intensity "," float w = (intensity - intensityMin) / intensityMax; "," vColor = vec3(w, w, w); "," //vColor = texture2D(gradient, vec2(w,1.0-w)).rgb; "," #elif defined color_type_intensity_gradient "," float w = (intensity - intensityMin) / intensityMax; "," vColor = texture2D(gradient, vec2(w,1.0-w)).rgb; "," #elif defined color_type_color "," vColor = uColor; "," #elif defined color_type_octree_depth "," float depth = getOctreeDepth(); "," float w = depth / 10.0; "," vColor = texture2D(gradient, vec2(w,1.0-w)).rgb; "," #elif defined color_type_point_index "," vColor = indices.rgb; "," #elif defined color_type_classification "," vColor = classificationColor(classification); "," #elif defined color_type_return_number "," float w = (returnNumber - 1.0) / 4.0 + 0.1; "," vColor = texture2D(gradient, vec2(w, 1.0 - w)).rgb; "," #elif defined color_type_source "," float w = mod(pointSourceID, 10.0) / 10.0; "," vColor = texture2D(gradient, vec2(w,1.0 - w)).rgb; "," #endif "," "," "," "," // "," // POINT SIZE TYPES "," // "," float r = spacing * 1.5; "," #if defined fixed_point_size "," gl_PointSize = size; "," #elif defined attenuated_point_size "," //gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," gl_PointSize = (1.0 / tan(fov/2.0)) * size / (-mvPosition.z); "," gl_PointSize = gl_PointSize * screenHeight / 2.0; "," #elif defined adaptive_point_size "," //gl_PointSize = size * ( 300.0 / length( mvPosition.xyz ) ); "," //gl_PointSize = (1.0 / tan(fov/2.0)) * r / sqrt( max(0.0, mvPosition.z * mvPosition.z - r * r)); "," gl_PointSize = (1.0 / tan(fov/2.0)) * r / (-mvPosition.z); "," gl_PointSize = size * gl_PointSize * screenHeight / 2.0; "," gl_PointSize = gl_PointSize / pow(1.9, getOctreeDepth()); "," #endif "," "," gl_PointSize = max(minSize, gl_PointSize); "," gl_PointSize = min(50.0, gl_PointSize); "," "," // clip box "," #if defined use_clip_box "," bool insideAny = false; "," for(int i = 0; i < clip_box_count; i++){ "," vec4 clipPosition = clipBoxes[i] * modelMatrix * vec4( position, 1.0 ); "," bool inside = -0.5 <= clipPosition.x && clipPosition.x <= 0.5; "," inside = inside && -0.5 <= clipPosition.y && clipPosition.y <= 0.5; "," inside = inside && -0.5 <= clipPosition.z && clipPosition.z <= 0.5; "," insideAny = insideAny || inside; "," } "," if(!insideAny){ "," "," #if defined clip_outside "," gl_Position = vec4(1000.0, 1000.0, 1000.0, 1.0); "," #elif defined clip_highlight_inside && !defined(color_type_depth) "," float c = (vColor.r + vColor.g + vColor.b) / 6.0; "," //vColor = vec3(c, c, c); "," #endif "," }else{ "," #if defined clip_highlight_inside "," vColor.r += 0.5; "," #endif "," } "," "," #endif "," "," ","} "],Potree.PointCloudMaterial.fs_points_rgb=["#if defined use_interpolation "," #extension GL_EXT_frag_depth : enable ","#endif "," ","precision mediump float; ","precision mediump int; "," ","//uniform float opacity; ","uniform float pcIndex; ","uniform float screenWidth; ","uniform float screenHeight; ","uniform float blendDepth; "," ","uniform sampler2D depthMap; "," ","varying vec3 vColor; ","varying float vOpacity; ","varying float vLinearDepth; ","varying float vDepth; "," ","void main() { "," "," #if defined(circle_point_shape) || defined(use_interpolation) || defined (weighted_splats) "," float a = pow(2.0*(gl_PointCoord.x - 0.5), 2.0); "," float b = pow(2.0*(gl_PointCoord.y - 0.5), 2.0); "," float c = 1.0 - (a + b); "," "," if(c < 0.0){ "," discard; "," } "," #endif "," "," #if defined weighted_splats "," vec2 uv = gl_FragCoord.xy / vec2(screenWidth, screenHeight); "," "," float depth = texture2D(depthMap, uv).r; "," if(vLinearDepth > depth + blendDepth){ "," discard; "," } "," #endif "," "," #if defined use_interpolation "," gl_FragDepthEXT = gl_FragCoord.z + 0.002*(1.0-pow(c, 1.0)) * gl_FragCoord.w; "," #endif "," "," "," #if defined color_type_point_index "," gl_FragColor = vec4(vColor, pcIndex / 255.0); "," #else "," gl_FragColor = vec4(vColor, vOpacity); "," #endif "," "," "," #if defined weighted_splats "," float w = pow(c, 2.0); "," gl_FragColor.rgb = gl_FragColor.rgb * w; "," gl_FragColor.a = w; "," #endif "," "," "," ","} "],THREE.FirstPersonControls=function(e,t){function o(e){l.enabled!==!1&&(e.preventDefault(),0===e.button?(P=b.ROTATE,c.set(e.clientX,e.clientY)):2===e.button&&(P=b.PAN,u.set(e.clientX,e.clientY)),l.domElement.addEventListener("mousemove",i,!1),l.domElement.addEventListener("mouseup",r,!1),l.dispatchEvent(R)) -}function i(e){if(l.enabled!==!1){e.preventDefault();var t=l.domElement===document?l.domElement.body:l.domElement;P===b.ROTATE?(d.set(e.clientX,e.clientY),h.subVectors(d,c),l.rotateLeft(2*Math.PI*h.x/t.clientWidth*l.rotateSpeed),l.rotateUp(2*Math.PI*h.y/t.clientHeight*l.rotateSpeed),c.copy(d)):P===b.PAN&&(p.set(e.clientX,e.clientY),m.subVectors(p,u),m.multiplyScalar(5e-4).multiplyScalar(l.moveSpeed),l.pan(m.x,m.y),u.copy(p))}}function r(){l.enabled!==!1&&(l.domElement.removeEventListener("mousemove",i,!1),l.domElement.removeEventListener("mouseup",r,!1),l.dispatchEvent(w),P=b.NONE)}function n(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(R),l.dispatchEvent(w)}}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,c=new THREE.Vector2,d=new THREE.Vector2,h=new THREE.Vector2,u=new THREE.Vector2,p=new THREE.Vector2,m=new THREE.Vector2,v=new THREE.Vector3,f=(new THREE.Vector3,0),E=0,y=1,g=new THREE.Vector3,T=new THREE.Vector3,b={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},P=b.NONE;this.position0=this.object.position.clone();var x={type:"change"},R={type:"start"},w={type:"end"};this.rotateLeft=function(e){E-=e},this.rotateUp=function(e){f-=e},this.panLeft=function(e){var t=this.object.matrix.elements;v.set(t[0],t[1],t[2]),v.multiplyScalar(-e),g.add(v)},this.panUp=function(e){var t=this.object.matrix.elements;v.set(t[4],t[5],t[6]),v.multiplyScalar(e),g.add(v)},this.panForward=function(e){var t=this.object.matrix.elements;v.set(t[8],t[9],t[10]),v.multiplyScalar(e),g.add(v)},this.pan=function(e,t){var o=l.domElement===document?l.domElement.body:l.domElement;if(void 0!==l.object.fov){var i=l.object.position,r=i.clone(),n=r.length();n*=Math.tan(l.object.fov/2*Math.PI/180),l.panLeft(2*e*n/o.clientHeight),l.panUp(2*t*n/o.clientHeight)}else void 0!==l.object.top?(l.panLeft(e*(l.object.right-l.object.left)/o.clientWidth),l.panUp(t*(l.object.top-l.object.bottom)/o.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(e){this.object.rotation.order="ZYX";var t=this.object.position;if(void 0!==e&&(this.moveRight&&this.panLeft(-e*this.moveSpeed),this.moveLeft&&this.panLeft(e*this.moveSpeed),this.moveForward&&this.panForward(-e*this.moveSpeed),this.moveBackward&&this.panForward(e*this.moveSpeed)),!g.equals(new THREE.Vector3(0,0,0))){var o={type:"move",translation:g.clone()};this.dispatchEvent(o)}if(t.add(g),0!==E||0!==f){var o={type:"rotate",thetaDelta:E,phiDelta:f};this.dispatchEvent(o)}this.object.updateMatrix();var i=(new THREE.Matrix4).makeRotationY(E),r=(new THREE.Matrix4).multiplyMatrices(i,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=f,E=0,f=0,y=1,g.set(0,0,0),T.distanceTo(this.object.position)>0&&(this.dispatchEvent(x),T.copy(this.object.position))},this.reset=function(){P=b.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",n,!1),this.domElement.addEventListener("DOMMouseScroll",n,!1),window.addEventListener("keydown",s,!1),window.addEventListener("keyup",a,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(e){return null==this.items[e.id]},LRU.prototype.touch=function(e){var t;null==this.items[e.id]?(t=new LRUItem(e),t.previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):(t=this.items[e.id],null===t.previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null===t.next||(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))},LRU.prototype.remove=function(){if(null===this.first)return null;var e=this.first;return null!==e.next?(this.first=e.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[e.node.id],this.elements--,this.numPoints-=e.node.numPoints,e.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var e=this.first;return e.node},LRU.prototype.toString=function(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.boundingBox=e.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileRequest=function(e,t,o,i,r){this.start=e,this.end=t,this.width=o,this.depth=i,this.callback=r,this.loadQueue=[];var n=((new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),(new THREE.Vector3).subVectors(t,e).length(),(new THREE.Vector3).subVectors(t,e).normalize()),s=new THREE.Vector3(0,1,0),a=(new THREE.Vector3).crossVectors(n,s).normalize(),l=a;this.plane=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,e)},Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.tightBoundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.material=t||new Potree.PointCloudMaterial,this.visiblePointsTarget=2e6,this.level=0,this.position.sub(e.offset),this.updateMatrix(),this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleBounds=new THREE.Box3,this.profileRequests=[],this.visibleNodes=[],this.visibleGeometry=[],this.pickTarget,this.pickMaterial,this.maxLevel=0;var o=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(o)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(e,t){this.updateMatrixWorld(!0),this.visibleGeometry=this.getVisibleGeometry(e);for(var o=[],i=0;i0;){{var s=n.shift(),a=s.node;s.weight}if(a.visible=!0,a.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.matrix),a instanceof Potree.PointCloudOctreeProxyNode){var l=a.geometryNode;l.loaded===!0?this.replaceProxy(a):this.loadQueue.push(s)}else if(a instanceof THREE.PointCloud){if(this.numVisibleNodes++,this.numVisiblePoints+=a.numPoints,a.material=this.material,this.visibleNodes.push(s),a.level&&(this.maxLevel=Math.max(a.level,this.maxLevel)),this.showBoundingBox&&!a.boundingBoxNode){var c=new THREE.BoxHelper(a);scene.add(c),this.boundingBoxNodes.push(c),a.boundingBoxNode=c}else this.showBoundingBox?(a.boundingBoxNode.visible=!0,a.boundingBoxNode.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.boundingBoxNode.matrix)):!this.showBoundingBox&&a.boundingBoxNode&&(a.boundingBoxNode.visible=!1);for(var i=0;i=0;if(h)for(var u=0;u0;){var v=n.shift();if(v instanceof Potree.PointCloudOctreeProxyNode){var f=Potree.utils.computeTransformedBoundingBox(v.boundingBox,v.matrixWorld),E=f.getBoundingSphere();Math.abs(p.distanceToPoint(E.center))0){var v=b.loadQueue[0],l=v.geometryNode;if(l.loaded===!0&&void 0!==v.parent){var a=this.replaceProxy(v);a.updateMatrixWorld(),a.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.matrix)}else v.geometryNode.load()}else{var P=this.getProfile(b.start,b.end,b.width,b.depth);b.callback({type:"finished",points:P}),T.push(b)}}for(var i=0;i-1&&this.profileRequests.splice(x,1)}if(this.loadQueue.length>0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.weight-e.weight});for(var i=0;i0;){y++;var g=p.shift(),T=g.node,b=T.boundingBox,v=T.boundingSphere,P=i.intersectsBox(b),x=P;if(x){if(m+T.numPoints>this.visiblePointsTarget)break;m+=T.numPoints,t.push(g);for(var R in T.children){var w=T.children[R],v=w.boundingSphere,f=v.center.distanceTo(h),H=v.radius,E=v.radius/f,C=e.fov/2*Math.PI/180,M=1/Math.tan(C)*H/Math.sqrt(f*f-H*H);if(!(.1>M))if(E=M,0>f-H&&(E=Number.MAX_VALUE),0===p.length)p.push({node:w,weight:E});else{for(var S=0,L=0;Lp[L].weight){var S=L;break}if(L==p.length-1){S=p.length;break}}p.splice(S,0,{node:w,weight:E})}}}}return t},Potree.PointCloudOctree.prototype.updateVisibilityTexture=function(){if(this.material){for(var e=this.material.visibleNodesTexture,t=e.image.data,o=[],i=0;io?-1:o>i?1:0};o.sort(r);for(var i=0;it.name?1:0}),t[3*i+0]=0,t[3*i+1]=0,t[3*i+2]=0;for(var a=0;an;n++)if(void 0!==t.children[n]){var s=t.children[n],a=new Potree.PointCloudOctreeProxyNode(s);i.add(a)}return i}},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o0;){var e=t.shift();e.visible=!1;for(var o=0;o0;){var v=n.shift(),f=0;if(v instanceof THREE.PointCloud)for(var E=v.geometry,y=E.attributes.position,g=y.array,T=y.length/y.itemSize,b=0;T>b;b++){var P=new THREE.Vector3(g[3*b],g[3*b+1],g[3*b+2]);P.applyMatrix4(this.matrixWorld);var x=Math.abs(u.distanceToPoint(P)),R=Math.abs(p.distanceToPoint(P));o/2>x&&a/2>R&&(m.push(P),f++)}if(v==this||v.levelt)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var r=0;r1||(this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++,this.pcoGeometry.loader.load(this))},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(e,t,o){var i=e.pcoGeometry.octreeDir+"/"+e.name;void 0!==t&&t.length>0&&(i+="."+t);var r=new XMLHttpRequest;r.open("GET",i,!0),r.responseType="arraybuffer",r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status||0===r.status){var t=r.response;o(e,t)}else console.log("Failed to load file! HTTP status: "+r.status+", file: "+i)};try{r.send(null)}catch(n){console.log("fehler beim laden der punktwolke: "+n)}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),200!==t.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(e,t){var o=[new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.max.z).applyMatrix4(t)],i=new THREE.Box3;return i.setFromPoints(o),i},Potree.utils.addCommas=function(e){e+="",x=e.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var t=/(\d+)(\d{3})/;t.test(x1);)x1=x1.replace(t,"$1,$2");return x1+x2},Potree.utils.createWorker=function(e){var t=new Blob([e],{type:"application/javascript"}),o=new Worker(URL.createObjectURL(t));return o},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),o=new THREE.Scene,i=".jpg",r=[e+"px"+i,e+"nx"+i,e+"py"+i,e+"ny"+i,e+"pz"+i,e+"nz"+i],n=THREE.ImageUtils.loadTextureCube(r,new THREE.CubeRefractionMapping),s=new THREE.MeshBasicMaterial({color:16777215,envMap:n,refractionRatio:.95}),a=THREE.ShaderLib.cube;a.uniforms.tCube.value=n;var s=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:a.uniforms,depthWrite:!1,side:THREE.BackSide}),l=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),s);return o.add(l),{camera:t,scene:o}},Potree.utils.createGrid=function(e,t,o,i){for(var r=new THREE.LineBasicMaterial({color:i||8947848}),n=new THREE.Geometry,s=0;t>=s;s++)n.vertices.push(new THREE.Vector3(-(o*e)/2,0,s*o-o*t/2)),n.vertices.push(new THREE.Vector3(+(o*e)/2,0,s*o-o*t/2));for(var s=0;e>=s;s++)n.vertices.push(new THREE.Vector3(s*o-o*e/2,0,-(o*t)/2)),n.vertices.push(new THREE.Vector3(s*o-o*e/2,0,+(o*t)/2));var a=new THREE.Line(n,r,THREE.LinePieces);return a.receiveShadow=!0,a},Potree.utils.createBackgroundTexture=function(e,t){function o(e,t){return 1/(2*Math.PI)*Math.exp(-(e*e+t*t)/2)}var i=THREE.ImageUtils.generateDataTexture(e,t,new THREE.Color);i.magFilter=THREE.NearestFilter;for(var r=i.image.data,n=[1,1.5,1.7],s=o(0,0),a=0;e>a;a++)for(var l=0;t>l;l++){var c=2*(a/e)-1,d=2*(l/t)-1,h=a+e*l,u=o(2*c,2*d)/s,p=(Math.random()+Math.random()+Math.random())/3;p=(.5*u+.5)*p*.03,p=.4*p,r[3*h+0]=255*(u/15+.05+p)*n[0],r[3*h+1]=255*(u/15+.05+p)*n[1],r[3*h+2]=255*(u/15+.05+p)*n[2]}return i},Potree.TextSprite=function(e){var t=new THREE.Texture,o=new THREE.SpriteMaterial({map:t,useScreenCoordinates:!1});THREE.Sprite.call(this,o),this.borderThickness=4,this.fontface="Arial",this.fontsize=28,this.borderColor={r:0,g:0,b:0,a:1},this.backgroundColor={r:255,g:255,b:255,a:1},this.text="",this.setText(e)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(e){this.text=e,this.update()},Potree.TextSprite.prototype.setBorderColor=function(e){this.borderColor=e,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(e){this.backgroundColor=e,this.update()},Potree.TextSprite.prototype.update=function(){var e=document.createElement("canvas"),t=e.getContext("2d");t.font="Bold "+this.fontsize+"px "+this.fontface;var o=t.measureText(this.text),i=o.width,r=i+2*this.borderThickness,n=1.4*this.fontsize+2*this.borderThickness,e=document.createElement("canvas"),t=e.getContext("2d");t.canvas.width=r,t.canvas.height=n,t.font="Bold "+this.fontsize+"px "+this.fontface,t.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",t.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",t.lineWidth=this.borderThickness,this.roundRect(t,this.borderThickness/2,this.borderThickness/2,i+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),t.strokeStyle="rgba(0, 0, 0, 1.0)",t.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),t.fillStyle="rgba(255, 255, 255, 1.0)",t.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var s=new THREE.Texture(e);s.needsUpdate=!0,this.material.map=s,this.scale.set(.01*r,.01*n,1)},Potree.TextSprite.prototype.roundRect=function(e,t,o,i,r,n){e.beginPath(),e.moveTo(t+n,o),e.lineTo(t+i-n,o),e.quadraticCurveTo(t+i,o,t+i,o+n),e.lineTo(t+i,o+r-n),e.quadraticCurveTo(t+i,o+r,t+i-n,o+r),e.lineTo(t+n,o+r),e.quadraticCurveTo(t,o+r,t,o+r-n),e.lineTo(t,o+n),e.quadraticCurveTo(t,o,t+n,o),e.closePath(),e.fill(),e.stroke()},Potree.Version=function(e){this.version=e;var t=-1===e.indexOf(".")?e.length:e.indexOf(".");this.versionMajor=e.substr(0,t),this.versionMinor=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.AreaTool=function(e,t,o){function i(e){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[],this.root=e,this.closed=!0,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.material.depthTest=!1,this.areaLabel.material.opacity=1,e.add(this.areaLabel);var t=new THREE.SphereGeometry(.4,10,10),o=new THREE.Color(16711680),i=function(){var e=new THREE.MeshLambertMaterial({shading:THREE.SmoothShading,color:16711680,ambient:11184810,depthTest:!1,depthWrite:!1});return e};this.add=function(e){this.points.push(e);var r=new THREE.Mesh(t,i());r.addEventListener("mousemove",m),r.addEventListener("mouseleave",v),r.addEventListener("mousedrag",f),r.addEventListener("drop",E);var n=new THREE.Geometry;n.vertices.push(new THREE.Vector3,new THREE.Vector3),n.colors.push(o,o,o);var s=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linewidth:2});s.depthTest=!1;var a=new THREE.Line(n,s),l=new Potree.TextSprite("abc");l.setBorderColor({r:0,g:255,b:0,a:0}),l.setBackgroundColor({r:0,g:255,b:0,a:0}),l.material.depthTest=!1,l.material.opacity=1,this.root.add(r),this.root.add(a),this.root.add(l),this.spheres.push(r),this.edges.push(a),this.edgeLabels.push(l),this.setPosition(this.points.length-1,e)},this.remove=function(e){this.points.splice(e,1),this.root.remove(this.spheres[e]),this.root.remove(this.edges[e]),this.root.remove(this.edgeLabels[e]),this.spheres.splice(e,1),this.edges.splice(e,1),this.edgeLabels.splice(e,1),this.update()},this.getArea=function(){for(var e=0,t=this.points.length-1,o=0;o=3,1===this.points.length){var e=this.points[0];return this.spheres[0].position.copy(e),this.edges[0].visible=!1,void(this.edgeLabels[0].visible=!1)}for(var t=new THREE.Vector3,o=this.points.length-1,i=0;o>=i;i++){var e=this.points[i],r=this.spheres[i],n=0===i?o:i-1,s=i===o?0:i+1,a=this.points[n],l=this.points[s],c=this.edges[n],d=this.edges[i],h=this.edgeLabels[n],u=this.edgeLabels[i],p=e.distanceTo(a),m=e.distanceTo(l),v=(new THREE.Vector3).addVectors(a,e).multiplyScalar(.5),f=(new THREE.Vector3).addVectors(e,l).multiplyScalar(.5);h.position.copy(v),u.position.copy(f),h.setText(p.toFixed(2)),u.setText(m.toFixed(2)),r.position.copy(e),c.geometry.vertices[1].copy(e),c.geometry.verticesNeedUpdate=!0,c.geometry.computeBoundingSphere(),d.geometry.vertices[0].copy(e),d.geometry.verticesNeedUpdate=!0,d.geometry.computeBoundingSphere(),i!==o||this.closed?(d.visible=!0,u.visible=!0):(d.visible=!1,u.visible=!1),t.add(e)}t.multiplyScalar(1/this.points.length);var E=Potree.utils.addCommas(this.getArea().toFixed(1))+"²";this.areaLabel.setText(E),this.areaLabel.position.copy(t)}}function r(e){if(h.enabled){var t=d();if(t){var o=t.clone();p===u.DEFAULT&&(p=u.PICKING,h.activeMeasurement=new i),h.activeMeasurement.add(o);var e={type:"newpoint",position:o.clone()};h.dispatchEvent(e)}}}function n(e){if(h.mouse.x=e.clientX/h.domElement.clientWidth*2-1,h.mouse.y=2*-(e.clientY/h.domElement.clientHeight)+1,h.dragstart)h.dragstart.object.dispatchEvent({type:"mousedrag",event:e});else if(p==u.PICKING&&h.activeMeasurement){var t=d();if(t){var o=h.activeMeasurement.points.length-1;h.activeMeasurement.setPosition(o,t)}}else{var t=c();t?(t.object.dispatchEvent({type:"mousemove",target:t.object,event:e}),h.hoveredElement&&h.hoveredElement!==t.object&&h.hoveredElement.dispatchEvent({type:"mouseleave",target:h.hoveredElement,event:e}),h.hoveredElement=t.object):(h.hoveredElement&&h.hoveredElement.dispatchEvent({type:"mouseleave",target:h.hoveredElement,event:e}),h.hoveredElement=null)}}function s(){p==u.PICKING&&(h.activeMeasurement.remove(h.activeMeasurement.points.length-1),h.measurements.push(h.activeMeasurement),h.activeMeasurement=void 0,p=u.DEFAULT,h.setEnabled(!1))}function a(e){if(1===e.which){var t=c();t&&(h.dragstart={object:t.object,sceneClickPos:t.point,sceneStartPos:h.sceneRoot.position.clone(),mousePos:{x:h.mouse.x,y:h.mouse.y}})}else 3===e.which&&s(e)}function l(e){h.dragstart&&(h.dragstart.object.dispatchEvent({type:"drop",event:e}),h.dragstart=null)}function c(){var e=new THREE.Vector3(h.mouse.x,h.mouse.y,.5);e.unproject(h.camera);var t=new THREE.Raycaster;t.ray.set(h.camera.position,e.sub(h.camera.position).normalize());for(var o=[],i=0;i0?s[0]:!1}function d(){var e=new THREE.Vector3(h.mouse.x,h.mouse.y,.5);e.unproject(h.camera);var t=e.sub(h.camera.position).normalize(),o=new THREE.Ray(h.camera.position,t),i=[];h.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});for(var r=null,n=null,s=0;sc)&&(r=l,n=c)}}return r?r.position:null}var h=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=o,this.domElement=o.domElement,this.mouse={x:0,y:0},this.accuracy=.5;{var u={DEFAULT:0,PICKING:1},p=u.DEFAULT;new THREE.SphereGeometry(.4,10,10)}this.activeMeasurement,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;var m=function(e){e.target.material.emissive.setHex(8947848)},v=function(e){e.target.material.emissive.setHex(0)},f=function(e){var t=d();if(t)for(var o=0;o=0){h.measurements[o].setPosition(r,t);break}}e.event.stopImmediatePropagation()},E=function(){};this.setEnabled=function(e){this.enabled!==e&&(this.enabled=e,e&&(p=u.PICKING,h.activeMeasurement=new i(h.sceneRoot),h.activeMeasurement.add(new THREE.Vector3(0,0,0)))) +}function i(e){if(l.enabled!==!1){e.preventDefault();var t=l.domElement===document?l.domElement.body:l.domElement;P===b.ROTATE?(d.set(e.clientX,e.clientY),h.subVectors(d,c),l.rotateLeft(2*Math.PI*h.x/t.clientWidth*l.rotateSpeed),l.rotateUp(2*Math.PI*h.y/t.clientHeight*l.rotateSpeed),c.copy(d)):P===b.PAN&&(p.set(e.clientX,e.clientY),m.subVectors(p,u),m.multiplyScalar(5e-4).multiplyScalar(l.moveSpeed),l.pan(m.x,m.y),u.copy(p))}}function r(){l.enabled!==!1&&(l.domElement.removeEventListener("mousemove",i,!1),l.domElement.removeEventListener("mouseup",r,!1),l.dispatchEvent(w),P=b.NONE)}function n(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(R),l.dispatchEvent(w)}}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,c=new THREE.Vector2,d=new THREE.Vector2,h=new THREE.Vector2,u=new THREE.Vector2,p=new THREE.Vector2,m=new THREE.Vector2,v=new THREE.Vector3,f=(new THREE.Vector3,0),E=0,y=1,g=new THREE.Vector3,T=new THREE.Vector3,b={NONE:-1,ROTATE:0,SPEEDCHANGE:1,PAN:2},P=b.NONE;this.position0=this.object.position.clone();var x={type:"change"},R={type:"start"},w={type:"end"};this.rotateLeft=function(e){E-=e},this.rotateUp=function(e){f-=e},this.panLeft=function(e){var t=this.object.matrix.elements;v.set(t[0],t[1],t[2]),v.multiplyScalar(-e),g.add(v)},this.panUp=function(e){var t=this.object.matrix.elements;v.set(t[4],t[5],t[6]),v.multiplyScalar(e),g.add(v)},this.panForward=function(e){var t=this.object.matrix.elements;v.set(t[8],t[9],t[10]),v.multiplyScalar(e),g.add(v)},this.pan=function(e,t){var o=l.domElement===document?l.domElement.body:l.domElement;if(void 0!==l.object.fov){var i=l.object.position,r=i.clone(),n=r.length();n*=Math.tan(l.object.fov/2*Math.PI/180),l.panLeft(2*e*n/o.clientHeight),l.panUp(2*t*n/o.clientHeight)}else void 0!==l.object.top?(l.panLeft(e*(l.object.right-l.object.left)/o.clientWidth),l.panUp(t*(l.object.top-l.object.bottom)/o.clientHeight)):console.warn("WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.")},this.update=function(e){this.object.rotation.order="ZYX";var t=this.object.position;if(void 0!==e&&(this.moveRight&&this.panLeft(-e*this.moveSpeed),this.moveLeft&&this.panLeft(e*this.moveSpeed),this.moveForward&&this.panForward(-e*this.moveSpeed),this.moveBackward&&this.panForward(e*this.moveSpeed)),!g.equals(new THREE.Vector3(0,0,0))){var o={type:"move",translation:g.clone()};this.dispatchEvent(o)}if(t.add(g),0!==E||0!==f){var o={type:"rotate",thetaDelta:E,phiDelta:f};this.dispatchEvent(o)}this.object.updateMatrix();var i=(new THREE.Matrix4).makeRotationY(E),r=(new THREE.Matrix4).multiplyMatrices(i,this.object.matrix);this.object.quaternion.setFromRotationMatrix(r),this.object.rotation.x+=f,E=0,f=0,y=1,g.set(0,0,0),T.distanceTo(this.object.position)>0&&(this.dispatchEvent(x),T.copy(this.object.position))},this.reset=function(){P=b.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",n,!1),this.domElement.addEventListener("DOMMouseScroll",n,!1),window.addEventListener("keydown",s,!1),window.addEventListener("keyup",a,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(e){return null==this.items[e.id]},LRU.prototype.touch=function(e){var t;null==this.items[e.id]?(t=new LRUItem(e),t.previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):(t=this.items[e.id],null===t.previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null===t.next||(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))},LRU.prototype.remove=function(){if(null===this.first)return null;var e=this.first;return null!==e.next?(this.first=e.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[e.node.id],this.elements--,this.numPoints-=e.node.numPoints,e.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var e=this.first;return e.node},LRU.prototype.toString=function(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.boundingBox=e.boundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.ProfileRequest=function(e,t,o,i,r){this.start=e,this.end=t,this.width=o,this.depth=i,this.callback=r,this.loadQueue=[];var n=((new THREE.Vector3).addVectors(t,e).multiplyScalar(.5),(new THREE.Vector3).subVectors(t,e).length(),(new THREE.Vector3).subVectors(t,e).normalize()),s=new THREE.Vector3(0,1,0),a=(new THREE.Vector3).crossVectors(n,s).normalize(),l=a;this.plane=(new THREE.Plane).setFromNormalAndCoplanarPoint(l,e)},Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.tightBoundingBox,this.boundingSphere=this.boundingBox.getBoundingSphere(),this.material=t||new Potree.PointCloudMaterial,this.visiblePointsTarget=2e6,this.level=0,this.position.sub(e.offset),this.updateMatrix(),this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4,this.showBoundingBox=!1,this.boundingBoxNodes=[],this.loadQueue=[],this.visibleBounds=new THREE.Box3,this.profileRequests=[],this.visibleNodes=[],this.visibleGeometry=[],this.pickTarget,this.pickMaterial,this.maxLevel=0;var o=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(o)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(e,t){this.updateMatrixWorld(!0),this.visibleGeometry=this.getVisibleGeometry(e);for(var o=[],i=0;i0;){{var s=n.shift(),a=s.node;s.weight}if(a.visible=!0,a.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.matrix),a instanceof Potree.PointCloudOctreeProxyNode){var l=a.geometryNode;l.loaded===!0?this.replaceProxy(a):this.loadQueue.push(s)}else if(a instanceof THREE.PointCloud){if(this.numVisibleNodes++,this.numVisiblePoints+=a.numPoints,a.material=this.material,this.visibleNodes.push(s),a.level&&(this.maxLevel=Math.max(a.level,this.maxLevel)),this.showBoundingBox&&!a.boundingBoxNode){var c=new THREE.BoxHelper(a);scene.add(c),this.boundingBoxNodes.push(c),a.boundingBoxNode=c}else this.showBoundingBox?(a.boundingBoxNode.visible=!0,a.boundingBoxNode.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.boundingBoxNode.matrix)):!this.showBoundingBox&&a.boundingBoxNode&&(a.boundingBoxNode.visible=!1);for(var i=0;i=0;if(h)for(var u=0;u0;){var v=n.shift();if(v instanceof Potree.PointCloudOctreeProxyNode){var f=Potree.utils.computeTransformedBoundingBox(v.boundingBox,v.matrixWorld),E=f.getBoundingSphere();Math.abs(p.distanceToPoint(E.center))0){var v=b.loadQueue[0],l=v.geometryNode;if(l.loaded===!0&&void 0!==v.parent){var a=this.replaceProxy(v);a.updateMatrixWorld(),a.matrixWorld.multiplyMatrices(a.parent.matrixWorld,a.matrix)}else v.geometryNode.load()}else{var P=this.getProfile(b.start,b.end,b.width,b.depth);b.callback({type:"finished",points:P}),T.push(b)}}for(var i=0;i-1&&this.profileRequests.splice(x,1)}if(this.loadQueue.length>0){this.loadQueue.length>=2&&this.loadQueue.sort(function(e,t){return t.weight-e.weight});for(var i=0;i0;){y++;var g=p.shift(),T=g.node,b=T.boundingBox,v=T.boundingSphere,P=i.intersectsBox(b),x=P;if(x){if(m+T.numPoints>this.visiblePointsTarget)break;m+=T.numPoints,t.push(g);for(var R in T.children){var w=T.children[R],v=w.boundingSphere,f=v.center.distanceTo(h),H=v.radius,E=v.radius/f,C=e.fov/2*Math.PI/180,M=1/Math.tan(C)*H/Math.sqrt(f*f-H*H);if(!(.1>M))if(E=M,0>f-H&&(E=Number.MAX_VALUE),0===p.length)p.push({node:w,weight:E});else{for(var S=0,L=0;Lp[L].weight){var S=L;break}if(L==p.length-1){S=p.length;break}}p.splice(S,0,{node:w,weight:E})}}}}return t},Potree.PointCloudOctree.prototype.updateVisibilityTexture=function(){if(this.material){for(var e=this.material.visibleNodesTexture,t=e.image.data,o=[],i=0;io?-1:o>i?1:0};o.sort(r);for(var i=0;it.name?1:0}),t[3*i+0]=0,t[3*i+1]=0,t[3*i+2]=0;for(var a=0;an;n++)if(void 0!==t.children[n]){var s=t.children[n],a=new Potree.PointCloudOctreeProxyNode(s);i.add(a)}return i}},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o0;){var e=t.shift();e.visible=!1;for(var o=0;o0;){var v=n.shift(),f=0;if(v instanceof THREE.PointCloud)for(var E=v.geometry,y=E.attributes.position,g=y.array,T=y.length/y.itemSize,b=0;T>b;b++){var P=new THREE.Vector3(g[3*b],g[3*b+1],g[3*b+2]);P.applyMatrix4(this.matrixWorld);var x=Math.abs(u.distanceToPoint(P)),R=Math.abs(p.distanceToPoint(P));o/2>x&&a/2>R&&(m.push(P),f++)}if(v==this||v.levelt)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var r=0;r1||(this.loading=!0,Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++,this.pcoGeometry.loader.load(this))},Potree.BinaryNodeLoader=function(){},Potree.BinaryNodeLoader.load=function(e,t,o){var i=e.pcoGeometry.octreeDir+"/"+e.name;void 0!==t&&t.length>0&&(i+="."+t);var r=new XMLHttpRequest;r.open("GET",i,!0),r.responseType="arraybuffer",r.overrideMimeType("text/plain; charset=x-user-defined"),r.onreadystatechange=function(){if(4===r.readyState)if(200===r.status||0===r.status){var t=r.response;o(e,t)}else console.log("Failed to load file! HTTP status: "+r.status+", file: "+i)};try{r.send(null)}catch(n){console.log("fehler beim laden der punktwolke: "+n)}},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),200!==t.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(e,t){var o=[new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.max.z).applyMatrix4(t)],i=new THREE.Box3;return i.setFromPoints(o),i},Potree.utils.addCommas=function(e){e+="",x=e.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var t=/(\d+)(\d{3})/;t.test(x1);)x1=x1.replace(t,"$1,$2");return x1+x2},Potree.utils.createWorker=function(e){var t=new Blob([e],{type:"application/javascript"}),o=new Worker(URL.createObjectURL(t));return o},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),o=new THREE.Scene,i=".jpg",r=[e+"px"+i,e+"nx"+i,e+"py"+i,e+"ny"+i,e+"pz"+i,e+"nz"+i],n=THREE.ImageUtils.loadTextureCube(r,new THREE.CubeRefractionMapping),s=new THREE.MeshBasicMaterial({color:16777215,envMap:n,refractionRatio:.95}),a=THREE.ShaderLib.cube;a.uniforms.tCube.value=n;var s=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:a.uniforms,depthWrite:!1,side:THREE.BackSide}),l=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),s);return o.add(l),{camera:t,scene:o}},Potree.utils.createGrid=function(e,t,o,i){for(var r=new THREE.LineBasicMaterial({color:i||8947848}),n=new THREE.Geometry,s=0;t>=s;s++)n.vertices.push(new THREE.Vector3(-(o*e)/2,0,s*o-o*t/2)),n.vertices.push(new THREE.Vector3(+(o*e)/2,0,s*o-o*t/2));for(var s=0;e>=s;s++)n.vertices.push(new THREE.Vector3(s*o-o*e/2,0,-(o*t)/2)),n.vertices.push(new THREE.Vector3(s*o-o*e/2,0,+(o*t)/2));var a=new THREE.Line(n,r,THREE.LinePieces);return a.receiveShadow=!0,a},Potree.utils.createBackgroundTexture=function(e,t){function o(e,t){return 1/(2*Math.PI)*Math.exp(-(e*e+t*t)/2)}var i=THREE.ImageUtils.generateDataTexture(e,t,new THREE.Color);i.magFilter=THREE.NearestFilter;for(var r=i.image.data,n=[1,1.5,1.7],s=o(0,0),a=0;e>a;a++)for(var l=0;t>l;l++){var c=2*(a/e)-1,d=2*(l/t)-1,h=a+e*l,u=o(2*c,2*d)/s,p=(Math.random()+Math.random()+Math.random())/3;p=(.5*u+.5)*p*.03,p=.4*p,r[3*h+0]=255*(u/15+.05+p)*n[0],r[3*h+1]=255*(u/15+.05+p)*n[1],r[3*h+2]=255*(u/15+.05+p)*n[2]}return i},Potree.TextSprite=function(e){var t=new THREE.Texture,o=new THREE.SpriteMaterial({map:t,useScreenCoordinates:!1});THREE.Sprite.call(this,o),this.borderThickness=4,this.fontface="Arial",this.fontsize=28,this.borderColor={r:0,g:0,b:0,a:1},this.backgroundColor={r:255,g:255,b:255,a:1},this.text="",this.setText(e)},Potree.TextSprite.prototype=new THREE.Sprite,Potree.TextSprite.prototype.setText=function(e){this.text=e,this.update()},Potree.TextSprite.prototype.setBorderColor=function(e){this.borderColor=e,this.update()},Potree.TextSprite.prototype.setBackgroundColor=function(e){this.backgroundColor=e,this.update()},Potree.TextSprite.prototype.update=function(){var e=document.createElement("canvas"),t=e.getContext("2d");t.font="Bold "+this.fontsize+"px "+this.fontface;var o=t.measureText(this.text),i=o.width,r=i+2*this.borderThickness,n=1.4*this.fontsize+2*this.borderThickness,e=document.createElement("canvas"),t=e.getContext("2d");t.canvas.width=r,t.canvas.height=n,t.font="Bold "+this.fontsize+"px "+this.fontface,t.fillStyle="rgba("+this.backgroundColor.r+","+this.backgroundColor.g+","+this.backgroundColor.b+","+this.backgroundColor.a+")",t.strokeStyle="rgba("+this.borderColor.r+","+this.borderColor.g+","+this.borderColor.b+","+this.borderColor.a+")",t.lineWidth=this.borderThickness,this.roundRect(t,this.borderThickness/2,this.borderThickness/2,i+this.borderThickness,1.4*this.fontsize+this.borderThickness,6),t.strokeStyle="rgba(0, 0, 0, 1.0)",t.strokeText(this.text,this.borderThickness,this.fontsize+this.borderThickness),t.fillStyle="rgba(255, 255, 255, 1.0)",t.fillText(this.text,this.borderThickness,this.fontsize+this.borderThickness);var s=new THREE.Texture(e);s.needsUpdate=!0,this.material.map=s,this.scale.set(.01*r,.01*n,1)},Potree.TextSprite.prototype.roundRect=function(e,t,o,i,r,n){e.beginPath(),e.moveTo(t+n,o),e.lineTo(t+i-n,o),e.quadraticCurveTo(t+i,o,t+i,o+n),e.lineTo(t+i,o+r-n),e.quadraticCurveTo(t+i,o+r,t+i-n,o+r),e.lineTo(t+n,o+r),e.quadraticCurveTo(t,o+r,t,o+r-n),e.lineTo(t,o+n),e.quadraticCurveTo(t,o,t+n,o),e.closePath(),e.fill(),e.stroke()},Potree.Version=function(e){this.version=e;var t=-1===e.indexOf(".")?e.length:e.indexOf(".");this.versionMajor=e.substr(0,t),this.versionMinor=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.AreaTool=function(e,t,o){function i(e){this.points=[],this.spheres=[],this.edges=[],this.sphereLabels=[],this.edgeLabels=[],this.root=e,this.closed=!0,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.material.depthTest=!1,this.areaLabel.material.opacity=1,e.add(this.areaLabel);var t=new THREE.SphereGeometry(.4,10,10),o=new THREE.Color(16711680),i=function(){var e=new THREE.MeshLambertMaterial({shading:THREE.SmoothShading,color:16711680,ambient:11184810,depthTest:!1,depthWrite:!1});return e};this.add=function(e){this.points.push(e);var r=new THREE.Mesh(t,i());r.addEventListener("mousemove",m),r.addEventListener("mouseleave",v),r.addEventListener("mousedrag",f),r.addEventListener("drop",E);var n=new THREE.Geometry;n.vertices.push(new THREE.Vector3,new THREE.Vector3),n.colors.push(o,o,o);var s=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linewidth:2});s.depthTest=!1;var a=new THREE.Line(n,s),l=new Potree.TextSprite("abc");l.setBorderColor({r:0,g:255,b:0,a:0}),l.setBackgroundColor({r:0,g:255,b:0,a:0}),l.material.depthTest=!1,l.material.opacity=1,this.root.add(r),this.root.add(a),this.root.add(l),this.spheres.push(r),this.edges.push(a),this.edgeLabels.push(l),this.setPosition(this.points.length-1,e)},this.remove=function(e){this.points.splice(e,1),this.root.remove(this.spheres[e]),this.root.remove(this.edges[e]),this.root.remove(this.edgeLabels[e]),this.spheres.splice(e,1),this.edges.splice(e,1),this.edgeLabels.splice(e,1),this.update()},this.getArea=function(){for(var e=0,t=this.points.length-1,o=0;o=3,1===this.points.length){var e=this.points[0];return this.spheres[0].position.copy(e),this.edges[0].visible=!1,void(this.edgeLabels[0].visible=!1)}for(var t=new THREE.Vector3,o=this.points.length-1,i=0;o>=i;i++){var e=this.points[i],r=this.spheres[i],n=0===i?o:i-1,s=i===o?0:i+1,a=this.points[n],l=this.points[s],c=this.edges[n],d=this.edges[i],h=this.edgeLabels[n],u=this.edgeLabels[i],p=e.distanceTo(a),m=e.distanceTo(l),v=(new THREE.Vector3).addVectors(a,e).multiplyScalar(.5),f=(new THREE.Vector3).addVectors(e,l).multiplyScalar(.5);h.position.copy(v),u.position.copy(f),h.setText(p.toFixed(2)),u.setText(m.toFixed(2)),r.position.copy(e),c.geometry.vertices[1].copy(e),c.geometry.verticesNeedUpdate=!0,c.geometry.computeBoundingSphere(),d.geometry.vertices[0].copy(e),d.geometry.verticesNeedUpdate=!0,d.geometry.computeBoundingSphere(),i!==o||this.closed?(d.visible=!0,u.visible=!0):(d.visible=!1,u.visible=!1),t.add(e)}t.multiplyScalar(1/this.points.length);var E=Potree.utils.addCommas(this.getArea().toFixed(1))+"²";this.areaLabel.setText(E),this.areaLabel.position.copy(t)}}function r(e){if(h.enabled){var t=d();if(t){var o=t.clone();p===u.DEFAULT&&(p=u.PICKING,h.activeMeasurement=new i),h.activeMeasurement.add(o);var e={type:"newpoint",position:o.clone()};h.dispatchEvent(e)}}}function n(e){if(h.mouse.x=e.clientX/h.domElement.clientWidth*2-1,h.mouse.y=2*-(e.clientY/h.domElement.clientHeight)+1,h.dragstart)h.dragstart.object.dispatchEvent({type:"mousedrag",event:e});else if(p==u.PICKING&&h.activeMeasurement){var t=d();if(t){var o=h.activeMeasurement.points.length-1;h.activeMeasurement.setPosition(o,t)}}else{var t=c();t?(t.object.dispatchEvent({type:"mousemove",target:t.object,event:e}),h.hoveredElement&&h.hoveredElement!==t.object&&h.hoveredElement.dispatchEvent({type:"mouseleave",target:h.hoveredElement,event:e}),h.hoveredElement=t.object):(h.hoveredElement&&h.hoveredElement.dispatchEvent({type:"mouseleave",target:h.hoveredElement,event:e}),h.hoveredElement=null)}}function s(){p==u.PICKING&&(h.activeMeasurement.remove(h.activeMeasurement.points.length-1),h.measurements.push(h.activeMeasurement),h.activeMeasurement=void 0,p=u.DEFAULT,h.setEnabled(!1))}function a(e){if(1===e.which){var t=c();t&&(h.dragstart={object:t.object,sceneClickPos:t.point,sceneStartPos:h.sceneRoot.position.clone(),mousePos:{x:h.mouse.x,y:h.mouse.y}})}else 3===e.which&&s(e)}function l(e){h.dragstart&&(h.dragstart.object.dispatchEvent({type:"drop",event:e}),h.dragstart=null)}function c(){var e=new THREE.Vector3(h.mouse.x,h.mouse.y,.5);e.unproject(h.camera);var t=new THREE.Raycaster;t.ray.set(h.camera.position,e.sub(h.camera.position).normalize());for(var o=[],i=0;i0?s[0]:!1}function d(){var e=new THREE.Vector3(h.mouse.x,h.mouse.y,.5);e.unproject(h.camera);var t=e.sub(h.camera.position).normalize(),o=new THREE.Ray(h.camera.position,t),i=[];h.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});for(var r=null,n=null,s=0;sc)&&(r=l,n=c)}}return r?r.position:null}var h=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=o,this.domElement=o.domElement,this.mouse={x:0,y:0},this.accuracy=.5;{var u={DEFAULT:0,PICKING:1},p=u.DEFAULT;new THREE.SphereGeometry(.4,10,10)}this.activeMeasurement,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;var m=function(e){e.target.material.emissive.setHex(8947848)},v=function(e){e.target.material.emissive.setHex(0)},f=function(e){var t=d();if(t)for(var o=0;o=0){h.measurements[o].setPosition(r,t);break}}e.event.stopImmediatePropagation()},E=function(){};this.setEnabled=function(e){this.enabled!==e&&(this.enabled=e,e&&(p=u.PICKING,h.activeMeasurement=new i(h.sceneRoot),h.activeMeasurement.add(new THREE.Vector3(0,0,0)))) },this.update=function(){for(var e=[],o=0;o0?s[0]:!1}function h(){var e=new THREE.Vector3(u.mouse.x,u.mouse.y,.5);e.unproject(u.camera);var t=e.sub(u.camera.position).normalize(),o=new THREE.Ray(u.camera.position,t),i=[];u.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});for(var r=null,n=null,s=0;sc)&&(r=l,n=c)}}return r?r.position:null}var u=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=o,this.domElement=o.domElement,this.mouse={x:0,y:0},this.accuracy=.5;var p={DEFAULT:0,PICKING:1},m=p.DEFAULT,v=new THREE.SphereGeometry(.4,10,10);this.activeMeasurement,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;var f=function(e){e.target.material.emissive.setHex(8947848)},E=function(e){e.target.material.emissive.setHex(0)},y=function(e){var t=h();if(t)for(var o=0;o=0){var n=i.spheres[r];if(0===r){var s=i.edges[r],a=i.edgeLabels[r];n.position.copy(t),s.geometry.vertices[0].copy(t),s.geometry.verticesNeedUpdate=!0,s.geometry.computeBoundingSphere();var l=s.geometry.vertices[0].clone().add(s.geometry.vertices[1]).multiplyScalar(.5),c=s.geometry.vertices[0].distanceTo(s.geometry.vertices[1]).toFixed(2);a.position.copy(l),a.setText(c),a.scale.multiplyScalar(10)}else if(r===i.spheres.length-1){var s=i.edges[r-1],a=i.edgeLabels[r-1];n.position.copy(t),s.geometry.vertices[1].copy(t),s.geometry.verticesNeedUpdate=!0,s.geometry.computeBoundingSphere();var l=s.geometry.vertices[0].clone().add(s.geometry.vertices[1]).multiplyScalar(.5),c=s.geometry.vertices[0].distanceTo(s.geometry.vertices[1]).toFixed(2);a.position.copy(l),a.setText(c),a.scale.multiplyScalar(10)}else{var d=i.edges[r-1],p=i.edges[r],m=i.edgeLabels[r-1],v=i.edgeLabels[r];n.position.copy(t),d.geometry.vertices[1].copy(t),d.geometry.verticesNeedUpdate=!0,d.geometry.computeBoundingSphere(),p.geometry.vertices[0].copy(t),p.geometry.verticesNeedUpdate=!0,p.geometry.computeBoundingSphere();var f=d.geometry.vertices[0].clone().add(d.geometry.vertices[1]).multiplyScalar(.5),E=d.geometry.vertices[0].distanceTo(d.geometry.vertices[1]).toFixed(2);m.position.copy(f),m.setText(E),m.scale.multiplyScalar(10);var y=p.geometry.vertices[0].clone().add(p.geometry.vertices[1]).multiplyScalar(.5),g=p.geometry.vertices[0].distanceTo(p.geometry.vertices[1]).toFixed(2);v.position.copy(y),v.setText(g),v.scale.multiplyScalar(10)}break}}e.event.stopImmediatePropagation()},g=function(){};this.setEnabled=function(e){if(this.enabled!==e&&(this.enabled=e,e)){m=p.PICKING,u.activeMeasurement=new i;var t=new THREE.Mesh(v,r());u.sceneRoot.add(t),u.activeMeasurement.spheres.push(t),t.addEventListener("mousemove",f),t.addEventListener("mouseleave",E),t.addEventListener("mousedrag",y),t.addEventListener("drop",g)}},this.update=function(){for(var e=[],o=0;o1){var n=new THREE.Geometry;n.vertices.push(new THREE.Vector3,new THREE.Vector3),n.colors.push(t,t,t);var s=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,linewidth:2,transparent:!0,opacity:.4});s.depthTest=!1;var a=new THREE.Line(n,s);a.visible=!1,this.add(a),this.edges.push(a);var l=new THREE.BoxGeometry(1,1,1),c=new THREE.MeshBasicMaterial({color:16711680,transparent:!0,opacity:.2}),d=new THREE.Mesh(l,c);d.visible=!1,this.add(d),this.boxes.push(d)}this.setPosition(this.points.length-1,i)},this.removeMarker=function(e){this.points.splice(e,1),this.remove(this.spheres[e]),e>0&&(this.remove(this.edges[e-1]),this.edges.splice(e-1,1),this.remove(this.boxes[e-1]),this.boxes.splice(e-1,1)),this.spheres.splice(e,1),this.update()},this.getArea=function(){for(var e=0,t=this.points.length-1,o=0;o=n;n++){{var e=this.points[n],s=this.spheres[n],a=0===n?r:n-1,l=n===r?0:n+1,c=this.points[a],d=this.points[l],h=this.edges[a],u=this.edges[n],p=this.boxes[a];this.boxes[n],e.distanceTo(c),e.distanceTo(d),(new THREE.Vector3).addVectors(c,e).multiplyScalar(.5),(new THREE.Vector3).addVectors(e,d).multiplyScalar(.5)}if(s.position.copy(e),h&&(h.geometry.vertices[1].copy(e),h.geometry.verticesNeedUpdate=!0,h.geometry.computeBoundingSphere()),u&&(u.geometry.vertices[0].copy(e),u.geometry.verticesNeedUpdate=!0,u.geometry.computeBoundingSphere()),p){var m=c,v=e,f=m.clone().setY(0).distanceTo(v.clone().setY(0));p.scale.set(f,this.height,this.width);var E=(new THREE.Vector3).addVectors(m,v).multiplyScalar(.5),y=(new THREE.Vector3).subVectors(v,m),g=new THREE.Vector3(y.z,0,-y.x);p.position.set(0,0,0),p.lookAt(g),p.position.copy(E)}i.add(e),t.min(e),o.max(e)}i.multiplyScalar(1/this.points.length);for(var n=0;n0?o[0]:!1}function d(){var e=new THREE.Vector3(h.mouse.x,h.mouse.y,.5);e.unproject(h.camera);var t=e.sub(h.camera.position).normalize(),o=new THREE.Ray(h.camera.position,t),i=[];h.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});for(var r=null,n=null,s=0;sc)&&(r=l,n=c)}}return r?r.position:null}var h=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=o,this.domElement=o.domElement,this.mouse={x:0,y:0},this.accuracy=.5;{var u={DEFAULT:0,INSERT:1},p=u.DEFAULT;new THREE.SphereGeometry(.4,10,10)}this.activeProfile,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;var m=function(e){e.target.material.emissive.setHex(8947848)},v=function(e){e.target.material.emissive.setHex(0)},f=function(e){if(e.event.ctrlKey){var t=new THREE.Vector3(h.dragstart.mousePos.x,h.dragstart.mousePos.y,0),o=new THREE.Vector3(h.mouse.x,h.mouse.y,0),i=h.dragstart.widthStart,r=1-10*(t.y-o.y);if(r=Math.max(.01,r),i)for(var n=0;n=0){s.setWidth(i*r),s.update();break}}}else{var l=d();if(l)for(var n=0;n=0){h.profiles[n].setPosition(a,l);break}}}e.event.stopImmediatePropagation()},E=function(){};i.prototype=Object.create(THREE.Object3D.prototype),this.startInsertion=function(e){p=u.INSERT;var e=e||{},t=e.clip||!1,o=e.width||1;this.activeProfile=new i,this.activeProfile.clip=t,this.activeProfile.setWidth(o),this.sceneProfile.add(this.activeProfile),this.profiles.push(this.activeProfile),this.activeProfile.addMarker(new THREE.Vector3(0,0,0))},this.finishInsertion=function(){this.activeProfile.removeMarker(this.activeProfile.points.length-1),this.activeProfile=null,p=u.DEFAULT},this.update=function(){for(var e=0;e0?i[0]:!1}}var a=this;this.enabled=!1,this.scene=e,this.camera=t,this.renderer=o,this.domElement=o.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),o=a.createArrow(a.parts.ARROW_Z,a.parts.ARROW_Z.color);o.rotation.x=-Math.PI/2,this.translationNode.add(e),this.translationNode.add(t),this.translationNode.add(o)},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),o=this.createScaleHandle(a.parts.SCALE_Z,255);o.rotation.x=-Math.PI/2,this.scaleNode.add(e),this.scaleNode.add(t),this.scaleNode.add(o)},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),o=this.createRotationCircle(a.parts.ROTATE_Z,255);t.rotation.x=-Math.PI/2,this.rotationNode.add(e),this.rotationNode.add(t),this.rotationNode.add(o);var i=new THREE.SphereGeometry(2.9,24,24),r=new THREE.Mesh(i,new THREE.MeshBasicMaterial({color:11184810,transparent:!0,opacity:.4}));this.sceneRotation.add(r);var n=function(){r.material.color.setHex(5592405)},s=function(){r.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),o=new THREE.Vector3(a.mouse.x,a.mouse.y,.1),i=(new THREE.Vector3).subVectors(o,t),r=t.clone().unproject(a.camera),n=o.clone().unproject(a.camera),s=(new THREE.Vector3).subVectors(n,r),l=s.clone().normalize(),c=(new THREE.Vector3).subVectors(a.camera.position,r).normalize(),d=c.clone().cross(l),h=6*i.length(),u=0;u=r;r++){var n=2*Math.PI*r/i,s=3*Math.cos(n),l=3*Math.sin(n);o.push(new THREE.Vector3(s,l,0))}for(var c=new THREE.Geometry,r=0;r0){var i=o[0];t.push({distance:i.distance,object:this,point:i.point.clone()})}}}function r(e){d.mouse.x=e.clientX/d.domElement.clientWidth*2-1,d.mouse.y=2*-(e.clientY/d.domElement.clientHeight)+1}function n(){}function s(e){if(u===h.INSERT_VOLUME)d.finishInsertion();else if(1===e.which){var t=l();t&&transformationTool.setTargets([t.object])}3===e.which}function a(e){return e.preventDefault(),!1}function l(){var e=new THREE.Vector3(d.mouse.x,d.mouse.y,.5);e.unproject(d.camera);var t=new THREE.Raycaster;t.ray.set(d.camera.position,e.sub(d.camera.position).normalize());for(var o=[],i=0;i0?n[0]:!1}function c(){var e=new THREE.Vector3(d.mouse.x,d.mouse.y,.5);e.unproject(d.camera);var t=e.sub(d.camera.position).normalize(),o=new THREE.Ray(d.camera.position,t),i=[];d.scene.traverse(function(e){e instanceof Potree.PointCloudOctree&&i.push(e)});for(var r=null,n=null,s=0;sc)&&(r=l,n=c)}}return r?r.position:null}var d=this;this.enabled=!1,this.scene=e,this.sceneVolume=new THREE.Scene,this.camera=t,this.renderer=o,this.domElement=o.domElement,this.mouse={x:0,y:0},this.accuracy=.5,this.volumes=[]; var h={DEFAULT:0,INSERT_VOLUME:1},u=h.DEFAULT,p=new THREE.BoxGeometry(1,1,1);p.computeBoundingBox();var m=new THREE.Geometry;m.vertices.push(new THREE.Vector3(-.5,-.5,.5)),m.vertices.push(new THREE.Vector3(.5,-.5,.5)),m.vertices.push(new THREE.Vector3(.5,-.5,.5)),m.vertices.push(new THREE.Vector3(.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,-.5,.5)),m.vertices.push(new THREE.Vector3(-.5,.5,.5)),m.vertices.push(new THREE.Vector3(.5,.5,.5)),m.vertices.push(new THREE.Vector3(.5,.5,.5)),m.vertices.push(new THREE.Vector3(.5,.5,-.5)),m.vertices.push(new THREE.Vector3(.5,.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,.5,.5)),m.vertices.push(new THREE.Vector3(-.5,-.5,.5)),m.vertices.push(new THREE.Vector3(-.5,.5,.5)),m.vertices.push(new THREE.Vector3(.5,-.5,.5)),m.vertices.push(new THREE.Vector3(.5,.5,.5)),m.vertices.push(new THREE.Vector3(.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(.5,.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,-.5,-.5)),m.vertices.push(new THREE.Vector3(-.5,.5,-.5)),i.prototype=Object.create(THREE.Object3D.prototype),Object.defineProperty(i.prototype,"clip",{get:function(){return this._clip},set:function(e){this._clip=e,this._clip?(this.box.visible=!1,this.label.visible=!1):(this.box.visible=!0,this.label.visible=!0)}}),this.update=function(){if(u===h.INSERT_VOLUME){var e=c();if(e){this.activeVolume.position.copy(e);var t=this.activeVolume.getWorldPosition().applyMatrix4(this.camera.matrixWorldInverse),o=(new THREE.Vector4(t.x,t.y,t.z).applyMatrix4(this.camera.projectionMatrix),Math.abs(t.z/10));this.activeVolume.scale.set(o,o,o)}}for(var i=[],r=0;r