diff --git a/build/potree/potree.css b/build/potree/potree.css index 8b4463ad..e6f3cf25 100644 --- a/build/potree/potree.css +++ b/build/potree/potree.css @@ -70,7 +70,7 @@ #potree_sidebar_container{ position: absolute; z-index: 0; - width: 300px; + width: 350px; height: 100%; overflow-y: auto; font-size: 85%; @@ -145,6 +145,7 @@ a:hover, a:visited, a:link, a:active{ position: absolute; padding: 10px; opacity: 0.5; + transform: translate(-50%, -30px); } .annotation-titlebar{ @@ -260,6 +261,7 @@ body{ position: absolute; width: 100%; height: 100%; + overflow: hidden; } .axis { @@ -285,6 +287,44 @@ body{ font-size: 12px; } + +.scene_item{ + border-bottom: 1px solid rgba(0, 0, 0, 0.5); + display: block; + position: relative; +} + +.scene_header{ + display:flex; + cursor: pointer; + padding: 2px; +} + +.scene_item:hover{ + background-color: rgba(255, 255, 255, 0.1); +} + +.scene_item_icon{ + width: 24px; + height: 24px; +} + +.scene_header_title{ + flex-grow: 1; + display: flex; + align-items: center; +} + +.scene_icon{ + padding: 0px 6px 0px 4px; +} + +.scene_content{ + padding: 5px 0px 5px 0px; + background-color: rgba(0, 0, 0, 0.4); +} + + .measurement_item{ border-bottom: 1px solid rgba(0, 0, 0, 0.5); display: block; @@ -443,12 +483,8 @@ body{ width: 100% !important; } -.pv-menu-list .ui-selectmenu-button span.ui-selectmenu-text{ - line-height: 0.8em; -} - -.ui-selectmenu-text{ - background-color: white; +.ui-widget{ + box-sizing:border-box } .panel-body > li > .ui-slider{ @@ -711,34 +747,36 @@ body{ } +.text-icon{ + opacity: 0.5; + height: 24px; +} - - - - - - +.text-icon:hover{ + opacity: 1.0; +} /* -.axis path, - .axis line{ - fill: none; - stroke: white; - } +label:hover{ + background-color: white; +} +*/ - .line{ - fill: none; - stroke: blue; - stroke-width: 2px; - } - .tick text{ - font-size: 12px; - } +.input-grid-cell{ + flex-grow: 1; margin: 0px 3px 0px 3px; +} + +.input-grid-label{ + flex-grow: 1; + margin: 0px 3px 0px 3px; + text-align:center; + font-weight: bold; +} + +.input-grid-cell > input{ + width: 100% +} - .tick line{ - opacity: 0.2; - } - */ \ No newline at end of file diff --git a/build/potree/potree.js b/build/potree/potree.js index 288f5bed..0b39eb40 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -110,6 +110,64 @@ Potree.MOUSE = { MIDDLE: 0b0100 }; +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){ @@ -249,6 +307,202 @@ function updateVisibilityStructures(pointclouds, camera, renderer){ }; } +Potree.getDEMWorkerInstance = function(){ + if(!Potree.DEMWorkerInstance){ + 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; + let triangles = []; + for(let i = 0; i < steps; i++){ + for(let j = 0; j < steps; j++){ + let u0 = i / steps; + 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; + //let y1 = box.min.y + v1 * box.getSize().y; + // + //let h00 = dem.height(new THREE.Vector3(x0, y0, 0)); + //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)); + geometry.computeBoundingSphere(); + geometry.computeVertexNormals(); + let material = new THREE.MeshNormalMaterial({side: THREE.DoubleSide}); + let mesh = new THREE.Mesh(geometry, material); + mesh.position.copy(box.min); + //mesh.position.copy(pointcloud.position); + viewer.scene.scene.add(mesh); +} + +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++){ + for(let j = 0; j < tileSize; j++){ + let u0 = i / tileSize; + 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)); + geometry.computeBoundingSphere(); + geometry.computeVertexNormals(); + let material = new THREE.MeshNormalMaterial({side: THREE.DoubleSide}); + let mesh = new THREE.Mesh(geometry, material); + 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); + let box = demNode.box; + let boxSize = box.getSize(); + for(let i = 0; i < steps; i++){ + for(let j = 0; j < steps; j++){ + let [u, v] = [i / (steps - 1), j / (steps - 1)]; + let pos = new THREE.Vector3( + u * boxSize.x + box.min.x, + 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; + //imgData[4*index + 2] = 0; + //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($(`| x | @@ -15599,6 +15992,7 @@ Potree.Viewer.Profile = class ProfileWindow{ this.mouse.copy(newMouse); }); + let onWheel = e => { this.autoFit = false; let delta = 0; @@ -15610,8 +16004,10 @@ Potree.Viewer.Profile = class ProfileWindow{ let ndelta = Math.sign(delta); - let sPos = new THREE.Vector3(this.mouse.x, this.mouse.y, 0); - let cPos = this.toCamSpace(sPos); + //let sPos = new THREE.Vector3(this.mouse.x, this.mouse.y, 0); + //let cPos = this.toCamSpace(sPos); + + let cPos = [this.scaleX.invert(this.mouse.x), this.scaleY.invert(this.mouse.y)]; if(ndelta > 0){ // + 10% @@ -15621,101 +16017,393 @@ Potree.Viewer.Profile = class ProfileWindow{ this.scale.multiplyScalar(100/110); } - this.scale.max(new THREE.Vector3(0.5, 0.5, 0.5)); - this.scale.min(new THREE.Vector3(100, 100, 100)); + //this.scale.max(new THREE.Vector3(0.5, 0.5, 0.5)); + //this.scale.min(new THREE.Vector3(100, 100, 100)); - let ncPos = this.toCamSpace(sPos); + this.updateScales(); + let ncPos = [this.scaleX.invert(this.mouse.x), this.scaleY.invert(this.mouse.y)]; - let diff = new THREE.Vector3().subVectors(ncPos, cPos); - this.camera.position.sub(diff); + this.camera.position.x -= ncPos[0] - cPos[0]; + this.camera.position.y -= ncPos[1] - cPos[1]; this.render(); }; $(this.renderArea)[0].addEventListener("mousewheel", onWheel, false ); $(this.renderArea)[0].addEventListener("DOMMouseScroll", onWheel, false ); // Firefox - - this.scheduledDraw = null; - - this.redraw = () => { - if(this.currentProfile){ - this.draw(this.currentProfile); - } - }; - $('#closeProfileContainer').click(() => { this.hide(); - this.enabled = false; }); - //$('#profile_toggle_size_button').click(() => { - // this.maximized = !this.maximized; - // - // if(this.maximized){ - // $('#profile_window').css("height", "100%"); - // }else{ - // $('#profile_window').css("height", "30%"); - // } - // - // this.render(); - //}); + $('#potree_download_csv_icon').click(() => { + let points = new Potree.Points(); + this.pointclouds.forEach((value, key) => { + points.add(value.points); + }); + + let string = Potree.CSVExporter.toString(points); + + let uri = "data:application/octet-stream;base64,"+btoa(string); + $('#potree_download_profile_ortho_link').attr("href", uri); + }); + $('#potree_download_las_icon').click(() => { + let points = new Potree.Points(); + this.pointclouds.forEach((value, key) => { + points.add(value.points); + }); + + let buffer = Potree.LASExporter.toLAS(points); + let u8view = new Uint8Array(buffer); + let binString = ""; + for(let i = 0; i < u8view.length; i++){ + binString += String.fromCharCode(u8view[i]); + } + + let uri = "data:application/octet-stream;base64,"+btoa(binString); + $('#potree_download_profile_link').attr("href", uri); + + //let uri = "data:application/octet-stream;base64,"+btoa(string); + //$('#potree_download_profile_ortho_link').attr("href", uri); + + //let las = viewer.profileWindow.getPointsInProfileAsLas(); + //let u8view = new Uint8Array(las); + // + //let binString = ""; + //for(let i = 0; i < u8view.length; i++){ + // binString += String.fromCharCode(u8view[i]); + //} + // + //let uri = "data:application/octet-stream;base64,"+btoa(binString); + //$('#potree_download_profile_link').attr("href", uri); + }); } - toCamSpace(coord){ + selectPoint(mileage, elevation, radius){ + + let closest = { + distance: Infinity, + pointcloud: null, + points: null, + index: null + }; + + for(let [pointcloud, entry] of this.pointclouds){ + let points = entry.points; + + for(let i = 0; i < points.numPoints; i++){ + + //let pos = new THREE.Vector3(...points.data.position.subarray(3*i, 3*i+3)); + let m = points.data.mileage[i] - mileage; + let e = points.data.position[3*i+2] - elevation; + + let r = Math.sqrt(m*m + e*e); + + if(r < radius && r < closest.distance){ + closest = { + distance: r, + pointcloud: pointcloud, + points: points, + index: i + }; + } + } + } + + if(closest.distance < Infinity){ + let points = closest.points; + + let point = {}; + + let attributes = Object.keys(points.data); + for(let attribute of attributes){ + let attributeData = points.data[attribute]; + let itemSize = attributeData.length / points.numPoints; + let value = attributeData.subarray(itemSize * closest.index, itemSize * closest.index + itemSize); + + if(value.length === 1){ + point[attribute] = value[0]; + }else{ + point[attribute] = value; + } + } + + return point; + }else{ + return null; + } + } + + initTHREE(){ + this.renderer = new THREE.WebGLRenderer({alpha: true, premultipliedAlpha: false}); + this.renderer.setClearColor( 0x000000, 0 ); + this.renderer.setSize(10, 10); + this.renderer.autoClear = true; + this.renderArea.append($(this.renderer.domElement)); + this.renderer.domElement.tabIndex = "2222"; + this.renderer.context.getExtension("EXT_frag_depth"); + $(this.renderer.domElement).css("width", "100%"); + $(this.renderer.domElement).css("height", "100%"); + + this.camera = new THREE.OrthographicCamera(-10, 10, 10, -10, -1000, 1000); + + this.scene = new THREE.Scene(); + + let sg = new THREE.SphereGeometry(1, 16, 16); + let sm = new THREE.MeshNormalMaterial(); + this.pickSphere = new THREE.Mesh(sg, sm); + this.pickSphere.visible = false; + this.scene.add(this.pickSphere); + } + + initSVG(){ + let width = this.renderArea[0].clientWidth; + let height = this.renderArea[0].clientHeight; + let marginLeft = this.renderArea[0].offsetLeft; + + this.svg.selectAll("*").remove(); + + this.scaleX = d3.scale.linear() + .domain([this.camera.left + this.camera.position.x, this.camera.right + this.camera.position.x]) + .range([0, width]); + this.scaleY = d3.scale.linear() + .domain([this.camera.bottom + this.camera.position.y, this.camera.top + this.camera.position.y]) + .range([height, 0]); + + this.xAxis = d3.svg.axis() + .scale(this.scaleX) + .orient("bottom") + .innerTickSize(-height) + .outerTickSize(1) + .tickPadding(10) + .ticks(width / 50); + + this.yAxis = d3.svg.axis() + .scale(this.scaleY) + .orient("left") + .innerTickSize(-width) + .outerTickSize(1) + .tickPadding(10) + .ticks(height / 20); + + this.svg.append("g") + .attr("class", "x axis") + .attr("transform", `translate(${marginLeft}, ${height})`) + .call(this.xAxis); + + this.svg.append("g") + .attr("class", "y axis") + .attr("transform", `translate(${marginLeft}, 0)`) + .call(this.yAxis); + } + + setProfile(profile){ + + this.render(); + } + + addPoints(pointcloud, points){ + + if(this.pointclouds.get(pointcloud) === undefined){ + + let material = this.materialPool.getMaterial(); + let geometry = this.geometryPool.getGeometry(); + let model = new THREE.Points(geometry, material); + this.scene.add(model); + + let materialChanged = e => { + this.render(); + }; + + pointcloud.material.addEventListener("material_property_changed", materialChanged); + + this.pointclouds.set(pointcloud, { + points: new Potree.Points(), + material: material, + geometry: geometry, + model: model, + listeners: [{ + target: pointcloud.material, + type: "material_property_changed", + callback: materialChanged}] + }); + } + + let pc = this.pointclouds.get(pointcloud); + pc.points.add(points); + + // rebuild 3d model + let projectedBox = new THREE.Box3(); + { + let geometry = pc.geometry; + + for(let attribute of Object.keys(pc.points.data)){ + + let buffer = pc.points.data[attribute]; + let itemSize = buffer.length / pc.points.numPoints; + + if(attribute === "position"){ + + let posBuffer = new Float32Array(buffer.length); + + for(let i = 0; i < pc.points.numPoints; i++){ + let x = pc.points.data.mileage[i]; + let y = buffer[3*i + 2]; + + posBuffer[3*i + 0] = x; + posBuffer[3*i + 1] = y; + posBuffer[3*i + 2] = y; + projectedBox.expandByPoint(new THREE.Vector3(x, y, 0)); + } + + if(!posBuffer){ + console.log("wtf"); + } + + geometry.attributes[attribute].array.set(posBuffer); + }else if(attribute === "color"){ + geometry.attributes[attribute].array.set(buffer); + }else if(attribute === "mileage"){ + continue; + }else if(geometry.attributes[attribute] === undefined){ + continue; + }else{ + geometry.attributes[attribute].array.set(buffer); + } + + geometry.attributes[attribute].needsUpdate = true; + geometry.setDrawRange(0, pc.points.numPoints); + } + + let radius = pc.points.boundingBox.getSize().toArray().reduce((a, v) => Math.max(a, v)) + geometry.boundingSphere = new THREE.Sphere(this.camera.position, radius) + geometry.boundingBox = geometry.boundingSphere.getBoundingBox(); + } + + this.projectedBox.union(projectedBox); + + if(this.autoFit){ // SCALE + let width = this.renderArea[0].clientWidth; + let height = this.renderArea[0].clientHeight; + + let size = this.projectedBox.getSize(); + + let sx = width / size.x; + let sy = height / size.y; + let scale = Math.min(sx, sy); + + let center = this.projectedBox.getCenter(); + this.scale.set(scale, scale, 1); + this.camera.position.copy(center); + } + + let numPoints = 0; + for(let entry of this.pointclouds.entries()){ + numPoints += entry[1].points.numPoints; + + $(`#profile_num_points`).html(Potree.utils.addCommas(numPoints)); + } + + this.render(); + } + + reset(){ + + this.autoFit = true; + this.projectedBox = new THREE.Box3(); + + for(let entry of this.pointclouds){ + + let pointcloud = entry[0]; + let material = entry[1].model.material; + let geometry = entry[1].model.geometry; + this.materialPool.returnMaterial(material); + this.geometryPool.returnGeometry(geometry); + entry[1].model.material = null; + entry[1].model.geometry = null; + + for(let listener of entry[1].listeners){ + listener.target.removeEventListener(listener.type, listener.callback); + } + + } + + this.pointclouds.clear(); + this.mouseIsDown = false; + this.mouse.set(0, 0); + this.scale.set(1, 1, 1); + this.pickSphere.visible = false; + + this.scene.children + .filter(c => c instanceof THREE.Points) + .forEach(c => this.scene.remove(c)); + + this.elRoot.find("#profileSelectionProperties").hide(); + + + this.render(); + } + + show(){ + this.elRoot.fadeIn(); + this.enabled = true; + } + + hide(){ + this.elRoot.fadeOut(); + this.enabled = false; + } + + updateScales(){ let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; - let cam = new THREE.Vector3( - coord.x - width / 2, - -coord.y + height / 2, - 0); + let left = (-width / 2) / this.scale.x; + let right = (+width / 2) / this.scale.x; + let top = (+height / 2) / this.scale.y; + let bottom = (-height / 2) / this.scale.y; - cam.divide(this.scale); - cam.add(this.camera.position); + this.camera.left = left; + this.camera.right = right; + this.camera.top = top; + this.camera.bottom = bottom; + this.camera.updateProjectionMatrix(); - return cam; - } - - toScreenSpace(coord){ - let width = this.renderArea[0].clientWidth; - let height = this.renderArea[0].clientHeight; - - let v = new THREE.Vector3().subVectors(coord, this.camera.position); - v.multiply(this.scale); - - let screen = new THREE.Vector3( - width / 2 + v.x, - height / 2 - v.y, - 0); - - return screen; + this.scaleX.domain([this.camera.left + this.camera.position.x, this.camera.right + this.camera.position.x]) + .range([0, width]); + this.scaleY.domain([this.camera.bottom + this.camera.position.y, this.camera.top + this.camera.position.y]) + .range([height, 0]); } render(){ let width = this.renderArea[0].clientWidth; let height = this.renderArea[0].clientHeight; + this.updateScales(); + { // THREEJS - - let left = (-width / 2) / this.scale.x; - let right = (+width / 2) / this.scale.x; - let top = (+height / 2) / this.scale.y; - let bottom = (-height / 2) / this.scale.y; - - this.camera.left = left; - this.camera.right = right; - this.camera.top = top; - this.camera.bottom = bottom; - this.camera.updateProjectionMatrix(); - let radius = - this.toCamSpace(new THREE.Vector3(0, 0, 0)).distanceTo( - this.toCamSpace(new THREE.Vector3(5, 0, 0))); + let radius = Math.abs(this.scaleX.invert(0) - this.scaleX.invert(5)); this.pickSphere.scale.set(radius, radius, radius); this.pickSphere.position.z = this.camera.far - radius; + for(let entry of this.pointclouds){ + let pointcloud = entry[0]; + let material = entry[1].material; + + material.pointColorType = pointcloud.material.pointColorType; + material.uniforms.intensityRange.value = pointcloud.material.uniforms.intensityRange.value; + material.heightMin = pointcloud.material.heightMin; + material.heightMax = pointcloud.material.heightMax; + material.rgbGamma = pointcloud.material.rgbGamma; + material.rgbContrast = pointcloud.material.rgbContrast; + material.rgbBrightness = pointcloud.material.rgbBrightness; + material.intensityRange = pointcloud.material.intensityRange; + material.intensityGamma = pointcloud.material.intensityGamma; + material.intensityContrast = pointcloud.material.intensityContrast; + material.intensityBrightness = pointcloud.material.intensityBrightness; + } this.renderer.setSize(width, height); @@ -15724,11 +16412,6 @@ Potree.Viewer.Profile = class ProfileWindow{ { // SVG SCALES let marginLeft = this.renderArea[0].offsetLeft; - - this.scaleX.domain([this.camera.left + this.camera.position.x, this.camera.right + this.camera.position.x]) - .range([0, width]); - this.scaleY.domain([this.camera.bottom + this.camera.position.y, this.camera.top + this.camera.position.y]) - .range([height, 0]); this.xAxis.scale(this.scaleX) .orient("bottom") @@ -15752,219 +16435,100 @@ Potree.Viewer.Profile = class ProfileWindow{ } } - show(){ - $('#profile_window').fadeIn(); - this.enabled = true; - }; +}; + +Potree.ProfileWindowController = class ProfileWindowController{ - hide(){ - $('#profile_window').fadeOut(); - }; + constructor(viewer){ + this.viewer = viewer; + this.profileWindow = viewer.profileWindow; + this.profile = null; + this.numPoints = 0; + this.threshold = 30*1000; + this.scheduledRecomputeTime = null; + + this.enabled = true; + + this.requests = []; + + this._recompute = () => {this.recompute()}; + } + + setProfile(profile){ + + if(this.profile !== null && this.profile !== profile){ + this.profile.removeEventListener("marker_moved", this._recompute); + this.profile.removeEventListener("marker_added", this._recompute); + this.profile.removeEventListener("marker_removed", this._recompute); + this.profile.removeEventListener("width_changed", this._recompute); + } + + this.profile = profile; + + { + this.profile.addEventListener("marker_moved", this._recompute); + this.profile.addEventListener("marker_added", this._recompute); + this.profile.addEventListener("marker_removed", this._recompute); + this.profile.addEventListener("width_changed", this._recompute); + + } + + this.recompute(); + } + + reset(){ + this.profileWindow.reset(); + + this.numPoints = 0; + + if(this.profile){ + for(let request of this.requests){ + request.cancel(); + } + } + } + + progressHandler(pointcloud, progress){ + + for(let segment of progress.segments){ + this.profileWindow.addPoints(pointcloud, segment.points); + this.numPoints += segment.points.numPoints; + } + } cancel(){ for(let request of this.requests){ request.cancel(); + //request.finishLevelThenCancel(); } this.requests = []; }; - handleNewPoints(profileProgress){ - this.points.onProgress(profileProgress); + recompute(){ - let prepared = this.preparePoints(profileProgress); - - if(prepared.numPoints === 0){ + if(!this.profile){ return; } - if(this.numPoints === 0){ - this.min.fromArray(prepared.buffers.position, 3); - this.max.fromArray(prepared.buffers.position, 3); - } - - for(let i = 0; i < prepared.numPoints; i++){ - let pos = new THREE.Vector3().fromArray( - prepared.buffers.position.slice(3*i, 3*i+3)); - this.min.min(pos); - this.max.max(pos); - } - let newSize = new THREE.Vector3().subVectors(this.max, this.min); - this.size.copy(newSize); - - let newNumPoints = this.numPoints + prepared.numPoints; - - let position = this.buffers.position; - let color = this.buffers.color; - - position.set(this.points.buffers.position.slice(3 * this.numPoints, 3 * newNumPoints), 3 * this.numPoints); - color.set(this.points.buffers.color.slice(3 * this.numPoints, 3 * newNumPoints), 3 * this.numPoints); - - this.geometry.attributes.position.needsUpdate = true; - this.geometry.attributes.color.needsUpdate = true; - - this.geometry.setDrawRange(0, newNumPoints); - - this.numPoints = newNumPoints; - - this.center = new THREE.Vector3().addVectors(this.min, this.max) - .multiplyScalar(0.5); - - if(this.autoFit){ // SCALE - let width = this.renderArea[0].clientWidth; - let height = this.renderArea[0].clientHeight; - - let sx = width / this.size.x; - let sy = height / this.size.y; - let scale = Math.min(sx, sy); - - this.scale.set(scale, scale, 1); - this.camera.position.copy(this.center); - } - - this.firstUpdateFollows = false; - - this.elRoot.find("#profile_num_points").html( - Potree.utils.addCommas(this.numPoints.toFixed(0))); - } - - preparePoints(profileProgress){ - - let segments = profileProgress.segments; - if (segments.length === 0){ - return false; - } - - let numPoints = profileProgress.size(); - - let position = new Float32Array(3 * numPoints); - let color = new Uint8Array(3 * numPoints); - - let distance = 0; - let totalDistance = 0; - let min = new THREE.Vector3(Math.max()); - let max = new THREE.Vector3(0); - - // Iterate the profile's segments - let i = 0; - for(let segment of segments){ - let sv = new THREE.Vector3().subVectors(segment.end, segment.start).setZ(0) - let segmentDir = sv.clone().normalize(); - let points = segment.points; - - // Iterate the segments' points - for(let j = 0; j < segment.numPoints; j++){ - let p = points.position[j]; - - //let svp = new THREE.Vector3().subVectors(p, segment.start); - //let distance = segmentDir.dot(svp); - - min.min(p); - max.max(p); - - //position[3*i + 0] = distance + totalDistance; - position[3*i + 0] = points.mileage[j]; - position[3*i + 1] = p.z; - position[3*i + 2] = 0; - - let c = points.color ? points.color[j] : [0, 0, 0]; - color[3*i + 0] = c[0]; - color[3*i + 1] = c[1]; - color[3*i + 2] = c[2]; - - - i++; - } - - totalDistance += segment.length; - } - - let result = { - numPoints: numPoints, - min: min, - max: max, - buffers: { - position: position, - color: color - } - }; - - return result; - }; - - draw(profile){ - if(!this.enabled){ + if(this.scheduledRecomputeTime !== null && this.scheduledRecomputeTime > new Date().getTime()){ return; + }else{ + this.scheduledRecomputeTime = new Date().getTime() + 100; } + this.scheduledRecomputeTime = null; - if(!profile){ - return; - } - - if(this.viewer.scene.pointclouds.length === 0){ - return; - } - - // avoid too many expensive draws/redraws - // 2d profile draws don't need frame-by-frame granularity, it's - // fine to handle a redraw once every 100ms - let executeScheduledDraw = () => { - this.prepareDraw(this.scheduledDraw); - this.scheduledDraw = null; - }; - - if(!this.scheduledDraw){ - setTimeout(executeScheduledDraw, 100); - } - this.scheduledDraw = profile; - } - - prepareDraw(profile){ - this.autoFit = true; - this.numPoints = 0; - this.geometry.setDrawRange(0, this.numPoints); - this.pickSphere.visible = false; - this.elRoot.find("#profileSelectionProperties").hide(); - - if(this.currentProfile){ - this.currentProfile.removeEventListener("marker_moved", this.redraw); - this.currentProfile.removeEventListener("marker_added", this.redraw); - this.currentProfile.removeEventListener("marker_removed", this.redraw); - this.currentProfile.removeEventListener("width_changed", this.redraw); - viewer.removeEventListener("material_changed", this.redraw); - viewer.removeEventListener("height_range_changed", this.redraw); - viewer.removeEventListener("intensity_range_changed", this.redraw); - - for(let request of this.requests){ - request.cancel(); - } - } - - - this.currentProfile = profile; - this.points = new Potree.ProfilePointStore(this.currentProfile); - - { - this.currentProfile.addEventListener("marker_moved", this.redraw); - this.currentProfile.addEventListener("marker_added", this.redraw); - this.currentProfile.addEventListener("marker_removed", this.redraw); - this.currentProfile.addEventListener("width_changed", this.redraw); - viewer.addEventListener("material_changed", this.redraw); - viewer.addEventListener("height_range_changed", this.redraw); - viewer.addEventListener("intensity_range_changed", this.redraw); - } + this.reset(); for(let pointcloud of this.viewer.scene.pointclouds.filter(p => p.visible)){ - let request = pointcloud.getPointsInProfile(profile, null, { + let request = pointcloud.getPointsInProfile(this.profile, null, { "onProgress": (event) => { if(!this.enabled){ return; } - this.handleNewPoints(event.points); - - this.render(); + this.progressHandler(pointcloud, event.points); if(this.numPoints > this.threshold){ this.cancel(); @@ -15984,259 +16548,10 @@ Potree.Viewer.Profile = class ProfileWindow{ this.requests.push(request); } + } - setThreshold(value){ - this.threshold = value; - - this.redraw(); - } - - getPointsInProfileAsCSV(){ - if(this.points.length === 0){ - return "no points in profile"; - } - - let file = ""; - - let pointsPerSegment = this.points.segments.map(s => s.points); - let points = {}; - let attributes = Object.keys(pointsPerSegment[0]); - for(let attribute of attributes){ - let arrays = pointsPerSegment.map(p => p[attribute]); - points[attribute] = arrays.reduce( (a, v) => a.concat(v)); - } - - { // header-line - let header = "x, y"; - - if(points.hasOwnProperty("color")){ - header += ", r, g, b"; - } - - if(points.hasOwnProperty("intensity")){ - header += ", intensity"; - } - - if(points.hasOwnProperty("classification")){ - header += ", classification"; - } - - if(points.hasOwnProperty("numberOfReturns")){ - header += ", numberOfReturns"; - } - - if(points.hasOwnProperty("pointSourceID")){ - header += ", pointSourceID"; - } - - if(points.hasOwnProperty("returnNumber")){ - header += ", returnNumber"; - } - - file += header + "\n"; - } - - let numPoints = points.position.length; - - // actual data - for(let i = 0; i < numPoints; i++){ - - let values = []; - - values.push(points.mileage[i].toFixed(4)); - values.push(points.position[i].z.toFixed(4)); - - if(attributes.includes("color")){ - values.push(points.color[i].join(", ")); - } - - if(attributes.includes("intensity")){ - values.push(points.intensity[i]); - } - - if(attributes.includes("classification")){ - values.push(points.classification[i]); - } - - if(attributes.includes("numberOfReturns")){ - values.push(points.numberOfReturns[i]); - } - - if(attributes.includes("pointSourceID")){ - values.push(points.pointSourceID[i]); - } - - if(attributes.includes("returnNumber")){ - values.push(points.returnNumber[i]); - } - - let line = values.join(", ") + "\n"; - - file = file + line; - } - - return file; - } - - getPointsInProfileAsLas(){ - - let pointsPerSegment = this.points.segments.map(s => s.points); - let points = {}; - let attributes = Object.keys(pointsPerSegment[0]); - for(let attribute of attributes){ - let arrays = pointsPerSegment.map(p => p[attribute]); - points[attribute] = arrays.reduce( (a, v) => a.concat(v)); - } - let numPoints = points.position.length; - - let boundingBox = new THREE.Box3(); - - for(let i = 0; i < numPoints; i++){ - let position = points.position[i]; - boundingBox.expandByPoint(position); - } - - - let offset = boundingBox.min.clone(); - let diagonal = boundingBox.min.distanceTo(boundingBox.max); - let scale = new THREE.Vector3(0.01, 0.01, 0.01); - if(diagonal > 100*1000){ - scale = new THREE.Vector3(0.01, 0.01, 0.01); - }else{ - scale = new THREE.Vector3(0.001, 0.001, 0.001); - } - - let setString = function(string, offset, buffer){ - let view = new Uint8Array(buffer); - - for(let i = 0; i < string.length; i++){ - let charCode = string.charCodeAt(i); - view[offset + i] = charCode; - } - } - - let buffer = new ArrayBuffer(227 + 28 * numPoints); - let view = new DataView(buffer); - let u8View = new Uint8Array(buffer); - - setString("LASF", 0, buffer); - u8View[24] = 1; - u8View[25] = 2; - - // system identifier o:26 l:32 - - // generating software o:58 l:32 - setString("potree 1.4", 58, buffer); - - // file creation day of year o:90 l:2 - // file creation year o:92 l:2 - - // header size o:94 l:2 - view.setUint16(94, 227, true); - - // offset to point data o:96 l:4 - view.setUint32(96, 227, true); - - // number of letiable length records o:100 l:4 - - // point data record format 104 1 - u8View[104] = 2; - - // point data record length 105 2 - view.setUint16(105, 28, true); - - // number of point records 107 4 - view.setUint32(107, numPoints, true); - - // number of points by return 111 20 - - // x scale factor 131 8 - view.setFloat64(131, scale.x, true); - - // y scale factor 139 8 - view.setFloat64(139, scale.y, true); - - // z scale factor 147 8 - view.setFloat64(147, scale.z, true); - - // x offset 155 8 - view.setFloat64(155, offset.x, true); - - // y offset 163 8 - view.setFloat64(163, offset.y, true); - - // z offset 171 8 - view.setFloat64(171, offset.z, true); - - let hasIntensity = attributes.includes("intensity"); - let hasReturnNumber = attributes.includes("returnNumber"); - let hasClassification = attributes.includes("classification"); - let hasPointSourceID = attributes.includes("pointSourceID"); - - let boffset = 227; - for(let i = 0; i < numPoints; i++){ - //let point = points[i]; - //let position = new THREE.Vector3(point.x, point.y, point.z); - let position = points.position[i]; - - let ux = parseInt((position.x - offset.x) / scale.x); - let uy = parseInt((position.y - offset.y) / scale.y); - let uz = parseInt((position.z - offset.z) / scale.z); - - view.setUint32(boffset + 0, ux, true); - view.setUint32(boffset + 4, uy, true); - view.setUint32(boffset + 8, uz, true); - - if(hasIntensity){ - view.setUint16(boffset + 12, (points.intensity[i]), true); - } - - if(hasReturnNumber){ - let rt = points.returnNumber[i]; - rt += (points.numberOfReturns[i] << 3); - view.setUint8(boffset + 14, rt); - } - - if(hasClassification){ - view.setUint8(boffset + 15, points.classification[i]); - } - - // scan angle rank - // user data - // point source id - if(hasPointSourceID){ - view.setUint16(boffset + 18, points.pointSourceID[i]); - } - view.setUint16(boffset + 20, (points.color[i][0] * 255), true); - view.setUint16(boffset + 22, (points.color[i][1] * 255), true); - view.setUint16(boffset + 24, (points.color[i][2] * 255), true); - - boffset += 28; - } - - // max x 179 8 - view.setFloat64(179, boundingBox.max.x, true); - - // min x 187 8 - view.setFloat64(187, boundingBox.min.x, true); - - // max y 195 8 - view.setFloat64(195, boundingBox.max.y, true); - - // min y 203 8 - view.setFloat64(203, boundingBox.min.y, true); - - // max z 211 8 - view.setFloat64(211, boundingBox.max.z, true); - - // min z 219 8 - view.setFloat64(219, boundingBox.min.z, true); - - return buffer; - } - }; // http://epsg.io/ @@ -16257,54 +16572,126 @@ Potree.MapView = class{ this.toolLayer = null; this.sourcesLayer = null; this.sourcesLabelLayer = null; + this.enabled = false; + + this.createAnnotationStyle = (text) => { + return [ + new ol.style.Style({ + image: new ol.style.Circle({ + radius: 10, + stroke: new ol.style.Stroke({ + color: [255, 255, 255, 0.5], + width: 2 + }), + fill: new ol.style.Fill({ + color: [0, 0, 0, 0.5] + }) + }) + })/*, + new ol.style.Style({ + text: new ol.style.Text({ + font: '12px helvetica,sans-serif', + text: text, + fill: new ol.style.Fill({ + color: '#000' + }), + stroke: new ol.style.Stroke({ + color: '#fff', + width: 2 + }) + }) + })*/ + ]; + } + + this.createLabelStyle = (text) => { + let style = new ol.style.Style({ + image: new ol.style.Circle({ + radius: 6, + stroke: new ol.style.Stroke({ + color: 'white', + width: 2 + }), + fill: new ol.style.Fill({ + color: 'green' + }) + }), + text: new ol.style.Text({ + font: '12px helvetica,sans-serif', + text: text, + fill: new ol.style.Fill({ + color: '#000' + }), + stroke: new ol.style.Stroke({ + color: '#fff', + width: 2 + }) + }) + }); + + return style; + } + + + } + + showSources(show){ + this.sourcesLayer.setVisible(show); + this.sourcesLabelLayer.setVisible(show); } init(){ - $( "#potree_map" ).draggable({ handle: $('#potree_map_header') }); - $( "#potree_map" ).resizable(); - //$( "#potree_map_toggle" ).css("display", "block"); + this.elMap = $("#potree_map"); + this.elMap.draggable({ handle: $('#potree_map_header') }); + this.elMap.resizable(); + + this.elTooltip = $(``); + this.elMap.append(this.elTooltip); let extentsLayer = this.getExtentsLayer(); let cameraLayer = this.getCameraLayer(); let toolLayer = this.getToolLayer(); let sourcesLayer = this.getSourcesLayer(); let sourcesLabelLayer = this.getSourcesLabelLayer(); + let annotationsLayer = this.getAnnotationsLayer(); - var mousePositionControl = new ol.control.MousePosition({ + let mousePositionControl = new ol.control.MousePosition({ coordinateFormat: ol.coordinate.createStringXY(5), projection: "EPSG:4326", undefinedHTML: ' ' }); + let _this = this; let DownloadSelectionControl = function(opt_options){ - var options = opt_options || {}; + let options = opt_options || {}; // TOGGLE TILES - var btToggleTiles = document.createElement('button'); + let btToggleTiles = document.createElement('button'); btToggleTiles.innerHTML = 'T'; btToggleTiles.addEventListener('click', () => { - var visible = this.sourcesLayer.getVisible(); - this.sourcesLayer.setVisible(!visible); - this.sourcesLabelLayer.setVisible(!visible); + let visible = sourcesLayer.getVisible(); + _this.showSources(!visible); + //sourcesLayer.setVisible(!visible); + //sourcesLabelLayer.setVisible(!visible); }, false); btToggleTiles.style.float = "left"; btToggleTiles.title = "show / hide tiles"; // DOWNLOAD SELECTED TILES - var link = document.createElement("a"); + let link = document.createElement("a"); link.href = "#"; link.download = "list.txt"; link.style.float = "left"; - var button = document.createElement('button'); + let button = document.createElement('button'); button.innerHTML = 'D'; link.appendChild(button); - var this_ = this; - var handleDownload = (e) => { - var features = selectedFeatures.getArray(); + let this_ = this; + let handleDownload = (e) => { + let features = selectedFeatures.getArray(); - var url = [location.protocol, '//', location.host, location.pathname].join(''); + let url = [location.protocol, '//', location.host, location.pathname].join(''); if(features.length === 0){ alert("No tiles were selected. Select area with ctrl + left mouse button!"); @@ -16312,27 +16699,27 @@ Potree.MapView = class{ e.stopImmediatePropagation(); return false; }else if(features.length === 1){ - var feature = features[0]; + let feature = features[0]; if(feature.source){ - var cloudjsurl = feature.pointcloud.pcoGeometry.url; - var sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); + let cloudjsurl = feature.pointcloud.pcoGeometry.url; + let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); link.href = sourceurl.href; link.download = feature.source.name; } }else{ - var content = ""; + let content = ""; for(var i = 0; i < features.length; i++){ - var feature = features[i]; + let feature = features[i]; if(feature.source){ - var cloudjsurl = feature.pointcloud.pcoGeometry.url; - var sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); + let cloudjsurl = feature.pointcloud.pcoGeometry.url; + let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name); content += sourceurl.href + "\n"; } } - var uri = "data:application/octet-stream;base64,"+btoa(content); + let uri = "data:application/octet-stream;base64,"+btoa(content); link.href = uri; link.download = "list_of_files.txt"; } @@ -16341,7 +16728,7 @@ Potree.MapView = class{ button.addEventListener('click', handleDownload, false); // assemble container - var element = document.createElement('div'); + let element = document.createElement('div'); element.className = 'ol-unselectable ol-control'; element.appendChild(link); element.appendChild(btToggleTiles); @@ -16370,6 +16757,7 @@ Potree.MapView = class{ layers: [ new ol.layer.Tile({source: new ol.source.OSM()}), this.toolLayer, + this.annotationsLayer, this.sourcesLayer, this.sourcesLabelLayer, extentsLayer, @@ -16394,24 +16782,50 @@ Potree.MapView = class{ }); this.map.addLayer(this.dragBoxLayer); - var select = new ol.interaction.Select(); + let select = new ol.interaction.Select(); this.map.addInteraction(select); - var selectedFeatures = select.getFeatures(); + let selectedFeatures = select.getFeatures(); - var dragBox = new ol.interaction.DragBox({ + let dragBox = new ol.interaction.DragBox({ condition: ol.events.condition.platformModifierKeyOnly }); this.map.addInteraction(dragBox); - + this.map.on('pointermove', evt => { + let pixel = evt.pixel; + let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) { + return feature; + }); + + //console.log(feature); + //this.elTooltip.css("display", feature ? '' : 'none'); + this.elTooltip.css("display", "none"); + if(feature && feature.onHover){ + feature.onHover(evt); + //overlay.setPosition(evt.coordinate); + //tooltip.innerHTML = feature.get('name'); + } + }); + + this.map.on('click', evt => { + let pixel = evt.pixel; + let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) { + return feature; + }); + + if(feature && feature.onHover){ + feature.onClick(evt); + } + }); + dragBox.on('boxend', (e) => { // features that intersect the box are added to the collection of // selected features, and their names are displayed in the "info" // div - var extent = dragBox.getGeometry().getExtent(); - this.sourcesLayer.getSource().forEachFeatureIntersectingExtent(extent, (feature) => { + let extent = dragBox.getGeometry().getExtent(); + this.getSourcesLayer().getSource().forEachFeatureIntersectingExtent(extent, (feature) => { selectedFeatures.push(feature); }); }); @@ -16423,25 +16837,6 @@ Potree.MapView = class{ this.map.on('click', () => { selectedFeatures.clear(); }); - - //// adding pointclouds to map - //this.viewer.addEventListener("pointcloud_added", (event) => { - // this.load(event.pointcloud); - //}); - //for(var i = 0; i < this.viewer.scene.pointclouds.length; i++){ - // this.load(this.viewer.scene.pointclouds[i]); - //} - - //this.viewer.profileTool.addEventListener("profile_added", this.updateToolDrawings); - //this.viewer.profileTool.addEventListener("profile_removed", this.updateToolDrawings); - //this.viewer.profileTool.addEventListener("marker_moved", this.updateToolDrawings); - //this.viewer.profileTool.addEventListener("marker_removed", this.updateToolDrawings); - //this.viewer.profileTool.addEventListener("marker_added", this.updateToolDrawings); - // - //this.viewer.measuringTool.addEventListener("measurement_added", this.updateToolDrawings); - //this.viewer.measuringTool.addEventListener("marker_added", this.updateToolDrawings); - //this.viewer.measuringTool.addEventListener("marker_removed", this.updateToolDrawings); - //this.viewer.measuringTool.addEventListener("marker_moved", this.updateToolDrawings); this.viewer.addEventListener("scene_changed", e => { this.setScene(e.scene); @@ -16451,6 +16846,37 @@ Potree.MapView = class{ this.load(e.pointcloud); }; + this.onAnnotationAdded = e => { + if(!this.sceneProjection){ + return; + } + + let annotation = e.annotation; + let position = annotation.position; + let mapPos = this.toMap.forward([position.x, position.y]); + let feature = new ol.Feature({ + geometry: new ol.geom.Point(mapPos), + name: annotation.title + }); + feature.setStyle(this.createAnnotationStyle(annotation.title)); + + feature.onHover = evt => { + let coordinates = feature.getGeometry().getCoordinates(); + let p = this.map.getPixelFromCoordinate(coordinates); + + this.elTooltip.html(annotation.title); + this.elTooltip.css("display", ""); + this.elTooltip.css("left", `${p[0]}px`); + this.elTooltip.css("top", `${p[1]}px`); + }; + + feature.onClick = evt => { + annotation.clickTitle(); + }; + + this.getAnnotationsLayer().getSource().addFeature(feature); + }; + this.setScene(this.viewer.scene); } @@ -16461,15 +16887,22 @@ Potree.MapView = class{ if(this.scene){ this.scene.removeEventListener("pointcloud_added", this.onPointcloudAdded); + this.scene.annotations.removeEventListener("annotation_added", this.onAnnotationAdded); } this.scene = scene; this.scene.addEventListener("pointcloud_added", this.onPointcloudAdded); + this.scene.annotations.addEventListener("annotation_added", this.onAnnotationAdded); - for(var i = 0; i < this.viewer.scene.pointclouds.length; i++){ - this.load(this.viewer.scene.pointclouds[i]); + for(let pointcloud of this.viewer.scene.pointclouds){ + this.load(pointcloud); } + + console.log("map.setScene"); + this.viewer.scene.annotations.traverseDescendants(annotation => { + this.onAnnotationAdded({annotation: annotation}); + }); } getExtentsLayer(){ @@ -16506,6 +16939,28 @@ Potree.MapView = class{ return this.extentsLayer; } + getAnnotationsLayer(){ + if(this.annotationsLayer){ + return this.annotationsLayer; + } + + this.annotationsLayer = new ol.layer.Vector({ + source: new ol.source.Vector({ + }), + style: new ol.style.Style({ + fill: new ol.style.Fill({ + color: 'rgba(255, 0, 0, 1)' + }), + stroke: new ol.style.Stroke({ + color: 'rgba(255, 0, 0, 1)', + width: 2 + }) + }) + }); + + return this.annotationsLayer; + } + getCameraLayer(){ if(this.cameraLayer){ return this.cameraLayer; @@ -16513,8 +16968,8 @@ Potree.MapView = class{ // CAMERA LAYER this.gCamera = new ol.geom.LineString([[0,0], [0,0], [0,0], [0,0]]); - var feature = new ol.Feature(this.gCamera); - var featureVector = new ol.source.Vector({ + let feature = new ol.Feature(this.gCamera); + let featureVector = new ol.source.Vector({ features: [feature] }); @@ -16605,14 +17060,14 @@ Potree.MapView = class{ }; getMapExtent(){ - var bb = this.viewer.getBoundingBox(); + let bb = this.viewer.getBoundingBox(); - var bottomLeft = this.toMap.forward([bb.min.x, bb.min.y]); - var bottomRight = this.toMap.forward([bb.max.x, bb.min.y]); - var topRight = this.toMap.forward([bb.max.x, bb.max.y]); - var topLeft = this.toMap.forward([bb.min.x, bb.max.y]); + let bottomLeft = this.toMap.forward([bb.min.x, bb.min.y]); + let bottomRight = this.toMap.forward([bb.max.x, bb.min.y]); + let topRight = this.toMap.forward([bb.max.x, bb.max.y]); + let topLeft = this.toMap.forward([bb.min.x, bb.max.y]); - var extent = { + let extent = { bottomLeft: bottomLeft, bottomRight: bottomRight, topRight: topRight, @@ -16623,9 +17078,9 @@ Potree.MapView = class{ }; getMapCenter(){ - var mapExtent = this.getMapExtent(); + let mapExtent = this.getMapExtent(); - var mapCenter = [ + let mapCenter = [ (mapExtent.bottomLeft[0] + mapExtent.topRight[0]) / 2, (mapExtent.bottomLeft[1] + mapExtent.topRight[1]) / 2 ]; @@ -16636,30 +17091,30 @@ Potree.MapView = class{ updateToolDrawings(){ this.toolLayer.getSource().clear(); - var profiles = this.viewer.profileTool.profiles; + let profiles = this.viewer.profileTool.profiles; for(var i = 0; i < profiles.length; i++){ - var profile = profiles[i]; - var coordinates = []; + let profile = profiles[i]; + let coordinates = []; for(var j = 0; j < profile.points.length; j++){ - var point = profile.points[j]; - var pointMap = this.toMap.forward([point.x, point.y]); + let point = profile.points[j]; + let pointMap = this.toMap.forward([point.x, point.y]); coordinates.push(pointMap); } - var line = new ol.geom.LineString(coordinates); - var feature = new ol.Feature(line); + let line = new ol.geom.LineString(coordinates); + let feature = new ol.Feature(line); this.toolLayer.getSource().addFeature(feature); } - var measurements = this.viewer.measuringTool.measurements; + let measurements = this.viewer.measuringTool.measurements; for(var i = 0; i < measurements.length; i++){ - var measurement = measurements[i]; - var coordinates = []; + let measurement = measurements[i]; + let coordinates = []; for(var j = 0; j < measurement.points.length; j++){ - var point = measurement.points[j].position; - var pointMap = this.toMap.forward([point.x, point.y]); + let point = measurement.points[j].position; + let pointMap = this.toMap.forward([point.x, point.y]); coordinates.push(pointMap); } @@ -16667,8 +17122,8 @@ Potree.MapView = class{ coordinates.push(coordinates[0]); } - var line = new ol.geom.LineString(coordinates); - var feature = new ol.Feature(line); + let line = new ol.geom.LineString(coordinates); + let feature = new ol.Feature(line); this.toolLayer.getSource().addFeature(feature); } } @@ -16676,7 +17131,7 @@ Potree.MapView = class{ load(pointcloud){ - if(!(pointcloud instanceof Potree.PointCloudOctree)){ + if(!pointcloud){ return; } @@ -16688,50 +17143,13 @@ Potree.MapView = class{ this.setSceneProjection(pointcloud.projection); } - var mapExtent = this.getMapExtent(); - var mapCenter = this.getMapCenter(); + let mapExtent = this.getMapExtent(); + let mapCenter = this.getMapCenter(); - var view = this.map.getView(); + let view = this.map.getView(); view.setCenter(mapCenter); - //{ - // let bb = this.viewer.getBoundingBox(); - // let corners = [ - // [bb.min.x, bb.min.y], - // [bb.max.x, bb.min.y], - // [bb.max.x, bb.max.y], - // [bb.min.x, bb.max.y], - // [bb.min.x, bb.min.y]]; - // - // let vertices = []; - // - // for(let i = 0; i < corners.length - 1; i++){ - // let pieces = 5; - // - // for(let j = 0; j < pieces; j++){ - // let t0 = j / pieces; - // let t1 = (j+1) / pieces; - // - // let c0 = corners[i+0]; - // let c1 = corners[i+1]; - // - // let p0 = [ - // (1 - t0) * c0[0] + t0 * c1[0], - // (1 - t0) * c0[1] + t0 * c1[1]]; - // - // let p1 = [ - // (1 - t1) * c0[0] + t1 * c1[0], - // (1 - t1) * c0[1] + t1 * c1[1]]; - // - // vertices.push(this.toMap.forward(p0)); - // vertices.push(this.toMap.forward(p1)); - // } - // } - // - // this.gExtent.setCoordinates(vertices); - //} - this.gExtent.setCoordinates([ mapExtent.bottomLeft, mapExtent.bottomRight, @@ -16744,120 +17162,115 @@ Potree.MapView = class{ constrainResolution: false }); - let createLabelStyle = (text) => { - var style = new ol.style.Style({ - image: new ol.style.Circle({ - fill: new ol.style.Fill({ - color: 'rgba(100,50,200,0.5)' - }), - stroke: new ol.style.Stroke({ - color: 'rgba(120,30,100,0.8)', - width: 3 - }) - }), - text: new ol.style.Text({ - font: '12px helvetica,sans-serif', - text: text, - fill: new ol.style.Fill({ - color: '#000' - }), - stroke: new ol.style.Stroke({ - color: '#fff', - width: 2 - }) - }) - }); - - return style; - } + - var url = pointcloud.pcoGeometry.url + "/../sources.json"; + let url = pointcloud.pcoGeometry.url + "/../sources.json"; $.getJSON(url, (data) => { - var sources = data.sources; + let sources = data.sources; for(var i = 0; i < sources.length; i++){ - var source = sources[i]; - var name = source.name; - var points = source.points; - var bounds = source.bounds; + let source = sources[i]; + let name = source.name; + let points = source.points; + let bounds = source.bounds; - var mapBounds = { + let mapBounds = { min: this.toMap.forward( [bounds.min[0], bounds.min[1]] ), max: this.toMap.forward( [bounds.max[0], bounds.max[1]] ) } - var mapCenter = [ + let mapCenter = [ (mapBounds.min[0] + mapBounds.max[0]) / 2, (mapBounds.min[1] + mapBounds.max[1]) / 2, ]; - var p1 = this.toMap.forward( [bounds.min[0], bounds.min[1]] ); - var p2 = this.toMap.forward( [bounds.max[0], bounds.min[1]] ); - var p3 = this.toMap.forward( [bounds.max[0], bounds.max[1]] ); - var p4 = this.toMap.forward( [bounds.min[0], bounds.max[1]] ); + let p1 = this.toMap.forward( [bounds.min[0], bounds.min[1]] ); + let p2 = this.toMap.forward( [bounds.max[0], bounds.min[1]] ); + let p3 = this.toMap.forward( [bounds.max[0], bounds.max[1]] ); + let p4 = this.toMap.forward( [bounds.min[0], bounds.max[1]] ); - var boxes = []; + let boxes = []; //var feature = new ol.Feature({ // 'geometry': new ol.geom.LineString([p1, p2, p3, p4, p1]) //}); - var feature = new ol.Feature({ + let feature = new ol.Feature({ 'geometry': new ol.geom.Polygon([[p1, p2, p3, p4, p1]]) }); feature.source = source; feature.pointcloud = pointcloud; - this.sourcesLayer.getSource().addFeature(feature); + this.getSourcesLayer().getSource().addFeature(feature); feature = new ol.Feature({ geometry: new ol.geom.Point(mapCenter), name: name }); - feature.setStyle(createLabelStyle(name)); + feature.setStyle(this.createLabelStyle(name)); this.sourcesLabelLayer.getSource().addFeature(feature); } }); } + toggle(){ + + if(this.elMap.is(":visible")){ + this.elMap.css("display", "none"); + this.enabled = false; + }else{ + this.elMap.css("display", "block"); + this.enabled = true; + } + + } + update(delta){ if(!this.sceneProjection){ return; } - var pm = $( "#potree_map" ); + let pm = $( "#potree_map" ); - if(!pm.is(":visible")){ + if(!this.enabled){ return; } // resize - var mapSize = this.map.getSize(); - var resized = (pm.width() != mapSize[0] || pm.height() != mapSize[1]); + let mapSize = this.map.getSize(); + let resized = (pm.width() != mapSize[0] || pm.height() != mapSize[1]); if(resized){ this.map.updateSize(); } // camera - var scale = this.map.getView().getResolution(); - var camera = this.viewer.scene.camera; - var campos = camera.position; - var camdir = camera.getWorldDirection(); - var sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos); - var geoPos = camera.position; - var geoLookAt = sceneLookAt; - var mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y])); - var mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y])); - var mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize(); + let scale = this.map.getView().getResolution(); + let camera = this.viewer.scene.camera; + let campos = camera.position; + let camdir = camera.getWorldDirection(); + let sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos); + let geoPos = camera.position; + let geoLookAt = sceneLookAt; + let mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y])); + let mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y])); + let mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize(); mapLookAt = mapPos.clone().add(mapDir.clone().multiplyScalar(30 * scale)); - var mapLength = mapPos.distanceTo(mapLookAt); - var mapSide = new THREE.Vector2(-mapDir.y, mapDir.x); + let mapLength = mapPos.distanceTo(mapLookAt); + let mapSide = new THREE.Vector2(-mapDir.y, mapDir.x); - var p1 = mapPos.toArray(); - var p2 = mapLookAt.clone().sub(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); - var p3 = mapLookAt.clone().add(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); + let p1 = mapPos.toArray(); + let p2 = mapLookAt.clone().sub(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); + let p3 = mapLookAt.clone().add(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray(); this.gCamera.setCoordinates([p1, p2, p3, p1]); } + get sourcesVisible(){ + return this.getSourcesLayer().getVisible(); + } + + set sourcesVisible(value){ + this.getSourcesLayer().setVisible(value); + } + }; @@ -16901,7 +17314,7 @@ function initToolbar(){ // POINT elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/point.svg", - "[title]tt.angle_measurement", + "[title]tt.point_measurement", function(){ $("#menu_measurements").next().slideDown(); viewer.measuringTool.startInsertion({ @@ -16993,314 +17406,6 @@ function initToolbar(){ )); } -function initMaterials(){ - - $( "#optMaterial" ).selectmenu({ - style:'popup', - position: { - my: "top", - at: "bottom", - collision: "flip" } - }); - - $( "#sldHeightRange" ).slider({ - range: true, - min: 0, - max: 1000, - values: [0, 1000], - step: 0.01, - slide: function( event, ui ) { - viewer.setHeightRange(ui.values[0], ui.values[1]); - } - }); - - $( "#sldTransition" ).slider({ - value: viewer.getMaterialTransition(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setMaterialTransition(ui.value);} - }); - - $( "#sldIntensityRange" ).slider({ - range: true, - min: 0, - max: 1, - values: [0, 1], - step: 0.01, - slide: function( event, ui ) { - let min = (ui.values[0] == 0) ? 0 : parseInt(Math.pow(2, 16 * ui.values[0])); - let max = parseInt(Math.pow(2, 16 * ui.values[1])); - viewer.setIntensityRange(min, max); - } - }); - - $( "#sldIntensityGamma" ).slider({ - value: viewer.getIntensityGamma(), - min: 0, - max: 4, - step: 0.01, - slide: function( event, ui ) {viewer.setIntensityGamma(ui.value);} - }); - - $( "#sldIntensityContrast" ).slider({ - value: viewer.getIntensityContrast(), - min: -1, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setIntensityContrast(ui.value);} - }); - - $( "#sldIntensityBrightness" ).slider({ - value: viewer.getIntensityBrightness(), - min: -1, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setIntensityBrightness(ui.value);} - }); - - $( "#sldRGBGamma" ).slider({ - value: viewer.getRGBGamma(), - min: 0, - max: 4, - step: 0.01, - slide: function( event, ui ) {viewer.setRGBGamma(ui.value);} - }); - - $( "#sldRGBContrast" ).slider({ - value: viewer.getRGBContrast(), - min: -1, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setRGBContrast(ui.value);} - }); - - $( "#sldRGBBrightness" ).slider({ - value: viewer.getRGBBrightness(), - min: -1, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setRGBBrightness(ui.value);} - }); - - $( "#sldWeightRGB" ).slider({ - value: viewer.getWeightRGB(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightRGB(ui.value);} - }); - - $( "#sldWeightIntensity" ).slider({ - value: viewer.getWeightIntensity(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightIntensity(ui.value);} - }); - - $( "#sldWeightElevation" ).slider({ - value: viewer.getWeightElevation(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightElevation(ui.value);} - }); - - $( "#sldWeightClassification" ).slider({ - value: viewer.getWeightClassification(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightClassification(ui.value);} - }); - - $( "#sldWeightReturnNumber" ).slider({ - value: viewer.getWeightReturnNumber(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightReturnNumber(ui.value);} - }); - - $( "#sldWeightSourceID" ).slider({ - value: viewer.getWeightSourceID(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setWeightSourceID(ui.value);} - }); - - let updateHeightRange = function(){ - let box = viewer.getBoundingBox(); - let bWidth = box.max.z - box.min.z; - bMin = box.min.z - 0.2 * bWidth; - bMax = box.max.z + 0.2 * bWidth; - - let hr = viewer.getHeightRange(); - let hrWidth = hr.max - hr.min; - - $( '#lblHeightRange')[0].innerHTML = hr.min.toFixed(2) + " to " + hr.max.toFixed(2); - $( "#sldHeightRange" ).slider({ - min: bMin, - max: bMax, - values: [hr.min, hr.max] - }); - }; - - let updateIntensityRange = function(){ - let range = viewer.getIntensityRange(); - let min = Math.log2(range[0]) / 16; - let max = Math.log2(range[1]) / 16; - - $('#lblIntensityRange')[0].innerHTML = - parseInt(viewer.getIntensityRange()[0]) + " to " + - parseInt(viewer.getIntensityRange()[1]); - $( "#sldIntensityRange" ).slider({ - values: [min, max] - }); - }; - - viewer.addEventListener("height_range_changed", updateHeightRange); - viewer.addEventListener("intensity_range_changed", updateIntensityRange); - - viewer.addEventListener("intensity_gamma_changed", function(event){ - let gamma = viewer.getIntensityGamma(); - - $('#lblIntensityGamma')[0].innerHTML = gamma.toFixed(2); - $("#sldIntensityGamma").slider({value: gamma}); - }); - - viewer.addEventListener("intensity_contrast_changed", function(event){ - let contrast = viewer.getIntensityContrast(); - - $('#lblIntensityContrast')[0].innerHTML = contrast.toFixed(2); - $("#sldIntensityContrast").slider({value: contrast}); - }); - - viewer.addEventListener("intensity_brightness_changed", function(event){ - let brightness = viewer.getIntensityBrightness(); - - $('#lblIntensityBrightness')[0].innerHTML = brightness.toFixed(2); - $("#sldIntensityBrightness").slider({value: brightness}); - }); - - viewer.addEventListener("rgb_gamma_changed", function(event){ - let gamma = viewer.getRGBGamma(); - - $('#lblRGBGamma')[0].innerHTML = gamma.toFixed(2); - $("#sldRGBGamma").slider({value: gamma}); - }); - - viewer.addEventListener("rgb_contrast_changed", function(event){ - let contrast = viewer.getRGBContrast(); - - $('#lblRGBContrast')[0].innerHTML = contrast.toFixed(2); - $("#sldRGBContrast").slider({value: contrast}); - }); - - viewer.addEventListener("rgb_brightness_changed", function(event){ - let brightness = viewer.getRGBBrightness(); - - $('#lblRGBBrightness')[0].innerHTML = brightness.toFixed(2); - $("#sldRGBBrightness").slider({value: brightness}); - }); - - viewer.addEventListener("pointcloud_loaded", updateHeightRange); - - updateHeightRange(); - updateIntensityRange(); - $('#lblIntensityGamma')[0].innerHTML = viewer.getIntensityGamma().toFixed(2); - $('#lblIntensityContrast')[0].innerHTML = viewer.getIntensityContrast().toFixed(2); - $('#lblIntensityBrightness')[0].innerHTML = viewer.getIntensityBrightness().toFixed(2); - - $('#lblRGBGamma')[0].innerHTML = viewer.getRGBGamma().toFixed(2); - $('#lblRGBContrast')[0].innerHTML = viewer.getRGBContrast().toFixed(2); - $('#lblRGBBrightness')[0].innerHTML = viewer.getRGBBrightness().toFixed(2); - - let options = [ - "RGB", - "RGB and Elevation", - "Color", - "Elevation", - "Intensity", - "Intensity Gradient", - "Classification", - "Return Number", - "Source", - "Phong", - "Level of Detail", - "Composite", - ]; - - let elMaterialList = $("#optMaterial"); - for(let i = 0; i < options.length; i++){ - let option = options[i]; - let id = "optMaterial_" + option; - - let elOption = $(` - `); - elMaterialList.append(elOption); - } - - let updateMaterialPanel = function(event, ui){ - //viewer.setMaterial(ui.item.value); - - let selectedValue = $("#optMaterial").selectmenu().val(); - viewer.setMaterial(selectedValue); - - let blockWeights = $("#materials\\.composite_weight_container"); - let blockElevation = $("#materials\\.elevation_container"); - let blockRGB = $("#materials\\.rgb_container"); - let blockIntensity = $("#materials\\.intensity_container"); - let blockTransition = $("#materials\\.transition_container"); - - blockIntensity.css("display", "none"); - blockElevation.css("display", "none"); - blockRGB.css("display", "none"); - blockWeights.css("display", "none"); - blockTransition.css("display", "none"); - - if(selectedValue === "Composite"){ - blockWeights.css("display", "block"); - blockElevation.css("display", "block"); - blockRGB.css("display", "block"); - blockIntensity.css("display", "block"); - } - - if(selectedValue === "Elevation"){ - blockElevation.css("display", "block"); - } - - if(selectedValue === "RGB and Elevation"){ - blockRGB.css("display", "block"); - blockElevation.css("display", "block"); - } - - if(selectedValue === "RGB"){ - blockRGB.css("display", "block"); - } - - if(selectedValue === "Intensity"){ - blockIntensity.css("display", "block"); - } - - if(selectedValue === "Intensity Gradient"){ - blockIntensity.css("display", "block"); - } - }; - - $("#optMaterial").selectmenu({change: updateMaterialPanel}); - $("#optMaterial").val(viewer.getMaterialName()).selectmenu("refresh"); - updateMaterialPanel(); - - viewer.addEventListener("material_changed", e => { - $("#optMaterial").val(viewer.getMaterialName()).selectmenu("refresh"); - }); -} - function initClassificationList(){ let elClassificationList = $("#classificationList"); @@ -17365,22 +17470,14 @@ function initAccordion(){ function initAppearance(){ - $( "#optPointSizing" ).selectmenu(); - $( "#optQuality" ).selectmenu(); + //$( "#optQuality" ).selectmenu(); - $("#optPointSizing").val(viewer.getPointSizing()).selectmenu("refresh") - $("#optPointSizing").selectmenu({ - change: function(event, ui){ - viewer.setPointSizing(ui.item.value); - } - }); - - $("#optQuality").val(viewer.getQuality()).selectmenu("refresh") - $("#optQuality").selectmenu({ - change: function(event, ui){ - viewer.setQuality(ui.item.value); - } - }); + //$("#optQuality").val(viewer.getQuality()).selectmenu("refresh") + //$("#optQuality").selectmenu({ + // change: function(event, ui){ + // viewer.setQuality(ui.item.value); + // } + //}); $( "#sldPointBudget" ).slider({ @@ -17391,14 +17488,6 @@ function initAppearance(){ slide: function( event, ui ) {viewer.setPointBudget(ui.value);} }); - $( "#sldPointSize" ).slider({ - value: viewer.getPointSize(), - min: 0, - max: 3, - step: 0.01, - slide: function( event, ui ) {viewer.setPointSize(ui.value);} - }); - $( "#sldFOV" ).slider({ value: viewer.getFOV(), min: 20, @@ -17407,14 +17496,6 @@ function initAppearance(){ slide: function( event, ui ) {viewer.setFOV(ui.value);} }); - $( "#sldOpacity" ).slider({ - value: viewer.getOpacity(), - min: 0, - max: 1, - step: 0.01, - slide: function( event, ui ) {viewer.setOpacity(ui.value);} - }); - $( "#sldEDLRadius" ).slider({ value: viewer.getEDLRadius(), min: 1, @@ -17436,46 +17517,20 @@ function initAppearance(){ $( "#sldPointBudget" ).slider({value: viewer.getPointBudget()}); }); - viewer.addEventListener("point_size_changed", function(event){ - $('#lblPointSize')[0].innerHTML = viewer.getPointSize().toFixed(2); - $( "#sldPointSize" ).slider({value: viewer.getPointSize()}); - }); - viewer.addEventListener("fov_changed", function(event){ $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); $( "#sldFOV" ).slider({value: viewer.getFOV()}); }); - - viewer.addEventListener("opacity_changed", function(event){ - $('#lblOpacity')[0].innerHTML = viewer.getOpacity().toFixed(2); - $( "#sldOpacity" ).slider({value: viewer.getOpacity()}); - }); - - viewer.addEventListener("point_sizing_changed", e => { - let type = viewer.pointSizeType; - let conversion = new Map([ - [Potree.PointSizeType.FIXED, "Fixed"], - [Potree.PointSizeType.ATTENUATED, "Attenuated"], - [Potree.PointSizeType.ADAPTIVE, "Adaptive"] - ]); - - let typename = conversion.get(type); - - $( "#optPointSizing" ) - .selectmenu() - .val(typename) - .selectmenu("refresh"); - }); - - viewer.addEventListener("quality_changed", e => { - - let name = viewer.quality; - - $( "#optQuality" ) - .selectmenu() - .val(name) - .selectmenu("refresh"); - }); + + //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); @@ -17493,9 +17548,7 @@ function initAppearance(){ $('#lblPointBudget')[0].innerHTML = Potree.utils.addCommas(viewer.getPointBudget()); - $('#lblPointSize')[0].innerHTML = viewer.getPointSize().toFixed(2); $('#lblFOV')[0].innerHTML = parseInt(viewer.getFOV()); - $('#lblOpacity')[0].innerHTML = viewer.getOpacity().toFixed(2); $('#lblEDLRadius')[0].innerHTML = viewer.getEDLRadius().toFixed(1); $('#lblEDLStrength')[0].innerHTML = viewer.getEDLStrength().toFixed(1); $('#chkEDLEnabled')[0].checked = viewer.getEDLEnabled(); @@ -17506,6 +17559,8 @@ function initAppearance(){ function initNavigation(){ let elNavigation = $("#navigation"); + let sldMoveSpeed = $("#sldMoveSpeed"); + let lblMoveSpeed = $('#lblMoveSpeed'); elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/earth_controls_1.png", @@ -17559,7 +17614,7 @@ function initNavigation(){ return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); }; - $( "#sldMoveSpeed" ).slider({ + sldMoveSpeed.slider({ value: toExpSpeed( viewer.getMoveSpeed() ), min: 0, max: 1, @@ -17568,11 +17623,11 @@ function initNavigation(){ }); viewer.addEventListener("move_speed_changed", function(event){ - $('#lblMoveSpeed')[0].innerHTML = viewer.getMoveSpeed().toFixed(1); - $( "#sldMoveSpeed" ).slider({value: toExpSpeed(viewer.getMoveSpeed())}); + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); + sldMoveSpeed.slider({value: toExpSpeed(viewer.getMoveSpeed())}); }); - $('#lblMoveSpeed')[0].innerHTML = viewer.getMoveSpeed().toFixed(1); + lblMoveSpeed.html(viewer.getMoveSpeed().toFixed(1)); } function initAnnotationDetails(){ @@ -17595,22 +17650,32 @@ function initAnnotationDetails(){ let checked = viewer.getShowAnnotations() ? "checked" : ""; let chkEnable = $(` - +