From a228347df84960afe686e8ff549e68c85144d252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20=C5=A0mon?= Date: Mon, 15 Jan 2018 14:46:44 +1100 Subject: [PATCH] Restored previous whitespace/tabs --- build/potree/potree.js | 1848 +++++++++++----------- package.json | 4 +- src/PointCloudOctreeGeometry.js | 66 +- src/Potree.js | 356 ++--- src/arena4d/PointCloudArena4DGeometry.js | 120 +- src/loader/GreyhoundLoader.js | 8 +- src/loader/LasLazLoader.js | 70 +- src/utils.js | 128 +- src/viewer/sidebar.js | 1100 ++++++------- 9 files changed, 1850 insertions(+), 1850 deletions(-) diff --git a/build/potree/potree.js b/build/potree/potree.js index ca54ba73..148cda38 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -7,7 +7,7 @@ function Potree(){ Potree.version = { major: 1, minor: 5, - suffix: "RC-Synth" + suffix: "RC" }; console.log("Potree " + Potree.version.major + "." + Potree.version.minor + Potree.version.suffix); @@ -48,17 +48,17 @@ Potree.startQuery = function(name, gl){ if(!Potree.timerQueriesEnabled){ return null; } - + if(Potree.timerQueries[name] === undefined){ Potree.timerQueries[name] = []; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); let query = ext.createQueryEXT(); ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, query); - + Potree.timerQueries[name].push(query); - + return query; }; @@ -66,7 +66,7 @@ Potree.endQuery = function(query, gl){ if(!Potree.timerQueriesEnabled){ return; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); ext.endQueryEXT(ext.TIME_ELAPSED_EXT); }; @@ -75,28 +75,28 @@ Potree.resolveQueries = function(gl){ if(!Potree.timerQueriesEnabled){ return; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); - + for(let name in Potree.timerQueries){ let queries = Potree.timerQueries[name]; - + if(queries.length > 0){ let query = queries[0]; - + let available = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_AVAILABLE_EXT); let disjoint = viewer.renderer.getContext().getParameter(ext.GPU_DISJOINT_EXT); - + if (available && !disjoint) { // See how much time the rendering of the object took in nanoseconds. let timeElapsed = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_EXT); let miliseconds = timeElapsed / (1000 * 1000); - + console.log(name + ": " + miliseconds + "ms"); queries.shift(); } } - + if(queries.length === 0){ delete Potree.timerQueries[name]; } @@ -111,75 +111,75 @@ Potree.MOUSE = { }; Potree.Points = class Points{ - + constructor(){ - + this.boundingBox = new THREE.Box3(); this.numPoints = 0; this.data = {}; - + } - + add(points){ - + let currentSize = this.numPoints; let additionalSize = points.numPoints; let newSize = currentSize + additionalSize; - + let thisAttributes = Object.keys(this.data); let otherAttributes = Object.keys(points.data); let attributes = new Set([...thisAttributes, ...otherAttributes]); - + for(let attribute of attributes){ if(thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + // attribute in both, merge let type = this.data[attribute].constructor; let merged = new type(this.data[attribute].length + points.data[attribute].length); merged.set(this.data[attribute], 0); merged.set(points.data[attribute], this.data[attribute].length); this.data[attribute] = merged; - + }else if(thisAttributes.includes(attribute) && !otherAttributes.includes(attribute)){ - + // attribute only in this; take over this and expand to new size let elementsPerPoint = this.data[attribute].length / this.numPoints; let type = this.data[attribute].constructor; let expanded = new type(elementsPerPoint * newSize); expanded.set(this.data[attribute], 0); this.data[attribute] = expanded; - + }else if(!thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + // attribute only in points to be added; take over new points and expand to new size let elementsPerPoint = points.data[attribute].length / points.numPoints; let type = points.data[attribute].constructor; let expanded = new type(elementsPerPoint * newSize); expanded.set(points.data[attribute], elementsPerPoint * currentSize); this.data[attribute] = expanded; - + } } - + this.numPoints = newSize; - + this.boundingBox.union(points.boundingBox); } - + }; Potree.loadPointCloud = function(path, name, callback){ - + let loaded = function(pointcloud){ pointcloud.name = name; - + callback({type: "pointcloud_loaded", pointcloud: pointcloud}); }; - + // load pointcloud if(!path){ - + }else if(path.indexOf("greyhound://") === 0){ // We check if the path string starts with 'greyhound:', if so we assume it's a greyhound server URL. Potree.GreyhoundLoader.load(path, function(geometry) { @@ -225,9 +225,9 @@ Potree.updatePointClouds = function(pointclouds, camera, renderer){ pointcloud.profileRequests[j].update(); } } - + let result = Potree.updateVisibility(pointclouds, camera, renderer); - + for(let i = 0; i < pointclouds.length; i++){ let pointcloud = pointclouds[i]; pointcloud.updateMaterial(pointcloud.material, pointcloud.visibleNodes, camera, renderer); @@ -252,10 +252,10 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ let frustums = []; let camObjPositions = []; let priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;}); - + for(let i = 0; i < pointclouds.length; i++){ let pointcloud = pointclouds[i]; - + if(!pointcloud.initialized()){ continue; } @@ -294,12 +294,12 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ if(pointcloud.root.isTreeNode()){ pointcloud.hideDescendants(pointcloud.root.sceneNode); } - + for(let j = 0; j < pointcloud.boundingBoxNodes.length; j++){ pointcloud.boundingBoxNodes[j].visible = false; } } - + return { "frustums": frustums, "camObjPositions" : camObjPositions, @@ -312,12 +312,12 @@ Potree.getDEMWorkerInstance = function(){ let workerPath = Potree.scriptPath + "/workers/DEMWorker.js"; Potree.DEMWorkerInstance = Potree.workerPool.getWorker(workerPath); } - + return Potree.DEMWorkerInstance; } function createDEMMesh(dem){ - + let box = dem.boundingBox; let steps = 256; @@ -328,7 +328,7 @@ function createDEMMesh(dem){ let u1 = (i+1) / steps; let v0 = j / steps; let v1 = (j+1) / steps; - + //let x0 = box.min.x + u0 * box.getSize().x; //let x1 = box.min.x + u1 * box.getSize().x; //let y0 = box.min.y + v0 * box.getSize().y; @@ -338,36 +338,36 @@ function createDEMMesh(dem){ //let h10 = dem.height(new THREE.Vector3(x1, y0, 0)); //let h01 = dem.height(new THREE.Vector3(x0, y1, 0)); //let h11 = dem.height(new THREE.Vector3(x1, y1, 0)); - + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - + //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + let h00 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - + if(![h00, h10, h01, h11].every(n => isFinite(n))){ continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); @@ -381,10 +381,10 @@ function createDEMMesh(dem){ } function createDEMMeshNode(dem, demNode){ - + let box = demNode.box; let tileSize = dem.tileSize * 1; - + let triangles = []; for(let i = 0; i < tileSize; i++){ //for(let j = 0; j < 1; j++){ @@ -393,36 +393,36 @@ function createDEMMeshNode(dem, demNode){ let u1 = (i+1) / tileSize; let v0 = j / tileSize; let v1 = (j+1) / tileSize; - + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - + //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + let h00 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - + if(![h00, h10, h01, h11].every(n => isFinite(n))){ continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); @@ -433,10 +433,10 @@ function createDEMMeshNode(dem, demNode){ mesh.position.copy(box.min); //mesh.position.copy(pointcloud.position); viewer.scene.scene.add(mesh); - + { // DEBUG code //let data = demNode.data; - + let steps = 64; let data = new Float32Array(steps * steps); let imgData = new Uint8Array(data.length * 4); @@ -450,12 +450,12 @@ function createDEMMeshNode(dem, demNode){ v * boxSize.y + box.min.y, 0 ); - + let height = demNode.height(pos); - + let index = i + steps * j; data[index] = height - + //let index = i + steps * j; //imgData[4*index + 0] = 255 * (height - min) / (max - min); //imgData[4*index + 1] = 100; @@ -463,97 +463,97 @@ function createDEMMeshNode(dem, demNode){ //imgData[4*index + 3] = 255; } } - + let [min, max] = [Infinity, -Infinity]; for(let height of data){ if(!isFinite(height)){ continue; } - + min = Math.min(min, height); max = Math.max(max, height); } - + for(let i = 0; i < data.length; i++){ imgData[4*i + 0] = 255 * (data[i] - min) / (max - min); imgData[4*i + 1] = 100; imgData[4*i + 2] = 0; imgData[4*i + 3] = 255; } - + let img = Potree.utils.pixelsArrayToImage(imgData, steps, steps); - + let screenshot = img.src; - + if(!this.debugDIV){ this.debugDIV = $(` -
`); $(document.body).append(this.debugDIV); } - + this.debugDIV.empty(); this.debugDIV.append($(``)); - + } } Potree.updateVisibility = function(pointclouds, camera, renderer){ let numVisibleNodes = 0; let numVisiblePoints = 0; - + let visibleNodes = []; let visibleGeometry = []; let unloadedGeometry = []; - + let lowestSpacing = Infinity; - + // calculate object space frustum and cam pos and setup priority queue let s = updateVisibilityStructures(pointclouds, camera, renderer); let frustums = s.frustums; let camObjPositions = s.camObjPositions; let priorityQueue = s.priorityQueue; - + let loadedToGPUThisFrame = 0; - + while(priorityQueue.size() > 0){ let element = priorityQueue.pop(); let node = element.node; let parent = element.parent; let pointcloud = pointclouds[element.pointcloud]; - + //{ // restrict to certain nodes for debugging // let allowedNodes = ["r", "r0", "r4"]; // if(!allowedNodes.includes(node.name)){ // continue; // } //} - + let box = node.getBoundingBox(); let frustum = frustums[element.pointcloud]; let camObjPos = camObjPositions[element.pointcloud]; - + let insideFrustum = frustum.intersectsBox(box); let maxLevel = pointcloud.maxLevel || Infinity; let level = node.getLevel(); let visible = insideFrustum; visible = visible && !(numVisiblePoints + node.getNumPoints() > Potree.pointBudget); visible = visible && level < maxLevel; - + if (pointcloud.material.numClipBoxes > 0 && visible && pointcloud.material.clipMode == Potree.ClipMode.CLIP_OUTSIDE) { - let box2 = box.clone(); + let box2 = box.clone(); pointcloud.updateMatrixWorld(true); box2.applyMatrix4(pointcloud.matrixWorld); let intersectsClipBoxes = false; for(let clipBox of pointcloud.material.clipBoxes) { let clipMatrixWorld = clipBox.matrix; let clipBoxWorld = new THREE.Box3( - new THREE.Vector3(-0.5, -0.5, -0.5), + new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, 0.5, 0.5)) .applyMatrix4(clipMatrixWorld); if (box2.intersectsBox(clipBoxWorld)) { @@ -563,21 +563,21 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ } visible = visible && intersectsClipBoxes; } - + //visible = ["r", "r0", "r06", "r060"].includes(node.name); //visible = ["r"].includes(node.name); - + if(node.spacing){ lowestSpacing = Math.min(lowestSpacing, node.spacing); }else if(node.geometryNode && node.geometryNode.spacing){ lowestSpacing = Math.min(lowestSpacing, node.geometryNode.spacing); } - + if(numVisiblePoints + node.getNumPoints() > Potree.pointBudget){ break; } - - + + if(!visible){ continue; } @@ -622,27 +622,27 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ }else if(!pointcloud.showBoundingBox && node.boundingBoxNode){ node.boundingBoxNode.visible = false; } - + } // add child nodes to priorityQueue let children = node.getChildren(); for(let i = 0; i < children.length; i++){ let child = children[i]; - + let sphere = child.getBoundingSphere(); let distance = sphere.center.distanceTo(camObjPos); let radius = sphere.radius; - + let fov = (camera.fov * Math.PI) / 180; let slope = Math.tan(fov / 2); let projFactor = (0.5 * renderer.domElement.clientHeight) / (slope * distance); let screenPixelRadius = radius * projFactor; - + if(screenPixelRadius < pointcloud.minimumNodePixelSize){ continue; } - + let weight = screenPixelRadius; if(distance - radius < 0){ @@ -654,7 +654,7 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ }// end priority queue loop - + { // update DEM let maxDEMLevel = 4; let candidates = pointclouds @@ -664,25 +664,25 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ pointcloud.dem.update(updatingNodes); } } - + for(let i = 0; i < Math.min(5, unloadedGeometry.length); i++){ unloadedGeometry[i].load(); } - + //for(let node of visibleNodes){ // let allowedNodes = ["r", "r0", "r4"]; // node.sceneNode.visible = allowedNodes.includes(node.geometryNode.name); - // + // // if(node.boundingBoxNode){ // node.boundingBoxNode.visible = node.boundingBoxNode.visible && node.sceneNode.visible; // } //} - - + + //Potree.updateDEMs(renderer, visibleNodes); return { - visibleNodes: visibleNodes, + visibleNodes: visibleNodes, numVisiblePoints: numVisiblePoints, lowestSpacing: lowestSpacing }; @@ -725,144 +725,144 @@ Potree.XHRFactory = { Potree.DEMRenderer = class{ constructor(renderer){ this.renderer = renderer; - + this.tileWidth = 64; this.tileHeight = 64; - - //this.target = new THREE.WebGLRenderTarget( 64, 64, { - // minFilter: THREE.NearestFilter, - // magFilter: THREE.NearestFilter, - // format: THREE.RGBAFormat, + + //this.target = new THREE.WebGLRenderTarget( 64, 64, { + // minFilter: THREE.NearestFilter, + // magFilter: THREE.NearestFilter, + // format: THREE.RGBAFormat, // type: THREE.FloatType //} ); //this.target.depthTexture = new THREE.DepthTexture(); //this.target.depthTexture.type = THREE.UnsignedIntType; - - this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - - this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - + this.vsElevation = ` precision mediump float; precision mediump int; - + attribute vec3 position; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying float vElevation; - + void main(){ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; gl_PointSize = 1.0; - + vElevation = position.z; } `; - + this.fsElevation = ` precision mediump float; precision mediump int; - + varying float vElevation; - + void main(){ gl_FragColor = vec4(vElevation, 0.0, 0.0, 1.0); } `; - + this.vsMedian = ` precision mediump float; precision mediump int; - + attribute vec3 position; attribute vec2 uv; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying vec2 vUV; void main() { vUV = uv; - + vec4 mvPosition = modelViewMatrix * vec4(position,1.0); gl_Position = projectionMatrix * mvPosition; } `; - + this.fsMedian = ` - + precision mediump float; precision mediump int; - + uniform float uWidth; - uniform float uHeight; + uniform float uHeight; uniform sampler2D uTexture; varying vec2 vUV; - + void main(){ - vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); - + vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); + vec4 color = texture2D(uTexture, uv); gl_FragColor = color; if(color.a == 0.0){ - + vec4 sum; - + float minVal = 1.0 / 0.0; - + float sumA = 0.0; for(int i = -1; i <= 1; i++){ for(int j = -1; j <= 1; j++){ vec2 n = gl_FragCoord.xy + vec2(i, j); - vec2 uv = n / vec2(uWidth, uHeight); + vec2 uv = n / vec2(uWidth, uHeight); vec4 c = texture2D(uTexture, uv); - + if(c.a == 1.0){ minVal = min(c.r, minVal); } - + sumA += c.a; } } - + if(sumA > 0.0){ gl_FragColor = vec4(minVal, 0.0, 0.0, 1.0); }else{ - discard; + discard; } }else{ //gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); gl_FragColor = vec4(color.rgb, 1.0); } - - + + } - + `; - + this.elevationMaterial = new THREE.RawShaderMaterial( { vertexShader: this.vsElevation, fragmentShader: this.fsElevation, } ); - + this.medianFilterMaterial = new THREE.RawShaderMaterial( { uniforms: { uWidth: {value: 1.0}, @@ -872,28 +872,28 @@ Potree.DEMRenderer = class{ vertexShader: this.vsMedian, fragmentShader: this.fsMedian, }); - + this.camera = new THREE.OrthographicCamera(0, 1, 1, 0, 0, 1); - - + + } - + render(pointcloud, node){ if(!node.geometryNode){ return; } - + Potree.timerQueriesEnabled = true; let start = new Date().getTime(); let queryAll = Potree.startQuery("All", this.renderer.getContext()); - + this.renderer.setClearColor(0x0000FF, 0); this.renderer.clearTarget( this.target, true, true, true ); this.renderer.clearTarget(this.targetElevation, true, true, false ); this.renderer.clearTarget(this.targetMedian, true, true, false ); - + let box = node.geometryNode.boundingBox; - + this.camera.up.set(0, 0, 1); //this.camera.rotation.x = Math.PI / 2; this.camera.left = box.min.x; @@ -903,53 +903,53 @@ Potree.DEMRenderer = class{ this.camera.near = -1000; this.camera.far = 1000; this.camera.updateProjectionMatrix(); - + let scene = new THREE.Scene(); //let material = new THREE.PointsMaterial({color: 0x00ff00, size: 0.0001}); let material = this.elevationMaterial; let points = new THREE.Points(node.geometryNode.geometry, material); scene.add(points); - + this.renderer.render(points, this.camera, this.targetElevation); - + this.medianFilterMaterial.uniforms.uWidth.value = this.targetMedian.width; this.medianFilterMaterial.uniforms.uHeight.value = this.targetMedian.height; this.medianFilterMaterial.uniforms.uTexture.value = this.targetElevation.texture; - + Potree.utils.screenPass.render(this.renderer, this.medianFilterMaterial, this.targetMedian); - + Potree.endQuery(queryAll, this.renderer.getContext()); Potree.resolveQueries(this.renderer.getContext()); Potree.timerQueriesEnabled = false; - - + + setTimeout( () => { let start = new Date().getTime(); - + let pixelCount = this.tileWidth * this.tileHeight; let buffer = new Uint8Array(4 * pixelCount); - this.renderer.readRenderTargetPixels(this.targetMedian, - 0, 0, this.tileWidth, this.tileHeight, + this.renderer.readRenderTargetPixels(this.targetMedian, + 0, 0, this.tileWidth, this.tileHeight, buffer); - + let end = new Date().getTime(); let duration = end - start; console.log(`read duration: ${duration}ms`); }, 3000); - + let end = new Date().getTime(); let duration = end - start; - + console.log(`duration: ${duration}ms`); - + //{ // open window with image // // let pixelCount = this.tileWidth * this.tileHeight; // let buffer = new Float32Array(4 * pixelCount); - // this.renderer.readRenderTargetPixels(this.targetMedian, - // 0, 0, this.tileWidth, this.tileHeight, + // this.renderer.readRenderTargetPixels(this.targetMedian, + // 0, 0, this.tileWidth, this.tileHeight, // buffer); - // + // // let uiBuffer = new Uint8Array(4 * pixelCount); // for(let i = 0; i < pixelCount; i++){ // uiBuffer[i] = buffer[i] / 1.0; @@ -957,18 +957,18 @@ Potree.DEMRenderer = class{ // // let img = Potree.utils.pixelsArrayToImage(uiBuffer, this.tileWidth, this.tileHeight); // let screenshot = img.src; - // + // // if(!this.debugDIV){ // this.debugDIV = $(` - //
`); // $(document.body).append(this.debugDIV); // } - // + // // this.debugDIV.empty(); // this.debugDIV.append($(``)); @@ -3036,7 +3036,7 @@ Potree.GreyhoundBinaryLoader.prototype.parse = function(node, buffer){ */ class GreyhoundUtils{ - + static getQueryParam(name) { name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), @@ -3045,7 +3045,7 @@ class GreyhoundUtils{ if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } - + static createSchema(attributes) { var schema = [ { "name": "X", "size": 4, "type": "signed" }, @@ -3075,7 +3075,7 @@ class GreyhoundUtils{ return schema; } - + static fetch(url, cb) { var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url, true); @@ -3158,7 +3158,7 @@ class GreyhoundUtils{ cb(null, { color: colorNorm, intensity: intensityNorm }); }); }; - + }; Potree.GreyhoundLoader = function() { }; @@ -3396,9 +3396,9 @@ Potree.GreyhoundLoader.createChildAABB = function(aabb, childIndex){ * Thanks to Uday Verma and Howard Butler * */ - + Potree.LasLazLoader = class LasLazLoader{ - + constructor(version){ if(typeof(version) === "string"){ this.version = new Potree.Version(version); @@ -3406,27 +3406,27 @@ Potree.LasLazLoader = class LasLazLoader{ this.version = version; } } - + static progressCB(){ - + } - + load(node){ - + if(node.loaded){ return; } - + let pointAttributes = node.pcoGeometry.pointAttributes; let url = node.getURL(); - + if(this.version.equalOrHigher("1.4")){ url += "." + pointAttributes.toLowerCase(); } - + let scope = this; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; @@ -3441,14 +3441,14 @@ Potree.LasLazLoader = class LasLazLoader{ } } }; - + xhr.send(null); } - + parse(node, buffer){ let lf = new LASFile(buffer); let handler = new Potree.LasLazBatcher(node); - + return Promise.resolve(lf).cancellable().then(function(lf) { return lf.open().then(function() { lf.isOpen = true; @@ -3468,7 +3468,7 @@ Potree.LasLazLoader = class LasLazLoader{ }).then(function(v) { let lf = v[0]; let header = v[1]; - + let skip = 1; let totalRead = 0; let totalToRead = (skip <= 1 ? header.pointsCount : header.pointsCount / skip); @@ -3497,7 +3497,7 @@ Potree.LasLazLoader = class LasLazLoader{ } }); }; - + return reader(); }).then(function(v) { let lf = v[0]; @@ -3519,7 +3519,7 @@ Potree.LasLazLoader = class LasLazLoader{ }).catch(Promise.CancellationError, function(e) { // If there was a cancellation, make sure the file is closed, if the file is open // close and then fail - if (lf.isOpen) + if (lf.isOpen) return lf.close().then(function() { lf.isOpen = false; throw e; @@ -3527,32 +3527,32 @@ Potree.LasLazLoader = class LasLazLoader{ throw e; }); } - + handle(node, url){ - + } - + }; Potree.LasLazBatcher = class LasLazBatcher{ - - constructor(node){ + + constructor(node){ this.node = node; } - + push(lasBuffer){ - + let workerPath = Potree.scriptPath + "/workers/LASDecoderWorker.js"; let worker = Potree.workerPool.getWorker(workerPath); - + worker.onmessage = (e) => { let geometry = new THREE.BufferGeometry(); let numPoints = lasBuffer.pointsCount; - + let endsWith = function(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; }; - + let positions = e.data.position; let colors = new Uint8Array(e.data.color); let intensities = e.data.intensity; @@ -3562,14 +3562,14 @@ Potree.LasLazBatcher = class LasLazBatcher{ let pointSourceIDs = new Uint16Array(e.data.pointSourceID); //let indices = new ArrayBuffer(numPoints*4); //let iIndices = new Uint32Array(indices); - + //let box = new THREE.Box3(); // //let fPositions = new Float32Array(positions); - //for(let i = 0; i < numPoints; i++){ + //for(let i = 0; i < numPoints; i++){ // box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2])); //} - + geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3)); geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(intensities), 1)); @@ -3578,28 +3578,28 @@ Potree.LasLazBatcher = class LasLazBatcher{ geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(numberOfReturns, 1)); geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(pointSourceIDs, 1)); geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + let indicesAttribute = new THREE.Uint8BufferAttribute(e.data.indices, 4); indicesAttribute.normalized = true; geometry.addAttribute("indices", indicesAttribute); - + let tightBoundingBox = new THREE.Box3( new THREE.Vector3().fromArray(e.data.tightBoundingBox.min), new THREE.Vector3().fromArray(e.data.tightBoundingBox.max) ); - + geometry.boundingBox = this.node.boundingBox; this.node.tightBoundingBox = tightBoundingBox; - + this.node.geometry = geometry; this.node.loaded = true; this.node.loading = false; this.node.pcoGeometry.numNodesLoading--; this.node.mean = new THREE.Vector3(...e.data.mean); - + Potree.workerPool.returnWorker(workerPath, worker); }; - + let message = { buffer: lasBuffer.arrayb, numPoints: lasBuffer.pointsCount, @@ -8826,13 +8826,13 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function(){ var children = []; - + for(var i = 0; i < 8; i++){ if(this.children[i]){ children.push(this.children[i]); } } - + return children; }; @@ -8842,9 +8842,9 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){ var url = ""; - + var version = this.pcoGeometry.loader.version; - + if(version.equalOrHigher("1.5")){ url = this.pcoGeometry.octreeDir + "/" + this.getHierarchyPath() + "/" + this.name; }else if(version.equalOrHigher("1.4")){ @@ -8852,7 +8852,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){ }else if(version.upTo("1.3")){ url = this.pcoGeometry.octreeDir + "/" + this.name; } - + return url; }; @@ -8861,12 +8861,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function(){ var hierarchyStepSize = this.pcoGeometry.hierarchyStepSize; var indices = this.name.substr(1); - + var numParts = Math.floor(indices.length / hierarchyStepSize); for(var i = 0; i < numParts; i++){ path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + "/"; } - + path = path.slice(0,-1); return path; @@ -8881,12 +8881,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ if(this.loading === true || this.loaded === true ||this.pcoGeometry.numNodesLoading > 3){ return; } - + this.loading = true; - + this.pcoGeometry.numNodesLoading++; - - + + if(this.pcoGeometry.loader.version.equalOrHigher("1.5")){ if((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren){ this.loadHierachyThenPoints(); @@ -8896,8 +8896,8 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ }else{ this.loadPoints(); } - - + + }; Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function(){ @@ -8913,51 +8913,51 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( var callback = function(node, hbuffer){ var count = hbuffer.byteLength / 5; var view = new DataView(hbuffer); - + var stack = []; var children = view.getUint8(0); var numPoints = view.getUint32(1, true); node.numPoints = numPoints; stack.push({children: children, numPoints: numPoints, name: node.name}); - + var decoded = []; - + var offset = 5; while(stack.length > 0){ - + var snode = stack.shift(); var mask = 1; for(var i = 0; i < 8; i++){ if((snode.children & mask) !== 0){ var childIndex = i; var childName = snode.name + i; - + var childChildren = view.getUint8(offset); var childNumPoints = view.getUint32(offset + 1, true); - + stack.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + decoded.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + offset += 5; } - + mask = mask * 2; } - + if(offset === hbuffer.byteLength){ break; } - + } - + //console.log(decoded); - + var nodes = {}; nodes[node.name] = node; var pco = node.pcoGeometry; - - + + for( var i = 0; i < decoded.length; i++){ var name = decoded[i].name; var numPoints = decoded[i].numPoints; @@ -8966,7 +8966,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( var parentNode = nodes[parentName]; var level = name.length-1; var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index); - + var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); currentNode.level = level; currentNode.numPoints = numPoints; @@ -8975,14 +8975,14 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( parentNode.addChild(currentNode); nodes[name] = currentNode; } - + node.loadPoints(); - + }; if((node.level % node.pcoGeometry.hierarchyStepSize) === 0){ //var hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc"; var hurl = node.pcoGeometry.octreeDir + "/" + node.getHierarchyPath() + "/" + node.name + ".hrc"; - + var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', hurl, true); xhr.responseType = 'arraybuffer'; @@ -9017,7 +9017,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ this.geometry.dispose(); this.geometry = null; this.loaded = false; - + //this.dispatchEvent( { type: 'dispose' } ); for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ var handler = this.oneTimeDisposeHandlers[i]; @@ -9377,15 +9377,15 @@ Object.assign( Potree.PointCloudGreyhoundGeometryNode.prototype, THREE.EventDisp Potree.utils = class{ - + static loadShapefileFeatures(file, callback){ - + let features = []; - + let handleFinish = () => { callback(features); }; - + shapefile.open(file) .then(source => {source.read() .then(function log(result){ @@ -9393,18 +9393,18 @@ Potree.utils = class{ handleFinish(); return; } - + //console.log(result.value); - + if(result.value && result.value.type === "Feature" && result.value.geometry !== undefined){ features.push(result.value); } - + return source.read().then(log); }) }); } - + static toString(value){ if(value instanceof THREE.Vector3){ return value.x.toFixed(2) + ", " + value.y.toFixed(2) + ", " + value.z.toFixed(2); @@ -9412,10 +9412,10 @@ Potree.utils = class{ return "" + value + ""; } } - + static normalizeURL(url){ let u = new URL(url); - + return u.protocol + "//" + u.hostname + u.pathname.replace(/\/+/g, "/"); }; @@ -9445,16 +9445,16 @@ Potree.utils = class{ new THREE.Vector3(box.max.x, box.min.y, box.max.z).applyMatrix4(transform), new THREE.Vector3(box.max.x, box.max.y, box.max.z).applyMatrix4(transform) ]; - + let boundingBox = new THREE.Box3(); boundingBox.setFromPoints( vertices ); - + return boundingBox; }; /** * add separators to large numbers - * + * * @param nStr * @returns */ @@ -9469,7 +9469,7 @@ Potree.utils = class{ } return x1 + x2; }; - + static removeCommas(str){ return str.replace(/,/g, ""); } @@ -9482,7 +9482,7 @@ Potree.utils = class{ static createWorker(code){ let blob = new Blob([code], {type: 'application/javascript'}); let worker = new Worker(URL.createObjectURL(blob)); - + return worker; }; @@ -9497,7 +9497,7 @@ Potree.utils = class{ path + 'py' + format, path + 'ny' + format, path + 'pz' + format, path + 'nz' + format ]; - + //var materialArray = []; //for (var i = 0; i < 6; i++){ // materialArray.push( new THREE.MeshBasicMaterial({ @@ -9508,20 +9508,20 @@ Potree.utils = class{ // }) // ); //} - + let materialArray = []; { for (let i = 0; i < 6; i++){ - + let material = new THREE.MeshBasicMaterial({ map: null, side: THREE.BackSide, depthTest: false, depthWrite: false }); - + materialArray.push(material); - + let loader = new THREE.TextureLoader(); loader.load( urls[i], function loaded(texture){ @@ -9534,18 +9534,18 @@ Potree.utils = class{ } ); } - - + + } - + var skyGeometry = new THREE.CubeGeometry( 5000, 5000, 5000 ); var skybox = new THREE.Mesh( skyGeometry, materialArray ); scene.add(skybox); - + // z up scene.rotation.x = Math.PI / 2; - + return {"camera": camera, "scene": scene}; }; @@ -9553,18 +9553,18 @@ Potree.utils = class{ let material = new THREE.LineBasicMaterial({ color: color || 0x888888 }); - + let geometry = new THREE.Geometry(); for(let i = 0; i <= length; i++){ geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); } - + for(let i = 0; i <= width; i++){ geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, -(spacing*length)/2, 0)); geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, +(spacing*length)/2, 0)); } - + let line = new THREE.LineSegments(geometry, material, THREE.LinePieces); line.receiveShadow = true; return line; @@ -9588,24 +9588,24 @@ Potree.utils = class{ for(let y = 0; y < height; y++){ let u = 2 * (x / width) - 1; let v = 2 * (y / height) - 1; - + let i = x + width*y; let d = gauss(2*u, 2*v) / max; let r = (Math.random() + Math.random() + Math.random()) / 3; r = (d * 0.5 + 0.5) * r * 0.03; r = r * 0.4; - + //d = Math.pow(d, 0.6); - + data[3*i+0] = 255 * (d / 15 + 0.05 + r) * chroma[0]; data[3*i+1] = 255 * (d / 15 + 0.05 + r) * chroma[1]; data[3*i+2] = 255 * (d / 15 + 0.05 + r) * chroma[2]; } } - + let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); texture.needsUpdate = true; - + return texture; }; @@ -9614,31 +9614,31 @@ Potree.utils = class{ x: (mouse.x / renderer.domElement.clientWidth ) * 2 - 1, y: - (mouse.y / renderer.domElement.clientHeight ) * 2 + 1 }; - + //let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); //vector.unproject(camera); //let direction = vector.sub(camera.position).normalize(); //let ray = new THREE.Ray(camera.position, direction); - + let raycaster = new THREE.Raycaster(); raycaster.setFromCamera(nmouse, camera); let ray = raycaster.ray; - + let selectedPointcloud = null; let closestDistance = Infinity; let closestIntersection = null; let closestPoint = null; - + for(let pointcloud of pointclouds){ let point = pointcloud.pick(renderer, camera, ray); - + if(!point){ continue; } - + let distance = camera.position.distanceTo(point.position); - + if(distance < closestDistance){ closestDistance = distance; selectedPointcloud = pointcloud; @@ -9646,7 +9646,7 @@ Potree.utils = class{ closestPoint = point; } } - + if(selectedPointcloud){ return { location: closestIntersection, @@ -9657,17 +9657,17 @@ Potree.utils = class{ }else{ return null; } - }; - + }; + static pixelsArrayToImage(pixels, width, height){ let canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; let context = canvas.getContext('2d'); - + pixels = new pixels.constructor(pixels); - + for(let i = 0; i < pixels.length; i++){ pixels[i*4 + 3] = 255; } @@ -9679,18 +9679,18 @@ Potree.utils = class{ let img = new Image(); img.src = canvas.toDataURL(); //img.style.transform = "scaleY(-1)"; - + return img; }; static projectedRadius(radius, fov, distance, screenHeight){ let projFactor = (1 / Math.tan(fov / 2)) / distance; projFactor = projFactor * screenHeight / 2; - + return radius * projFactor; }; - - + + static topView(camera, node){ camera.position.set(0, 1, 0); camera.rotation.set(-Math.PI / 2, 0, 0); @@ -9715,9 +9715,9 @@ Potree.utils = class{ camera.rotation.set(0, Math.PI / 2, 0); camera.zoomTo(node, 1); }; - + /** - * + * * 0: no intersection * 1: intersection * 2: fully inside @@ -9728,7 +9728,7 @@ Potree.utils = class{ let negRadius = - sphere.radius; let minDistance = Number.MAX_VALUE; - + for ( let i = 0; i < 6; i ++ ) { let distance = planes[ i ].distanceToPoint( center ); @@ -9738,47 +9738,47 @@ Potree.utils = class{ return 0; } - + minDistance = Math.min(minDistance, distance); } return (minDistance >= sphere.radius) ? 2 : 1; }; - + // code taken from three.js // ImageUtils - generateDataTexture() static generateDataTexture(width, height, color){ let size = width * height; let data = new Uint8Array(3 * width * height); - + let r = Math.floor( color.r * 255 ); let g = Math.floor( color.g * 255 ); let b = Math.floor( color.b * 255 ); - + for ( let i = 0; i < size; i ++ ) { data[ i * 3 ] = r; data[ i * 3 + 1 ] = g; data[ i * 3 + 2 ] = b; } - + let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); texture.needsUpdate = true; texture.magFilter = THREE.NearestFilter; - + return texture; }; - + // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript static getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " ")); } - + static setParameter(name, value){ //value = encodeURIComponent(value); - + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); let regex = new RegExp("([\\?&])(" + name + "=([^&#]*))"); let results = regex.exec(location.search); @@ -9798,7 +9798,7 @@ Potree.utils = class{ } window.history.replaceState({}, "", url); } - + }; Potree.utils.screenPass = new function(){ @@ -9810,10 +9810,10 @@ Potree.utils.screenPass = new function(){ this.screenQuad.material.transparent = true; this.screenScene.add(this.screenQuad); this.camera = new THREE.Camera(); - + this.render = function(renderer, material, target){ this.screenQuad.material = material; - + if(typeof target === "undefined"){ renderer.render(this.screenScene, this.camera); }else{ @@ -13524,15 +13524,15 @@ Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudArena4DGeometryNode.prototype.getChildren = function(){ var children = []; - + if(this.left){ children.push(this.left); - } - + } + if(this.right){ children.push(this.right); } - + return children; }; @@ -13549,36 +13549,36 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){ if(this.loaded || this.loading){ return; } - + if(Potree.PointCloudArena4DGeometryNode.nodesLoading >= 5){ return; } - + this.loading = true; - + Potree.PointCloudArena4DGeometryNode.nodesLoading++; - + var url = this.pcoGeometry.url + "?node=" + this.number; var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; - + var scope = this; - + xhr.onreadystatechange = function(){ if(!(xhr.readyState === 4 && xhr.status === 200)){ return; } - + var buffer = xhr.response; var view = new DataView(buffer); var numPoints = buffer.byteLength / 17; - + var positions = new Float32Array(numPoints*3); var colors = new Uint8Array(numPoints*3); var indices = new ArrayBuffer(numPoints*4); var iIndices = new Uint32Array(indices); - + for(var i = 0; i < numPoints; i++){ var x = view.getFloat32(i*17 + 0, true) + scope.boundingBox.min.x; var y = view.getFloat32(i*17 + 4, true) + scope.boundingBox.min.y; @@ -13586,40 +13586,40 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){ var r = view.getUint8(i*17 + 12, true); var g = view.getUint8(i*17 + 13, true); var b = view.getUint8(i*17 + 14, true); - + positions[i*3+0] = x; positions[i*3+1] = y; positions[i*3+2] = z; - + colors[i*3+0] = r; colors[i*3+1] = g; colors[i*3+2] = b; - + iIndices[i] = i; } - - + + var geometry = new THREE.BufferGeometry(); geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + let indicesAttribute = new THREE.Uint8BufferAttribute(indices, 4); indicesAttribute.normalized = true; geometry.addAttribute("indices", indicesAttribute); - + scope.geometry = geometry; scope.loaded = true; Potree.PointCloudArena4DGeometryNode.nodesLoading--; - + geometry.boundingBox = scope.boundingBox; geometry.boundingSphere = scope.boundingSphere; - + scope.numPoints = numPoints; scope.loading = false; }; - + xhr.send(null); }; @@ -13628,7 +13628,7 @@ Potree.PointCloudArena4DGeometryNode.prototype.dispose = function(){ this.geometry.dispose(); this.geometry = null; this.loaded = false; - + //this.dispatchEvent( { type: 'dispose' } ); for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ var handler = this.oneTimeDisposeHandlers[i]; @@ -13668,12 +13668,12 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url + "?info", true); - + xhr.onreadystatechange = function(){ try{ if(xhr.readyState === 4 && xhr.status === 200){ var response = JSON.parse(xhr.responseText); - + var geometry = new Potree.PointCloudArena4DGeometry(); geometry.url = url; geometry.name = response.Name; @@ -13688,19 +13688,19 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ if(response.Spacing){ geometry.spacing = response.Spacing; } - + var offset = geometry.boundingBox.min.clone().multiplyScalar(-1); - + geometry.boundingBox.min.add(offset); geometry.boundingBox.max.add(offset); geometry.offset = offset; - + var center = geometry.boundingBox.getCenter(); var radius = geometry.boundingBox.getSize().length() / 2; geometry.boundingSphere = new THREE.Sphere(center, radius); - + geometry.loadHierarchy(); - + callback(geometry); }else if(xhr.readyState === 4){ callback(null); @@ -13710,39 +13710,39 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ callback(null); } }; - + xhr.send(null); }; Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ - var url = this.url + "?tree"; + var url = this.url + "?tree"; var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; - + var scope = this; - + xhr.onreadystatechange = function(){ if(!(xhr.readyState === 4 && xhr.status === 200)){ return; } - + var buffer = xhr.response; var numNodes = buffer.byteLength / 3; var view = new DataView(buffer); var stack = []; var root = null; - + var levels = 0; - + var start = new Date().getTime(); // read hierarchy for(var i = 0; i < numNodes; i++){ var mask = view.getUint8(i*3+0, true); var numPoints = view.getUint16(i*3+1, true); - - + + var hasLeft = (mask & 1) > 0; var hasRight = (mask & 2) > 0; var splitX = (mask & 4) > 0; @@ -13756,8 +13756,8 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }if(splitZ){ split = "Z"; } - - + + var node = new Potree.PointCloudArena4DGeometryNode(); node.hasLeft = hasLeft; node.hasRight = hasRight; @@ -13769,16 +13769,16 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ node.pcoGeometry = scope; node.level = stack.length; levels = Math.max(levels, node.level); - + if(stack.length > 0){ var parent = stack[stack.length-1]; node.boundingBox = parent.boundingBox.clone(); var parentBBSize = parent.boundingBox.getSize(); - + if(parent.hasLeft && !parent.left){ parent.left = node; parent.children.push(node); - + if(parent.split === "X"){ node.boundingBox.max.x = node.boundingBox.min.x + parentBBSize.x / 2; }else if(parent.split === "Y"){ @@ -13786,15 +13786,15 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }else if(parent.split === "Z"){ node.boundingBox.max.z = node.boundingBox.min.z + parentBBSize.z / 2; } - + var center = node.boundingBox.getCenter(); var radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); - + }else{ parent.right = node; parent.children.push(node); - + if(parent.split === "X"){ node.boundingBox.min.x = node.boundingBox.min.x + parentBBSize.x / 2; }else if(parent.split === "Y"){ @@ -13802,7 +13802,7 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }else if(parent.split === "Z"){ node.boundingBox.min.z = node.boundingBox.min.z + parentBBSize.z / 2; } - + var center = node.boundingBox.getCenter(); var radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); @@ -13814,19 +13814,19 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ var radius = root.boundingBox.getSize().length() / 2; root.boundingSphere = new THREE.Sphere(center, radius); } - + var bbSize = node.boundingBox.getSize(); node.spacing = ((bbSize.x + bbSize.y + bbSize.z) / 3) / 75; - + stack.push(node); - + if(node.isLeaf){ var done = false; while(!done && stack.length > 0){ stack.pop(); - + var top = stack[stack.length-1]; - + done = stack.length > 0 && top.hasRight && top.right == null; } } @@ -13835,18 +13835,18 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ var parseDuration = end - start; var msg = parseDuration; //document.getElementById("lblDebug").innerHTML = msg; - + scope.root = root; scope.levels = levels; //console.log(this.root); - + scope.dispatchEvent({type: "hierarchy_loaded"}); - + }; - + xhr.send(null); - - + + }; Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype, "spacing", { @@ -17253,14 +17253,14 @@ Potree.MapView = class{ let createToolIcon = function(icon, title, callback){ let element = $(` - `); - + element.click(callback); - + return element; }; @@ -17274,15 +17274,15 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: true, - showArea: false, - closed: true, + showDistances: false, + showAngles: true, + showArea: false, + closed: true, maxMarkers: 3, name: "Angle"}); } )); - + // POINT elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/point.svg", @@ -17290,16 +17290,16 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: false, - showCoordinates: true, - showArea: false, - closed: true, + showDistances: false, + showAngles: false, + showCoordinates: true, + showArea: false, + closed: true, maxMarkers: 1, name: "Point"}); } )); - + // DISTANCE elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/distance.svg", @@ -17307,13 +17307,13 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: false, + showDistances: true, + showArea: false, closed: false, name: "Distance"}); } )); - + // HEIGHT elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/height.svg", @@ -17321,15 +17321,15 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showHeight: true, - showArea: false, - closed: false, + showDistances: false, + showHeight: true, + showArea: false, + closed: false, maxMarkers: 2, name: "Height"}); } )); - + // AREA elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/area.svg", @@ -17337,20 +17337,20 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: true, + showDistances: true, + showArea: true, closed: true, name: "Area"}); } )); - + // VOLUME elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/volume.svg", "[title]tt.volume_measurement", function(){viewer.volumeTool.startInsertion()} )); - + // PROFILE elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/profile.svg", @@ -17360,14 +17360,14 @@ function initToolbar(){ viewer.profileTool.startInsertion(); } )); - + // CLIP VOLUME elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/clip_volume.svg", "[title]tt.clip_volume", function(){viewer.volumeTool.startInsertion({clip: true})} )); - + // REMOVE ALL elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/reset_tools.svg", @@ -17380,11 +17380,11 @@ function initToolbar(){ function initClassificationList(){ let elClassificationList = $("#classificationList"); - + let addClassificationItem = function(code, name){ - + let inputID = "chkClassification_" + code; - + let element = $(`
  • `); - + let elInput = element.find("input"); - + elInput.click(event => { viewer.setClassificationVisibility(code, event.target.checked); }); - + elClassificationList.append(element); }; - + addClassificationItem(0, "never classified"); addClassificationItem(1, "unclassified"); addClassificationItem(2, "ground"); @@ -17417,33 +17417,33 @@ function initClassificationList(){ } function initAccordion(){ - + $(".accordion > h3").each(function(){ let header = $(this); let content = $(this).next(); - + header.addClass("accordion-header ui-widget"); content.addClass("accordion-content ui-widget"); - + content.hide(); - + header.click(function(){ content.slideToggle(); }); }); - + // to close all, call // $(".accordion > div").hide() - - // to open the, for example, tool menu, call: + + // to open the, for example, tool menu, call: // $("#menu_tools").next().show() - + } function initAppearance(){ //$( "#optQuality" ).selectmenu(); - + //$("#optQuality").val(viewer.getQuality()).selectmenu("refresh") //$("#optQuality").selectmenu({ // change: function(event, ui){ @@ -17459,7 +17459,7 @@ function initAppearance(){ step: 1000, slide: function( event, ui ) {viewer.setPointBudget(ui.value);} }); - + $( "#sldFOV" ).slider({ value: viewer.getFOV(), min: 20, @@ -17467,7 +17467,7 @@ function initAppearance(){ step: 1, slide: function( event, ui ) {viewer.setFOV(ui.value);} }); - + $( "#sldEDLRadius" ).slider({ value: viewer.getEDLRadius(), min: 1, @@ -17475,7 +17475,7 @@ function initAppearance(){ step: 0.01, slide: function( event, ui ) {viewer.setEDLRadius(ui.value);} }); - + $( "#sldEDLStrength" ).slider({ value: viewer.getEDLStrength(), min: 0, @@ -17483,42 +17483,42 @@ function initAppearance(){ step: 0.01, slide: function( event, ui ) {viewer.setEDLStrength(ui.value);} }); - + viewer.addEventListener("point_budget_changed", function(event){ $( '#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); $( "#sldPointBudget" ).slider({value: viewer.getPointBudget()}); }); - + viewer.addEventListener("fov_changed", function(event){ $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); $( "#sldFOV" ).slider({value: viewer.getFOV()}); }); //viewer.addEventListener("quality_changed", e => { - // + // // let name = viewer.quality; - // + // // $( "#optQuality" ) // .selectmenu() // .val(name) // .selectmenu("refresh"); //}); - + viewer.addEventListener("edl_radius_changed", function(event){ $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); $( "#sldEDLRadius" ).slider({value: viewer.getEDLRadius()}); }); - + viewer.addEventListener("edl_strength_changed", function(event){ $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); $( "#sldEDLStrength" ).slider({value: viewer.getEDLStrength()}); }); - + viewer.addEventListener("background_changed", function(event){ $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); }); - - + + $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); @@ -17526,62 +17526,62 @@ function initAppearance(){ $('#chkEDLEnabled')[0].checked = viewer.getEDLEnabled(); $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); } - - + + function initNavigation(){ let elNavigation = $("#navigation"); let sldMoveSpeed = $("#sldMoveSpeed"); let lblMoveSpeed = $('#lblMoveSpeed'); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/earth_controls_1.png", "[title]tt.earth_control", function(){viewer.setNavigationMode(Potree.EarthControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/fps_controls.png", "[title]tt.flight_control", function(){viewer.setNavigationMode(Potree.FirstPersonControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/orbit_controls.svg", "[title]tt.orbit_control", function(){viewer.setNavigationMode(Potree.OrbitControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/focus.svg", "[title]tt.focus_control", function(){viewer.fitToScreen()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/topview.svg", "[title]tt.top_view_control", function(){viewer.setTopView()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/frontview.svg", "[title]tt.front_view_control", function(){viewer.setFrontView()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/leftview.svg", "[title]tt.left_view_control", function(){viewer.setLeftView()} )); - + let speedRange = new THREE.Vector2(1, 10*1000); - + let toLinearSpeed = function(value){ return Math.pow(value, 4) * speedRange.y + speedRange.x; }; - + let toExpSpeed = function(value){ return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); }; @@ -17593,22 +17593,22 @@ function initNavigation(){ step: 0.01, slide: function( event, ui ) { viewer.setMoveSpeed(toLinearSpeed(ui.value)); } }); - + viewer.addEventListener("move_speed_changed", function(event){ lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); sldMoveSpeed.slider({value: toExpSpeed(viewer.getMoveSpeed())}); }); - + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); } function initAnnotationDetails(){ - + // annotation_details let annotationPanel = $("#annotation_details"); - + let registeredEvents = []; - + let rebuild = () => { annotationPanel.empty(); for(let registeredEvent of registeredEvents){ @@ -17616,9 +17616,9 @@ function initAnnotationDetails(){ dispatcher.removeEventListener(type, callback); } registeredEvents = []; - + let checked = viewer.getShowAnnotations() ? "checked" : ""; - + let chkEnable = $(`
  • `); annotationPanel.append(chkEnable); - - + + //let stack = viewer.scene.annotations.children.reverse().map( // a => ({annotation: a, container: annotationPanel})); - + let stack = viewer.scene.annotations.children.map( a => ({annotation: a, container: annotationPanel})); - - + + while(stack.length > 0){ - + let {annotation, container} = stack.shift(); - + // ► U+25BA \u25BA // ▼ U+25BC \u25BC - + let element = $(`
    @@ -17660,12 +17660,12 @@ function initAnnotationDetails(){
    `); - + let elMain = element.find(".annotation-main"); let elExpand = element.find(".annotation-expand"); - + elExpand.css("display", annotation.children.length > 0 ? "block" : "none"); - + let actions = []; { // ACTIONS, INCLUDING GOTO LOCATION if(annotation.hasView()){ @@ -17673,38 +17673,38 @@ function initAnnotationDetails(){ "icon": Potree.resourcePath + "/icons/target.svg", "onclick": (e) => {annotation.moveHere(viewer.scene.camera)} }); - + actions.push(action); } - + for(let action of annotation.actions){ actions.push(action); } } - + actions = actions.filter( a => a.showIn === undefined || a.showIn.includes("sidebar")); - + // FIRST ACTION if(annotation.children.length === 0 && actions.length > 0){ let action = actions[0]; - + let elIcon = $(``); - + if(action.tooltip){ elIcon.attr("title", action.tooltip); } - + elMain.append(elIcon); elMain.click(e => action.onclick({annotation: annotation})); elMain.mouseover(e => elIcon.css("opacity", 1)); elMain.mouseout(e => elIcon.css("opacity", 0.5)); - + { let iconChanged = e => { elIcon.attr("src", e.icon); }; - + action.addEventListener("icon_changed", iconChanged); registeredEvents.push({ type: "icon_changed", @@ -17712,31 +17712,31 @@ function initAnnotationDetails(){ callback: iconChanged }); } - + actions.splice(0, 1); } - + // REMAINING ACTIONS for(let action of actions){ - + let elIcon = $(``); - + if(action.tooltip){ elIcon.attr("title", action.tooltip); } - + elIcon.click(e => { - action.onclick({annotation: annotation}); + action.onclick({annotation: annotation}); return false; }); elIcon.mouseover(e => elIcon.css("opacity", 1)); elIcon.mouseout(e => elIcon.css("opacity", 0.5)); - + { let iconChanged = e => { elIcon.attr("src", e.icon); }; - + action.addEventListener("icon_changed", iconChanged); registeredEvents.push({ type: "icon_changed", @@ -17744,30 +17744,30 @@ function initAnnotationDetails(){ callback: iconChanged }); } - + element.append(elIcon); } - + element.mouseover(e => annotation.setHighlighted(true)); element.mouseout(e => annotation.setHighlighted(false)); - + annotation.setHighlighted(false); - + container.append(element); - + if(annotation.children.length > 0){ - + element.click(e => { - + if(element.next().is(":visible")){ elExpand.html("\u25BA"); }else{ elExpand.html("\u25BC"); } - + element.next().toggle(100); }); - + //let left = ((annotation.level()) * 20) + "px"; let left = "20px"; let childContainer = $(`
    `); @@ -17776,38 +17776,38 @@ function initAnnotationDetails(){ stack.push({annotation: child, container: childContainer}); } } - + }; - + annotationPanel.i18n(); }; - + let annotationsChanged = e => { rebuild(); }; - + viewer.addEventListener("scene_changed", e => { e.oldScene.annotations.removeEventListener("annotation_added", annotationsChanged); e.scene.annotations.addEventListener("annotation_added", annotationsChanged); - + rebuild(); }); - + viewer.scene.annotations.addEventListener("annotation_added", annotationsChanged); - + rebuild(); } function initMeasurementDetails(){ - + let id = 0; let trackedItems = new Map(); - + let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; let mlist = $("#measurement_list"); - + let createCoordinatesTable = (measurement) => { - + let table = $(` @@ -17817,14 +17817,14 @@ function initMeasurementDetails(){
    `); - + for(let point of measurement.points){ let position = point instanceof THREE.Vector3 ? point : point.position; - + let x = Potree.utils.addCommas(position.x.toFixed(3)); let y = Potree.utils.addCommas(position.y.toFixed(3)); let z = Potree.utils.addCommas(position.z.toFixed(3)); - + let row = $(` ${x} @@ -17832,23 +17832,23 @@ function initMeasurementDetails(){ ${z} `); - + table.append(row); } - + return table; }; - + let createAttributesTable = (measurement) => { - + let elTable = $('
    '); - + let point = measurement.points[0]; - + if(point.color){ let color = point.color; let text = color.join(", "); - + elTable.append($(` rgb @@ -17856,21 +17856,21 @@ function initMeasurementDetails(){ `)); } - + return elTable; }; - + class MeasurePanel{ constructor(scene, measurement){ this.scene = scene; this.measurement = measurement; this.icon = null; - + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; this.id = this.constructor.counter; - + let title = measurement.name; - + this.elPanel = $(` @@ -17878,47 +17878,47 @@ function initMeasurementDetails(){ ${title} - + `); - + this.elContentContainer = this.elPanel.find(".measurement_content"); this.elIcon = this.elPanel.find(".measurement_item_icon"); - + this._update = () => {this.update()}; } - + destroy(){ - + } - + update(){ - + } }; - + class DistancePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Distance"; this.icon = Potree.resourcePath + "/icons/distance.svg"; this.elIcon.attr("src", this.icon); - + this.elContent = $(`
    - - - + + +
    - +
    @@ -17928,34 +17928,34 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - - + + let positions = this.measurement.points.map(p => p.position); let distances = []; for(let i = 0; i < positions.length - 1; i++){ let d = positions[i].distanceTo(positions[i+1]); distances.push(d.toFixed(3)); } - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); let elDistanceTable = this.elContent.find(`#distances_table_${this.id}`); elDistanceTable.empty(); - + for(let i = 0; i < distances.length; i++){ let label = (i === 0) ? "Distances: " : ""; let distance = distances[i]; @@ -17966,47 +17966,47 @@ function initMeasurementDetails(){ `); elDistanceTable.append(elDistance); } - - + + let elTotal = $(` Total: ${totalDistance} `); elDistanceTable.append(elTotal); - + //let elDistance = this.elContent.find(`#distance_${this.id}`); //elDistance.html(totalDistance); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class PointPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Point"; this.icon = Potree.resourcePath + "/icons/point.svg"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + - - + +
    @@ -18016,56 +18016,56 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let elAttributesContainer = this.elContent.find(".attributes_table_container"); elAttributesContainer.empty(); elAttributesContainer.append(createAttributesTable(this.measurement)); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class AreaPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Area"; this.icon = Potree.resourcePath + "/icons/area.svg"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + Area: - +
    @@ -18075,52 +18075,52 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let elArea = this.elContent.find(`#measurement_area_${this.id}`); elArea.html(this.measurement.getArea().toFixed(3)); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class AnglePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Angle"; this.icon = Potree.resourcePath + "/icons/angle.png"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + @@ -18133,7 +18133,7 @@ function initMeasurementDetails(){
    \u03b1
    - +
    @@ -18143,64 +18143,64 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let angles = []; for(let i = 0; i < this.measurement.points.length; i++){ angles.push(this.measurement.getAngle(i) * (180.0/Math.PI)); } angles = angles.map(a => a.toFixed(1) + '\u00B0'); - + let elAlpha = this.elContent.find(`#angle_cell_alpha_${this.id}`); let elBetta = this.elContent.find(`#angle_cell_betta_${this.id}`); let elGamma = this.elContent.find(`#angle_cell_gamma_${this.id}`); - + elAlpha.html(angles[0]); elBetta.html(angles[1]); elGamma.html(angles[2]); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class HeightPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Height"; this.icon = Potree.resourcePath + "/icons/height.svg"; - + this.elIcon.attr("src", this.icon); - + this.elContent = $(`
    - +
    - + Height:
    - +
    @@ -18210,25 +18210,25 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + { let points = this.measurement.points; - + let sorted = points.slice().sort( (a, b) => a.position.z - b.position.z ); let lowPoint = sorted[0].position.clone(); let highPoint = sorted[sorted.length - 1].position.clone(); @@ -18236,53 +18236,53 @@ function initMeasurementDetails(){ let max = highPoint.z; let height = max - min; height = height.toFixed(3); - + this.elHeightLabel = this.elContent.find(`#height_label_${this.id}`); this.elHeightLabel.html(`Height: ${height}`); } } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class ProfilePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Profile"; this.icon = Potree.resourcePath + "/icons/profile.svg"; - + this.elIcon.attr("src", this.icon); - + let labelID = "lblProfileWidth_" + this.id; let sliderID = "sldProfileWidth_" + this.id; - + this.elContent = $(`
    - +
    - + Width:
    - + - +
    - + - +
    @@ -18298,23 +18298,23 @@ function initMeasurementDetails(){ viewer.profileWindowController.setProfile(measurement); //viewer.profileWindow.draw(measurement); }); - + { // download this.elDownloadButton = this.elContent.find(`#download_profile_${this.id}`); - + if(viewer.server){ this.elDownloadButton.click(() => this.download()); }else{ this.elDownloadButton.hide(); } } - + { // width spinner let elWidthLabel = this.elContent.find(`#${labelID}`); let elWidthSlider = this.elContent.find(`#${sliderID}`); - + let startValue = 0; - + elWidthSlider.spinner({ min: 0, max: 10*1000*1000, @@ -18338,10 +18338,10 @@ function initMeasurementDetails(){ incremental: (count) => { let value = elWidthSlider.spinner("value"); let step = elWidthSlider.spinner("option", "step"); - + let delta = value * 0.05; let increments = Math.max(1, parseInt(delta / step)); - + return increments; } }); @@ -18354,55 +18354,55 @@ function initMeasurementDetails(){ elWidthSlider.spinner("value", measurement.getWidth()); } }; - + measurement.addEventListener("width_changed", this.widthListener); } - - + + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeProfile(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); let coordinatesTable = createCoordinatesTable(this.measurement); - + let validate = input => { return !isNaN(Number(input)); }; - + let cells = coordinatesTable.find("span"); cells.attr("contenteditable", "true"); - + cells = cells.toArray(); - + for(let i = 0; i < cells.length; i++){ let cell = cells[i]; let measure = this.measurement; let updateCallback = this._update; - + let assignValue = () => { let text = Potree.utils.removeCommas($(cell).html()); - + let num = Number(text); - + if(!isNaN(num)){ $(cell).removeClass("invalid_value"); - + measure.removeEventListener("marker_moved", updateCallback); - + let index = parseInt(i / 3); let coordinateComponent = i % 3; - + let position = measure.points[index].clone(); - + if(coordinateComponent === 0){ position.x = num; } else if(coordinateComponent === 1){ @@ -18410,50 +18410,50 @@ function initMeasurementDetails(){ } else if(coordinateComponent === 2){ position.z = num; } - + measure.setPosition(index, position); measure.addEventListener("marker_moved", updateCallback); }else{ $(cell).addClass("invalid_value"); } }; - + $(cell).on("keypress", (e) => { if(e.which === 13){ assignValue(); return false; } }); - + $(cell).focusout(() => assignValue()); - + $(cell).on("input", function(e){ let text = Potree.utils.removeCommas($(this).html()); - + let num = Number(text); - + if(!isNaN(num)){ $(this).removeClass("invalid_value"); }else{ $(this).addClass("invalid_value"); } - + }); } - + elCoordiantesContainer.append(coordinatesTable); } - + download(){ - + let profile = this.measurement; let boxes = profile.getSegmentMatrices() .map(m => m.elements.join(",")) .join(","); - + let minLOD = 0; let maxLOD = 100; - + let pcs = []; for(let pointcloud of this.scene.pointclouds){ let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); @@ -18463,54 +18463,54 @@ function initMeasurementDetails(){ }else{ pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; } - + pcs.push(pc); } - + let pc = pcs .map( v => `pointcloud[]=${v}`) .join("&"); - + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`; //console.log(request); - + let elMessage = this.elContent.find(`#download_profile_status_${this.id}`); elMessage.html("sending request..."); - + let workerID = null; - + let start = new Date().getTime(); - + let observe = () => { let request = `${viewer.server}/observe_status?workerID=${workerID}`; - + let loaded = 0; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("progress", e => { let nowLoaded = e.loaded; - + let response = xhr.responseText.substring(loaded, nowLoaded); response = JSON.parse(response); - + if(response.status === "FINISHED"){ elMessage.html(`
    Download ready`); }else{ let current = new Date().getTime(); let duration = (current - start); let seconds = parseInt(duration / 1000); - + elMessage.html(`processing request... ${seconds}s`); } - - + + loaded = nowLoaded; }); xhr.open('GET', request, true); xhr.send(null) }; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = () => { @@ -18518,7 +18518,7 @@ function initMeasurementDetails(){ //alert(xhr.responseText); let res = JSON.parse(xhr.responseText); console.log(res); - + if(res.status === "OK"){ workerID = res.workerID; elMessage.html("request is being processed"); @@ -18533,31 +18533,31 @@ function initMeasurementDetails(){ } xhr.open('GET', request, true); xhr.send(null); - + } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); this.measurement.removeEventListener("width_changed", this.widthListener); } - + }; - + class VolumePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Volume"; this.icon = Potree.resourcePath + "/icons/volume.svg"; - + this.elIcon.attr("src", this.icon); - + this.values = {}; - + this.elContent = $(`
    @@ -18573,7 +18573,7 @@ function initMeasurementDetails(){
    - +
    length @@ -18599,14 +18599,14 @@ function initMeasurementDetails(){
    - + - - + + - +
    @@ -18616,146 +18616,146 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + this.elClip = this.elContent.find(`#chkClip_${this.measurement.id}`); this.elVisible = this.elContent.find(`#chkVisible_${this.measurement.id}`); - + this.elClip.click( () => { this.measurement.clip = this.elClip.is(":checked"); }); - + this.elVisible.click( () => { this.measurement.visible = this.elVisible.is(":checked"); }); - + this.elClip.prop('checked', this.measurement.clip); this.elVisible.prop('checked', this.measurement.visible); - + this.elX = this.elContent.find(`#volume_input_x_${this.measurement.id}`); this.elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); this.elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); - + this.elLength = this.elContent.find(`#volume_input_length_${this.measurement.id}`); this.elWidth = this.elContent.find(`#volume_input_width_${this.measurement.id}`); this.elHeight = this.elContent.find(`#volume_input_height_${this.measurement.id}`); - + this.elAlpha = this.elContent.find(`#volume_input_alpha_${this.measurement.id}`); this.elBeta = this.elContent.find(`#volume_input_beta_${this.measurement.id}`); this.elGamma = this.elContent.find(`#volume_input_gamma_${this.measurement.id}`); - - + + this.elX.on("change", (e) => { let val = this.elX.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.x = val; } }); - + this.elY.on("change", (e) => { let val = this.elY.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.y = val; } }); - + this.elZ.on("change", (e) => { let val = this.elZ.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.z = val; } }); - + this.elLength.on("change", (e) => { let val = this.elLength.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.x = val; } }); - + this.elWidth.on("change", (e) => { let val = this.elWidth.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.y = val; } }); - + this.elHeight.on("change", (e) => { let val = this.elHeight.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.z = val; } }); - + let toRadians = (d) => Math.PI * d / 180; - + this.elAlpha.on("change", (e) => { let val = this.elAlpha.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.x = toRadians(val); } }); - + this.elBeta.on("change", (e) => { let val = this.elBeta.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.y = toRadians(val); } }); - + this.elGamma.on("change", (e) => { let val = this.elGamma.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.z = toRadians(val); } }); - - - + + + this.elDownloadButton = this.elContent.find(`#download_volume_${this.id}`); - + if(viewer.server){ this.elDownloadButton.click(() => this.download()); }else{ this.elDownloadButton.hide(); } - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeVolume(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.elContent.i18n(); - + this.update(); } - + download(){ - + let volume = this.measurement; let boxes = volume.matrixWorld.elements.join(","); let minLOD = 0; let maxLOD = 100; - + let pcs = []; for(let pointcloud of this.scene.pointclouds){ let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); @@ -18765,54 +18765,54 @@ function initMeasurementDetails(){ }else{ pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; } - + pcs.push(pc); } - + let pc = pcs .map( v => `pointcloud[]=${v}`) .join("&"); - + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`;//&pointCloud=${pc}`; //console.log(request); - + let elMessage = this.elContent.find(`#download_volume_status_${this.id}`); elMessage.html("sending request..."); - + let workerID = null; - + let start = new Date().getTime(); - + let observe = () => { let request = `${viewer.server}/observe_status?workerID=${workerID}`; - + let loaded = 0; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("progress", e => { let nowLoaded = e.loaded; - + let response = xhr.responseText.substring(loaded, nowLoaded); response = JSON.parse(response); - + if(response.status === "FINISHED"){ elMessage.html(`
    Download ready`); }else{ let current = new Date().getTime(); let duration = (current - start); let seconds = parseInt(duration / 1000); - + elMessage.html(`processing request... ${seconds}s`); } - - + + loaded = nowLoaded; }); xhr.open('GET', request, true); xhr.send(null) }; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = () => { @@ -18820,7 +18820,7 @@ function initMeasurementDetails(){ //alert(xhr.responseText); let res = JSON.parse(xhr.responseText); console.log(res); - + if(res.status === "OK"){ workerID = res.workerID; elMessage.html("request is being processed"); @@ -18835,81 +18835,81 @@ function initMeasurementDetails(){ } xhr.open('GET', request, true); xhr.send(null); - + } - + update(){ if(!this.destroyed){ requestAnimationFrame(this._update); } - + if(!this.elContent.is(":visible")){ return; } - + if(this.measurement.position.x !== this.values.x){ this.elX.val(this.measurement.position.x.toFixed(3)); this.values.x = this.measurement.position.x; } - + if(this.measurement.position.y !== this.values.y){ let elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); elY.val(this.measurement.position.y.toFixed(3)); this.values.y = this.measurement.position.y; } - + if(this.measurement.position.z !== this.values.z){ let elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); elZ.val(this.measurement.position.z.toFixed(3)); this.values.z = this.measurement.position.z; } - + if(this.measurement.scale.x !== this.values.length){ this.elLength.val(this.measurement.scale.x.toFixed(3)); this.values.length = this.measurement.scale.x; } - + if(this.measurement.scale.y !== this.values.width){ this.elWidth.val(this.measurement.scale.y.toFixed(3)); this.values.width = this.measurement.scale.y; } - + if(this.measurement.scale.z !== this.values.height){ this.elHeight.val(this.measurement.scale.z.toFixed(3)); this.values.height = this.measurement.scale.z; } - + let toDegrees = (r) => 180 * r / Math.PI; - + if(this.measurement.rotation.x !== this.values.alpha){ this.elAlpha.val(toDegrees(this.measurement.rotation.x).toFixed(1)); this.values.alpha = this.measurement.rotation.x; } - + if(this.measurement.rotation.y !== this.values.beta){ this.elBeta.val(toDegrees(this.measurement.rotation.y).toFixed(1)); this.values.beta = this.measurement.rotation.y; } - + if(this.measurement.rotation.z !== this.values.gamma){ this.elGamma.val(toDegrees(this.measurement.rotation.z).toFixed(1)); this.values.gamma = this.measurement.rotation.z; } - + } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); - + this.destroyed = true; } - + }; - + let TYPE = { DISTANCE: {panel: DistancePanel}, AREA: {panel: AreaPanel}, @@ -18919,7 +18919,7 @@ function initMeasurementDetails(){ PROFILE: {panel: ProfilePanel}, VOLUME: {panel: VolumePanel}, }; - + let getType = (measurement) => { if(measurement instanceof Potree.Measure){ if(measurement.showDistances && !measurement.showArea && !measurement.showAngles){ @@ -18941,15 +18941,15 @@ function initMeasurementDetails(){ return TYPE.VOLUME; } }; - + let trackMeasurement = (scene, measurement) => { id++; - + let type = getType(measurement); - + let panel = new type.panel(scene, measurement); mlist.append(panel.elPanel); - + let track = { scene: scene, measurement: measurement, @@ -18959,14 +18959,14 @@ function initMeasurementDetails(){ trackedItems.set(measurement, track); let onremove = (e) => { - + let remove = () => { panel.destroy(); scene.removeEventListener("measurement_removed", onremove); scene.removeEventListener("profile_removed", onremove); scene.removeEventListener("volume_removed", onremove); }; - + if(e.measurement instanceof Potree.Measure && e.measurement === measurement){ remove(); }else if(e.profile instanceof Potree.Profile && e.profile === measurement){ @@ -18974,63 +18974,63 @@ function initMeasurementDetails(){ }else if(e.volume instanceof Potree.Volume && e.volume === measurement){ remove(); } - + }; - + scene.addEventListener("measurement_removed", onremove); scene.addEventListener("profile_removed", onremove); scene.addEventListener("volume_removed", onremove); }; - + let scenelistener = (e) => { if(e.measurement){ trackMeasurement(e.scene, e.measurement); }else if(e.profile){ trackMeasurement(e.scene, e.profile); - + viewer.profileWindow.show(); viewer.profileWindowController.setProfile(e.profile); }else if(e.volume){ trackMeasurement(e.scene, e.volume); } }; - + let trackScene = (scene) => { //$("#measurement_details").empty(); - + trackedItems.forEach(function(trackedItem, key, map){ trackedItem.stopTracking(); }); - + let items = scene.measurements .concat(scene.profiles) .concat(scene.volumes); - + for(let measurement of items){ trackMeasurement(scene, measurement); } - + if(!scene.hasEventListener("measurement_added", scenelistener)){ scene.addEventListener("measurement_added", scenelistener); } - + if(!scene.hasEventListener("profile_added", scenelistener)){ scene.addEventListener("profile_added", scenelistener); } - + if(!scene.hasEventListener("volume_added", scenelistener)){ scene.addEventListener("volume_added", scenelistener); } }; - + trackScene(viewer.scene); - + viewer.addEventListener("scene_changed", (e) => {trackScene(e.scene)}); - - + + { // BOTTOM ACTIONS let elActionsB = $("#measurement_list_after"); - + { let icon = Potree.resourcePath + "/icons/file_geojson.svg"; let elDownload = $(` @@ -19038,18 +19038,18 @@ function initMeasurementDetails(){ `); elActionsB.append(elDownload); - + elDownload.click(function(e){ let scene = viewer.scene; let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); - + let geojson = Potree.GeoJSONExporter.toString(measurements); - + let url = window.URL.createObjectURL(new Blob([geojson], {type: 'data:application/octet-stream'})); elDownload.attr("href", url); }); } - + { let icon = Potree.resourcePath + "/icons/file_dxf.svg"; let elDownload = $(` @@ -19057,18 +19057,18 @@ function initMeasurementDetails(){ `); elActionsB.append(elDownload); - + elDownload.click(function(e){ let scene = viewer.scene; let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); - + let dxf = Potree.DXFExporter.toString(measurements); - + let url = window.URL.createObjectURL(new Blob([dxf], {type: 'data:application/octet-stream'})); elDownload.attr("href", url); }); } - + } }; @@ -19076,22 +19076,22 @@ function initMeasurementDetails(){ function initSceneList(){ let scenelist = $('#scene_list'); - + // length units $("#optLengthUnit").selectmenu({ style:'popup', - position: { - my: "top", - at: "bottom", + position: { + my: "top", + at: "bottom", collision: "flip" }, change: function(e) { let selectedValue = $("#optLengthUnit").selectmenu().val(); viewer.setLengthUnit(selectedValue); } - }); + }); $("#optLengthUnit").selectmenu().val(viewer.lengthUnit.code); $("#optLengthUnit").selectmenu("refresh"); - + let initUIElements = function(i) { // scene panel in scene list @@ -19108,16 +19108,16 @@ function initSceneList(){ ${title}
    - + `); - + { // POINT SIZE let sldPointSize = scenePanel.find(`#sldPointSize_${i}`); let lblPointSize = scenePanel.find(`#lblPointSize_${i}`); - + sldPointSize.slider({ value: pcMaterial.size, min: 0, @@ -19240,59 +19240,59 @@ function initSceneList(){ step: 0.01, slide: function( event, ui ) {pcMaterial.size = ui.value;} }); - + let update = (e) => { lblPointSize.html(pcMaterial.size.toFixed(2)); sldPointSize.slider({value: pcMaterial.size}); }; - + pcMaterial.addEventListener("point_size_changed", update); update(); } - + { // POINT SIZE TYPE let strSizeType = Object.keys(Potree.PointSizeType)[pcMaterial.pointSizeType]; - + let opt = scenePanel.find(`#optPointSizing_${i}`); opt.selectmenu(); opt.val(strSizeType).selectmenu("refresh"); - + opt.selectmenu({ change: (event, ui) => { pcMaterial.pointSizeType = Potree.PointSizeType[ui.item.value]; } }); - + pcMaterial.addEventListener("point_size_type_changed", e => { let typename = Object.keys(Potree.PointSizeType)[pcMaterial.pointSizeType]; - + $( "#optPointSizing" ).selectmenu().val(typename).selectmenu("refresh"); }); } - + { // SHAPE - + let opt = scenePanel.find(`#optShape_${i}`); - + opt.selectmenu({ change: (event, ui) => { let value = ui.item.value; - + pcMaterial.shape = Potree.PointShape[value]; } }); - + pcMaterial.addEventListener("point_shape_changed", e => { let typename = Object.keys(Potree.PointShape)[pcMaterial.shape]; - + opt.selectmenu().val(typename).selectmenu("refresh"); }); } - + { // OPACITY let sldOpacity = scenePanel.find(`#sldOpacity_${i}`); let lblOpacity = scenePanel.find(`#lblOpacity_${i}`); - + sldOpacity.slider({ value: pcMaterial.opacity, min: 0, @@ -19300,18 +19300,18 @@ function initSceneList(){ step: 0.001, slide: function( event, ui ) {pcMaterial.opacity = ui.value;} }); - + let update = (e) => { lblOpacity.html(pcMaterial.opacity.toFixed(2)); sldOpacity.slider({value: pcMaterial.opacity}); }; - + pcMaterial.addEventListener("opacity_changed", update); update(); } let inputVis = scenePanel.find("input[type='checkbox']"); - + inputVis.click(function(event){ pointcloud.visible = event.target.checked; if(viewer.profileWindowController){ @@ -19325,12 +19325,12 @@ function initSceneList(){ // ui elements $( "#optMaterial" + i ).selectmenu({ style:'popup', - position: { - my: "top", - at: "bottom", - collision: "flip" } + position: { + my: "top", + at: "bottom", + collision: "flip" } }); - + $( "#sldHeightRange" + i ).slider({ range: true, min: 0, @@ -19343,7 +19343,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "height_range_changed" + i, "viewer": viewer}); } }); - + $( "#sldTransition" + i ).slider({ value: pcMaterial.materialTransition, min: 0, @@ -19354,7 +19354,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "material_transition_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityRange" + i ).slider({ range: true, min: 0, @@ -19370,7 +19370,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_range_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityGamma" + i ).slider({ value: pcMaterial.intensityGamma, min: 0, @@ -19381,7 +19381,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_gamma_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityContrast" + i ).slider({ value: pcMaterial.intensityContrast, min: -1, @@ -19392,7 +19392,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_contrast_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityBrightness" + i ).slider({ value: pcMaterial.intensityBrightness, min: -1, @@ -19403,7 +19403,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_brightness_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBGamma" + i ).slider({ value: pcMaterial.rgbGamma, min: 0, @@ -19414,7 +19414,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_gamma_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBContrast" + i ).slider({ value: pcMaterial.rgbContrast, min: -1, @@ -19425,7 +19425,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_contrast_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBBrightness" + i ).slider({ value: pcMaterial.rgbBrightness, min: -1, @@ -19436,7 +19436,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_brightness_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightRGB" + i ).slider({ value: pcMaterial.weightRGB, min: 0, @@ -19447,7 +19447,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightIntensity" + i ).slider({ value: pcMaterial.weightIntensity, min: 0, @@ -19458,7 +19458,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightElevation" + i ).slider({ value: pcMaterial.weightElevation, min: 0, @@ -19469,7 +19469,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightClassification" + i ).slider({ value: pcMaterial.weightClassification, min: 0, @@ -19480,7 +19480,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightReturnNumber" + i ).slider({ value: pcMaterial.weightReturnNumber, min: 0, @@ -19491,7 +19491,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightSourceID" + i ).slider({ value: pcMaterial.weightSourceID, min: 0, @@ -19502,7 +19502,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $(`#materials\\.color\\.picker${i}`).spectrum({ flat: true, showInput: true, @@ -19514,14 +19514,14 @@ function initSceneList(){ let cRGB = color.toRgb(); let tc = new THREE.Color().setRGB(cRGB.r / 255, cRGB.g / 255, cRGB.b / 255); pcMaterial.color = tc; - }, + }, change: color => { let cRGB = color.toRgb(); let tc = new THREE.Color().setRGB(cRGB.r / 255, cRGB.g / 255, cRGB.b / 255); pcMaterial.color = tc; } }); - + pcMaterial.addEventListener("color_changed", e => { $(`#materials\\.color\\.picker${i}`) .spectrum("set", `#${pcMaterial.color.getHexString()}`); @@ -19530,14 +19530,14 @@ function initSceneList(){ let updateHeightRange = function(){ let box = [pointcloud.pcoGeometry.tightBoundingBox, pointcloud.getBoundingBoxWorld()] .find(v => v !== undefined); - + pointcloud.updateMatrixWorld(true); box = Potree.utils.computeTransformedBoundingBox(box, pointcloud.matrixWorld); - + let bWidth = box.max.z - box.min.z; bMin = box.min.z - 0.2 * bWidth; bMax = box.max.z + 0.2 * bWidth; - + $( "#lblHeightRange" + i )[0].innerHTML = pcMaterial.heightMin.toFixed(2) + " to " + pcMaterial.heightMax.toFixed(2); $( "#sldHeightRange" + i ).slider({ min: bMin, @@ -19545,96 +19545,96 @@ function initSceneList(){ values: [pcMaterial.heightMin, pcMaterial.heightMax] }); }; - + let updateIntensityRange = function(){ let range = pcMaterial.intensityRange; let min = Math.log2(range[0]) / 16; let max = Math.log2(range[1]) / 16; - - $( "#lblIntensityRange" + i )[0].innerHTML = - parseInt(pcMaterial.intensityRange[0]) + " to " + + + $( "#lblIntensityRange" + i )[0].innerHTML = + parseInt(pcMaterial.intensityRange[0]) + " to " + parseInt(pcMaterial.intensityRange[1]); $( "#sldIntensityRange" + i ).slider({ values: [min, max] }); }; - + { updateHeightRange(); let min = $(`#sldHeightRange${i}`).slider("option", "min"); let max = $(`#sldHeightRange${i}`).slider("option", "max"); } - + pcMaterial.addEventListener("material_property_changed", (event) => { - + updateHeightRange(); - + { // INTENSITY let gamma = pcMaterial.intensityGamma; let contrast = pcMaterial.intensityContrast; let brightness = pcMaterial.intensityBrightness; - + updateIntensityRange(); - + $('#lblIntensityGamma' + i)[0].innerHTML = gamma.toFixed(2); $("#sldIntensityGamma" + i).slider({value: gamma}); - + $('#lblIntensityContrast' + i)[0].innerHTML = contrast.toFixed(2); $("#sldIntensityContrast" + i).slider({value: contrast}); - + $('#lblIntensityBrightness' + i)[0].innerHTML = brightness.toFixed(2); $("#sldIntensityBrightness" + i).slider({value: brightness}); } - + { // RGB let gamma = pcMaterial.rgbGamma; let contrast = pcMaterial.rgbContrast; let brightness = pcMaterial.rgbBrightness; - + $('#lblRGBGamma' + i)[0].innerHTML = gamma.toFixed(2); $("#sldRGBGamma" + i).slider({value: gamma}); - + $('#lblRGBContrast' + i)[0].innerHTML = contrast.toFixed(2); $("#sldRGBContrast" + i).slider({value: contrast}); - + $('#lblRGBBrightness' + i)[0].innerHTML = brightness.toFixed(2); $("#sldRGBBrightness" + i).slider({value: brightness}); } }); - - + + viewer.addEventListener("length_unit_changed", e => { $("#optLengthUnit").selectmenu().val(e.value); $("#optLengthUnit").selectmenu("refresh"); }); - + viewer.addEventListener("pointcloud_loaded", updateHeightRange); - + updateHeightRange(); updateIntensityRange(); $('#lblIntensityGamma' + i)[0].innerHTML = pcMaterial.intensityGamma.toFixed(2); $('#lblIntensityContrast' + i)[0].innerHTML = pcMaterial.intensityContrast.toFixed(2); $('#lblIntensityBrightness' + i)[0].innerHTML = pcMaterial.intensityBrightness.toFixed(2); - + $('#lblRGBGamma' + i)[0].innerHTML = pcMaterial.rgbGamma.toFixed(2); $('#lblRGBContrast' + i)[0].innerHTML = pcMaterial.rgbContrast.toFixed(2); $('#lblRGBBrightness' + i)[0].innerHTML = pcMaterial.rgbBrightness.toFixed(2); - let options = [ - "RGB", + let options = [ + "RGB", "RGB and Elevation", - "Color", - "Elevation", - "Intensity", - "Intensity Gradient", - "Classification", - "Return Number", - "Source", + "Color", + "Elevation", + "Intensity", + "Intensity Gradient", + "Classification", + "Return Number", + "Source", "Phong", "Level of Detail", "Composite", ]; - + let elMaterialList = $("#optMaterial" + i); for(let i = 0; i < options.length; i++){ let option = options[i]; @@ -19646,26 +19646,26 @@ function initSceneList(){ `); elMaterialList.append(elOption); } - - let updateMaterialPanel = function(event, ui){ + + let updateMaterialPanel = function(event, ui){ let selectedValue = $("#optMaterial" + i).selectmenu().val(); pcMaterial.pointColorType = viewer.toMaterialID(selectedValue); viewer.dispatchEvent({"type": "material_changed" + i, "viewer": viewer}); - + let blockWeights = $("#materials\\.composite_weight_container" + i); let blockElevation = $("#materials\\.elevation_container" + i); let blockRGB = $("#materials\\.rgb_container" + i); let blockColor = $("#materials\\.color_container" + i); let blockIntensity = $("#materials\\.intensity_container" + i); let blockTransition = $("#materials\\.transition_container" + i); - + blockIntensity.css("display", "none"); blockElevation.css("display", "none"); blockRGB.css("display", "none"); blockColor.css("display", "none"); blockWeights.css("display", "none"); blockTransition.css("display", "none"); - + if(selectedValue === "Composite"){ blockWeights.css("display", "block"); blockElevation.css("display", "block"); @@ -19686,65 +19686,65 @@ function initSceneList(){ blockIntensity.css("display", "block"); } }; - + $("#optMaterial" + i).selectmenu({change: updateMaterialPanel}); $("#optMaterial" + i).val(viewer.toMaterialName(pcMaterial.pointColorType)).selectmenu("refresh"); updateMaterialPanel(); - + viewer.addEventListener("material_changed" + i, e => { $("#optMaterial" + i).val(viewer.toMaterialName(pcMaterial.pointColorType)).selectmenu("refresh"); }); scenePanel.i18n(); - }; - + }; + let buildSceneList = () => { scenelist.empty(); - + for(let i = 0; i < viewer.scene.pointclouds.length; i++) { initUIElements(i); } }; - + buildSceneList(); viewer.addEventListener("scene_changed", (e) => { buildSceneList(); - + if(e.oldScene){ e.oldScene.removeEventListener("pointcloud_added", buildSceneList); } e.scene.addEventListener("pointcloud_added", buildSceneList); }); - + viewer.scene.addEventListener("pointcloud_added", buildSceneList); - - + + let lastPos = new THREE.Vector3(); let lastTarget = new THREE.Vector3(); viewer.addEventListener("update", e => { let pos = viewer.scene.view.position; let target = viewer.scene.view.getPivot(); - + if(pos.equals(lastPos) && target.equals(lastTarget)){ return; }else{ lastPos.copy(pos); lastTarget.copy(target); } - + let strCamPos = "
    " + [pos.x, pos.y, pos.z].map(e => e.toFixed(2)).join(", "); let strCamTarget = "
    " + [target.x, target.y, target.z].map(e => e.toFixed(2)).join(", "); - + $('#lblCameraPosition').html(strCamPos); $('#lblCameraTarget').html(strCamTarget); - - + + }); }; let initSettings = function(){ - + $( "#sldMinNodeSize" ).slider({ value: viewer.getMinNodeSize(), min: 0, @@ -19752,14 +19752,14 @@ let initSettings = function(){ step: 0.01, slide: function( event, ui ) {viewer.setMinNodeSize(ui.value);} }); - + viewer.addEventListener("minnodesize_changed", function(event){ $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize())); $("#sldMinNodeSize").slider({value: viewer.getMinNodeSize()}); }); $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize())); - - + + let toClipModeCode = function(string){ if(string === "No Clipping"){ return Potree.ClipMode.DISABLED; @@ -19769,7 +19769,7 @@ let initSettings = function(){ return Potree.ClipMode.CLIP_OUTSIDE; } }; - + let toClipModeString = function(code){ if(code === Potree.ClipMode.DISABLED){ return "No Clipping"; @@ -19779,7 +19779,7 @@ let initSettings = function(){ return "Clip Outside"; } }; - + $("#optClipMode").selectmenu(); $("#optClipMode").val(toClipModeString(viewer.getClipMode())).selectmenu("refresh") $("#optClipMode").selectmenu({ @@ -19787,10 +19787,10 @@ let initSettings = function(){ viewer.setClipMode(toClipModeCode(ui.item.value)); } }); - + viewer.addEventListener("clip_mode_changed", e => { let string = toClipModeString(viewer.clipMode); - + $( "#optClipMode" ) .selectmenu() .val(string) @@ -19808,7 +19808,7 @@ let initSidebar = function(){ initMeasurementDetails(); initSceneList(); initSettings() - + $('#potree_version_number').html(Potree.version.major + "." + Potree.version.minor + Potree.version.suffix); $('.perfect_scrollbar').perfectScrollbar(); } diff --git a/package.json b/package.json index bed03ce2..78e0d22a 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "license": "BSD-2-CLAUSE", "devDependencies": { "gulp": "~3.5.2", - "gulp-jshint": "^2.0.4", + "gulp-jshint": "^2.0.4", "gulp-size": "^2.1.0", - "jshint": "^2.9.5" + "jshint": "^2.9.5", "gulp-concat": "~2.1.7", "gulp-connect": "^2.3.1", "gulp-rename": "~1.0.0", diff --git a/src/PointCloudOctreeGeometry.js b/src/PointCloudOctreeGeometry.js index eccb251b..f28273d0 100644 --- a/src/PointCloudOctreeGeometry.js +++ b/src/PointCloudOctreeGeometry.js @@ -59,13 +59,13 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function(){ var children = []; - + for(var i = 0; i < 8; i++){ if(this.children[i]){ children.push(this.children[i]); } } - + return children; }; @@ -75,9 +75,9 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){ var url = ""; - + var version = this.pcoGeometry.loader.version; - + if(version.equalOrHigher("1.5")){ url = this.pcoGeometry.octreeDir + "/" + this.getHierarchyPath() + "/" + this.name; }else if(version.equalOrHigher("1.4")){ @@ -85,7 +85,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){ }else if(version.upTo("1.3")){ url = this.pcoGeometry.octreeDir + "/" + this.name; } - + return url; }; @@ -94,12 +94,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function(){ var hierarchyStepSize = this.pcoGeometry.hierarchyStepSize; var indices = this.name.substr(1); - + var numParts = Math.floor(indices.length / hierarchyStepSize); for(var i = 0; i < numParts; i++){ path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + "/"; } - + path = path.slice(0,-1); return path; @@ -114,12 +114,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ if(this.loading === true || this.loaded === true ||this.pcoGeometry.numNodesLoading > 3){ return; } - + this.loading = true; - + this.pcoGeometry.numNodesLoading++; - - + + if(this.pcoGeometry.loader.version.equalOrHigher("1.5")){ if((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren){ this.loadHierachyThenPoints(); @@ -129,8 +129,8 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ }else{ this.loadPoints(); } - - + + }; Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function(){ @@ -146,51 +146,51 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( var callback = function(node, hbuffer){ var count = hbuffer.byteLength / 5; var view = new DataView(hbuffer); - + var stack = []; var children = view.getUint8(0); var numPoints = view.getUint32(1, true); node.numPoints = numPoints; stack.push({children: children, numPoints: numPoints, name: node.name}); - + var decoded = []; - + var offset = 5; while(stack.length > 0){ - + var snode = stack.shift(); var mask = 1; for(var i = 0; i < 8; i++){ if((snode.children & mask) !== 0){ var childIndex = i; var childName = snode.name + i; - + var childChildren = view.getUint8(offset); var childNumPoints = view.getUint32(offset + 1, true); - + stack.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + decoded.push({children: childChildren, numPoints: childNumPoints, name: childName}); - + offset += 5; } - + mask = mask * 2; } - + if(offset === hbuffer.byteLength){ break; } - + } - + //console.log(decoded); - + var nodes = {}; nodes[node.name] = node; var pco = node.pcoGeometry; - - + + for( var i = 0; i < decoded.length; i++){ var name = decoded[i].name; var numPoints = decoded[i].numPoints; @@ -199,7 +199,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( var parentNode = nodes[parentName]; var level = name.length-1; var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index); - + var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); currentNode.level = level; currentNode.numPoints = numPoints; @@ -208,14 +208,14 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function( parentNode.addChild(currentNode); nodes[name] = currentNode; } - + node.loadPoints(); - + }; if((node.level % node.pcoGeometry.hierarchyStepSize) === 0){ //var hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc"; var hurl = node.pcoGeometry.octreeDir + "/" + node.getHierarchyPath() + "/" + node.name + ".hrc"; - + var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', hurl, true); xhr.responseType = 'arraybuffer'; @@ -250,7 +250,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ this.geometry.dispose(); this.geometry = null; this.loaded = false; - + //this.dispatchEvent( { type: 'dispose' } ); for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ var handler = this.oneTimeDisposeHandlers[i]; diff --git a/src/Potree.js b/src/Potree.js index ff2ed502..77f2c7bf 100644 --- a/src/Potree.js +++ b/src/Potree.js @@ -7,7 +7,7 @@ function Potree(){ Potree.version = { major: 1, minor: 5, - suffix: "RC-Synth" + suffix: "RC" }; console.log("Potree " + Potree.version.major + "." + Potree.version.minor + Potree.version.suffix); @@ -48,17 +48,17 @@ Potree.startQuery = function(name, gl){ if(!Potree.timerQueriesEnabled){ return null; } - + if(Potree.timerQueries[name] === undefined){ Potree.timerQueries[name] = []; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); let query = ext.createQueryEXT(); ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, query); - + Potree.timerQueries[name].push(query); - + return query; }; @@ -66,7 +66,7 @@ Potree.endQuery = function(query, gl){ if(!Potree.timerQueriesEnabled){ return; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); ext.endQueryEXT(ext.TIME_ELAPSED_EXT); }; @@ -75,28 +75,28 @@ Potree.resolveQueries = function(gl){ if(!Potree.timerQueriesEnabled){ return; } - + let ext = gl.getExtension("EXT_disjoint_timer_query"); - + for(let name in Potree.timerQueries){ let queries = Potree.timerQueries[name]; - + if(queries.length > 0){ let query = queries[0]; - + let available = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_AVAILABLE_EXT); let disjoint = viewer.renderer.getContext().getParameter(ext.GPU_DISJOINT_EXT); - + if (available && !disjoint) { // See how much time the rendering of the object took in nanoseconds. let timeElapsed = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_EXT); let miliseconds = timeElapsed / (1000 * 1000); - + console.log(name + ": " + miliseconds + "ms"); queries.shift(); } } - + if(queries.length === 0){ delete Potree.timerQueries[name]; } @@ -111,75 +111,75 @@ Potree.MOUSE = { }; Potree.Points = class Points{ - + constructor(){ - + this.boundingBox = new THREE.Box3(); this.numPoints = 0; this.data = {}; - + } - + add(points){ - + let currentSize = this.numPoints; let additionalSize = points.numPoints; let newSize = currentSize + additionalSize; - + let thisAttributes = Object.keys(this.data); let otherAttributes = Object.keys(points.data); let attributes = new Set([...thisAttributes, ...otherAttributes]); - + for(let attribute of attributes){ if(thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + // attribute in both, merge let type = this.data[attribute].constructor; let merged = new type(this.data[attribute].length + points.data[attribute].length); merged.set(this.data[attribute], 0); merged.set(points.data[attribute], this.data[attribute].length); this.data[attribute] = merged; - + }else if(thisAttributes.includes(attribute) && !otherAttributes.includes(attribute)){ - + // attribute only in this; take over this and expand to new size let elementsPerPoint = this.data[attribute].length / this.numPoints; let type = this.data[attribute].constructor; let expanded = new type(elementsPerPoint * newSize); expanded.set(this.data[attribute], 0); this.data[attribute] = expanded; - + }else if(!thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){ - + // attribute only in points to be added; take over new points and expand to new size let elementsPerPoint = points.data[attribute].length / points.numPoints; let type = points.data[attribute].constructor; let expanded = new type(elementsPerPoint * newSize); expanded.set(points.data[attribute], elementsPerPoint * currentSize); this.data[attribute] = expanded; - + } } - + this.numPoints = newSize; - + this.boundingBox.union(points.boundingBox); } - + }; Potree.loadPointCloud = function(path, name, callback){ - + let loaded = function(pointcloud){ pointcloud.name = name; - + callback({type: "pointcloud_loaded", pointcloud: pointcloud}); }; - + // load pointcloud if(!path){ - + }else if(path.indexOf("greyhound://") === 0){ // We check if the path string starts with 'greyhound:', if so we assume it's a greyhound server URL. Potree.GreyhoundLoader.load(path, function(geometry) { @@ -225,9 +225,9 @@ Potree.updatePointClouds = function(pointclouds, camera, renderer){ pointcloud.profileRequests[j].update(); } } - + let result = Potree.updateVisibility(pointclouds, camera, renderer); - + for(let i = 0; i < pointclouds.length; i++){ let pointcloud = pointclouds[i]; pointcloud.updateMaterial(pointcloud.material, pointcloud.visibleNodes, camera, renderer); @@ -252,10 +252,10 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ let frustums = []; let camObjPositions = []; let priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;}); - + for(let i = 0; i < pointclouds.length; i++){ let pointcloud = pointclouds[i]; - + if(!pointcloud.initialized()){ continue; } @@ -294,12 +294,12 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ if(pointcloud.root.isTreeNode()){ pointcloud.hideDescendants(pointcloud.root.sceneNode); } - + for(let j = 0; j < pointcloud.boundingBoxNodes.length; j++){ pointcloud.boundingBoxNodes[j].visible = false; } } - + return { "frustums": frustums, "camObjPositions" : camObjPositions, @@ -312,12 +312,12 @@ Potree.getDEMWorkerInstance = function(){ let workerPath = Potree.scriptPath + "/workers/DEMWorker.js"; Potree.DEMWorkerInstance = Potree.workerPool.getWorker(workerPath); } - + return Potree.DEMWorkerInstance; } function createDEMMesh(dem){ - + let box = dem.boundingBox; let steps = 256; @@ -328,7 +328,7 @@ function createDEMMesh(dem){ let u1 = (i+1) / steps; let v0 = j / steps; let v1 = (j+1) / steps; - + //let x0 = box.min.x + u0 * box.getSize().x; //let x1 = box.min.x + u1 * box.getSize().x; //let y0 = box.min.y + v0 * box.getSize().y; @@ -338,36 +338,36 @@ function createDEMMesh(dem){ //let h10 = dem.height(new THREE.Vector3(x1, y0, 0)); //let h01 = dem.height(new THREE.Vector3(x0, y1, 0)); //let h11 = dem.height(new THREE.Vector3(x1, y1, 0)); - + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - + //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + let h00 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - + if(![h00, h10, h01, h11].every(n => isFinite(n))){ continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); @@ -381,10 +381,10 @@ function createDEMMesh(dem){ } function createDEMMeshNode(dem, demNode){ - + let box = demNode.box; let tileSize = dem.tileSize * 1; - + let triangles = []; for(let i = 0; i < tileSize; i++){ //for(let j = 0; j < 1; j++){ @@ -393,36 +393,36 @@ function createDEMMeshNode(dem, demNode){ let u1 = (i+1) / tileSize; let v0 = j / tileSize; let v1 = (j+1) / tileSize; - + let x0 = u0 * box.getSize().x; let x1 = u1 * box.getSize().x; let y0 = v0 * box.getSize().y; let y1 = v1 * box.getSize().y; - + //let h00 = demNode.data[(i+0) + tileSize * (j+0)]; //let h10 = demNode.data[(i+1) + tileSize * (j+0)]; //let h01 = demNode.data[(i+0) + tileSize * (j+1)]; //let h11 = demNode.data[(i+1) + tileSize * (j+1)]; - + let h00 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0)); let h10 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0)); let h01 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1)); let h11 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1)); - + if(![h00, h10, h01, h11].every(n => isFinite(n))){ continue; } - + triangles.push(x0, y0, h00); triangles.push(x0, y1, h01); triangles.push(x1, y0, h10); - + triangles.push(x0, y1, h01); triangles.push(x1, y1, h11); triangles.push(x1, y0, h10); } } - + let geometry = new THREE.BufferGeometry(); let positions = new Float32Array(triangles); geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3)); @@ -433,10 +433,10 @@ function createDEMMeshNode(dem, demNode){ mesh.position.copy(box.min); //mesh.position.copy(pointcloud.position); viewer.scene.scene.add(mesh); - + { // DEBUG code //let data = demNode.data; - + let steps = 64; let data = new Float32Array(steps * steps); let imgData = new Uint8Array(data.length * 4); @@ -450,12 +450,12 @@ function createDEMMeshNode(dem, demNode){ v * boxSize.y + box.min.y, 0 ); - + let height = demNode.height(pos); - + let index = i + steps * j; data[index] = height - + //let index = i + steps * j; //imgData[4*index + 0] = 255 * (height - min) / (max - min); //imgData[4*index + 1] = 100; @@ -463,97 +463,97 @@ function createDEMMeshNode(dem, demNode){ //imgData[4*index + 3] = 255; } } - + let [min, max] = [Infinity, -Infinity]; for(let height of data){ if(!isFinite(height)){ continue; } - + min = Math.min(min, height); max = Math.max(max, height); } - + for(let i = 0; i < data.length; i++){ imgData[4*i + 0] = 255 * (data[i] - min) / (max - min); imgData[4*i + 1] = 100; imgData[4*i + 2] = 0; imgData[4*i + 3] = 255; } - + let img = Potree.utils.pixelsArrayToImage(imgData, steps, steps); - + let screenshot = img.src; - + if(!this.debugDIV){ this.debugDIV = $(` -
    `); $(document.body).append(this.debugDIV); } - + this.debugDIV.empty(); this.debugDIV.append($(``)); - + } } Potree.updateVisibility = function(pointclouds, camera, renderer){ let numVisibleNodes = 0; let numVisiblePoints = 0; - + let visibleNodes = []; let visibleGeometry = []; let unloadedGeometry = []; - + let lowestSpacing = Infinity; - + // calculate object space frustum and cam pos and setup priority queue let s = updateVisibilityStructures(pointclouds, camera, renderer); let frustums = s.frustums; let camObjPositions = s.camObjPositions; let priorityQueue = s.priorityQueue; - + let loadedToGPUThisFrame = 0; - + while(priorityQueue.size() > 0){ let element = priorityQueue.pop(); let node = element.node; let parent = element.parent; let pointcloud = pointclouds[element.pointcloud]; - + //{ // restrict to certain nodes for debugging // let allowedNodes = ["r", "r0", "r4"]; // if(!allowedNodes.includes(node.name)){ // continue; // } //} - + let box = node.getBoundingBox(); let frustum = frustums[element.pointcloud]; let camObjPos = camObjPositions[element.pointcloud]; - + let insideFrustum = frustum.intersectsBox(box); let maxLevel = pointcloud.maxLevel || Infinity; let level = node.getLevel(); let visible = insideFrustum; visible = visible && !(numVisiblePoints + node.getNumPoints() > Potree.pointBudget); visible = visible && level < maxLevel; - + if (pointcloud.material.numClipBoxes > 0 && visible && pointcloud.material.clipMode == Potree.ClipMode.CLIP_OUTSIDE) { - let box2 = box.clone(); + let box2 = box.clone(); pointcloud.updateMatrixWorld(true); box2.applyMatrix4(pointcloud.matrixWorld); let intersectsClipBoxes = false; for(let clipBox of pointcloud.material.clipBoxes) { let clipMatrixWorld = clipBox.matrix; let clipBoxWorld = new THREE.Box3( - new THREE.Vector3(-0.5, -0.5, -0.5), + new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, 0.5, 0.5)) .applyMatrix4(clipMatrixWorld); if (box2.intersectsBox(clipBoxWorld)) { @@ -563,21 +563,21 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ } visible = visible && intersectsClipBoxes; } - + //visible = ["r", "r0", "r06", "r060"].includes(node.name); //visible = ["r"].includes(node.name); - + if(node.spacing){ lowestSpacing = Math.min(lowestSpacing, node.spacing); }else if(node.geometryNode && node.geometryNode.spacing){ lowestSpacing = Math.min(lowestSpacing, node.geometryNode.spacing); } - + if(numVisiblePoints + node.getNumPoints() > Potree.pointBudget){ break; } - - + + if(!visible){ continue; } @@ -622,27 +622,27 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ }else if(!pointcloud.showBoundingBox && node.boundingBoxNode){ node.boundingBoxNode.visible = false; } - + } // add child nodes to priorityQueue let children = node.getChildren(); for(let i = 0; i < children.length; i++){ let child = children[i]; - + let sphere = child.getBoundingSphere(); let distance = sphere.center.distanceTo(camObjPos); let radius = sphere.radius; - + let fov = (camera.fov * Math.PI) / 180; let slope = Math.tan(fov / 2); let projFactor = (0.5 * renderer.domElement.clientHeight) / (slope * distance); let screenPixelRadius = radius * projFactor; - + if(screenPixelRadius < pointcloud.minimumNodePixelSize){ continue; } - + let weight = screenPixelRadius; if(distance - radius < 0){ @@ -654,7 +654,7 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ }// end priority queue loop - + { // update DEM let maxDEMLevel = 4; let candidates = pointclouds @@ -664,25 +664,25 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ pointcloud.dem.update(updatingNodes); } } - + for(let i = 0; i < Math.min(5, unloadedGeometry.length); i++){ unloadedGeometry[i].load(); } - + //for(let node of visibleNodes){ // let allowedNodes = ["r", "r0", "r4"]; // node.sceneNode.visible = allowedNodes.includes(node.geometryNode.name); - // + // // if(node.boundingBoxNode){ // node.boundingBoxNode.visible = node.boundingBoxNode.visible && node.sceneNode.visible; // } //} - - + + //Potree.updateDEMs(renderer, visibleNodes); return { - visibleNodes: visibleNodes, + visibleNodes: visibleNodes, numVisiblePoints: numVisiblePoints, lowestSpacing: lowestSpacing }; @@ -725,144 +725,144 @@ Potree.XHRFactory = { Potree.DEMRenderer = class{ constructor(renderer){ this.renderer = renderer; - + this.tileWidth = 64; this.tileHeight = 64; - - //this.target = new THREE.WebGLRenderTarget( 64, 64, { - // minFilter: THREE.NearestFilter, - // magFilter: THREE.NearestFilter, - // format: THREE.RGBAFormat, + + //this.target = new THREE.WebGLRenderTarget( 64, 64, { + // minFilter: THREE.NearestFilter, + // magFilter: THREE.NearestFilter, + // format: THREE.RGBAFormat, // type: THREE.FloatType //} ); //this.target.depthTexture = new THREE.DepthTexture(); //this.target.depthTexture.type = THREE.UnsignedIntType; - - this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - - this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { - minFilter: THREE.NearestFilter, - magFilter: THREE.NearestFilter, + + this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, { + minFilter: THREE.NearestFilter, + magFilter: THREE.NearestFilter, format: THREE.RGBAFormat, //type: THREE.FloatType }); - + this.vsElevation = ` precision mediump float; precision mediump int; - + attribute vec3 position; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying float vElevation; - + void main(){ vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; gl_PointSize = 1.0; - + vElevation = position.z; } `; - + this.fsElevation = ` precision mediump float; precision mediump int; - + varying float vElevation; - + void main(){ gl_FragColor = vec4(vElevation, 0.0, 0.0, 1.0); } `; - + this.vsMedian = ` precision mediump float; precision mediump int; - + attribute vec3 position; attribute vec2 uv; - + uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; - + varying vec2 vUV; void main() { vUV = uv; - + vec4 mvPosition = modelViewMatrix * vec4(position,1.0); gl_Position = projectionMatrix * mvPosition; } `; - + this.fsMedian = ` - + precision mediump float; precision mediump int; - + uniform float uWidth; - uniform float uHeight; + uniform float uHeight; uniform sampler2D uTexture; varying vec2 vUV; - + void main(){ - vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); - + vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight); + vec4 color = texture2D(uTexture, uv); gl_FragColor = color; if(color.a == 0.0){ - + vec4 sum; - + float minVal = 1.0 / 0.0; - + float sumA = 0.0; for(int i = -1; i <= 1; i++){ for(int j = -1; j <= 1; j++){ vec2 n = gl_FragCoord.xy + vec2(i, j); - vec2 uv = n / vec2(uWidth, uHeight); + vec2 uv = n / vec2(uWidth, uHeight); vec4 c = texture2D(uTexture, uv); - + if(c.a == 1.0){ minVal = min(c.r, minVal); } - + sumA += c.a; } } - + if(sumA > 0.0){ gl_FragColor = vec4(minVal, 0.0, 0.0, 1.0); }else{ - discard; + discard; } }else{ //gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); gl_FragColor = vec4(color.rgb, 1.0); } - - + + } - + `; - + this.elevationMaterial = new THREE.RawShaderMaterial( { vertexShader: this.vsElevation, fragmentShader: this.fsElevation, } ); - + this.medianFilterMaterial = new THREE.RawShaderMaterial( { uniforms: { uWidth: {value: 1.0}, @@ -872,28 +872,28 @@ Potree.DEMRenderer = class{ vertexShader: this.vsMedian, fragmentShader: this.fsMedian, }); - + this.camera = new THREE.OrthographicCamera(0, 1, 1, 0, 0, 1); - - + + } - + render(pointcloud, node){ if(!node.geometryNode){ return; } - + Potree.timerQueriesEnabled = true; let start = new Date().getTime(); let queryAll = Potree.startQuery("All", this.renderer.getContext()); - + this.renderer.setClearColor(0x0000FF, 0); this.renderer.clearTarget( this.target, true, true, true ); this.renderer.clearTarget(this.targetElevation, true, true, false ); this.renderer.clearTarget(this.targetMedian, true, true, false ); - + let box = node.geometryNode.boundingBox; - + this.camera.up.set(0, 0, 1); //this.camera.rotation.x = Math.PI / 2; this.camera.left = box.min.x; @@ -903,53 +903,53 @@ Potree.DEMRenderer = class{ this.camera.near = -1000; this.camera.far = 1000; this.camera.updateProjectionMatrix(); - + let scene = new THREE.Scene(); //let material = new THREE.PointsMaterial({color: 0x00ff00, size: 0.0001}); let material = this.elevationMaterial; let points = new THREE.Points(node.geometryNode.geometry, material); scene.add(points); - + this.renderer.render(points, this.camera, this.targetElevation); - + this.medianFilterMaterial.uniforms.uWidth.value = this.targetMedian.width; this.medianFilterMaterial.uniforms.uHeight.value = this.targetMedian.height; this.medianFilterMaterial.uniforms.uTexture.value = this.targetElevation.texture; - + Potree.utils.screenPass.render(this.renderer, this.medianFilterMaterial, this.targetMedian); - + Potree.endQuery(queryAll, this.renderer.getContext()); Potree.resolveQueries(this.renderer.getContext()); Potree.timerQueriesEnabled = false; - - + + setTimeout( () => { let start = new Date().getTime(); - + let pixelCount = this.tileWidth * this.tileHeight; let buffer = new Uint8Array(4 * pixelCount); - this.renderer.readRenderTargetPixels(this.targetMedian, - 0, 0, this.tileWidth, this.tileHeight, + this.renderer.readRenderTargetPixels(this.targetMedian, + 0, 0, this.tileWidth, this.tileHeight, buffer); - + let end = new Date().getTime(); let duration = end - start; console.log(`read duration: ${duration}ms`); }, 3000); - + let end = new Date().getTime(); let duration = end - start; - + console.log(`duration: ${duration}ms`); - + //{ // open window with image // // let pixelCount = this.tileWidth * this.tileHeight; // let buffer = new Float32Array(4 * pixelCount); - // this.renderer.readRenderTargetPixels(this.targetMedian, - // 0, 0, this.tileWidth, this.tileHeight, + // this.renderer.readRenderTargetPixels(this.targetMedian, + // 0, 0, this.tileWidth, this.tileHeight, // buffer); - // + // // let uiBuffer = new Uint8Array(4 * pixelCount); // for(let i = 0; i < pixelCount; i++){ // uiBuffer[i] = buffer[i] / 1.0; @@ -957,18 +957,18 @@ Potree.DEMRenderer = class{ // // let img = Potree.utils.pixelsArrayToImage(uiBuffer, this.tileWidth, this.tileHeight); // let screenshot = img.src; - // + // // if(!this.debugDIV){ // this.debugDIV = $(` - //
    `); // $(document.body).append(this.debugDIV); // } - // + // // this.debugDIV.empty(); // this.debugDIV.append($(``)); diff --git a/src/arena4d/PointCloudArena4DGeometry.js b/src/arena4d/PointCloudArena4DGeometry.js index aefb492b..f6506ccd 100644 --- a/src/arena4d/PointCloudArena4DGeometry.js +++ b/src/arena4d/PointCloudArena4DGeometry.js @@ -39,15 +39,15 @@ Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function(){ Potree.PointCloudArena4DGeometryNode.prototype.getChildren = function(){ var children = []; - + if(this.left){ children.push(this.left); - } - + } + if(this.right){ children.push(this.right); } - + return children; }; @@ -64,36 +64,36 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){ if(this.loaded || this.loading){ return; } - + if(Potree.PointCloudArena4DGeometryNode.nodesLoading >= 5){ return; } - + this.loading = true; - + Potree.PointCloudArena4DGeometryNode.nodesLoading++; - + var url = this.pcoGeometry.url + "?node=" + this.number; var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; - + var scope = this; - + xhr.onreadystatechange = function(){ if(!(xhr.readyState === 4 && xhr.status === 200)){ return; } - + var buffer = xhr.response; var view = new DataView(buffer); var numPoints = buffer.byteLength / 17; - + var positions = new Float32Array(numPoints*3); var colors = new Uint8Array(numPoints*3); var indices = new ArrayBuffer(numPoints*4); var iIndices = new Uint32Array(indices); - + for(var i = 0; i < numPoints; i++){ var x = view.getFloat32(i*17 + 0, true) + scope.boundingBox.min.x; var y = view.getFloat32(i*17 + 4, true) + scope.boundingBox.min.y; @@ -101,40 +101,40 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){ var r = view.getUint8(i*17 + 12, true); var g = view.getUint8(i*17 + 13, true); var b = view.getUint8(i*17 + 14, true); - + positions[i*3+0] = x; positions[i*3+1] = y; positions[i*3+2] = z; - + colors[i*3+0] = r; colors[i*3+1] = g; colors[i*3+2] = b; - + iIndices[i] = i; } - - + + var geometry = new THREE.BufferGeometry(); geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3)); geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + let indicesAttribute = new THREE.Uint8BufferAttribute(indices, 4); indicesAttribute.normalized = true; geometry.addAttribute("indices", indicesAttribute); - + scope.geometry = geometry; scope.loaded = true; Potree.PointCloudArena4DGeometryNode.nodesLoading--; - + geometry.boundingBox = scope.boundingBox; geometry.boundingSphere = scope.boundingSphere; - + scope.numPoints = numPoints; scope.loading = false; }; - + xhr.send(null); }; @@ -143,7 +143,7 @@ Potree.PointCloudArena4DGeometryNode.prototype.dispose = function(){ this.geometry.dispose(); this.geometry = null; this.loaded = false; - + //this.dispatchEvent( { type: 'dispose' } ); for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){ var handler = this.oneTimeDisposeHandlers[i]; @@ -183,12 +183,12 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url + "?info", true); - + xhr.onreadystatechange = function(){ try{ if(xhr.readyState === 4 && xhr.status === 200){ var response = JSON.parse(xhr.responseText); - + var geometry = new Potree.PointCloudArena4DGeometry(); geometry.url = url; geometry.name = response.Name; @@ -203,19 +203,19 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ if(response.Spacing){ geometry.spacing = response.Spacing; } - + var offset = geometry.boundingBox.min.clone().multiplyScalar(-1); - + geometry.boundingBox.min.add(offset); geometry.boundingBox.max.add(offset); geometry.offset = offset; - + var center = geometry.boundingBox.getCenter(); var radius = geometry.boundingBox.getSize().length() / 2; geometry.boundingSphere = new THREE.Sphere(center, radius); - + geometry.loadHierarchy(); - + callback(geometry); }else if(xhr.readyState === 4){ callback(null); @@ -225,39 +225,39 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){ callback(null); } }; - + xhr.send(null); }; Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ - var url = this.url + "?tree"; + var url = this.url + "?tree"; var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open("GET", url, true); xhr.responseType = "arraybuffer"; - + var scope = this; - + xhr.onreadystatechange = function(){ if(!(xhr.readyState === 4 && xhr.status === 200)){ return; } - + var buffer = xhr.response; var numNodes = buffer.byteLength / 3; var view = new DataView(buffer); var stack = []; var root = null; - + var levels = 0; - + var start = new Date().getTime(); // read hierarchy for(var i = 0; i < numNodes; i++){ var mask = view.getUint8(i*3+0, true); var numPoints = view.getUint16(i*3+1, true); - - + + var hasLeft = (mask & 1) > 0; var hasRight = (mask & 2) > 0; var splitX = (mask & 4) > 0; @@ -271,8 +271,8 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }if(splitZ){ split = "Z"; } - - + + var node = new Potree.PointCloudArena4DGeometryNode(); node.hasLeft = hasLeft; node.hasRight = hasRight; @@ -284,16 +284,16 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ node.pcoGeometry = scope; node.level = stack.length; levels = Math.max(levels, node.level); - + if(stack.length > 0){ var parent = stack[stack.length-1]; node.boundingBox = parent.boundingBox.clone(); var parentBBSize = parent.boundingBox.getSize(); - + if(parent.hasLeft && !parent.left){ parent.left = node; parent.children.push(node); - + if(parent.split === "X"){ node.boundingBox.max.x = node.boundingBox.min.x + parentBBSize.x / 2; }else if(parent.split === "Y"){ @@ -301,15 +301,15 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }else if(parent.split === "Z"){ node.boundingBox.max.z = node.boundingBox.min.z + parentBBSize.z / 2; } - + var center = node.boundingBox.getCenter(); var radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); - + }else{ parent.right = node; parent.children.push(node); - + if(parent.split === "X"){ node.boundingBox.min.x = node.boundingBox.min.x + parentBBSize.x / 2; }else if(parent.split === "Y"){ @@ -317,7 +317,7 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ }else if(parent.split === "Z"){ node.boundingBox.min.z = node.boundingBox.min.z + parentBBSize.z / 2; } - + var center = node.boundingBox.getCenter(); var radius = node.boundingBox.getSize().length() / 2; node.boundingSphere = new THREE.Sphere(center, radius); @@ -329,19 +329,19 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ var radius = root.boundingBox.getSize().length() / 2; root.boundingSphere = new THREE.Sphere(center, radius); } - + var bbSize = node.boundingBox.getSize(); node.spacing = ((bbSize.x + bbSize.y + bbSize.z) / 3) / 75; - + stack.push(node); - + if(node.isLeaf){ var done = false; while(!done && stack.length > 0){ stack.pop(); - + var top = stack[stack.length-1]; - + done = stack.length > 0 && top.hasRight && top.right == null; } } @@ -350,18 +350,18 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){ var parseDuration = end - start; var msg = parseDuration; //document.getElementById("lblDebug").innerHTML = msg; - + scope.root = root; scope.levels = levels; //console.log(this.root); - + scope.dispatchEvent({type: "hierarchy_loaded"}); - + }; - + xhr.send(null); - - + + }; Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype, "spacing", { diff --git a/src/loader/GreyhoundLoader.js b/src/loader/GreyhoundLoader.js index 48206752..002538d6 100644 --- a/src/loader/GreyhoundLoader.js +++ b/src/loader/GreyhoundLoader.js @@ -7,7 +7,7 @@ */ class GreyhoundUtils{ - + static getQueryParam(name) { name = name.replace(/[\[\]]/g, "\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), @@ -16,7 +16,7 @@ class GreyhoundUtils{ if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\+/g, " ")); } - + static createSchema(attributes) { var schema = [ { "name": "X", "size": 4, "type": "signed" }, @@ -46,7 +46,7 @@ class GreyhoundUtils{ return schema; } - + static fetch(url, cb) { var xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url, true); @@ -129,7 +129,7 @@ class GreyhoundUtils{ cb(null, { color: colorNorm, intensity: intensityNorm }); }); }; - + }; Potree.GreyhoundLoader = function() { }; diff --git a/src/loader/LasLazLoader.js b/src/loader/LasLazLoader.js index 105a027d..0bb6bbb6 100644 --- a/src/loader/LasLazLoader.js +++ b/src/loader/LasLazLoader.js @@ -7,9 +7,9 @@ * Thanks to Uday Verma and Howard Butler * */ - + Potree.LasLazLoader = class LasLazLoader{ - + constructor(version){ if(typeof(version) === "string"){ this.version = new Potree.Version(version); @@ -17,27 +17,27 @@ Potree.LasLazLoader = class LasLazLoader{ this.version = version; } } - + static progressCB(){ - + } - + load(node){ - + if(node.loaded){ return; } - + let pointAttributes = node.pcoGeometry.pointAttributes; let url = node.getURL(); - + if(this.version.equalOrHigher("1.4")){ url += "." + pointAttributes.toLowerCase(); } - + let scope = this; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; @@ -52,14 +52,14 @@ Potree.LasLazLoader = class LasLazLoader{ } } }; - + xhr.send(null); } - + parse(node, buffer){ let lf = new LASFile(buffer); let handler = new Potree.LasLazBatcher(node); - + return Promise.resolve(lf).cancellable().then(function(lf) { return lf.open().then(function() { lf.isOpen = true; @@ -79,7 +79,7 @@ Potree.LasLazLoader = class LasLazLoader{ }).then(function(v) { let lf = v[0]; let header = v[1]; - + let skip = 1; let totalRead = 0; let totalToRead = (skip <= 1 ? header.pointsCount : header.pointsCount / skip); @@ -108,7 +108,7 @@ Potree.LasLazLoader = class LasLazLoader{ } }); }; - + return reader(); }).then(function(v) { let lf = v[0]; @@ -130,7 +130,7 @@ Potree.LasLazLoader = class LasLazLoader{ }).catch(Promise.CancellationError, function(e) { // If there was a cancellation, make sure the file is closed, if the file is open // close and then fail - if (lf.isOpen) + if (lf.isOpen) return lf.close().then(function() { lf.isOpen = false; throw e; @@ -138,32 +138,32 @@ Potree.LasLazLoader = class LasLazLoader{ throw e; }); } - + handle(node, url){ - + } - + }; Potree.LasLazBatcher = class LasLazBatcher{ - - constructor(node){ + + constructor(node){ this.node = node; } - + push(lasBuffer){ - + let workerPath = Potree.scriptPath + "/workers/LASDecoderWorker.js"; let worker = Potree.workerPool.getWorker(workerPath); - + worker.onmessage = (e) => { let geometry = new THREE.BufferGeometry(); let numPoints = lasBuffer.pointsCount; - + let endsWith = function(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; }; - + let positions = e.data.position; let colors = new Uint8Array(e.data.color); let intensities = e.data.intensity; @@ -173,14 +173,14 @@ Potree.LasLazBatcher = class LasLazBatcher{ let pointSourceIDs = new Uint16Array(e.data.pointSourceID); //let indices = new ArrayBuffer(numPoints*4); //let iIndices = new Uint32Array(indices); - + //let box = new THREE.Box3(); // //let fPositions = new Float32Array(positions); - //for(let i = 0; i < numPoints; i++){ + //for(let i = 0; i < numPoints; i++){ // box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2])); //} - + geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3)); geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true)); geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(intensities), 1)); @@ -189,28 +189,28 @@ Potree.LasLazBatcher = class LasLazBatcher{ geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(numberOfReturns, 1)); geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(pointSourceIDs, 1)); geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3)); - + let indicesAttribute = new THREE.Uint8BufferAttribute(e.data.indices, 4); indicesAttribute.normalized = true; geometry.addAttribute("indices", indicesAttribute); - + let tightBoundingBox = new THREE.Box3( new THREE.Vector3().fromArray(e.data.tightBoundingBox.min), new THREE.Vector3().fromArray(e.data.tightBoundingBox.max) ); - + geometry.boundingBox = this.node.boundingBox; this.node.tightBoundingBox = tightBoundingBox; - + this.node.geometry = geometry; this.node.loaded = true; this.node.loading = false; this.node.pcoGeometry.numNodesLoading--; this.node.mean = new THREE.Vector3(...e.data.mean); - + Potree.workerPool.returnWorker(workerPath, worker); }; - + let message = { buffer: lasBuffer.arrayb, numPoints: lasBuffer.pointsCount, diff --git a/src/utils.js b/src/utils.js index f0497b9c..b83dc640 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,15 +1,15 @@ Potree.utils = class{ - + static loadShapefileFeatures(file, callback){ - + let features = []; - + let handleFinish = () => { callback(features); }; - + shapefile.open(file) .then(source => {source.read() .then(function log(result){ @@ -17,18 +17,18 @@ Potree.utils = class{ handleFinish(); return; } - + //console.log(result.value); - + if(result.value && result.value.type === "Feature" && result.value.geometry !== undefined){ features.push(result.value); } - + return source.read().then(log); }) }); } - + static toString(value){ if(value instanceof THREE.Vector3){ return value.x.toFixed(2) + ", " + value.y.toFixed(2) + ", " + value.z.toFixed(2); @@ -36,10 +36,10 @@ Potree.utils = class{ return "" + value + ""; } } - + static normalizeURL(url){ let u = new URL(url); - + return u.protocol + "//" + u.hostname + u.pathname.replace(/\/+/g, "/"); }; @@ -69,16 +69,16 @@ Potree.utils = class{ new THREE.Vector3(box.max.x, box.min.y, box.max.z).applyMatrix4(transform), new THREE.Vector3(box.max.x, box.max.y, box.max.z).applyMatrix4(transform) ]; - + let boundingBox = new THREE.Box3(); boundingBox.setFromPoints( vertices ); - + return boundingBox; }; /** * add separators to large numbers - * + * * @param nStr * @returns */ @@ -93,7 +93,7 @@ Potree.utils = class{ } return x1 + x2; }; - + static removeCommas(str){ return str.replace(/,/g, ""); } @@ -106,7 +106,7 @@ Potree.utils = class{ static createWorker(code){ let blob = new Blob([code], {type: 'application/javascript'}); let worker = new Worker(URL.createObjectURL(blob)); - + return worker; }; @@ -121,7 +121,7 @@ Potree.utils = class{ path + 'py' + format, path + 'ny' + format, path + 'pz' + format, path + 'nz' + format ]; - + //var materialArray = []; //for (var i = 0; i < 6; i++){ // materialArray.push( new THREE.MeshBasicMaterial({ @@ -132,20 +132,20 @@ Potree.utils = class{ // }) // ); //} - + let materialArray = []; { for (let i = 0; i < 6; i++){ - + let material = new THREE.MeshBasicMaterial({ map: null, side: THREE.BackSide, depthTest: false, depthWrite: false }); - + materialArray.push(material); - + let loader = new THREE.TextureLoader(); loader.load( urls[i], function loaded(texture){ @@ -158,18 +158,18 @@ Potree.utils = class{ } ); } - - + + } - + var skyGeometry = new THREE.CubeGeometry( 5000, 5000, 5000 ); var skybox = new THREE.Mesh( skyGeometry, materialArray ); scene.add(skybox); - + // z up scene.rotation.x = Math.PI / 2; - + return {"camera": camera, "scene": scene}; }; @@ -177,18 +177,18 @@ Potree.utils = class{ let material = new THREE.LineBasicMaterial({ color: color || 0x888888 }); - + let geometry = new THREE.Geometry(); for(let i = 0; i <= length; i++){ geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, i*spacing-(spacing*length)/2, 0)); } - + for(let i = 0; i <= width; i++){ geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, -(spacing*length)/2, 0)); geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, +(spacing*length)/2, 0)); } - + let line = new THREE.LineSegments(geometry, material, THREE.LinePieces); line.receiveShadow = true; return line; @@ -212,24 +212,24 @@ Potree.utils = class{ for(let y = 0; y < height; y++){ let u = 2 * (x / width) - 1; let v = 2 * (y / height) - 1; - + let i = x + width*y; let d = gauss(2*u, 2*v) / max; let r = (Math.random() + Math.random() + Math.random()) / 3; r = (d * 0.5 + 0.5) * r * 0.03; r = r * 0.4; - + //d = Math.pow(d, 0.6); - + data[3*i+0] = 255 * (d / 15 + 0.05 + r) * chroma[0]; data[3*i+1] = 255 * (d / 15 + 0.05 + r) * chroma[1]; data[3*i+2] = 255 * (d / 15 + 0.05 + r) * chroma[2]; } } - + let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); texture.needsUpdate = true; - + return texture; }; @@ -238,31 +238,31 @@ Potree.utils = class{ x: (mouse.x / renderer.domElement.clientWidth ) * 2 - 1, y: - (mouse.y / renderer.domElement.clientHeight ) * 2 + 1 }; - + //let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 ); //vector.unproject(camera); //let direction = vector.sub(camera.position).normalize(); //let ray = new THREE.Ray(camera.position, direction); - + let raycaster = new THREE.Raycaster(); raycaster.setFromCamera(nmouse, camera); let ray = raycaster.ray; - + let selectedPointcloud = null; let closestDistance = Infinity; let closestIntersection = null; let closestPoint = null; - + for(let pointcloud of pointclouds){ let point = pointcloud.pick(renderer, camera, ray); - + if(!point){ continue; } - + let distance = camera.position.distanceTo(point.position); - + if(distance < closestDistance){ closestDistance = distance; selectedPointcloud = pointcloud; @@ -270,7 +270,7 @@ Potree.utils = class{ closestPoint = point; } } - + if(selectedPointcloud){ return { location: closestIntersection, @@ -281,17 +281,17 @@ Potree.utils = class{ }else{ return null; } - }; - + }; + static pixelsArrayToImage(pixels, width, height){ let canvas = document.createElement('canvas'); canvas.width = width; canvas.height = height; let context = canvas.getContext('2d'); - + pixels = new pixels.constructor(pixels); - + for(let i = 0; i < pixels.length; i++){ pixels[i*4 + 3] = 255; } @@ -303,18 +303,18 @@ Potree.utils = class{ let img = new Image(); img.src = canvas.toDataURL(); //img.style.transform = "scaleY(-1)"; - + return img; }; static projectedRadius(radius, fov, distance, screenHeight){ let projFactor = (1 / Math.tan(fov / 2)) / distance; projFactor = projFactor * screenHeight / 2; - + return radius * projFactor; }; - - + + static topView(camera, node){ camera.position.set(0, 1, 0); camera.rotation.set(-Math.PI / 2, 0, 0); @@ -339,9 +339,9 @@ Potree.utils = class{ camera.rotation.set(0, Math.PI / 2, 0); camera.zoomTo(node, 1); }; - + /** - * + * * 0: no intersection * 1: intersection * 2: fully inside @@ -352,7 +352,7 @@ Potree.utils = class{ let negRadius = - sphere.radius; let minDistance = Number.MAX_VALUE; - + for ( let i = 0; i < 6; i ++ ) { let distance = planes[ i ].distanceToPoint( center ); @@ -362,47 +362,47 @@ Potree.utils = class{ return 0; } - + minDistance = Math.min(minDistance, distance); } return (minDistance >= sphere.radius) ? 2 : 1; }; - + // code taken from three.js // ImageUtils - generateDataTexture() static generateDataTexture(width, height, color){ let size = width * height; let data = new Uint8Array(3 * width * height); - + let r = Math.floor( color.r * 255 ); let g = Math.floor( color.g * 255 ); let b = Math.floor( color.b * 255 ); - + for ( let i = 0; i < size; i ++ ) { data[ i * 3 ] = r; data[ i * 3 + 1 ] = g; data[ i * 3 + 2 ] = b; } - + let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat ); texture.needsUpdate = true; texture.magFilter = THREE.NearestFilter; - + return texture; }; - + // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript static getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " ")); } - + static setParameter(name, value){ //value = encodeURIComponent(value); - + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); let regex = new RegExp("([\\?&])(" + name + "=([^&#]*))"); let results = regex.exec(location.search); @@ -422,7 +422,7 @@ Potree.utils = class{ } window.history.replaceState({}, "", url); } - + }; Potree.utils.screenPass = new function(){ @@ -434,10 +434,10 @@ Potree.utils.screenPass = new function(){ this.screenQuad.material.transparent = true; this.screenScene.add(this.screenQuad); this.camera = new THREE.Camera(); - + this.render = function(renderer, material, target){ this.screenQuad.material = material; - + if(typeof target === "undefined"){ renderer.render(this.screenScene, this.camera); }else{ diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index f1656dc0..ac5d1faa 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -3,14 +3,14 @@ let createToolIcon = function(icon, title, callback){ let element = $(` - `); - + element.click(callback); - + return element; }; @@ -24,15 +24,15 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: true, - showArea: false, - closed: true, + showDistances: false, + showAngles: true, + showArea: false, + closed: true, maxMarkers: 3, name: "Angle"}); } )); - + // POINT elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/point.svg", @@ -40,16 +40,16 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showAngles: false, - showCoordinates: true, - showArea: false, - closed: true, + showDistances: false, + showAngles: false, + showCoordinates: true, + showArea: false, + closed: true, maxMarkers: 1, name: "Point"}); } )); - + // DISTANCE elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/distance.svg", @@ -57,13 +57,13 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: false, + showDistances: true, + showArea: false, closed: false, name: "Distance"}); } )); - + // HEIGHT elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/height.svg", @@ -71,15 +71,15 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: false, - showHeight: true, - showArea: false, - closed: false, + showDistances: false, + showHeight: true, + showArea: false, + closed: false, maxMarkers: 2, name: "Height"}); } )); - + // AREA elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/area.svg", @@ -87,20 +87,20 @@ function initToolbar(){ function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ - showDistances: true, - showArea: true, + showDistances: true, + showArea: true, closed: true, name: "Area"}); } )); - + // VOLUME elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/volume.svg", "[title]tt.volume_measurement", function(){viewer.volumeTool.startInsertion()} )); - + // PROFILE elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/profile.svg", @@ -110,14 +110,14 @@ function initToolbar(){ viewer.profileTool.startInsertion(); } )); - + // CLIP VOLUME elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/clip_volume.svg", "[title]tt.clip_volume", function(){viewer.volumeTool.startInsertion({clip: true})} )); - + // REMOVE ALL elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/reset_tools.svg", @@ -130,11 +130,11 @@ function initToolbar(){ function initClassificationList(){ let elClassificationList = $("#classificationList"); - + let addClassificationItem = function(code, name){ - + let inputID = "chkClassification_" + code; - + let element = $(`
  • `); - + let elInput = element.find("input"); - + elInput.click(event => { viewer.setClassificationVisibility(code, event.target.checked); }); - + elClassificationList.append(element); }; - + addClassificationItem(0, "never classified"); addClassificationItem(1, "unclassified"); addClassificationItem(2, "ground"); @@ -167,33 +167,33 @@ function initClassificationList(){ } function initAccordion(){ - + $(".accordion > h3").each(function(){ let header = $(this); let content = $(this).next(); - + header.addClass("accordion-header ui-widget"); content.addClass("accordion-content ui-widget"); - + content.hide(); - + header.click(function(){ content.slideToggle(); }); }); - + // to close all, call // $(".accordion > div").hide() - - // to open the, for example, tool menu, call: + + // to open the, for example, tool menu, call: // $("#menu_tools").next().show() - + } function initAppearance(){ //$( "#optQuality" ).selectmenu(); - + //$("#optQuality").val(viewer.getQuality()).selectmenu("refresh") //$("#optQuality").selectmenu({ // change: function(event, ui){ @@ -209,7 +209,7 @@ function initAppearance(){ step: 1000, slide: function( event, ui ) {viewer.setPointBudget(ui.value);} }); - + $( "#sldFOV" ).slider({ value: viewer.getFOV(), min: 20, @@ -217,7 +217,7 @@ function initAppearance(){ step: 1, slide: function( event, ui ) {viewer.setFOV(ui.value);} }); - + $( "#sldEDLRadius" ).slider({ value: viewer.getEDLRadius(), min: 1, @@ -225,7 +225,7 @@ function initAppearance(){ step: 0.01, slide: function( event, ui ) {viewer.setEDLRadius(ui.value);} }); - + $( "#sldEDLStrength" ).slider({ value: viewer.getEDLStrength(), min: 0, @@ -233,42 +233,42 @@ function initAppearance(){ step: 0.01, slide: function( event, ui ) {viewer.setEDLStrength(ui.value);} }); - + viewer.addEventListener("point_budget_changed", function(event){ $( '#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); $( "#sldPointBudget" ).slider({value: viewer.getPointBudget()}); }); - + viewer.addEventListener("fov_changed", function(event){ $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); $( "#sldFOV" ).slider({value: viewer.getFOV()}); }); //viewer.addEventListener("quality_changed", e => { - // + // // let name = viewer.quality; - // + // // $( "#optQuality" ) // .selectmenu() // .val(name) // .selectmenu("refresh"); //}); - + viewer.addEventListener("edl_radius_changed", function(event){ $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); $( "#sldEDLRadius" ).slider({value: viewer.getEDLRadius()}); }); - + viewer.addEventListener("edl_strength_changed", function(event){ $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); $( "#sldEDLStrength" ).slider({value: viewer.getEDLStrength()}); }); - + viewer.addEventListener("background_changed", function(event){ $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); }); - - + + $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); @@ -276,62 +276,62 @@ function initAppearance(){ $('#chkEDLEnabled')[0].checked = viewer.getEDLEnabled(); $("input[name=background][value='" + viewer.getBackground() + "']").prop("checked",true); } - - + + function initNavigation(){ let elNavigation = $("#navigation"); let sldMoveSpeed = $("#sldMoveSpeed"); let lblMoveSpeed = $('#lblMoveSpeed'); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/earth_controls_1.png", "[title]tt.earth_control", function(){viewer.setNavigationMode(Potree.EarthControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/fps_controls.png", "[title]tt.flight_control", function(){viewer.setNavigationMode(Potree.FirstPersonControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/orbit_controls.svg", "[title]tt.orbit_control", function(){viewer.setNavigationMode(Potree.OrbitControls)} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/focus.svg", "[title]tt.focus_control", function(){viewer.fitToScreen()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/topview.svg", "[title]tt.top_view_control", function(){viewer.setTopView()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/frontview.svg", "[title]tt.front_view_control", function(){viewer.setFrontView()} )); - + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/leftview.svg", "[title]tt.left_view_control", function(){viewer.setLeftView()} )); - + let speedRange = new THREE.Vector2(1, 10*1000); - + let toLinearSpeed = function(value){ return Math.pow(value, 4) * speedRange.y + speedRange.x; }; - + let toExpSpeed = function(value){ return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); }; @@ -343,22 +343,22 @@ function initNavigation(){ step: 0.01, slide: function( event, ui ) { viewer.setMoveSpeed(toLinearSpeed(ui.value)); } }); - + viewer.addEventListener("move_speed_changed", function(event){ lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); sldMoveSpeed.slider({value: toExpSpeed(viewer.getMoveSpeed())}); }); - + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); } function initAnnotationDetails(){ - + // annotation_details let annotationPanel = $("#annotation_details"); - + let registeredEvents = []; - + let rebuild = () => { annotationPanel.empty(); for(let registeredEvent of registeredEvents){ @@ -366,9 +366,9 @@ function initAnnotationDetails(){ dispatcher.removeEventListener(type, callback); } registeredEvents = []; - + let checked = viewer.getShowAnnotations() ? "checked" : ""; - + let chkEnable = $(`
  • `); annotationPanel.append(chkEnable); - - + + //let stack = viewer.scene.annotations.children.reverse().map( // a => ({annotation: a, container: annotationPanel})); - + let stack = viewer.scene.annotations.children.map( a => ({annotation: a, container: annotationPanel})); - - + + while(stack.length > 0){ - + let {annotation, container} = stack.shift(); - + // ► U+25BA \u25BA // ▼ U+25BC \u25BC - + let element = $(`
    @@ -410,12 +410,12 @@ function initAnnotationDetails(){
    `); - + let elMain = element.find(".annotation-main"); let elExpand = element.find(".annotation-expand"); - + elExpand.css("display", annotation.children.length > 0 ? "block" : "none"); - + let actions = []; { // ACTIONS, INCLUDING GOTO LOCATION if(annotation.hasView()){ @@ -423,38 +423,38 @@ function initAnnotationDetails(){ "icon": Potree.resourcePath + "/icons/target.svg", "onclick": (e) => {annotation.moveHere(viewer.scene.camera)} }); - + actions.push(action); } - + for(let action of annotation.actions){ actions.push(action); } } - + actions = actions.filter( a => a.showIn === undefined || a.showIn.includes("sidebar")); - + // FIRST ACTION if(annotation.children.length === 0 && actions.length > 0){ let action = actions[0]; - + let elIcon = $(``); - + if(action.tooltip){ elIcon.attr("title", action.tooltip); } - + elMain.append(elIcon); elMain.click(e => action.onclick({annotation: annotation})); elMain.mouseover(e => elIcon.css("opacity", 1)); elMain.mouseout(e => elIcon.css("opacity", 0.5)); - + { let iconChanged = e => { elIcon.attr("src", e.icon); }; - + action.addEventListener("icon_changed", iconChanged); registeredEvents.push({ type: "icon_changed", @@ -462,31 +462,31 @@ function initAnnotationDetails(){ callback: iconChanged }); } - + actions.splice(0, 1); } - + // REMAINING ACTIONS for(let action of actions){ - + let elIcon = $(``); - + if(action.tooltip){ elIcon.attr("title", action.tooltip); } - + elIcon.click(e => { - action.onclick({annotation: annotation}); + action.onclick({annotation: annotation}); return false; }); elIcon.mouseover(e => elIcon.css("opacity", 1)); elIcon.mouseout(e => elIcon.css("opacity", 0.5)); - + { let iconChanged = e => { elIcon.attr("src", e.icon); }; - + action.addEventListener("icon_changed", iconChanged); registeredEvents.push({ type: "icon_changed", @@ -494,30 +494,30 @@ function initAnnotationDetails(){ callback: iconChanged }); } - + element.append(elIcon); } - + element.mouseover(e => annotation.setHighlighted(true)); element.mouseout(e => annotation.setHighlighted(false)); - + annotation.setHighlighted(false); - + container.append(element); - + if(annotation.children.length > 0){ - + element.click(e => { - + if(element.next().is(":visible")){ elExpand.html("\u25BA"); }else{ elExpand.html("\u25BC"); } - + element.next().toggle(100); }); - + //let left = ((annotation.level()) * 20) + "px"; let left = "20px"; let childContainer = $(`
    `); @@ -526,38 +526,38 @@ function initAnnotationDetails(){ stack.push({annotation: child, container: childContainer}); } } - + }; - + annotationPanel.i18n(); }; - + let annotationsChanged = e => { rebuild(); }; - + viewer.addEventListener("scene_changed", e => { e.oldScene.annotations.removeEventListener("annotation_added", annotationsChanged); e.scene.annotations.addEventListener("annotation_added", annotationsChanged); - + rebuild(); }); - + viewer.scene.annotations.addEventListener("annotation_added", annotationsChanged); - + rebuild(); } function initMeasurementDetails(){ - + let id = 0; let trackedItems = new Map(); - + let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; let mlist = $("#measurement_list"); - + let createCoordinatesTable = (measurement) => { - + let table = $(` @@ -567,14 +567,14 @@ function initMeasurementDetails(){
    `); - + for(let point of measurement.points){ let position = point instanceof THREE.Vector3 ? point : point.position; - + let x = Potree.utils.addCommas(position.x.toFixed(3)); let y = Potree.utils.addCommas(position.y.toFixed(3)); let z = Potree.utils.addCommas(position.z.toFixed(3)); - + let row = $(` ${x} @@ -582,23 +582,23 @@ function initMeasurementDetails(){ ${z} `); - + table.append(row); } - + return table; }; - + let createAttributesTable = (measurement) => { - + let elTable = $('
    '); - + let point = measurement.points[0]; - + if(point.color){ let color = point.color; let text = color.join(", "); - + elTable.append($(` rgb @@ -606,21 +606,21 @@ function initMeasurementDetails(){ `)); } - + return elTable; }; - + class MeasurePanel{ constructor(scene, measurement){ this.scene = scene; this.measurement = measurement; this.icon = null; - + this.constructor.counter = (this.constructor.counter === undefined) ? 0 : this.constructor.counter + 1; this.id = this.constructor.counter; - + let title = measurement.name; - + this.elPanel = $(` @@ -628,47 +628,47 @@ function initMeasurementDetails(){ ${title}
    - + `); - + this.elContentContainer = this.elPanel.find(".measurement_content"); this.elIcon = this.elPanel.find(".measurement_item_icon"); - + this._update = () => {this.update()}; } - + destroy(){ - + } - + update(){ - + } }; - + class DistancePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Distance"; this.icon = Potree.resourcePath + "/icons/distance.svg"; this.elIcon.attr("src", this.icon); - + this.elContent = $(`
    - - - + + +
    - +
    @@ -678,34 +678,34 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - - + + let positions = this.measurement.points.map(p => p.position); let distances = []; for(let i = 0; i < positions.length - 1; i++){ let d = positions[i].distanceTo(positions[i+1]); distances.push(d.toFixed(3)); } - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); let elDistanceTable = this.elContent.find(`#distances_table_${this.id}`); elDistanceTable.empty(); - + for(let i = 0; i < distances.length; i++){ let label = (i === 0) ? "Distances: " : ""; let distance = distances[i]; @@ -716,47 +716,47 @@ function initMeasurementDetails(){ `); elDistanceTable.append(elDistance); } - - + + let elTotal = $(` Total: ${totalDistance} `); elDistanceTable.append(elTotal); - + //let elDistance = this.elContent.find(`#distance_${this.id}`); //elDistance.html(totalDistance); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class PointPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Point"; this.icon = Potree.resourcePath + "/icons/point.svg"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + - - + +
    @@ -766,56 +766,56 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let elAttributesContainer = this.elContent.find(".attributes_table_container"); elAttributesContainer.empty(); elAttributesContainer.append(createAttributesTable(this.measurement)); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class AreaPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Area"; this.icon = Potree.resourcePath + "/icons/area.svg"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + Area: - +
    @@ -825,52 +825,52 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let elArea = this.elContent.find(`#measurement_area_${this.id}`); elArea.html(this.measurement.getArea().toFixed(3)); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class AnglePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Angle"; this.icon = Potree.resourcePath + "/icons/angle.png"; - + this.elIcon.attr("src", this.icon); - + let totalDistance = this.measurement.getTotalDistance().toFixed(3); this.elContent = $(`
    - +
    - + @@ -883,7 +883,7 @@ function initMeasurementDetails(){
    \u03b1
    - +
    @@ -893,64 +893,64 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + let angles = []; for(let i = 0; i < this.measurement.points.length; i++){ angles.push(this.measurement.getAngle(i) * (180.0/Math.PI)); } angles = angles.map(a => a.toFixed(1) + '\u00B0'); - + let elAlpha = this.elContent.find(`#angle_cell_alpha_${this.id}`); let elBetta = this.elContent.find(`#angle_cell_betta_${this.id}`); let elGamma = this.elContent.find(`#angle_cell_gamma_${this.id}`); - + elAlpha.html(angles[0]); elBetta.html(angles[1]); elGamma.html(angles[2]); } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class HeightPanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Height"; this.icon = Potree.resourcePath + "/icons/height.svg"; - + this.elIcon.attr("src", this.icon); - + this.elContent = $(`
    - +
    - + Height:
    - +
    @@ -960,25 +960,25 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeMeasurement(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); elCoordiantesContainer.append(createCoordinatesTable(this.measurement)); - + { let points = this.measurement.points; - + let sorted = points.slice().sort( (a, b) => a.position.z - b.position.z ); let lowPoint = sorted[0].position.clone(); let highPoint = sorted[sorted.length - 1].position.clone(); @@ -986,53 +986,53 @@ function initMeasurementDetails(){ let max = highPoint.z; let height = max - min; height = height.toFixed(3); - + this.elHeightLabel = this.elContent.find(`#height_label_${this.id}`); this.elHeightLabel.html(`Height: ${height}`); } } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); } - + }; - + class ProfilePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Profile"; this.icon = Potree.resourcePath + "/icons/profile.svg"; - + this.elIcon.attr("src", this.icon); - + let labelID = "lblProfileWidth_" + this.id; let sliderID = "sldProfileWidth_" + this.id; - + this.elContent = $(`
    - +
    - + Width:
    - + - +
    - + - +
    @@ -1048,23 +1048,23 @@ function initMeasurementDetails(){ viewer.profileWindowController.setProfile(measurement); //viewer.profileWindow.draw(measurement); }); - + { // download this.elDownloadButton = this.elContent.find(`#download_profile_${this.id}`); - + if(viewer.server){ this.elDownloadButton.click(() => this.download()); }else{ this.elDownloadButton.hide(); } } - + { // width spinner let elWidthLabel = this.elContent.find(`#${labelID}`); let elWidthSlider = this.elContent.find(`#${sliderID}`); - + let startValue = 0; - + elWidthSlider.spinner({ min: 0, max: 10*1000*1000, @@ -1088,10 +1088,10 @@ function initMeasurementDetails(){ incremental: (count) => { let value = elWidthSlider.spinner("value"); let step = elWidthSlider.spinner("option", "step"); - + let delta = value * 0.05; let increments = Math.max(1, parseInt(delta / step)); - + return increments; } }); @@ -1104,55 +1104,55 @@ function initMeasurementDetails(){ elWidthSlider.spinner("value", measurement.getWidth()); } }; - + measurement.addEventListener("width_changed", this.widthListener); } - - + + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeProfile(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.update(); } - + update(){ let elCoordiantesContainer = this.elContent.find(".coordinates_table_container"); elCoordiantesContainer.empty(); let coordinatesTable = createCoordinatesTable(this.measurement); - + let validate = input => { return !isNaN(Number(input)); }; - + let cells = coordinatesTable.find("span"); cells.attr("contenteditable", "true"); - + cells = cells.toArray(); - + for(let i = 0; i < cells.length; i++){ let cell = cells[i]; let measure = this.measurement; let updateCallback = this._update; - + let assignValue = () => { let text = Potree.utils.removeCommas($(cell).html()); - + let num = Number(text); - + if(!isNaN(num)){ $(cell).removeClass("invalid_value"); - + measure.removeEventListener("marker_moved", updateCallback); - + let index = parseInt(i / 3); let coordinateComponent = i % 3; - + let position = measure.points[index].clone(); - + if(coordinateComponent === 0){ position.x = num; } else if(coordinateComponent === 1){ @@ -1160,50 +1160,50 @@ function initMeasurementDetails(){ } else if(coordinateComponent === 2){ position.z = num; } - + measure.setPosition(index, position); measure.addEventListener("marker_moved", updateCallback); }else{ $(cell).addClass("invalid_value"); } }; - + $(cell).on("keypress", (e) => { if(e.which === 13){ assignValue(); return false; } }); - + $(cell).focusout(() => assignValue()); - + $(cell).on("input", function(e){ let text = Potree.utils.removeCommas($(this).html()); - + let num = Number(text); - + if(!isNaN(num)){ $(this).removeClass("invalid_value"); }else{ $(this).addClass("invalid_value"); } - + }); } - + elCoordiantesContainer.append(coordinatesTable); } - + download(){ - + let profile = this.measurement; let boxes = profile.getSegmentMatrices() .map(m => m.elements.join(",")) .join(","); - + let minLOD = 0; let maxLOD = 100; - + let pcs = []; for(let pointcloud of this.scene.pointclouds){ let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); @@ -1213,54 +1213,54 @@ function initMeasurementDetails(){ }else{ pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; } - + pcs.push(pc); } - + let pc = pcs .map( v => `pointcloud[]=${v}`) .join("&"); - + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`; //console.log(request); - + let elMessage = this.elContent.find(`#download_profile_status_${this.id}`); elMessage.html("sending request..."); - + let workerID = null; - + let start = new Date().getTime(); - + let observe = () => { let request = `${viewer.server}/observe_status?workerID=${workerID}`; - + let loaded = 0; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("progress", e => { let nowLoaded = e.loaded; - + let response = xhr.responseText.substring(loaded, nowLoaded); response = JSON.parse(response); - + if(response.status === "FINISHED"){ elMessage.html(`
    Download ready`); }else{ let current = new Date().getTime(); let duration = (current - start); let seconds = parseInt(duration / 1000); - + elMessage.html(`processing request... ${seconds}s`); } - - + + loaded = nowLoaded; }); xhr.open('GET', request, true); xhr.send(null) }; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = () => { @@ -1268,7 +1268,7 @@ function initMeasurementDetails(){ //alert(xhr.responseText); let res = JSON.parse(xhr.responseText); console.log(res); - + if(res.status === "OK"){ workerID = res.workerID; elMessage.html("request is being processed"); @@ -1283,31 +1283,31 @@ function initMeasurementDetails(){ } xhr.open('GET', request, true); xhr.send(null); - + } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); this.measurement.removeEventListener("width_changed", this.widthListener); } - + }; - + class VolumePanel extends MeasurePanel{ constructor(scene, measurement){ super(scene, measurement); - + this.typename = "Volume"; this.icon = Potree.resourcePath + "/icons/volume.svg"; - + this.elIcon.attr("src", this.icon); - + this.values = {}; - + this.elContent = $(`
    @@ -1323,7 +1323,7 @@ function initMeasurementDetails(){
    - +
    length @@ -1349,14 +1349,14 @@ function initMeasurementDetails(){
    - + - - + + - +
    @@ -1366,146 +1366,146 @@ function initMeasurementDetails(){
    `); this.elContentContainer.append(this.elContent); - + this.elClip = this.elContent.find(`#chkClip_${this.measurement.id}`); this.elVisible = this.elContent.find(`#chkVisible_${this.measurement.id}`); - + this.elClip.click( () => { this.measurement.clip = this.elClip.is(":checked"); }); - + this.elVisible.click( () => { this.measurement.visible = this.elVisible.is(":checked"); }); - + this.elClip.prop('checked', this.measurement.clip); this.elVisible.prop('checked', this.measurement.visible); - + this.elX = this.elContent.find(`#volume_input_x_${this.measurement.id}`); this.elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); this.elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); - + this.elLength = this.elContent.find(`#volume_input_length_${this.measurement.id}`); this.elWidth = this.elContent.find(`#volume_input_width_${this.measurement.id}`); this.elHeight = this.elContent.find(`#volume_input_height_${this.measurement.id}`); - + this.elAlpha = this.elContent.find(`#volume_input_alpha_${this.measurement.id}`); this.elBeta = this.elContent.find(`#volume_input_beta_${this.measurement.id}`); this.elGamma = this.elContent.find(`#volume_input_gamma_${this.measurement.id}`); - - + + this.elX.on("change", (e) => { let val = this.elX.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.x = val; } }); - + this.elY.on("change", (e) => { let val = this.elY.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.y = val; } }); - + this.elZ.on("change", (e) => { let val = this.elZ.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.position.z = val; } }); - + this.elLength.on("change", (e) => { let val = this.elLength.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.x = val; } }); - + this.elWidth.on("change", (e) => { let val = this.elWidth.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.y = val; } }); - + this.elHeight.on("change", (e) => { let val = this.elHeight.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.scale.z = val; } }); - + let toRadians = (d) => Math.PI * d / 180; - + this.elAlpha.on("change", (e) => { let val = this.elAlpha.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.x = toRadians(val); } }); - + this.elBeta.on("change", (e) => { let val = this.elBeta.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.y = toRadians(val); } }); - + this.elGamma.on("change", (e) => { let val = this.elGamma.val(); if($.isNumeric(val)){ val = parseFloat(val); - + this.measurement.rotation.z = toRadians(val); } }); - - - + + + this.elDownloadButton = this.elContent.find(`#download_volume_${this.id}`); - + if(viewer.server){ this.elDownloadButton.click(() => this.download()); }else{ this.elDownloadButton.hide(); } - + let elRemove = this.elContent.find(".measurement_action_remove"); elRemove.click(() => {this.scene.removeVolume(measurement)}); - + this.measurement.addEventListener("marker_added", this._update); this.measurement.addEventListener("marker_removed", this._update); this.measurement.addEventListener("marker_moved", this._update); - + this.elContent.i18n(); - + this.update(); } - + download(){ - + let volume = this.measurement; let boxes = volume.matrixWorld.elements.join(","); let minLOD = 0; let maxLOD = 100; - + let pcs = []; for(let pointcloud of this.scene.pointclouds){ let urlIsAbsolute = new RegExp('^(?:[a-z]+:)?//', 'i').test(pointcloud.pcoGeometry.url); @@ -1515,54 +1515,54 @@ function initMeasurementDetails(){ }else{ pc = `${window.location.href}/../${pointcloud.pcoGeometry.url}`; } - + pcs.push(pc); } - + let pc = pcs .map( v => `pointcloud[]=${v}`) .join("&"); - + let request = `${viewer.server}/start_extract_region_worker?minLOD=${minLOD}&maxLOD=${maxLOD}&box=${boxes}&${pc}`;//&pointCloud=${pc}`; //console.log(request); - + let elMessage = this.elContent.find(`#download_volume_status_${this.id}`); elMessage.html("sending request..."); - + let workerID = null; - + let start = new Date().getTime(); - + let observe = () => { let request = `${viewer.server}/observe_status?workerID=${workerID}`; - + let loaded = 0; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.addEventListener("progress", e => { let nowLoaded = e.loaded; - + let response = xhr.responseText.substring(loaded, nowLoaded); response = JSON.parse(response); - + if(response.status === "FINISHED"){ elMessage.html(`
    Download ready`); }else{ let current = new Date().getTime(); let duration = (current - start); let seconds = parseInt(duration / 1000); - + elMessage.html(`processing request... ${seconds}s`); } - - + + loaded = nowLoaded; }); xhr.open('GET', request, true); xhr.send(null) }; - + let xhr = Potree.XHRFactory.createXMLHttpRequest(); xhr.withCredentials = true; xhr.onreadystatechange = () => { @@ -1570,7 +1570,7 @@ function initMeasurementDetails(){ //alert(xhr.responseText); let res = JSON.parse(xhr.responseText); console.log(res); - + if(res.status === "OK"){ workerID = res.workerID; elMessage.html("request is being processed"); @@ -1585,81 +1585,81 @@ function initMeasurementDetails(){ } xhr.open('GET', request, true); xhr.send(null); - + } - + update(){ if(!this.destroyed){ requestAnimationFrame(this._update); } - + if(!this.elContent.is(":visible")){ return; } - + if(this.measurement.position.x !== this.values.x){ this.elX.val(this.measurement.position.x.toFixed(3)); this.values.x = this.measurement.position.x; } - + if(this.measurement.position.y !== this.values.y){ let elY = this.elContent.find(`#volume_input_y_${this.measurement.id}`); elY.val(this.measurement.position.y.toFixed(3)); this.values.y = this.measurement.position.y; } - + if(this.measurement.position.z !== this.values.z){ let elZ = this.elContent.find(`#volume_input_z_${this.measurement.id}`); elZ.val(this.measurement.position.z.toFixed(3)); this.values.z = this.measurement.position.z; } - + if(this.measurement.scale.x !== this.values.length){ this.elLength.val(this.measurement.scale.x.toFixed(3)); this.values.length = this.measurement.scale.x; } - + if(this.measurement.scale.y !== this.values.width){ this.elWidth.val(this.measurement.scale.y.toFixed(3)); this.values.width = this.measurement.scale.y; } - + if(this.measurement.scale.z !== this.values.height){ this.elHeight.val(this.measurement.scale.z.toFixed(3)); this.values.height = this.measurement.scale.z; } - + let toDegrees = (r) => 180 * r / Math.PI; - + if(this.measurement.rotation.x !== this.values.alpha){ this.elAlpha.val(toDegrees(this.measurement.rotation.x).toFixed(1)); this.values.alpha = this.measurement.rotation.x; } - + if(this.measurement.rotation.y !== this.values.beta){ this.elBeta.val(toDegrees(this.measurement.rotation.y).toFixed(1)); this.values.beta = this.measurement.rotation.y; } - + if(this.measurement.rotation.z !== this.values.gamma){ this.elGamma.val(toDegrees(this.measurement.rotation.z).toFixed(1)); this.values.gamma = this.measurement.rotation.z; } - + } - + destroy(){ this.elPanel.remove(); - + this.measurement.removeEventListener("marker_added", this._update); this.measurement.removeEventListener("marker_removed", this._update); this.measurement.removeEventListener("marker_moved", this._update); - + this.destroyed = true; } - + }; - + let TYPE = { DISTANCE: {panel: DistancePanel}, AREA: {panel: AreaPanel}, @@ -1669,7 +1669,7 @@ function initMeasurementDetails(){ PROFILE: {panel: ProfilePanel}, VOLUME: {panel: VolumePanel}, }; - + let getType = (measurement) => { if(measurement instanceof Potree.Measure){ if(measurement.showDistances && !measurement.showArea && !measurement.showAngles){ @@ -1691,15 +1691,15 @@ function initMeasurementDetails(){ return TYPE.VOLUME; } }; - + let trackMeasurement = (scene, measurement) => { id++; - + let type = getType(measurement); - + let panel = new type.panel(scene, measurement); mlist.append(panel.elPanel); - + let track = { scene: scene, measurement: measurement, @@ -1709,14 +1709,14 @@ function initMeasurementDetails(){ trackedItems.set(measurement, track); let onremove = (e) => { - + let remove = () => { panel.destroy(); scene.removeEventListener("measurement_removed", onremove); scene.removeEventListener("profile_removed", onremove); scene.removeEventListener("volume_removed", onremove); }; - + if(e.measurement instanceof Potree.Measure && e.measurement === measurement){ remove(); }else if(e.profile instanceof Potree.Profile && e.profile === measurement){ @@ -1724,63 +1724,63 @@ function initMeasurementDetails(){ }else if(e.volume instanceof Potree.Volume && e.volume === measurement){ remove(); } - + }; - + scene.addEventListener("measurement_removed", onremove); scene.addEventListener("profile_removed", onremove); scene.addEventListener("volume_removed", onremove); }; - + let scenelistener = (e) => { if(e.measurement){ trackMeasurement(e.scene, e.measurement); }else if(e.profile){ trackMeasurement(e.scene, e.profile); - + viewer.profileWindow.show(); viewer.profileWindowController.setProfile(e.profile); }else if(e.volume){ trackMeasurement(e.scene, e.volume); } }; - + let trackScene = (scene) => { //$("#measurement_details").empty(); - + trackedItems.forEach(function(trackedItem, key, map){ trackedItem.stopTracking(); }); - + let items = scene.measurements .concat(scene.profiles) .concat(scene.volumes); - + for(let measurement of items){ trackMeasurement(scene, measurement); } - + if(!scene.hasEventListener("measurement_added", scenelistener)){ scene.addEventListener("measurement_added", scenelistener); } - + if(!scene.hasEventListener("profile_added", scenelistener)){ scene.addEventListener("profile_added", scenelistener); } - + if(!scene.hasEventListener("volume_added", scenelistener)){ scene.addEventListener("volume_added", scenelistener); } }; - + trackScene(viewer.scene); - + viewer.addEventListener("scene_changed", (e) => {trackScene(e.scene)}); - - + + { // BOTTOM ACTIONS let elActionsB = $("#measurement_list_after"); - + { let icon = Potree.resourcePath + "/icons/file_geojson.svg"; let elDownload = $(` @@ -1788,18 +1788,18 @@ function initMeasurementDetails(){ `); elActionsB.append(elDownload); - + elDownload.click(function(e){ let scene = viewer.scene; let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); - + let geojson = Potree.GeoJSONExporter.toString(measurements); - + let url = window.URL.createObjectURL(new Blob([geojson], {type: 'data:application/octet-stream'})); elDownload.attr("href", url); }); } - + { let icon = Potree.resourcePath + "/icons/file_dxf.svg"; let elDownload = $(` @@ -1807,18 +1807,18 @@ function initMeasurementDetails(){ `); elActionsB.append(elDownload); - + elDownload.click(function(e){ let scene = viewer.scene; let measurements = [scene.measurements, scene.profiles, scene.volumes].reduce((a, v) => a.concat(v)); - + let dxf = Potree.DXFExporter.toString(measurements); - + let url = window.URL.createObjectURL(new Blob([dxf], {type: 'data:application/octet-stream'})); elDownload.attr("href", url); }); } - + } }; @@ -1826,22 +1826,22 @@ function initMeasurementDetails(){ function initSceneList(){ let scenelist = $('#scene_list'); - + // length units $("#optLengthUnit").selectmenu({ style:'popup', - position: { - my: "top", - at: "bottom", + position: { + my: "top", + at: "bottom", collision: "flip" }, change: function(e) { let selectedValue = $("#optLengthUnit").selectmenu().val(); viewer.setLengthUnit(selectedValue); } - }); + }); $("#optLengthUnit").selectmenu().val(viewer.lengthUnit.code); $("#optLengthUnit").selectmenu("refresh"); - + let initUIElements = function(i) { // scene panel in scene list @@ -1858,16 +1858,16 @@ function initSceneList(){ ${title}
    - + `); - + { // POINT SIZE let sldPointSize = scenePanel.find(`#sldPointSize_${i}`); let lblPointSize = scenePanel.find(`#lblPointSize_${i}`); - + sldPointSize.slider({ value: pcMaterial.size, min: 0, @@ -1990,59 +1990,59 @@ function initSceneList(){ step: 0.01, slide: function( event, ui ) {pcMaterial.size = ui.value;} }); - + let update = (e) => { lblPointSize.html(pcMaterial.size.toFixed(2)); sldPointSize.slider({value: pcMaterial.size}); }; - + pcMaterial.addEventListener("point_size_changed", update); update(); } - + { // POINT SIZE TYPE let strSizeType = Object.keys(Potree.PointSizeType)[pcMaterial.pointSizeType]; - + let opt = scenePanel.find(`#optPointSizing_${i}`); opt.selectmenu(); opt.val(strSizeType).selectmenu("refresh"); - + opt.selectmenu({ change: (event, ui) => { pcMaterial.pointSizeType = Potree.PointSizeType[ui.item.value]; } }); - + pcMaterial.addEventListener("point_size_type_changed", e => { let typename = Object.keys(Potree.PointSizeType)[pcMaterial.pointSizeType]; - + $( "#optPointSizing" ).selectmenu().val(typename).selectmenu("refresh"); }); } - + { // SHAPE - + let opt = scenePanel.find(`#optShape_${i}`); - + opt.selectmenu({ change: (event, ui) => { let value = ui.item.value; - + pcMaterial.shape = Potree.PointShape[value]; } }); - + pcMaterial.addEventListener("point_shape_changed", e => { let typename = Object.keys(Potree.PointShape)[pcMaterial.shape]; - + opt.selectmenu().val(typename).selectmenu("refresh"); }); } - + { // OPACITY let sldOpacity = scenePanel.find(`#sldOpacity_${i}`); let lblOpacity = scenePanel.find(`#lblOpacity_${i}`); - + sldOpacity.slider({ value: pcMaterial.opacity, min: 0, @@ -2050,18 +2050,18 @@ function initSceneList(){ step: 0.001, slide: function( event, ui ) {pcMaterial.opacity = ui.value;} }); - + let update = (e) => { lblOpacity.html(pcMaterial.opacity.toFixed(2)); sldOpacity.slider({value: pcMaterial.opacity}); }; - + pcMaterial.addEventListener("opacity_changed", update); update(); } let inputVis = scenePanel.find("input[type='checkbox']"); - + inputVis.click(function(event){ pointcloud.visible = event.target.checked; if(viewer.profileWindowController){ @@ -2075,12 +2075,12 @@ function initSceneList(){ // ui elements $( "#optMaterial" + i ).selectmenu({ style:'popup', - position: { - my: "top", - at: "bottom", - collision: "flip" } + position: { + my: "top", + at: "bottom", + collision: "flip" } }); - + $( "#sldHeightRange" + i ).slider({ range: true, min: 0, @@ -2093,7 +2093,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "height_range_changed" + i, "viewer": viewer}); } }); - + $( "#sldTransition" + i ).slider({ value: pcMaterial.materialTransition, min: 0, @@ -2104,7 +2104,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "material_transition_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityRange" + i ).slider({ range: true, min: 0, @@ -2120,7 +2120,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_range_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityGamma" + i ).slider({ value: pcMaterial.intensityGamma, min: 0, @@ -2131,7 +2131,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_gamma_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityContrast" + i ).slider({ value: pcMaterial.intensityContrast, min: -1, @@ -2142,7 +2142,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_contrast_changed" + i, "viewer": viewer}); } }); - + $( "#sldIntensityBrightness" + i ).slider({ value: pcMaterial.intensityBrightness, min: -1, @@ -2153,7 +2153,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "intensity_brightness_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBGamma" + i ).slider({ value: pcMaterial.rgbGamma, min: 0, @@ -2164,7 +2164,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_gamma_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBContrast" + i ).slider({ value: pcMaterial.rgbContrast, min: -1, @@ -2175,7 +2175,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_contrast_changed" + i, "viewer": viewer}); } }); - + $( "#sldRGBBrightness" + i ).slider({ value: pcMaterial.rgbBrightness, min: -1, @@ -2186,7 +2186,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "rgb_brightness_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightRGB" + i ).slider({ value: pcMaterial.weightRGB, min: 0, @@ -2197,7 +2197,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightIntensity" + i ).slider({ value: pcMaterial.weightIntensity, min: 0, @@ -2208,7 +2208,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightElevation" + i ).slider({ value: pcMaterial.weightElevation, min: 0, @@ -2219,7 +2219,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightClassification" + i ).slider({ value: pcMaterial.weightClassification, min: 0, @@ -2230,7 +2230,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightReturnNumber" + i ).slider({ value: pcMaterial.weightReturnNumber, min: 0, @@ -2241,7 +2241,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $( "#sldWeightSourceID" + i ).slider({ value: pcMaterial.weightSourceID, min: 0, @@ -2252,7 +2252,7 @@ function initSceneList(){ viewer.dispatchEvent({"type": "attribute_weights_changed" + i, "viewer": viewer}); } }); - + $(`#materials\\.color\\.picker${i}`).spectrum({ flat: true, showInput: true, @@ -2264,14 +2264,14 @@ function initSceneList(){ let cRGB = color.toRgb(); let tc = new THREE.Color().setRGB(cRGB.r / 255, cRGB.g / 255, cRGB.b / 255); pcMaterial.color = tc; - }, + }, change: color => { let cRGB = color.toRgb(); let tc = new THREE.Color().setRGB(cRGB.r / 255, cRGB.g / 255, cRGB.b / 255); pcMaterial.color = tc; } }); - + pcMaterial.addEventListener("color_changed", e => { $(`#materials\\.color\\.picker${i}`) .spectrum("set", `#${pcMaterial.color.getHexString()}`); @@ -2280,14 +2280,14 @@ function initSceneList(){ let updateHeightRange = function(){ let box = [pointcloud.pcoGeometry.tightBoundingBox, pointcloud.getBoundingBoxWorld()] .find(v => v !== undefined); - + pointcloud.updateMatrixWorld(true); box = Potree.utils.computeTransformedBoundingBox(box, pointcloud.matrixWorld); - + let bWidth = box.max.z - box.min.z; bMin = box.min.z - 0.2 * bWidth; bMax = box.max.z + 0.2 * bWidth; - + $( "#lblHeightRange" + i )[0].innerHTML = pcMaterial.heightMin.toFixed(2) + " to " + pcMaterial.heightMax.toFixed(2); $( "#sldHeightRange" + i ).slider({ min: bMin, @@ -2295,96 +2295,96 @@ function initSceneList(){ values: [pcMaterial.heightMin, pcMaterial.heightMax] }); }; - + let updateIntensityRange = function(){ let range = pcMaterial.intensityRange; let min = Math.log2(range[0]) / 16; let max = Math.log2(range[1]) / 16; - - $( "#lblIntensityRange" + i )[0].innerHTML = - parseInt(pcMaterial.intensityRange[0]) + " to " + + + $( "#lblIntensityRange" + i )[0].innerHTML = + parseInt(pcMaterial.intensityRange[0]) + " to " + parseInt(pcMaterial.intensityRange[1]); $( "#sldIntensityRange" + i ).slider({ values: [min, max] }); }; - + { updateHeightRange(); let min = $(`#sldHeightRange${i}`).slider("option", "min"); let max = $(`#sldHeightRange${i}`).slider("option", "max"); } - + pcMaterial.addEventListener("material_property_changed", (event) => { - + updateHeightRange(); - + { // INTENSITY let gamma = pcMaterial.intensityGamma; let contrast = pcMaterial.intensityContrast; let brightness = pcMaterial.intensityBrightness; - + updateIntensityRange(); - + $('#lblIntensityGamma' + i)[0].innerHTML = gamma.toFixed(2); $("#sldIntensityGamma" + i).slider({value: gamma}); - + $('#lblIntensityContrast' + i)[0].innerHTML = contrast.toFixed(2); $("#sldIntensityContrast" + i).slider({value: contrast}); - + $('#lblIntensityBrightness' + i)[0].innerHTML = brightness.toFixed(2); $("#sldIntensityBrightness" + i).slider({value: brightness}); } - + { // RGB let gamma = pcMaterial.rgbGamma; let contrast = pcMaterial.rgbContrast; let brightness = pcMaterial.rgbBrightness; - + $('#lblRGBGamma' + i)[0].innerHTML = gamma.toFixed(2); $("#sldRGBGamma" + i).slider({value: gamma}); - + $('#lblRGBContrast' + i)[0].innerHTML = contrast.toFixed(2); $("#sldRGBContrast" + i).slider({value: contrast}); - + $('#lblRGBBrightness' + i)[0].innerHTML = brightness.toFixed(2); $("#sldRGBBrightness" + i).slider({value: brightness}); } }); - - + + viewer.addEventListener("length_unit_changed", e => { $("#optLengthUnit").selectmenu().val(e.value); $("#optLengthUnit").selectmenu("refresh"); }); - + viewer.addEventListener("pointcloud_loaded", updateHeightRange); - + updateHeightRange(); updateIntensityRange(); $('#lblIntensityGamma' + i)[0].innerHTML = pcMaterial.intensityGamma.toFixed(2); $('#lblIntensityContrast' + i)[0].innerHTML = pcMaterial.intensityContrast.toFixed(2); $('#lblIntensityBrightness' + i)[0].innerHTML = pcMaterial.intensityBrightness.toFixed(2); - + $('#lblRGBGamma' + i)[0].innerHTML = pcMaterial.rgbGamma.toFixed(2); $('#lblRGBContrast' + i)[0].innerHTML = pcMaterial.rgbContrast.toFixed(2); $('#lblRGBBrightness' + i)[0].innerHTML = pcMaterial.rgbBrightness.toFixed(2); - let options = [ - "RGB", + let options = [ + "RGB", "RGB and Elevation", - "Color", - "Elevation", - "Intensity", - "Intensity Gradient", - "Classification", - "Return Number", - "Source", + "Color", + "Elevation", + "Intensity", + "Intensity Gradient", + "Classification", + "Return Number", + "Source", "Phong", "Level of Detail", "Composite", ]; - + let elMaterialList = $("#optMaterial" + i); for(let i = 0; i < options.length; i++){ let option = options[i]; @@ -2396,26 +2396,26 @@ function initSceneList(){ `); elMaterialList.append(elOption); } - - let updateMaterialPanel = function(event, ui){ + + let updateMaterialPanel = function(event, ui){ let selectedValue = $("#optMaterial" + i).selectmenu().val(); pcMaterial.pointColorType = viewer.toMaterialID(selectedValue); viewer.dispatchEvent({"type": "material_changed" + i, "viewer": viewer}); - + let blockWeights = $("#materials\\.composite_weight_container" + i); let blockElevation = $("#materials\\.elevation_container" + i); let blockRGB = $("#materials\\.rgb_container" + i); let blockColor = $("#materials\\.color_container" + i); let blockIntensity = $("#materials\\.intensity_container" + i); let blockTransition = $("#materials\\.transition_container" + i); - + blockIntensity.css("display", "none"); blockElevation.css("display", "none"); blockRGB.css("display", "none"); blockColor.css("display", "none"); blockWeights.css("display", "none"); blockTransition.css("display", "none"); - + if(selectedValue === "Composite"){ blockWeights.css("display", "block"); blockElevation.css("display", "block"); @@ -2436,65 +2436,65 @@ function initSceneList(){ blockIntensity.css("display", "block"); } }; - + $("#optMaterial" + i).selectmenu({change: updateMaterialPanel}); $("#optMaterial" + i).val(viewer.toMaterialName(pcMaterial.pointColorType)).selectmenu("refresh"); updateMaterialPanel(); - + viewer.addEventListener("material_changed" + i, e => { $("#optMaterial" + i).val(viewer.toMaterialName(pcMaterial.pointColorType)).selectmenu("refresh"); }); scenePanel.i18n(); - }; - + }; + let buildSceneList = () => { scenelist.empty(); - + for(let i = 0; i < viewer.scene.pointclouds.length; i++) { initUIElements(i); } }; - + buildSceneList(); viewer.addEventListener("scene_changed", (e) => { buildSceneList(); - + if(e.oldScene){ e.oldScene.removeEventListener("pointcloud_added", buildSceneList); } e.scene.addEventListener("pointcloud_added", buildSceneList); }); - + viewer.scene.addEventListener("pointcloud_added", buildSceneList); - - + + let lastPos = new THREE.Vector3(); let lastTarget = new THREE.Vector3(); viewer.addEventListener("update", e => { let pos = viewer.scene.view.position; let target = viewer.scene.view.getPivot(); - + if(pos.equals(lastPos) && target.equals(lastTarget)){ return; }else{ lastPos.copy(pos); lastTarget.copy(target); } - + let strCamPos = "
    " + [pos.x, pos.y, pos.z].map(e => e.toFixed(2)).join(", "); let strCamTarget = "
    " + [target.x, target.y, target.z].map(e => e.toFixed(2)).join(", "); - + $('#lblCameraPosition').html(strCamPos); $('#lblCameraTarget').html(strCamTarget); - - + + }); }; let initSettings = function(){ - + $( "#sldMinNodeSize" ).slider({ value: viewer.getMinNodeSize(), min: 0, @@ -2502,14 +2502,14 @@ let initSettings = function(){ step: 0.01, slide: function( event, ui ) {viewer.setMinNodeSize(ui.value);} }); - + viewer.addEventListener("minnodesize_changed", function(event){ $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize())); $("#sldMinNodeSize").slider({value: viewer.getMinNodeSize()}); }); $('#lblMinNodeSize').html(parseInt(viewer.getMinNodeSize())); - - + + let toClipModeCode = function(string){ if(string === "No Clipping"){ return Potree.ClipMode.DISABLED; @@ -2519,7 +2519,7 @@ let initSettings = function(){ return Potree.ClipMode.CLIP_OUTSIDE; } }; - + let toClipModeString = function(code){ if(code === Potree.ClipMode.DISABLED){ return "No Clipping"; @@ -2529,7 +2529,7 @@ let initSettings = function(){ return "Clip Outside"; } }; - + $("#optClipMode").selectmenu(); $("#optClipMode").val(toClipModeString(viewer.getClipMode())).selectmenu("refresh") $("#optClipMode").selectmenu({ @@ -2537,10 +2537,10 @@ let initSettings = function(){ viewer.setClipMode(toClipModeCode(ui.item.value)); } }); - + viewer.addEventListener("clip_mode_changed", e => { let string = toClipModeString(viewer.clipMode); - + $( "#optClipMode" ) .selectmenu() .val(string) @@ -2558,7 +2558,7 @@ let initSidebar = function(){ initMeasurementDetails(); initSceneList(); initSettings() - + $('#potree_version_number').html(Potree.version.major + "." + Potree.version.minor + Potree.version.suffix); $('.perfect_scrollbar').perfectScrollbar(); }