From b04b1fcb55c8e4f07d0f1ebb45e06566a8a27f20 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Thu, 23 Feb 2017 13:20:42 +0100 Subject: [PATCH 1/8] fix area measurement; fix some hierarchical annotation stuff --- build/potree/potree.js | 62 ++++++++++++++---------------------------- src/Annotation.js | 3 +- src/utils/Measure.js | 2 +- src/viewer/sidebar.js | 9 ++++-- src/viewer/viewer.js | 22 ++++++--------- 5 files changed, 38 insertions(+), 60 deletions(-) diff --git a/build/potree/potree.js b/build/potree/potree.js index 0438f0fc..b5bd2721 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -6024,6 +6024,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.actions = args.actions || []; this.isHighlighted = false; this.visible = true; + this.collapseThreshold = [args.collapseThreshold, 100].find(e => e !== undefined); this.children = []; this.parent = null; @@ -6088,7 +6089,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ let c = this; while(c !== null){ - this.dispatchEvent({ + c.dispatchEvent({ "type": "annotation_added", "annotation": annotation }); @@ -9120,7 +9121,7 @@ Potree.Measure = class Measure extends THREE.Object3D{ for(let i = 0; i < this.points.length; i++){ let p1 = this.points[i].position; let p2 = this.points[j].position; - area += (p2.x + p1.x) * (p1.z - p2.z); + area += (p2.x + p1.x) * (p1.y - p2.y); j = i; } @@ -11030,8 +11031,8 @@ Potree.GeoJSONExporter = class GeoJSONExporter{ /** * * @author sigeom sa / http://sigeom.ch - * @author Ioda-Net Sàrl / https://www.ioda-net.ch/ - * @author Markus Schütz / http://potree.org + * @author Ioda-Net S�rl / https://www.ioda-net.ch/ + * @author Markus Sch�tz / http://potree.org * */ @@ -12672,28 +12673,6 @@ Potree.Scene = class extends THREE.EventDispatcher{ } let annotation = new Potree.Annotation(args); this.annotations.add(annotation); - - //if(position instanceof Array){ - // args.position = new THREE.Vector3().fromArray(position); - //}else if(position instanceof THREE.Vector3){ - // args.position = position; - //} - // - // - //if(!args.cameraTarget){ - // args.cameraTarget = position; - //} - // - //var annotation = new Potree.Annotation(this, args); - // - //this.annotations.push(annotation); - // - //this.dispatchEvent({ - // "type": "annotation_added", - // "scene": this, - // "annotation": annotation}); - // - //return annotation; } getAnnotations(){ @@ -12896,18 +12875,14 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ if(!this.onAnnotationAdded){ this.onAnnotationAdded = e => { - //this.renderArea.appendChild(e.annotation.domElement[0]); - - e.annotation.traverse(node => { - this.renderArea.appendChild(node.domElement[0]); - }); - - ////focusing_finished - //e.annotation.addEventListener("focusing_finished", (event) => { - // let distance = this.scene.view.position.distanceTo(this.scene.view.getPivot()); - // this.setMoveSpeed(Math.pow(distance, 0.4)); - // this.renderer.domElement.focus(); - //}); + + //console.log("annotation added: " + e.annotation.title); + + e.annotation.traverse(node => { + this.renderArea.appendChild(node.domElement[0]); + node.scene = this.scene; + }); + }; } @@ -13937,7 +13912,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ element.style.zIndex = parseInt(zIndex); if(annotation.children.length > 0){ - let expand = screenSize > 100 || annotation.boundingBox.containsPoint(this.scene.camera.position); + let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); if(!expand){ // TODO make sure descendants are invisible @@ -17220,7 +17195,8 @@ function initAnnotationDetails(){ element.next().toggle(100); }); - let left = ((annotation.level()) * 20) + "px"; + //let left = ((annotation.level()) * 20) + "px"; + let left = "20px"; let childContainer = $(`
`); for(let child of annotation.children){ container.append(childContainer); @@ -17236,12 +17212,14 @@ function initAnnotationDetails(){ }; viewer.addEventListener("scene_changed", e => { - e.oldScene.removeEventListener("annotation_added", annotationsChanged); - e.scene.addEventListener("annotation_added", annotationsChanged); + e.oldScene.annotations.removeEventListener("annotation_added", annotationsChanged); + e.scene.annotations.addEventListener("annotation_added", annotationsChanged); rebuild(); }); + viewer.scene.annotations.addEventListener("annotation_added", annotationsChanged); + rebuild(); } diff --git a/src/Annotation.js b/src/Annotation.js index d6ef4d25..29cbd240 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -28,6 +28,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.actions = args.actions || []; this.isHighlighted = false; this.visible = true; + this.collapseThreshold = [args.collapseThreshold, 100].find(e => e !== undefined); this.children = []; this.parent = null; @@ -92,7 +93,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ let c = this; while(c !== null){ - this.dispatchEvent({ + c.dispatchEvent({ "type": "annotation_added", "annotation": annotation }); diff --git a/src/utils/Measure.js b/src/utils/Measure.js index e404d19c..d1483561 100644 --- a/src/utils/Measure.js +++ b/src/utils/Measure.js @@ -246,7 +246,7 @@ Potree.Measure = class Measure extends THREE.Object3D{ for(let i = 0; i < this.points.length; i++){ let p1 = this.points[i].position; let p2 = this.points[j].position; - area += (p2.x + p1.x) * (p1.z - p2.z); + area += (p2.x + p1.x) * (p1.y - p2.y); j = i; } diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 61bea26c..bf052288 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -803,7 +803,8 @@ function initAnnotationDetails(){ element.next().toggle(100); }); - let left = ((annotation.level()) * 20) + "px"; + //let left = ((annotation.level()) * 20) + "px"; + let left = "20px"; let childContainer = $(`
`); for(let child of annotation.children){ container.append(childContainer); @@ -819,12 +820,14 @@ function initAnnotationDetails(){ }; viewer.addEventListener("scene_changed", e => { - e.oldScene.removeEventListener("annotation_added", annotationsChanged); - e.scene.addEventListener("annotation_added", annotationsChanged); + e.oldScene.annotations.removeEventListener("annotation_added", annotationsChanged); + e.scene.annotations.addEventListener("annotation_added", annotationsChanged); rebuild(); }); + viewer.scene.annotations.addEventListener("annotation_added", annotationsChanged); + rebuild(); } diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index d9aad34e..551e0bd4 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -510,18 +510,14 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ if(!this.onAnnotationAdded){ this.onAnnotationAdded = e => { - //this.renderArea.appendChild(e.annotation.domElement[0]); - - e.annotation.traverse(node => { - this.renderArea.appendChild(node.domElement[0]); - }); - - ////focusing_finished - //e.annotation.addEventListener("focusing_finished", (event) => { - // let distance = this.scene.view.position.distanceTo(this.scene.view.getPivot()); - // this.setMoveSpeed(Math.pow(distance, 0.4)); - // this.renderer.domElement.focus(); - //}); + + //console.log("annotation added: " + e.annotation.title); + + e.annotation.traverse(node => { + this.renderArea.appendChild(node.domElement[0]); + node.scene = this.scene; + }); + }; } @@ -1551,7 +1547,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ element.style.zIndex = parseInt(zIndex); if(annotation.children.length > 0){ - let expand = screenSize > 100 || annotation.boundingBox.containsPoint(this.scene.camera.position); + let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); if(!expand){ // TODO make sure descendants are invisible From b84fed6451f58a698631df551a386db4b7ce6b4d Mon Sep 17 00:00:00 2001 From: mschuetz Date: Thu, 23 Feb 2017 15:02:52 +0100 Subject: [PATCH 2/8] add annotation enabled checkbox; fix annotation sutff --- build/potree/potree.js | 45 ++++++++++++++++++- .../potree/resources/lang/en/translation.json | 5 ++- resources/lang/en/translation.json | 5 ++- src/viewer/sidebar.js | 14 ++++++ src/viewer/viewer.js | 31 ++++++++++++- 5 files changed, 94 insertions(+), 6 deletions(-) diff --git a/build/potree/potree.js b/build/potree/potree.js index b5bd2721..dee52b6a 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -12733,6 +12733,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ this.moveSpeed = 10; this.showBoundingBox = false; + this.showAnnotations = true; this.freeze = false; this.mapView; @@ -13213,7 +13214,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ setPointBudget(value){ - if(Potree.pointBudget != value){ + if(Potree.pointBudget !== value){ Potree.pointBudget = parseInt(value); this.dispatchEvent({"type": "point_budget_changed", "viewer": this}); } @@ -13223,8 +13224,19 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return Potree.pointBudget; }; + setShowAnnotations(value){ + if(this.showAnnotations !== value){ + this.showAnnotations = value; + this.dispatchEvent({"type": "show_annotations_changed", "viewer": this}); + } + } + + getShowAnnotations(){ + return this.showAnnotations; + } + setClipMode(clipMode){ - if(this.clipMode != clipMode){ + if(this.clipMode !== clipMode){ this.clipMode = clipMode; this.dispatchEvent({"type": "clip_mode_changed", "viewer": this}); } @@ -13859,6 +13871,21 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ updateAnnotations(){ + if(!this.getShowAnnotations()){ + this.scene.annotations.traverseDescendants(descendant => { + if(!descendant.visible){ + return false; + }else{ + descendant.visible = false; + descendant.domElement[0].style.display = "none"; + } + + return; + }); + + return; + } + this.scene.annotations.updateBounds(); this.scene.camera.updateMatrixWorld(); @@ -17103,6 +17130,18 @@ function initAnnotationDetails(){ annotationPanel.empty(); + let checked = viewer.getShowAnnotations() ? "checked" : ""; + + let chkEnable = $(` +
  • + `); + annotationPanel.append(chkEnable); + + let stack = viewer.scene.annotations.children.reverse().map( a => ({annotation: a, container: annotationPanel})); @@ -17205,6 +17244,8 @@ function initAnnotationDetails(){ } }; + + annotationPanel.i18n(); }; let annotationsChanged = e => { diff --git a/build/potree/resources/lang/en/translation.json b/build/potree/resources/lang/en/translation.json index 53d4a6fc..910305e8 100644 --- a/build/potree/resources/lang/en/translation.json +++ b/build/potree/resources/lang/en/translation.json @@ -49,7 +49,10 @@ "freeze": "Lock view", "language": "Language" }, - "profile": { + "annotations": { + "show": "show annotations" + }, + "profile": { "nb_points": "Point number", "title": "Height profile", "save_las": "Save LAS(3D)", diff --git a/resources/lang/en/translation.json b/resources/lang/en/translation.json index 53d4a6fc..910305e8 100644 --- a/resources/lang/en/translation.json +++ b/resources/lang/en/translation.json @@ -49,7 +49,10 @@ "freeze": "Lock view", "language": "Language" }, - "profile": { + "annotations": { + "show": "show annotations" + }, + "profile": { "nb_points": "Point number", "title": "Height profile", "save_las": "Save LAS(3D)", diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index bf052288..cc1516b3 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -711,6 +711,18 @@ function initAnnotationDetails(){ annotationPanel.empty(); + let checked = viewer.getShowAnnotations() ? "checked" : ""; + + let chkEnable = $(` +
  • + `); + annotationPanel.append(chkEnable); + + let stack = viewer.scene.annotations.children.reverse().map( a => ({annotation: a, container: annotationPanel})); @@ -813,6 +825,8 @@ function initAnnotationDetails(){ } }; + + annotationPanel.i18n(); }; let annotationsChanged = e => { diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 551e0bd4..0474ab51 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -368,6 +368,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ this.moveSpeed = 10; this.showBoundingBox = false; + this.showAnnotations = true; this.freeze = false; this.mapView; @@ -848,7 +849,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ setPointBudget(value){ - if(Potree.pointBudget != value){ + if(Potree.pointBudget !== value){ Potree.pointBudget = parseInt(value); this.dispatchEvent({"type": "point_budget_changed", "viewer": this}); } @@ -858,8 +859,19 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return Potree.pointBudget; }; + setShowAnnotations(value){ + if(this.showAnnotations !== value){ + this.showAnnotations = value; + this.dispatchEvent({"type": "show_annotations_changed", "viewer": this}); + } + } + + getShowAnnotations(){ + return this.showAnnotations; + } + setClipMode(clipMode){ - if(this.clipMode != clipMode){ + if(this.clipMode !== clipMode){ this.clipMode = clipMode; this.dispatchEvent({"type": "clip_mode_changed", "viewer": this}); } @@ -1494,6 +1506,21 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ updateAnnotations(){ + if(!this.getShowAnnotations()){ + this.scene.annotations.traverseDescendants(descendant => { + if(!descendant.visible){ + return false; + }else{ + descendant.visible = false; + descendant.domElement[0].style.display = "none"; + } + + return; + }); + + return; + } + this.scene.annotations.updateBounds(); this.scene.camera.updateMatrixWorld(); From 057d5229d3130c7ee5aca060a83ea87faa2eee7b Mon Sep 17 00:00:00 2001 From: Markus Schuetz Date: Wed, 8 Mar 2017 14:05:21 +0100 Subject: [PATCH 3/8] cleanup --- src/utils.js | 5 +- src/utils/Measure.js | 6 + src/viewer/sidebar.js | 584 +++++++++++++++++++++--------------------- src/viewer/viewer.js | 60 ----- 4 files changed, 295 insertions(+), 360 deletions(-) diff --git a/src/utils.js b/src/utils.js index 5d30ea8c..5d75ee1e 100644 --- a/src/utils.js +++ b/src/utils.js @@ -189,6 +189,7 @@ Potree.utils = class{ let selectedPointcloud = null; let closestDistance = Infinity; let closestIntersection = null; + let closestPoint = null; for(let pointcloud of pointclouds){ let point = pointcloud.pick(renderer, camera, ray); @@ -203,6 +204,7 @@ Potree.utils = class{ closestDistance = distance; selectedPointcloud = pointcloud; closestIntersection = point.position; + closestPoint = point; } } @@ -210,7 +212,8 @@ Potree.utils = class{ return { location: closestIntersection, distance: closestDistance, - pointcloud: selectedPointcloud + pointcloud: selectedPointcloud, + point: closestPoint }; }else{ return null; diff --git a/src/utils/Measure.js b/src/utils/Measure.js index d1483561..5961400f 100644 --- a/src/utils/Measure.js +++ b/src/utils/Measure.js @@ -150,6 +150,12 @@ Potree.Measure = class Measure extends THREE.Object3D{ if(I){ let i = this.spheres.indexOf(e.drag.object); if(i !== -1){ + + let point = this.points[i]; + for(let key of Object.keys(I.point).filter(e => e !== "position")){ + point[key] = I.point[key]; + } + this.setPosition(i, I.location); this.dispatchEvent({ "type": "marker_moved", diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index cc1516b3..d5f19f87 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -1,22 +1,24 @@ -var createToolIcon = function(icon, title, callback){ - var elImg = document.createElement("img"); - elImg.src = icon; - elImg.onclick = callback; - elImg.style.width = "32px"; - elImg.style.height = "32px"; - elImg.classList.add("button-icon"); - elImg.setAttribute("data-i18n", title); - return elImg; +let createToolIcon = function(icon, title, callback){ + let element = $(` + + `); + + element.click(callback); + + return element; }; function initToolbar(){ // ANGLE - let elToolbar = document.getElementById("tools"); - elToolbar.appendChild(createToolIcon( + let elToolbar = $("#tools"); + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/angle.png", "[title]tt.angle_measurement", function(){ @@ -31,7 +33,7 @@ function initToolbar(){ )); // POINT - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/point.svg", "[title]tt.angle_measurement", function(){ @@ -47,7 +49,7 @@ function initToolbar(){ )); // DISTANCE - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/distance.svg", "[title]tt.distance_measurement", function(){ @@ -60,7 +62,7 @@ function initToolbar(){ )); // HEIGHT - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/height.svg", "[title]tt.height_measurement", function(){ @@ -75,7 +77,7 @@ function initToolbar(){ )); // AREA - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/area.svg", "[title]tt.area_measurement", function(){ @@ -88,14 +90,14 @@ function initToolbar(){ )); // VOLUME - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/volume.svg", "[title]tt.volume_measurement", function(){viewer.volumeTool.startInsertion()} )); // PROFILE - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/profile.svg", "[title]tt.height_profile", function(){ @@ -105,14 +107,14 @@ function initToolbar(){ )); // CLIP VOLUME - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/clip_volume.svg", "[title]tt.clip_volume", function(){viewer.volumeTool.startInsertion({clip: true})} )); // REMOVE ALL - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/reset_tools.svg", "[title]tt.remove_all_measurement", function(){ @@ -259,7 +261,7 @@ function initMaterials(){ slide: function( event, ui ) {viewer.setWeightSourceID(ui.value);} }); - var updateHeightRange = function(){ + let updateHeightRange = function(){ let box = viewer.getBoundingBox(); let bWidth = box.max.z - box.min.z; bMin = box.min.z - 0.2 * bWidth; @@ -346,7 +348,7 @@ function initMaterials(){ $('#lblRGBContrast')[0].innerHTML = viewer.getRGBContrast().toFixed(2); $('#lblRGBBrightness')[0].innerHTML = viewer.getRGBBrightness().toFixed(2); - var options = [ + let options = [ "RGB", "RGB and Elevation", "Color", @@ -361,15 +363,16 @@ function initMaterials(){ "Composite", ]; - var elMaterialList = document.getElementById("optMaterial"); - for(var i = 0; i < options.length; i++){ - var option = options[i]; - - var elOption = document.createElement("option"); - elOption.innerHTML = option; - elOption.id = "optMaterial_" + option; - - elMaterialList.appendChild(elOption); + 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){ @@ -429,27 +432,28 @@ function initMaterials(){ } function initClassificationList(){ - var addClassificationItem = function(code, name){ - var elClassificationList = document.getElementById("classificationList"); + let elClassificationList = $("#classificationList"); + + let addClassificationItem = function(code, name){ - var elLi = document.createElement("li"); - var elLabel = document.createElement("label"); - var elInput = document.createElement("input"); - var elText = document.createTextNode(" " + name); + let inputID = "chkClassification_" + code; - elInput.id = "chkClassification_" + code; - elInput.type = "checkbox"; - elInput.checked = true; - elInput.onclick = function(event){ + let element = $(` +
  • + +
  • + `); + + let elInput = element.find("input"); + + elInput.click(event => { viewer.setClassificationVisibility(code, event.target.checked); - } + }); - elLabel.style.whiteSpace = "nowrap"; - - elClassificationList.appendChild(elLi); - elLi.appendChild(elLabel); - elLabel.appendChild(elInput); - elLabel.appendChild(elText); + elClassificationList.append(element); }; addClassificationItem(0, "never classified"); @@ -631,57 +635,57 @@ function initAppearance(){ function initNavigation(){ - var elNavigation = document.getElementById("navigation"); + let elNavigation = $("#navigation"); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/earth_controls_1.png", "[title]tt.earth_control", function(){viewer.setNavigationMode(Potree.EarthControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/fps_controls.png", "[title]tt.flight_control", function(){viewer.setNavigationMode(Potree.FirstPersonControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/orbit_controls.svg", "[title]tt.orbit_control", function(){viewer.setNavigationMode(Potree.OrbitControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/focus.svg", "[title]tt.focus_control", function(){viewer.fitToScreen()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/topview.svg", "[title]tt.top_view_control", function(){viewer.setTopView()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/frontview.svg", "[title]tt.front_view_control", function(){viewer.setFrontView()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/leftview.svg", "[title]tt.left_view_control", function(){viewer.setLeftView()} )); - var speedRange = new THREE.Vector2(1, 10*1000); + let speedRange = new THREE.Vector2(1, 10*1000); - var toLinearSpeed = function(value){ + let toLinearSpeed = function(value){ return Math.pow(value, 4) * speedRange.y + speedRange.x; }; - var toExpSpeed = function(value){ + let toExpSpeed = function(value){ return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); }; @@ -847,10 +851,10 @@ function initAnnotationDetails(){ function initMeasurementDetails(){ - var id = 0; + let id = 0; let trackedItems = new Map(); - var trackMeasurement = function(scene, measurement){ + let trackMeasurement = function(scene, measurement){ id++; let track = { @@ -860,77 +864,93 @@ function initMeasurementDetails(){ }; trackedItems.set(measurement, track); - - var elLi = document.createElement("li"); - var elPanel = document.createElement("div"); - var elPanelHeader = document.createElement("div"); - var elPanelBody = document.createElement("div"); - var elPanelIcon = document.createElement("img"); - var elPanelStretch = document.createElement("span"); - var elPanelRemove = document.createElement("img"); - - elPanel.classList.add("potree-panel", "panel-default"); - elPanelHeader.classList.add("potree-panel-heading", "pv-panel-heading"); + let panelIcon = ""; + let panelTitle = ""; + let removeCallback; if(measurement instanceof Potree.Measure){ if(measurement.showDistances && !measurement.showArea && !measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/distance.svg"; - elPanelStretch.innerHTML = "Distance"; + panelIcon = Potree.resourcePath + "/icons/distance.svg"; + panelTitle = "Distance"; }else if(measurement.showDistances && measurement.showArea && !measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/area.svg"; - elPanelStretch.innerHTML = "Area"; + panelIcon = Potree.resourcePath + "/icons/area.svg"; + panelTitle = "Area"; }else if(measurement.maxMarkers === 1){ - elPanelIcon.src = Potree.resourcePath + "/icons/point.svg"; - elPanelStretch.innerHTML = "Coordinate"; + panelIcon = Potree.resourcePath + "/icons/point.svg"; + panelTitle = "Coordinate"; }else if(!measurement.showDistances && !measurement.showArea && measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/angle.png"; - elPanelStretch.innerHTML = "Angle"; + panelIcon = Potree.resourcePath + "/icons/angle.png"; + panelTitle = "Angle"; }else if(measurement.showHeight){ - elPanelIcon.src = Potree.resourcePath + "/icons/height.svg"; - elPanelStretch.innerHTML = "Height"; + panelIcon = Potree.resourcePath + "/icons/height.svg"; + panelTitle = "Height"; } - elPanelRemove.onclick = function(){scene.removeMeasurement(measurement);}; + removeCallback = () => scene.removeMeasurement(measurement); } else if(measurement instanceof Potree.Profile){ - elPanelIcon.src = Potree.resourcePath + "/icons/profile.svg"; - elPanelStretch.innerHTML = "Profile"; + panelIcon = Potree.resourcePath + "/icons/profile.svg"; + panelTitle = "Profile"; - elPanelRemove.onclick = function(){scene.removeProfile(measurement);}; + removeCallback = () => scene.removeProfile(measurement); } else if(measurement instanceof Potree.Volume){ - elPanelIcon.src = Potree.resourcePath + "/icons/volume.svg"; - elPanelStretch.innerHTML = "Volume"; + panelIcon = Potree.resourcePath + "/icons/volume.svg"; + panelTitle = "Volume"; - elPanelRemove.onclick = function(){scene.removeVolume(volume);}; + removeCallback = () => scene.removeVolume(measurement); } - elPanelIcon.style.width = "16px"; - elPanelIcon.style.height = "16px"; - elPanelStretch.style.flexGrow = 1; - elPanelStretch.style.textAlign = "center"; - elPanelRemove.src = Potree.resourcePath + "/icons/remove.svg"; - elPanelRemove.style.width = "16px"; - elPanelRemove.style.height = "16px"; - elPanelBody.classList.add("panel-body"); + let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; - elLi.appendChild(elPanel); - elPanel.appendChild(elPanelHeader); - elPanelHeader.appendChild(elPanelIcon); - elPanelHeader.appendChild(elPanelStretch); - elPanelHeader.appendChild(elPanelRemove); - elPanel.appendChild(elPanelBody); + let elLi = $(` +
  • +
    + + +
    + + ${panelTitle} + +
    + + +
    + +
    +
    +
  • + `); + $("#measurement_details").append(elLi); - document.getElementById("measurement_details").appendChild(elLi); + let elPanelBody = elLi.find(".panel-body"); + let elPanelHeader = elLi.find(".potree-panel-heading"); + let elRemove = elPanelHeader.find("img:last"); + elRemove.click(removeCallback); + let widthListener = null; - var updateDisplay = function(event){ + let updateDisplay = function(event){ - $(elPanelBody).empty(); + elPanelBody.empty(); + measurement.removeEventListener("width_changed", widthListener); + if(measurement instanceof Potree.Profile){ - var elLi = $('
  • '); - var elText = document.createTextNode("width: "); - var elWidthLabel = $(''); - var elWidthSlider = $('
    '); + + let widthText = measurement.getWidth() ? + Potree.utils.addCommas(measurement.getWidth().toFixed(3)) : "-"; + + let labelID = "lblProfileWidth_" + id; + let sliderID = "sldProfileWidth_" + id; + + let elLi = $(` +
  • + width: ${widthText} +
    +
  • ` + ); + + let elWidthLabel = elLi.find(`#${labelID}`); + let elWidthSlider = elLi.find(`#${sliderID}`); elWidthSlider.slider({ value: Math.pow((measurement.getWidth() / 1000), 1/4).toFixed(3), @@ -938,43 +958,32 @@ function initMeasurementDetails(){ max: 1, step: 0.01, slide: function(event, ui){ - var val = Math.pow(ui.value, 4) * 1000; + let val = Math.pow(ui.value, 4) * 1000; measurement.setWidth(val); } }); - if(measurement.getWidth()){ - elWidthLabel.html(Potree.utils.addCommas(measurement.getWidth().toFixed(3))); - }else{ - elWidthLabel.html("-"); - } - if(widthListener === null){ - widthListener = function(event){ - var val = Math.pow((event.width / 1000), 1/4); - elWidthLabel.html(Potree.utils.addCommas(event.width.toFixed(3))); - elWidthSlider.slider({value: val}); - }; - } - if(!measurement.hasEventListener("width_changed", widthListener)){ - measurement.addEventListener("width_changed", widthListener); - } - elLi.append(elText); - elLi.append(elWidthLabel); - elLi.append(elWidthSlider); + widthListener = (event) => { + let val = Math.pow((event.width / 1000), 1/4); + elWidthLabel.html(Potree.utils.addCommas(event.width.toFixed(3))); + elWidthSlider.slider({value: val}); + }; - elPanelBody.appendChild(elLi[0]); + measurement.addEventListener("width_changed", widthListener); + + elPanelBody.append(elLi); } - var positions = []; - var points; + let positions = []; + let points; if(measurement instanceof Potree.Measure){ points = measurement.points; - for(var i = 0; i < points.length; i++){ + for(let i = 0; i < points.length; i++){ positions.push(points[i].position); } - } else if(measurement instanceof Potree.Profile){ + }else if(measurement instanceof Potree.Profile){ positions = measurement.points; } @@ -990,188 +999,170 @@ function initMeasurementDetails(){ let txt = height.toFixed(3); - var elNodeHeight = $('
    ').addClass("measurement-detail-node-marker"); - elNodeHeight.html(txt); - $(elPanelBody).append(elNodeHeight); + let elNodeHeight = $(` +
    + ${txt} +
    `); + elPanelBody.append(elNodeHeight); } - for(var i = 0; i < positions.length; i++){ - // TODO clean this up from the toGeo legacy - var point = positions[i]; - var geoCoord = point; - - var txt = geoCoord.x.toFixed(2) + ", "; - txt += (geoCoord.y).toFixed(2) + ", "; - txt += geoCoord.z.toFixed(2); + for(let i = 0; i < positions.length; i++){ + let point = positions[i]; + + let txt = [point.x, point.y, point.z].map(p => p.toFixed(3)).join(", "); if(measurement && !measurement.showHeight){ - var elNodeMarker = $('
    ').addClass("measurement-detail-node-marker"); - elNodeMarker.html(txt); - $(elPanelBody).append(elNodeMarker); + let elNodeMarker = $(` +
    + ${txt} +
    `); + elPanelBody.append(elNodeMarker); } if(i < positions.length - 1){ if(measurement && measurement.showDistances){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); - $(elPanelBody).append(elEdge); + let elEdge = $('
    '); + elPanelBody.append(elEdge); - var nextPoint = positions[i+1]; - var nextGeo = nextPoint; - var distance = nextGeo.distanceTo(geoCoord); - var txt = Potree.utils.addCommas(distance.toFixed(2)); + let nextPoint = positions[i+1]; + let distance = nextPoint.distanceTo(point); + let txt = Potree.utils.addCommas(distance.toFixed(3)); - var elNodeDistance = $('
    ').addClass("measurement-detail-node-distance"); - elNodeDistance.html(txt); + let elNodeDistance = $(` +
    + ${txt} +
    `); - $(elPanelBody).append(elNodeDistance); + elPanelBody.append(elNodeDistance); } } if(measurement && measurement.showAngles){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); + let elEdge = $('
    '); $(elPanelBody).append(elEdge); - var angle = measurement.getAngle(i); - var txt = Potree.utils.addCommas((angle*(180.0/Math.PI)).toFixed(1)) + '\u00B0'; - var elNodeAngle = $('
    ').addClass("measurement-detail-node-angle"); - elNodeAngle.html(txt); + let angle = measurement.getAngle(i); + let txt = Potree.utils.addCommas((angle*(180.0/Math.PI)).toFixed(1)) + '\u00B0'; + let elNodeAngle = $(`
    ${txt}
    `); $(elPanelBody).append(elNodeAngle); } if(i < positions.length - 1){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); + let elEdge = $('
    '); $(elPanelBody).append(elEdge); } } if(points && points.length === 1){ - var point = points[0]; + let point = points[0]; - var elTable = $('').css("width", "100%"); + let elTable = $('
    '); $(elPanelBody).append(elTable); if(point.color){ - var color = point.color; + let color = point.color; + let text = color.join(", "); - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.intensity !== "undefined"){ - var intensity = point.intensity; + if(point.intensity !== undefined){ + let intensity = point.intensity; - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.classification !== "undefined"){ - var classification = point.classification; + if(point.classification !== undefined){ + let classification = point.classification; - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.returnNumber !== "undefined"){ - var returnNumber = point.returnNumber; + if(point.returnNumber !== undefined){ + let returnNumber = point.returnNumber; - var elTr = $(''); - var elKey = $(' + + + + `)); } if(typeof point.pointSourceID !== "undefined"){ - var source = point.pointSourceID; + let source = point.pointSourceID; - var elTr = $(''); - var elKey = $(' + + + + `)); } } if(measurement && measurement.showDistances && measurement.points.length > 1){ - var txt = "Total: " + Potree.utils.addCommas(measurement.getTotalDistance().toFixed(3)); + let txt = "Total: " + Potree.utils.addCommas(measurement.getTotalDistance().toFixed(3)); - var elNodeTotalDistance = $('
    ').addClass("measurement-detail-node-distance"); - elNodeTotalDistance.html(txt); - - $(elPanelBody).append(elNodeTotalDistance); + $(elPanelBody).append($(` +
    ${txt}
    + `)); } if(measurement && measurement.showArea){ - var txt = Potree.utils.addCommas(measurement.getArea().toFixed(1)) + "\u00B2"; + let txt = Potree.utils.addCommas(measurement.getArea().toFixed(1)) + "\u00B2"; - var elNodeArea = $('
    ').addClass("measurement-detail-node-area"); - elNodeArea.html(txt); - - $(elPanelBody).append(elNodeArea); + $(elPanelBody).append($(` +
    ${txt}
    + `)); } if(measurement instanceof Potree.Profile){ - var elOpenProfileWindow = $('') - .addClass("measurement-detail-button"); - elOpenProfileWindow[0].onclick = function(){ + let elOpenProfileWindow = $(` + + `); + + elOpenProfileWindow.click(e => { viewer._2dprofile.show(); viewer._2dprofile.draw(measurement); - }; - $(elPanelBody).append(elOpenProfileWindow); + }); + + elPanelBody.append(elOpenProfileWindow); } let doExport = measurement.showDistances && !measurement.showAngles; if(doExport){ - let elBottomBar = $(` - - `); + let elBottomBar = $(` + + + `); $(elPanelBody).append(elBottomBar); { let icon = Potree.resourcePath + "/icons/file_geojson.svg"; - let elDownload = $(``); + let elDownload = $(` + + + `); elDownload.click(function(e){ let geojson = Potree.GeoJSONExporter.toString(measurement); @@ -1184,7 +1175,10 @@ function initMeasurementDetails(){ { let icon = Potree.resourcePath + "/icons/file_dxf.svg"; - let elDownload = $(``); + let elDownload = $(` + + + `); elDownload.click(function(e){ let dxf = Potree.DXFExporter.toString(measurement); @@ -1202,9 +1196,6 @@ function initMeasurementDetails(){ if(measurement instanceof Potree.Measure){ let onremove = function(event){ if(event.measurement === measurement){ - //scene.removeEventListener("marker_added", updateDisplay); - //scene.removeEventListener("marker_removed", updateDisplay); - //scene.removeEventListener("marker_moved", updateDisplay); $(elLi).remove(); } }; @@ -1265,11 +1256,11 @@ function initMeasurementDetails(){ trackedItem.stopTracking(); }); - for(var i = 0; i < scene.measurements.length; i++){ + for(let i = 0; i < scene.measurements.length; i++){ trackMeasurement(scene, scene.measurements[i]); } - for(var i = 0; i < scene.profiles.length; i++){ + for(let i = 0; i < scene.profiles.length; i++){ trackMeasurement(scene, scene.profiles[i]); } @@ -1289,64 +1280,60 @@ function initMeasurementDetails(){ function initSceneList(){ - var scenelist = $('#sceneList'); + let scenelist = $('#sceneList'); - var id = 0; - // this works but it looks so wrong. any better way to create a closure around pointcloud? - var addPointcloud = function(pointcloud){ - (function(pointcloud){ - var elLi = $('
  • '); - var elLabel = $('
  • + +
  • + `); + + let elInput = elPointclouds.find("input"); + let elPointCloudLabel = elPointclouds.find("span"); + + elInput.click(function(event){ + pointcloud.visible = event.target.checked; + if(viewer._2dprofile){ + viewer._2dprofile.redraw(); + } + }); + + scenelist.append(elPointclouds); + + pointcloud.addEventListener("name_changed", function(e){ + if(e.name){ + elPointCloudLabel.innerHTML = " " + e.name; + }else{ + elPointCloudLabel.innerHTML = " point cloud " + id; + } + }); + + id++; }; - for(var i = 0; i < viewer.scene.pointclouds.length; i++){ - var pointcloud = viewer.scene.pointclouds[i]; + for(let pointcloud of viewer.scene.pointclouds){ addPointcloud(pointcloud); } viewer.addEventListener("scene_changed", (e) => { scenelist.empty(); - let scene = e.scene; - for(var i = 0; i < scene.pointclouds.length; i++){ - var pointcloud = scene.pointclouds[i]; + for(let pointcloud of e.scene.pointclouds){ addPointcloud(pointcloud); } }); - // TODO update scene list on scene switch viewer.addEventListener("pointcloud_loaded", function(event){ addPointcloud(event.pointcloud); }); @@ -1373,7 +1360,6 @@ function initSceneList(){ }; initSettings = function(){ - //
  • Min Node Size:
  • $( "#sldMinNodeSize" ).slider({ value: viewer.getMinNodeSize(), @@ -1389,7 +1375,7 @@ initSettings = function(){ }); - var toClipModeCode = function(string){ + let toClipModeCode = function(string){ if(string === "No Clipping"){ return Potree.ClipMode.DISABLED; }else if(string === "Highlight Inside"){ @@ -1399,7 +1385,7 @@ initSettings = function(){ } }; - var toClipModeString = function(code){ + let toClipModeString = function(code){ if(code === Potree.ClipMode.DISABLED){ return "No Clipping"; }else if(code === Potree.ClipMode.HIGHLIGHT_INSIDE){ diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 0474ab51..b7427517 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -1577,7 +1577,6 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); if(!expand){ - // TODO make sure descendants are invisible annotation.traverseDescendants(descendant => { if(!descendant.visible){ return; @@ -1603,65 +1602,6 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ } } }); - - //let distances = []; - //let annotations = this.scene.annotations.descendants(); - // - //let i = 0; - //for(let annotation of annotations){ - // - // let element = annotation.domElement[0]; - // - // let position = annotation.position; - // if(!position){ - // position = annotation.boundingBox.getCenter(); - // } - // - // let distance = viewer.scene.camera.position.distanceTo(position); - // - // let screenPos = new THREE.Vector3(); - // let screenSize = 0; - // { - // // SCREEN POS - // screenPos.copy(position).project(this.scene.camera); - // screenPos.x = this.renderArea.clientWidth * (screenPos.x + 1) / 2; - // screenPos.y = this.renderArea.clientHeight * (1 - (screenPos.y + 1) / 2); - // - // screenPos.x = Math.floor(screenPos.x - element.clientWidth / 2); - // screenPos.y = Math.floor(screenPos.y - annotation.elTitlebar[0].clientHeight / 2); - // - // // SCREEN SIZE - // let fov = Math.PI * viewer.scene.camera.fov / 180; - // let slope = Math.tan(fov / 2.0); - // let projFactor = 0.5 * this.renderArea.clientHeight / (slope * distance); - // - // let radius = annotation.boundingBox.getBoundingSphere().radius; - // screenSize = radius * projFactor; - // } - // - // element.style.left = screenPos.x + "px"; - // element.style.top = screenPos.y + "px"; - // - // - // let visible = screenSize > 100 && (-1 <= screenPos.z && screenPos.z <= 1); - // - // if(visible){ - // element.style.display = "inline-block"; - // }else{ - // element.style.display = "none"; - // } - // - // annotation.visible = visible; - // - // let zIndex = 10000000 - distance * (10000000 / this.scene.camera.far); - // if(annotation.descriptionVisible){ - // zIndex += 10000000; - // } - // - // element.style.zIndex = parseInt(zIndex); - // - // i++; - //} } update(delta, timestamp){ From 291f9e0265ac612252f6fd814f342b707f66fe1c Mon Sep 17 00:00:00 2001 From: Markus Schuetz Date: Wed, 8 Mar 2017 15:39:18 +0100 Subject: [PATCH 4/8] improve annotation actions --- build/potree/potree.js | 708 +++++++++--------- build/potree/resources/icons/eye.svg | 93 +++ build/potree/resources/icons/eye_crossed.svg | 93 +++ .../potree/resources/icons/image_preview.php | 24 + resources/icons/eye.svg | 93 +++ resources/icons/eye_crossed.svg | 93 +++ resources/icons/image_preview.php | 24 + resources/icons/round_dropdown.svg | 237 ------ resources/icons/round_icon.svg | 230 ------ src/Annotation.js | 25 +- src/viewer/sidebar.js | 4 +- src/viewer/viewer.js | 20 +- 12 files changed, 791 insertions(+), 853 deletions(-) create mode 100644 build/potree/resources/icons/eye.svg create mode 100644 build/potree/resources/icons/eye_crossed.svg create mode 100644 build/potree/resources/icons/image_preview.php create mode 100644 resources/icons/eye.svg create mode 100644 resources/icons/eye_crossed.svg create mode 100644 resources/icons/image_preview.php delete mode 100644 resources/icons/round_dropdown.svg delete mode 100644 resources/icons/round_icon.svg diff --git a/build/potree/potree.js b/build/potree/potree.js index dee52b6a..f2c57f2e 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -6023,7 +6023,8 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.showDescription = true; this.actions = args.actions || []; this.isHighlighted = false; - this.visible = true; + this._visible = true; + this.__visible = true; this.collapseThreshold = [args.collapseThreshold, 100].find(e => e !== undefined); this.children = []; @@ -6064,7 +6065,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ let elButton = $(``); this.elTitlebar.append(elButton); - elButton.click(() => action.onclick()); + elButton.click(() => action.onclick({annotation: this})); } this.elDescriptionClose.hover( @@ -6254,6 +6255,26 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }; + get visible(){ + return this._visible; + } + + set visible(value){ + this._visible = value; + + if(!value){ + this.traverse(node => { + node.__visible = false; + node.domElement.css("display", "none"); + }); + }else{ + this.traverse(node => { + node.__visible = true; + //node.domElement.css("display", "inline-block"); + }); + } + } + toString(){ return "Annotation: " + this.title; } @@ -8350,6 +8371,7 @@ Potree.utils = class{ let selectedPointcloud = null; let closestDistance = Infinity; let closestIntersection = null; + let closestPoint = null; for(let pointcloud of pointclouds){ let point = pointcloud.pick(renderer, camera, ray); @@ -8364,6 +8386,7 @@ Potree.utils = class{ closestDistance = distance; selectedPointcloud = pointcloud; closestIntersection = point.position; + closestPoint = point; } } @@ -8371,7 +8394,8 @@ Potree.utils = class{ return { location: closestIntersection, distance: closestDistance, - pointcloud: selectedPointcloud + pointcloud: selectedPointcloud, + point: closestPoint }; }else{ return null; @@ -9025,6 +9049,12 @@ Potree.Measure = class Measure extends THREE.Object3D{ if(I){ let i = this.spheres.indexOf(e.drag.object); if(i !== -1){ + + let point = this.points[i]; + for(let key of Object.keys(I.point).filter(e => e !== "position")){ + point[key] = I.point[key]; + } + this.setPosition(i, I.location); this.dispatchEvent({ "type": "marker_moved", @@ -11031,8 +11061,8 @@ Potree.GeoJSONExporter = class GeoJSONExporter{ /** * * @author sigeom sa / http://sigeom.ch - * @author Ioda-Net S�rl / https://www.ioda-net.ch/ - * @author Markus Sch�tz / http://potree.org + * @author Ioda-Net Sàrl / https://www.ioda-net.ch/ + * @author Markus Schütz / http://potree.org * */ @@ -13873,10 +13903,10 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ if(!this.getShowAnnotations()){ this.scene.annotations.traverseDescendants(descendant => { - if(!descendant.visible){ + if(!descendant.__visible || !descendant.visible){ return false; }else{ - descendant.visible = false; + descendant.__visible = false; descendant.domElement[0].style.display = "none"; } @@ -13897,6 +13927,10 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return true; } + if(!annotation.visible){ + return false; + } + annotation.scene = this.scene; let element = annotation.domElement[0]; @@ -13942,91 +13976,31 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); if(!expand){ - // TODO make sure descendants are invisible annotation.traverseDescendants(descendant => { - if(!descendant.visible){ + if(!descendant.__visible){ return; }else{ - descendant.visible = false; + descendant.__visible = false; descendant.domElement[0].style.display = "none"; } }); - annotation.visible = true; + annotation.__visible = true; element.style.display = "inline-block"; }else{ - annotation.visible = true; + annotation.__visible = true; element.style.display = "none"; } return expand; }else{ - annotation.visible = (-1 <= screenPos.z && screenPos.z <= 1); - if(annotation.visible){ + annotation.__visible = (-1 <= screenPos.z && screenPos.z <= 1); + if(annotation.__visible){ element.style.display = "inline-block"; }else{ element.style.display = "none"; } } }); - - //let distances = []; - //let annotations = this.scene.annotations.descendants(); - // - //let i = 0; - //for(let annotation of annotations){ - // - // let element = annotation.domElement[0]; - // - // let position = annotation.position; - // if(!position){ - // position = annotation.boundingBox.getCenter(); - // } - // - // let distance = viewer.scene.camera.position.distanceTo(position); - // - // let screenPos = new THREE.Vector3(); - // let screenSize = 0; - // { - // // SCREEN POS - // screenPos.copy(position).project(this.scene.camera); - // screenPos.x = this.renderArea.clientWidth * (screenPos.x + 1) / 2; - // screenPos.y = this.renderArea.clientHeight * (1 - (screenPos.y + 1) / 2); - // - // screenPos.x = Math.floor(screenPos.x - element.clientWidth / 2); - // screenPos.y = Math.floor(screenPos.y - annotation.elTitlebar[0].clientHeight / 2); - // - // // SCREEN SIZE - // let fov = Math.PI * viewer.scene.camera.fov / 180; - // let slope = Math.tan(fov / 2.0); - // let projFactor = 0.5 * this.renderArea.clientHeight / (slope * distance); - // - // let radius = annotation.boundingBox.getBoundingSphere().radius; - // screenSize = radius * projFactor; - // } - // - // element.style.left = screenPos.x + "px"; - // element.style.top = screenPos.y + "px"; - // - // - // let visible = screenSize > 100 && (-1 <= screenPos.z && screenPos.z <= 1); - // - // if(visible){ - // element.style.display = "inline-block"; - // }else{ - // element.style.display = "none"; - // } - // - // annotation.visible = visible; - // - // let zIndex = 10000000 - distance * (10000000 / this.scene.camera.far); - // if(annotation.descriptionVisible){ - // zIndex += 10000000; - // } - // - // element.style.zIndex = parseInt(zIndex); - // - // i++; - //} } update(delta, timestamp){ @@ -16420,22 +16394,24 @@ Potree.MapView = class{ -var createToolIcon = function(icon, title, callback){ - var elImg = document.createElement("img"); - elImg.src = icon; - elImg.onclick = callback; - elImg.style.width = "32px"; - elImg.style.height = "32px"; - elImg.classList.add("button-icon"); - elImg.setAttribute("data-i18n", title); - return elImg; +let createToolIcon = function(icon, title, callback){ + let element = $(` + + `); + + element.click(callback); + + return element; }; function initToolbar(){ // ANGLE - let elToolbar = document.getElementById("tools"); - elToolbar.appendChild(createToolIcon( + let elToolbar = $("#tools"); + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/angle.png", "[title]tt.angle_measurement", function(){ @@ -16450,7 +16426,7 @@ function initToolbar(){ )); // POINT - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/point.svg", "[title]tt.angle_measurement", function(){ @@ -16466,7 +16442,7 @@ function initToolbar(){ )); // DISTANCE - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/distance.svg", "[title]tt.distance_measurement", function(){ @@ -16479,7 +16455,7 @@ function initToolbar(){ )); // HEIGHT - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/height.svg", "[title]tt.height_measurement", function(){ @@ -16494,7 +16470,7 @@ function initToolbar(){ )); // AREA - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/area.svg", "[title]tt.area_measurement", function(){ @@ -16507,14 +16483,14 @@ function initToolbar(){ )); // VOLUME - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/volume.svg", "[title]tt.volume_measurement", function(){viewer.volumeTool.startInsertion()} )); // PROFILE - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/profile.svg", "[title]tt.height_profile", function(){ @@ -16524,14 +16500,14 @@ function initToolbar(){ )); // CLIP VOLUME - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/clip_volume.svg", "[title]tt.clip_volume", function(){viewer.volumeTool.startInsertion({clip: true})} )); // REMOVE ALL - elToolbar.appendChild(createToolIcon( + elToolbar.append(createToolIcon( Potree.resourcePath + "/icons/reset_tools.svg", "[title]tt.remove_all_measurement", function(){ @@ -16678,7 +16654,7 @@ function initMaterials(){ slide: function( event, ui ) {viewer.setWeightSourceID(ui.value);} }); - var updateHeightRange = function(){ + let updateHeightRange = function(){ let box = viewer.getBoundingBox(); let bWidth = box.max.z - box.min.z; bMin = box.min.z - 0.2 * bWidth; @@ -16765,7 +16741,7 @@ function initMaterials(){ $('#lblRGBContrast')[0].innerHTML = viewer.getRGBContrast().toFixed(2); $('#lblRGBBrightness')[0].innerHTML = viewer.getRGBBrightness().toFixed(2); - var options = [ + let options = [ "RGB", "RGB and Elevation", "Color", @@ -16780,15 +16756,16 @@ function initMaterials(){ "Composite", ]; - var elMaterialList = document.getElementById("optMaterial"); - for(var i = 0; i < options.length; i++){ - var option = options[i]; - - var elOption = document.createElement("option"); - elOption.innerHTML = option; - elOption.id = "optMaterial_" + option; - - elMaterialList.appendChild(elOption); + 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){ @@ -16848,27 +16825,28 @@ function initMaterials(){ } function initClassificationList(){ - var addClassificationItem = function(code, name){ - var elClassificationList = document.getElementById("classificationList"); + let elClassificationList = $("#classificationList"); + + let addClassificationItem = function(code, name){ - var elLi = document.createElement("li"); - var elLabel = document.createElement("label"); - var elInput = document.createElement("input"); - var elText = document.createTextNode(" " + name); + let inputID = "chkClassification_" + code; - elInput.id = "chkClassification_" + code; - elInput.type = "checkbox"; - elInput.checked = true; - elInput.onclick = function(event){ + let element = $(` +
  • + +
  • + `); + + let elInput = element.find("input"); + + elInput.click(event => { viewer.setClassificationVisibility(code, event.target.checked); - } + }); - elLabel.style.whiteSpace = "nowrap"; - - elClassificationList.appendChild(elLi); - elLi.appendChild(elLabel); - elLabel.appendChild(elInput); - elLabel.appendChild(elText); + elClassificationList.append(element); }; addClassificationItem(0, "never classified"); @@ -17050,57 +17028,57 @@ function initAppearance(){ function initNavigation(){ - var elNavigation = document.getElementById("navigation"); + let elNavigation = $("#navigation"); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/earth_controls_1.png", "[title]tt.earth_control", function(){viewer.setNavigationMode(Potree.EarthControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/fps_controls.png", "[title]tt.flight_control", function(){viewer.setNavigationMode(Potree.FirstPersonControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/orbit_controls.svg", "[title]tt.orbit_control", function(){viewer.setNavigationMode(Potree.OrbitControls)} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/focus.svg", "[title]tt.focus_control", function(){viewer.fitToScreen()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/topview.svg", "[title]tt.top_view_control", function(){viewer.setTopView()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/frontview.svg", "[title]tt.front_view_control", function(){viewer.setFrontView()} )); - elNavigation.appendChild(createToolIcon( + elNavigation.append(createToolIcon( Potree.resourcePath + "/icons/leftview.svg", "[title]tt.left_view_control", function(){viewer.setLeftView()} )); - var speedRange = new THREE.Vector2(1, 10*1000); + let speedRange = new THREE.Vector2(1, 10*1000); - var toLinearSpeed = function(value){ + let toLinearSpeed = function(value){ return Math.pow(value, 4) * speedRange.y + speedRange.x; }; - var toExpSpeed = function(value){ + let toExpSpeed = function(value){ return Math.pow((value - speedRange.x) / speedRange.y, 1 / 4); }; @@ -17192,7 +17170,7 @@ function initAnnotationDetails(){ let elIcon = $(``); elMain.append(elIcon); - elMain.click(e => action.onclick(e)); + elMain.click(e => action.onclick({annotation: annotation})); elMain.mouseover(e => elIcon.css("opacity", 1)); elMain.mouseout(e => elIcon.css("opacity", 0.5)); @@ -17205,7 +17183,7 @@ function initAnnotationDetails(){ let elIcon = $(``); elIcon.click(e => { - action.onclick(e); + action.onclick({annotation: annotation}); return false; }); elIcon.mouseover(e => elIcon.css("opacity", 1)); @@ -17266,10 +17244,10 @@ function initAnnotationDetails(){ function initMeasurementDetails(){ - var id = 0; + let id = 0; let trackedItems = new Map(); - var trackMeasurement = function(scene, measurement){ + let trackMeasurement = function(scene, measurement){ id++; let track = { @@ -17279,77 +17257,93 @@ function initMeasurementDetails(){ }; trackedItems.set(measurement, track); - - var elLi = document.createElement("li"); - var elPanel = document.createElement("div"); - var elPanelHeader = document.createElement("div"); - var elPanelBody = document.createElement("div"); - var elPanelIcon = document.createElement("img"); - var elPanelStretch = document.createElement("span"); - var elPanelRemove = document.createElement("img"); - - elPanel.classList.add("potree-panel", "panel-default"); - elPanelHeader.classList.add("potree-panel-heading", "pv-panel-heading"); + let panelIcon = ""; + let panelTitle = ""; + let removeCallback; if(measurement instanceof Potree.Measure){ if(measurement.showDistances && !measurement.showArea && !measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/distance.svg"; - elPanelStretch.innerHTML = "Distance"; + panelIcon = Potree.resourcePath + "/icons/distance.svg"; + panelTitle = "Distance"; }else if(measurement.showDistances && measurement.showArea && !measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/area.svg"; - elPanelStretch.innerHTML = "Area"; + panelIcon = Potree.resourcePath + "/icons/area.svg"; + panelTitle = "Area"; }else if(measurement.maxMarkers === 1){ - elPanelIcon.src = Potree.resourcePath + "/icons/point.svg"; - elPanelStretch.innerHTML = "Coordinate"; + panelIcon = Potree.resourcePath + "/icons/point.svg"; + panelTitle = "Coordinate"; }else if(!measurement.showDistances && !measurement.showArea && measurement.showAngles){ - elPanelIcon.src = Potree.resourcePath + "/icons/angle.png"; - elPanelStretch.innerHTML = "Angle"; + panelIcon = Potree.resourcePath + "/icons/angle.png"; + panelTitle = "Angle"; }else if(measurement.showHeight){ - elPanelIcon.src = Potree.resourcePath + "/icons/height.svg"; - elPanelStretch.innerHTML = "Height"; + panelIcon = Potree.resourcePath + "/icons/height.svg"; + panelTitle = "Height"; } - elPanelRemove.onclick = function(){scene.removeMeasurement(measurement);}; + removeCallback = () => scene.removeMeasurement(measurement); } else if(measurement instanceof Potree.Profile){ - elPanelIcon.src = Potree.resourcePath + "/icons/profile.svg"; - elPanelStretch.innerHTML = "Profile"; + panelIcon = Potree.resourcePath + "/icons/profile.svg"; + panelTitle = "Profile"; - elPanelRemove.onclick = function(){scene.removeProfile(measurement);}; + removeCallback = () => scene.removeProfile(measurement); } else if(measurement instanceof Potree.Volume){ - elPanelIcon.src = Potree.resourcePath + "/icons/volume.svg"; - elPanelStretch.innerHTML = "Volume"; + panelIcon = Potree.resourcePath + "/icons/volume.svg"; + panelTitle = "Volume"; - elPanelRemove.onclick = function(){scene.removeVolume(volume);}; + removeCallback = () => scene.removeVolume(measurement); } - elPanelIcon.style.width = "16px"; - elPanelIcon.style.height = "16px"; - elPanelStretch.style.flexGrow = 1; - elPanelStretch.style.textAlign = "center"; - elPanelRemove.src = Potree.resourcePath + "/icons/remove.svg"; - elPanelRemove.style.width = "16px"; - elPanelRemove.style.height = "16px"; - elPanelBody.classList.add("panel-body"); + let removeIconPath = Potree.resourcePath + "/icons/remove.svg"; - elLi.appendChild(elPanel); - elPanel.appendChild(elPanelHeader); - elPanelHeader.appendChild(elPanelIcon); - elPanelHeader.appendChild(elPanelStretch); - elPanelHeader.appendChild(elPanelRemove); - elPanel.appendChild(elPanelBody); + let elLi = $(` +
  • +
    + + +
    + + ${panelTitle} + +
    + + +
    + +
    +
    +
  • + `); + $("#measurement_details").append(elLi); - document.getElementById("measurement_details").appendChild(elLi); + let elPanelBody = elLi.find(".panel-body"); + let elPanelHeader = elLi.find(".potree-panel-heading"); + let elRemove = elPanelHeader.find("img:last"); + elRemove.click(removeCallback); + let widthListener = null; - var updateDisplay = function(event){ + let updateDisplay = function(event){ - $(elPanelBody).empty(); + elPanelBody.empty(); + measurement.removeEventListener("width_changed", widthListener); + if(measurement instanceof Potree.Profile){ - var elLi = $('
  • '); - var elText = document.createTextNode("width: "); - var elWidthLabel = $(''); - var elWidthSlider = $('
    '); + + let widthText = measurement.getWidth() ? + Potree.utils.addCommas(measurement.getWidth().toFixed(3)) : "-"; + + let labelID = "lblProfileWidth_" + id; + let sliderID = "sldProfileWidth_" + id; + + let elLi = $(` +
  • + width: ${widthText} +
    +
  • ` + ); + + let elWidthLabel = elLi.find(`#${labelID}`); + let elWidthSlider = elLi.find(`#${sliderID}`); elWidthSlider.slider({ value: Math.pow((measurement.getWidth() / 1000), 1/4).toFixed(3), @@ -17357,43 +17351,32 @@ function initMeasurementDetails(){ max: 1, step: 0.01, slide: function(event, ui){ - var val = Math.pow(ui.value, 4) * 1000; + let val = Math.pow(ui.value, 4) * 1000; measurement.setWidth(val); } }); - if(measurement.getWidth()){ - elWidthLabel.html(Potree.utils.addCommas(measurement.getWidth().toFixed(3))); - }else{ - elWidthLabel.html("-"); - } - if(widthListener === null){ - widthListener = function(event){ - var val = Math.pow((event.width / 1000), 1/4); - elWidthLabel.html(Potree.utils.addCommas(event.width.toFixed(3))); - elWidthSlider.slider({value: val}); - }; - } - if(!measurement.hasEventListener("width_changed", widthListener)){ - measurement.addEventListener("width_changed", widthListener); - } - elLi.append(elText); - elLi.append(elWidthLabel); - elLi.append(elWidthSlider); + widthListener = (event) => { + let val = Math.pow((event.width / 1000), 1/4); + elWidthLabel.html(Potree.utils.addCommas(event.width.toFixed(3))); + elWidthSlider.slider({value: val}); + }; - elPanelBody.appendChild(elLi[0]); + measurement.addEventListener("width_changed", widthListener); + + elPanelBody.append(elLi); } - var positions = []; - var points; + let positions = []; + let points; if(measurement instanceof Potree.Measure){ points = measurement.points; - for(var i = 0; i < points.length; i++){ + for(let i = 0; i < points.length; i++){ positions.push(points[i].position); } - } else if(measurement instanceof Potree.Profile){ + }else if(measurement instanceof Potree.Profile){ positions = measurement.points; } @@ -17409,188 +17392,170 @@ function initMeasurementDetails(){ let txt = height.toFixed(3); - var elNodeHeight = $('
    ').addClass("measurement-detail-node-marker"); - elNodeHeight.html(txt); - $(elPanelBody).append(elNodeHeight); + let elNodeHeight = $(` +
    + ${txt} +
    `); + elPanelBody.append(elNodeHeight); } - for(var i = 0; i < positions.length; i++){ - // TODO clean this up from the toGeo legacy - var point = positions[i]; - var geoCoord = point; - - var txt = geoCoord.x.toFixed(2) + ", "; - txt += (geoCoord.y).toFixed(2) + ", "; - txt += geoCoord.z.toFixed(2); + for(let i = 0; i < positions.length; i++){ + let point = positions[i]; + + let txt = [point.x, point.y, point.z].map(p => p.toFixed(3)).join(", "); if(measurement && !measurement.showHeight){ - var elNodeMarker = $('
    ').addClass("measurement-detail-node-marker"); - elNodeMarker.html(txt); - $(elPanelBody).append(elNodeMarker); + let elNodeMarker = $(` +
    + ${txt} +
    `); + elPanelBody.append(elNodeMarker); } if(i < positions.length - 1){ if(measurement && measurement.showDistances){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); - $(elPanelBody).append(elEdge); + let elEdge = $('
    '); + elPanelBody.append(elEdge); - var nextPoint = positions[i+1]; - var nextGeo = nextPoint; - var distance = nextGeo.distanceTo(geoCoord); - var txt = Potree.utils.addCommas(distance.toFixed(2)); + let nextPoint = positions[i+1]; + let distance = nextPoint.distanceTo(point); + let txt = Potree.utils.addCommas(distance.toFixed(3)); - var elNodeDistance = $('
    ').addClass("measurement-detail-node-distance"); - elNodeDistance.html(txt); + let elNodeDistance = $(` +
    + ${txt} +
    `); - $(elPanelBody).append(elNodeDistance); + elPanelBody.append(elNodeDistance); } } if(measurement && measurement.showAngles){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); + let elEdge = $('
    '); $(elPanelBody).append(elEdge); - var angle = measurement.getAngle(i); - var txt = Potree.utils.addCommas((angle*(180.0/Math.PI)).toFixed(1)) + '\u00B0'; - var elNodeAngle = $('
    ').addClass("measurement-detail-node-angle"); - elNodeAngle.html(txt); + let angle = measurement.getAngle(i); + let txt = Potree.utils.addCommas((angle*(180.0/Math.PI)).toFixed(1)) + '\u00B0'; + let elNodeAngle = $(`
    ${txt}
    `); $(elPanelBody).append(elNodeAngle); } if(i < positions.length - 1){ - var elEdge = $('
    ').addClass("measurement-detail-edge"); + let elEdge = $('
    '); $(elPanelBody).append(elEdge); } } if(points && points.length === 1){ - var point = points[0]; + let point = points[0]; - var elTable = $('
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - var value = parseInt(color[0]) - + ", " + parseInt(color[1]) - + ", " + parseInt(color[2]); - - elKey.html("rgb"); - elValue.html(value); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    rgb${text}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("intensity"); - elValue.html(intensity); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    intensity${intensity}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("classification"); - elValue.html(classification); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    classification${classification}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("return nr."); - elValue.html(returnNumber); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    return nr.${returnNumber}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("source"); - elValue.html(source); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    source${source}
    ').css("width", "100%"); + let elTable = $('
    '); $(elPanelBody).append(elTable); if(point.color){ - var color = point.color; + let color = point.color; + let text = color.join(", "); - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.intensity !== "undefined"){ - var intensity = point.intensity; + if(point.intensity !== undefined){ + let intensity = point.intensity; - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.classification !== "undefined"){ - var classification = point.classification; + if(point.classification !== undefined){ + let classification = point.classification; - var elTr = $(''); - var elKey = $(' + + + + `)); } - if(typeof point.returnNumber !== "undefined"){ - var returnNumber = point.returnNumber; + if(point.returnNumber !== undefined){ + let returnNumber = point.returnNumber; - var elTr = $(''); - var elKey = $(' + + + + `)); } if(typeof point.pointSourceID !== "undefined"){ - var source = point.pointSourceID; + let source = point.pointSourceID; - var elTr = $(''); - var elKey = $(' + + + + `)); } } if(measurement && measurement.showDistances && measurement.points.length > 1){ - var txt = "Total: " + Potree.utils.addCommas(measurement.getTotalDistance().toFixed(3)); + let txt = "Total: " + Potree.utils.addCommas(measurement.getTotalDistance().toFixed(3)); - var elNodeTotalDistance = $('
    ').addClass("measurement-detail-node-distance"); - elNodeTotalDistance.html(txt); - - $(elPanelBody).append(elNodeTotalDistance); + $(elPanelBody).append($(` +
    ${txt}
    + `)); } if(measurement && measurement.showArea){ - var txt = Potree.utils.addCommas(measurement.getArea().toFixed(1)) + "\u00B2"; + let txt = Potree.utils.addCommas(measurement.getArea().toFixed(1)) + "\u00B2"; - var elNodeArea = $('
    ').addClass("measurement-detail-node-area"); - elNodeArea.html(txt); - - $(elPanelBody).append(elNodeArea); + $(elPanelBody).append($(` +
    ${txt}
    + `)); } if(measurement instanceof Potree.Profile){ - var elOpenProfileWindow = $('') - .addClass("measurement-detail-button"); - elOpenProfileWindow[0].onclick = function(){ + let elOpenProfileWindow = $(` + + `); + + elOpenProfileWindow.click(e => { viewer._2dprofile.show(); viewer._2dprofile.draw(measurement); - }; - $(elPanelBody).append(elOpenProfileWindow); + }); + + elPanelBody.append(elOpenProfileWindow); } let doExport = measurement.showDistances && !measurement.showAngles; if(doExport){ - let elBottomBar = $(` - - `); + let elBottomBar = $(` + + + `); $(elPanelBody).append(elBottomBar); { let icon = Potree.resourcePath + "/icons/file_geojson.svg"; - let elDownload = $(``); + let elDownload = $(` + + + `); elDownload.click(function(e){ let geojson = Potree.GeoJSONExporter.toString(measurement); @@ -17603,7 +17568,10 @@ function initMeasurementDetails(){ { let icon = Potree.resourcePath + "/icons/file_dxf.svg"; - let elDownload = $(``); + let elDownload = $(` + + + `); elDownload.click(function(e){ let dxf = Potree.DXFExporter.toString(measurement); @@ -17621,9 +17589,6 @@ function initMeasurementDetails(){ if(measurement instanceof Potree.Measure){ let onremove = function(event){ if(event.measurement === measurement){ - //scene.removeEventListener("marker_added", updateDisplay); - //scene.removeEventListener("marker_removed", updateDisplay); - //scene.removeEventListener("marker_moved", updateDisplay); $(elLi).remove(); } }; @@ -17684,11 +17649,11 @@ function initMeasurementDetails(){ trackedItem.stopTracking(); }); - for(var i = 0; i < scene.measurements.length; i++){ + for(let i = 0; i < scene.measurements.length; i++){ trackMeasurement(scene, scene.measurements[i]); } - for(var i = 0; i < scene.profiles.length; i++){ + for(let i = 0; i < scene.profiles.length; i++){ trackMeasurement(scene, scene.profiles[i]); } @@ -17708,64 +17673,60 @@ function initMeasurementDetails(){ function initSceneList(){ - var scenelist = $('#sceneList'); + let scenelist = $('#sceneList'); - var id = 0; - // this works but it looks so wrong. any better way to create a closure around pointcloud? - var addPointcloud = function(pointcloud){ - (function(pointcloud){ - var elLi = $('
  • '); - var elLabel = $('
  • + +
  • + `); + + let elInput = elPointclouds.find("input"); + let elPointCloudLabel = elPointclouds.find("span"); + + elInput.click(function(event){ + pointcloud.visible = event.target.checked; + if(viewer._2dprofile){ + viewer._2dprofile.redraw(); + } + }); + + scenelist.append(elPointclouds); + + pointcloud.addEventListener("name_changed", function(e){ + if(e.name){ + elPointCloudLabel.innerHTML = " " + e.name; + }else{ + elPointCloudLabel.innerHTML = " point cloud " + id; + } + }); + + id++; }; - for(var i = 0; i < viewer.scene.pointclouds.length; i++){ - var pointcloud = viewer.scene.pointclouds[i]; + for(let pointcloud of viewer.scene.pointclouds){ addPointcloud(pointcloud); } viewer.addEventListener("scene_changed", (e) => { scenelist.empty(); - let scene = e.scene; - for(var i = 0; i < scene.pointclouds.length; i++){ - var pointcloud = scene.pointclouds[i]; + for(let pointcloud of e.scene.pointclouds){ addPointcloud(pointcloud); } }); - // TODO update scene list on scene switch viewer.addEventListener("pointcloud_loaded", function(event){ addPointcloud(event.pointcloud); }); @@ -17792,7 +17753,6 @@ function initSceneList(){ }; initSettings = function(){ - //
  • Min Node Size:
  • $( "#sldMinNodeSize" ).slider({ value: viewer.getMinNodeSize(), @@ -17808,7 +17768,7 @@ initSettings = function(){ }); - var toClipModeCode = function(string){ + let toClipModeCode = function(string){ if(string === "No Clipping"){ return Potree.ClipMode.DISABLED; }else if(string === "Highlight Inside"){ @@ -17818,7 +17778,7 @@ initSettings = function(){ } }; - var toClipModeString = function(code){ + let toClipModeString = function(code){ if(code === Potree.ClipMode.DISABLED){ return "No Clipping"; }else if(code === Potree.ClipMode.HIGHLIGHT_INSIDE){ diff --git a/build/potree/resources/icons/eye.svg b/build/potree/resources/icons/eye.svg new file mode 100644 index 00000000..dadbff4b --- /dev/null +++ b/build/potree/resources/icons/eye.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/build/potree/resources/icons/eye_crossed.svg b/build/potree/resources/icons/eye_crossed.svg new file mode 100644 index 00000000..786a7f4c --- /dev/null +++ b/build/potree/resources/icons/eye_crossed.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/build/potree/resources/icons/image_preview.php b/build/potree/resources/icons/image_preview.php new file mode 100644 index 00000000..7288b6a4 --- /dev/null +++ b/build/potree/resources/icons/image_preview.php @@ -0,0 +1,24 @@ + $value){ + + if($value === "." || $value === ".." || $value === "image_preview.php"){ + continue; + } + + ?> +
    +
    + +
    + \ No newline at end of file diff --git a/resources/icons/eye.svg b/resources/icons/eye.svg new file mode 100644 index 00000000..dadbff4b --- /dev/null +++ b/resources/icons/eye.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/resources/icons/eye_crossed.svg b/resources/icons/eye_crossed.svg new file mode 100644 index 00000000..786a7f4c --- /dev/null +++ b/resources/icons/eye_crossed.svg @@ -0,0 +1,93 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/resources/icons/image_preview.php b/resources/icons/image_preview.php new file mode 100644 index 00000000..7288b6a4 --- /dev/null +++ b/resources/icons/image_preview.php @@ -0,0 +1,24 @@ + $value){ + + if($value === "." || $value === ".." || $value === "image_preview.php"){ + continue; + } + + ?> +
    +
    + +
    + \ No newline at end of file diff --git a/resources/icons/round_dropdown.svg b/resources/icons/round_dropdown.svg deleted file mode 100644 index cee3cbf7..00000000 --- a/resources/icons/round_dropdown.svg +++ /dev/null @@ -1,237 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - diff --git a/resources/icons/round_icon.svg b/resources/icons/round_icon.svg deleted file mode 100644 index b7bf8fdb..00000000 --- a/resources/icons/round_icon.svg +++ /dev/null @@ -1,230 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - diff --git a/src/Annotation.js b/src/Annotation.js index 29cbd240..7839f0cd 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -27,7 +27,8 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.showDescription = true; this.actions = args.actions || []; this.isHighlighted = false; - this.visible = true; + this._visible = true; + this.__visible = true; this.collapseThreshold = [args.collapseThreshold, 100].find(e => e !== undefined); this.children = []; @@ -68,7 +69,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ let elButton = $(``); this.elTitlebar.append(elButton); - elButton.click(() => action.onclick()); + elButton.click(() => action.onclick({annotation: this})); } this.elDescriptionClose.hover( @@ -258,6 +259,26 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }; + get visible(){ + return this._visible; + } + + set visible(value){ + this._visible = value; + + if(!value){ + this.traverse(node => { + node.__visible = false; + node.domElement.css("display", "none"); + }); + }else{ + this.traverse(node => { + node.__visible = true; + //node.domElement.css("display", "inline-block"); + }); + } + } + toString(){ return "Annotation: " + this.title; } diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index d5f19f87..77aae6cf 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -777,7 +777,7 @@ function initAnnotationDetails(){ let elIcon = $(``); elMain.append(elIcon); - elMain.click(e => action.onclick(e)); + elMain.click(e => action.onclick({annotation: annotation})); elMain.mouseover(e => elIcon.css("opacity", 1)); elMain.mouseout(e => elIcon.css("opacity", 0.5)); @@ -790,7 +790,7 @@ function initAnnotationDetails(){ let elIcon = $(``); elIcon.click(e => { - action.onclick(e); + action.onclick({annotation: annotation}); return false; }); elIcon.mouseover(e => elIcon.css("opacity", 1)); diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index b7427517..0cbdc0a1 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -1508,10 +1508,10 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ if(!this.getShowAnnotations()){ this.scene.annotations.traverseDescendants(descendant => { - if(!descendant.visible){ + if(!descendant.__visible || !descendant.visible){ return false; }else{ - descendant.visible = false; + descendant.__visible = false; descendant.domElement[0].style.display = "none"; } @@ -1532,6 +1532,10 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return true; } + if(!annotation.visible){ + return false; + } + annotation.scene = this.scene; let element = annotation.domElement[0]; @@ -1578,24 +1582,24 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ if(!expand){ annotation.traverseDescendants(descendant => { - if(!descendant.visible){ + if(!descendant.__visible){ return; }else{ - descendant.visible = false; + descendant.__visible = false; descendant.domElement[0].style.display = "none"; } }); - annotation.visible = true; + annotation.__visible = true; element.style.display = "inline-block"; }else{ - annotation.visible = true; + annotation.__visible = true; element.style.display = "none"; } return expand; }else{ - annotation.visible = (-1 <= screenPos.z && screenPos.z <= 1); - if(annotation.visible){ + annotation.__visible = (-1 <= screenPos.z && screenPos.z <= 1); + if(annotation.__visible){ element.style.display = "inline-block"; }else{ element.style.display = "none"; From d44abec1184111af96417598a321f292681eef0b Mon Sep 17 00:00:00 2001 From: Markus Schuetz Date: Wed, 8 Mar 2017 15:51:09 +0100 Subject: [PATCH 5/8] annotation actions can be shown in sidebar only, scene only, or both --- build/potree/potree.js | 13 ++++++++++++- src/Annotation.js | 10 +++++++++- src/viewer/sidebar.js | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/build/potree/potree.js b/build/potree/potree.js index f2c57f2e..e55e3c03 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -6060,7 +6060,15 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.dispatchEvent({type: "click", target: this}); }); - for(let action of this.actions){ + let actions = this.actions.filter( + a => a.showIn === undefined || a.showIn.includes("scene")); + + for(let action of actions){ + + //if(action.showIn !== undefined && !action.showIn.includes("scene")){ + // continue; + //} + this.elTitle.css("padding", "1px 3px 0px 8px"); let elButton = $(``); @@ -17163,6 +17171,9 @@ function initAnnotationDetails(){ } } + 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]; diff --git a/src/Annotation.js b/src/Annotation.js index 7839f0cd..bafa0ac6 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -64,7 +64,15 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.dispatchEvent({type: "click", target: this}); }); - for(let action of this.actions){ + let actions = this.actions.filter( + a => a.showIn === undefined || a.showIn.includes("scene")); + + for(let action of actions){ + + //if(action.showIn !== undefined && !action.showIn.includes("scene")){ + // continue; + //} + this.elTitle.css("padding", "1px 3px 0px 8px"); let elButton = $(``); diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 77aae6cf..638002c9 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -770,6 +770,9 @@ function initAnnotationDetails(){ } } + 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]; From b4cd822b9ecfc416e4d78f9c0744751db335269c Mon Sep 17 00:00:00 2001 From: Markus Schuetz Date: Thu, 9 Mar 2017 12:42:58 +0100 Subject: [PATCH 6/8] added annotation action class and a predefined show/hide annotation action --- build/potree/potree.css | 5 +- build/potree/potree.js | 152 ++++++++++++++++--- build/potree/resources/icons/eye_crossed.svg | 20 +-- examples/annotations.html | 2 +- gulpfile.js | 1 + resources/icons/eye_crossed.svg | 20 +-- src/Actions.js | 63 ++++++++ src/Annotation.js | 17 ++- src/viewer/potree.css | 5 +- src/viewer/sidebar.js | 45 +++++- src/viewer/viewer.js | 26 ++-- 11 files changed, 293 insertions(+), 63 deletions(-) create mode 100644 src/Actions.js diff --git a/build/potree/potree.css b/build/potree/potree.css index 4ea62400..66c6a303 100644 --- a/build/potree/potree.css +++ b/build/potree/potree.css @@ -144,8 +144,8 @@ a:hover, a:visited, a:link, a:active{ } .annotation{ - -webkit-transition: opacity .1s; - transition: opacity .1s; + //-webkit-transition: opacity .1s; + //transition: opacity .1s; position: absolute; padding: 10px; opacity: 0.5; @@ -234,6 +234,7 @@ a:hover, a:visited, a:link, a:active{ border-radius: 4px; display: none; max-width: 500px; + width: 500px; } .annotation-description-close{ diff --git a/build/potree/potree.js b/build/potree/potree.js index e55e3c03..9f1a2859 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -6059,16 +6059,19 @@ Potree.Annotation = class extends THREE.EventDispatcher{ } this.dispatchEvent({type: "click", target: this}); }); + + this.actions = this.actions.map(a => { + if(a instanceof Potree.Action){ + return a; + }else{ + return new Potree.Action(a); + } + }); let actions = this.actions.filter( a => a.showIn === undefined || a.showIn.includes("scene")); for(let action of actions){ - - //if(action.showIn !== undefined && !action.showIn.includes("scene")){ - // continue; - //} - this.elTitle.css("padding", "1px 3px 0px 8px"); let elButton = $(``); @@ -6182,7 +6185,8 @@ Potree.Annotation = class extends THREE.EventDispatcher{ if(this.description){ this.descriptionVisible = true; - this.elDescription.css("display", "block"); + //this.elDescription.css("display", "block"); + this.elDescription.fadeIn(200); this.elDescription.css("position", "relative"); } }else{ @@ -6191,6 +6195,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.domElement.css("z-index", "100"); this.descriptionVisible = false; this.elDescription.css("display", "none"); + //this.elDescription.fadeOut(200); } this.isHighlighted = highlighted; @@ -6289,6 +6294,70 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }; +Potree.Action = class Action extends THREE.EventDispatcher{ + + constructor(args = {}){ + super(); + + this.icon = args.icon || ""; + this.tooltip = args.tooltip; + + if(args.onclick !== undefined){ + this.onclick = args.onclick; + } + + } + + onclick(event){ + + } + + setIcon(newIcon){ + let oldIcon = this.icon; + + if(newIcon === oldIcon){ + return; + } + + this.icon = newIcon; + + this.dispatchEvent({ + type: "icon_changed", + action: this, + icon: newIcon, + oldIcon: oldIcon + }); + } + +}; + +Potree.Actions = {}; + +Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility extends Potree.Action{ + + constructor(args = {}){ + super(args); + + this.icon = Potree.resourcePath + "/icons/eye.svg"; + this.showIn = "sidebar"; + this.tooltip = "toggle visibility"; + } + + onclick(event){ + let annotation = event.annotation; + + annotation.visible = !annotation.visible; + + if(annotation.visible){ + this.setIcon(Potree.resourcePath + "/icons/eye.svg"); + }else{ + this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + } + } +} + + + Potree.ProfileData = function(profile){ this.profile = profile; @@ -13915,7 +13984,8 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return false; }else{ descendant.__visible = false; - descendant.domElement[0].style.display = "none"; + //descendant.domElement[0].style.display = "none"; + descendant.domElement.fadeOut(200); } return; @@ -13941,7 +14011,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ annotation.scene = this.scene; - let element = annotation.domElement[0]; + let element = annotation.domElement; let position = annotation.position; if(!position){ @@ -13959,7 +14029,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ screenPos.x = this.renderArea.clientWidth * (screenPos.x + 1) / 2; screenPos.y = this.renderArea.clientHeight * (1 - (screenPos.y + 1) / 2); - screenPos.x = Math.floor(screenPos.x - element.clientWidth / 2); + screenPos.x = Math.floor(screenPos.x - element[0].clientWidth / 2); screenPos.y = Math.floor(screenPos.y - annotation.elTitlebar[0].clientHeight / 2); // SCREEN SIZE @@ -13970,15 +14040,15 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ screenSize = radius * projFactor; } - element.style.left = screenPos.x + "px"; - element.style.top = screenPos.y + "px"; + element.css("left", screenPos.x + "px"); + element.css("top", screenPos.y + "px"); let zIndex = 10000000 - distance * (10000000 / this.scene.camera.far); if(annotation.descriptionVisible){ zIndex += 10000000; } - element.style.zIndex = parseInt(zIndex); + element.css("z-index", parseInt(zIndex)); if(annotation.children.length > 0){ let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); @@ -13989,25 +14059,28 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return; }else{ descendant.__visible = false; - descendant.domElement[0].style.display = "none"; + //descendant.domElement.fadeOut(200); + descendant.domElement.hide(); } }); annotation.__visible = true; - element.style.display = "inline-block"; + element.fadeIn(200); }else{ annotation.__visible = true; - element.style.display = "none"; + element.fadeOut(200); } return expand; }else{ annotation.__visible = (-1 <= screenPos.z && screenPos.z <= 1); if(annotation.__visible){ - element.style.display = "inline-block"; + $(element).fadeIn(200); }else{ - element.style.display = "none"; + $(element).fadeOut(200); } } + + }); } @@ -17111,10 +17184,17 @@ function initAnnotationDetails(){ // annotation_details let annotationPanel = $("#annotation_details"); + let registeredEvents = []; + let rebuild = () => { console.log("rebuild"); annotationPanel.empty(); + for(let registeredEvent of registeredEvents){ + let {type, dispatcher, callback} = registeredEvent; + dispatcher.removeEventListener(type, callback); + } + registeredEvents = []; let checked = viewer.getShowAnnotations() ? "checked" : ""; @@ -17158,10 +17238,10 @@ function initAnnotationDetails(){ let actions = []; { // ACTIONS, INCLUDING GOTO LOCATION if(annotation.hasView()){ - let action = { + let action = new Potree.Action({ "icon": Potree.resourcePath + "/icons/target.svg", "onclick": (e) => {annotation.moveHere(viewer.scene.camera)} - }; + }); actions.push(action); } @@ -17180,11 +17260,28 @@ function initAnnotationDetails(){ 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", + dispatcher: action, + callback: iconChanged + }); + } + actions.splice(0, 1); } @@ -17193,6 +17290,10 @@ function initAnnotationDetails(){ let elIcon = $(``); + if(action.tooltip){ + elIcon.attr("title", action.tooltip); + } + elIcon.click(e => { action.onclick({annotation: annotation}); return false; @@ -17200,6 +17301,19 @@ function initAnnotationDetails(){ 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", + dispatcher: action, + callback: iconChanged + }); + } + element.append(elIcon); } diff --git a/build/potree/resources/icons/eye_crossed.svg b/build/potree/resources/icons/eye_crossed.svg index 786a7f4c..e5eaa68f 100644 --- a/build/potree/resources/icons/eye_crossed.svg +++ b/build/potree/resources/icons/eye_crossed.svg @@ -26,8 +26,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="7.9195959" - inkscape:cx="-11.588817" - inkscape:cy="29.04571" + inkscape:cx="26.72264" + inkscape:cy="42.323076" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -61,21 +61,21 @@ cx="32.167046" cy="1019.7532" r="12.911013" /> + - + transform="translate(-0.63134584,0)">
  • Click on the annotation label to move a predefined view.
  • Click on the icon to execute the specified action.
  • In this case, the action will bring you to another scene and point cloud.`, - "actions": [{ + actions: [{ "icon": Potree.resourcePath + "/icons/goto.svg", "onclick": function(){ viewer.setScene(sceneLion); diff --git a/gulpfile.js b/gulpfile.js index 904db75b..7efaf82c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -40,6 +40,7 @@ var paths = { "src/navigation/EarthControls.js", "src/LRU.js", "src/Annotation.js", + "src/Actions.js", "src/ProfileRequest.js", "src/PointCloudOctree.js", "src/PointCloudOctreeGeometry.js", diff --git a/resources/icons/eye_crossed.svg b/resources/icons/eye_crossed.svg index 786a7f4c..e5eaa68f 100644 --- a/resources/icons/eye_crossed.svg +++ b/resources/icons/eye_crossed.svg @@ -26,8 +26,8 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="7.9195959" - inkscape:cx="-11.588817" - inkscape:cy="29.04571" + inkscape:cx="26.72264" + inkscape:cy="42.323076" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" @@ -61,21 +61,21 @@ cx="32.167046" cy="1019.7532" r="12.911013" /> + - + transform="translate(-0.63134584,0)"> { + if(a instanceof Potree.Action){ + return a; + }else{ + return new Potree.Action(a); + } + }); let actions = this.actions.filter( a => a.showIn === undefined || a.showIn.includes("scene")); for(let action of actions){ - - //if(action.showIn !== undefined && !action.showIn.includes("scene")){ - // continue; - //} - this.elTitle.css("padding", "1px 3px 0px 8px"); let elButton = $(``); @@ -186,7 +189,8 @@ Potree.Annotation = class extends THREE.EventDispatcher{ if(this.description){ this.descriptionVisible = true; - this.elDescription.css("display", "block"); + //this.elDescription.css("display", "block"); + this.elDescription.fadeIn(200); this.elDescription.css("position", "relative"); } }else{ @@ -195,6 +199,7 @@ Potree.Annotation = class extends THREE.EventDispatcher{ this.domElement.css("z-index", "100"); this.descriptionVisible = false; this.elDescription.css("display", "none"); + //this.elDescription.fadeOut(200); } this.isHighlighted = highlighted; diff --git a/src/viewer/potree.css b/src/viewer/potree.css index 4ea62400..66c6a303 100644 --- a/src/viewer/potree.css +++ b/src/viewer/potree.css @@ -144,8 +144,8 @@ a:hover, a:visited, a:link, a:active{ } .annotation{ - -webkit-transition: opacity .1s; - transition: opacity .1s; + //-webkit-transition: opacity .1s; + //transition: opacity .1s; position: absolute; padding: 10px; opacity: 0.5; @@ -234,6 +234,7 @@ a:hover, a:visited, a:link, a:active{ border-radius: 4px; display: none; max-width: 500px; + width: 500px; } .annotation-description-close{ diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 638002c9..58c6c51e 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -710,10 +710,17 @@ function initAnnotationDetails(){ // annotation_details let annotationPanel = $("#annotation_details"); + let registeredEvents = []; + let rebuild = () => { console.log("rebuild"); annotationPanel.empty(); + for(let registeredEvent of registeredEvents){ + let {type, dispatcher, callback} = registeredEvent; + dispatcher.removeEventListener(type, callback); + } + registeredEvents = []; let checked = viewer.getShowAnnotations() ? "checked" : ""; @@ -757,10 +764,10 @@ function initAnnotationDetails(){ let actions = []; { // ACTIONS, INCLUDING GOTO LOCATION if(annotation.hasView()){ - let action = { + let action = new Potree.Action({ "icon": Potree.resourcePath + "/icons/target.svg", "onclick": (e) => {annotation.moveHere(viewer.scene.camera)} - }; + }); actions.push(action); } @@ -779,11 +786,28 @@ function initAnnotationDetails(){ 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", + dispatcher: action, + callback: iconChanged + }); + } + actions.splice(0, 1); } @@ -792,6 +816,10 @@ function initAnnotationDetails(){ let elIcon = $(``); + if(action.tooltip){ + elIcon.attr("title", action.tooltip); + } + elIcon.click(e => { action.onclick({annotation: annotation}); return false; @@ -799,6 +827,19 @@ function initAnnotationDetails(){ 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", + dispatcher: action, + callback: iconChanged + }); + } + element.append(elIcon); } diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 0cbdc0a1..2d5d2889 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -1512,7 +1512,8 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return false; }else{ descendant.__visible = false; - descendant.domElement[0].style.display = "none"; + //descendant.domElement[0].style.display = "none"; + descendant.domElement.fadeOut(200); } return; @@ -1538,7 +1539,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ annotation.scene = this.scene; - let element = annotation.domElement[0]; + let element = annotation.domElement; let position = annotation.position; if(!position){ @@ -1556,7 +1557,7 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ screenPos.x = this.renderArea.clientWidth * (screenPos.x + 1) / 2; screenPos.y = this.renderArea.clientHeight * (1 - (screenPos.y + 1) / 2); - screenPos.x = Math.floor(screenPos.x - element.clientWidth / 2); + screenPos.x = Math.floor(screenPos.x - element[0].clientWidth / 2); screenPos.y = Math.floor(screenPos.y - annotation.elTitlebar[0].clientHeight / 2); // SCREEN SIZE @@ -1567,15 +1568,15 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ screenSize = radius * projFactor; } - element.style.left = screenPos.x + "px"; - element.style.top = screenPos.y + "px"; + element.css("left", screenPos.x + "px"); + element.css("top", screenPos.y + "px"); let zIndex = 10000000 - distance * (10000000 / this.scene.camera.far); if(annotation.descriptionVisible){ zIndex += 10000000; } - element.style.zIndex = parseInt(zIndex); + element.css("z-index", parseInt(zIndex)); if(annotation.children.length > 0){ let expand = screenSize > annotation.collapseThreshold || annotation.boundingBox.containsPoint(this.scene.camera.position); @@ -1586,25 +1587,28 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ return; }else{ descendant.__visible = false; - descendant.domElement[0].style.display = "none"; + //descendant.domElement.fadeOut(200); + descendant.domElement.hide(); } }); annotation.__visible = true; - element.style.display = "inline-block"; + element.fadeIn(200); }else{ annotation.__visible = true; - element.style.display = "none"; + element.fadeOut(200); } return expand; }else{ annotation.__visible = (-1 <= screenPos.z && screenPos.z <= 1); if(annotation.__visible){ - element.style.display = "inline-block"; + $(element).fadeIn(200); }else{ - element.style.display = "none"; + $(element).fadeOut(200); } } + + }); } From 9cb302d395f5c9d7dfd928339f8dfd8ea7f381f2 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Thu, 9 Mar 2017 13:19:48 +0100 Subject: [PATCH 7/8] can pair actions with annotations --- build/potree/potree.js | 47 ++++++++++++++++++++++++++++++++++++------ src/Actions.js | 23 +++++++++++++++++++++ src/Annotation.js | 14 ++++++++++++- src/viewer/viewer.js | 6 +++--- 4 files changed, 80 insertions(+), 10 deletions(-) diff --git a/build/potree/potree.js b/build/potree/potree.js index 9f1a2859..5e4951c2 100644 --- a/build/potree/potree.js +++ b/build/potree/potree.js @@ -6067,6 +6067,10 @@ Potree.Annotation = class extends THREE.EventDispatcher{ return new Potree.Action(a); } }); + + for(let action of this.actions){ + action.pairWith(this); + } let actions = this.actions.filter( a => a.showIn === undefined || a.showIn.includes("scene")); @@ -6273,6 +6277,10 @@ Potree.Annotation = class extends THREE.EventDispatcher{ } set visible(value){ + if(this._visible === value){ + return; + } + this._visible = value; if(!value){ @@ -6283,9 +6291,13 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }else{ this.traverse(node => { node.__visible = true; - //node.domElement.css("display", "inline-block"); }); } + + this.dispatchEvent({ + type: "visibility_changed", + annotation: this + }); } toString(){ @@ -6312,6 +6324,10 @@ Potree.Action = class Action extends THREE.EventDispatcher{ } + pairWith(object){ + + } + setIcon(newIcon){ let oldIcon = this.icon; @@ -6343,6 +6359,25 @@ Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility ext this.tooltip = "toggle visibility"; } + pairWith(annotation){ + + if(annotation.visible){ + this.setIcon(Potree.resourcePath + "/icons/eye.svg"); + }else{ + this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + } + + annotation.addEventListener("visibility_changed", e => { + let annotation = e.annotation; + + if(annotation.visible){ + this.setIcon(Potree.resourcePath + "/icons/eye.svg"); + }else{ + this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + } + }); + } + onclick(event){ let annotation = event.annotation; @@ -11138,8 +11173,8 @@ Potree.GeoJSONExporter = class GeoJSONExporter{ /** * * @author sigeom sa / http://sigeom.ch - * @author Ioda-Net Sàrl / https://www.ioda-net.ch/ - * @author Markus Schütz / http://potree.org + * @author Ioda-Net S�rl / https://www.ioda-net.ch/ + * @author Markus Sch�tz / http://potree.org * */ @@ -12848,9 +12883,9 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ this.progressBar = new ProgressBar(); this.stats = new Stats(); - this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom - document.body.appendChild( this.stats.dom ); - this.stats.dom.style.left = "100px"; + //this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom + //document.body.appendChild( this.stats.dom ); + //this.stats.dom.style.left = "100px"; this.potreeRenderer = null; this.highQualityRenderer = null; diff --git a/src/Actions.js b/src/Actions.js index 3d28236a..443fb851 100644 --- a/src/Actions.js +++ b/src/Actions.js @@ -17,6 +17,10 @@ Potree.Action = class Action extends THREE.EventDispatcher{ } + pairWith(object){ + + } + setIcon(newIcon){ let oldIcon = this.icon; @@ -48,6 +52,25 @@ Potree.Actions.ToggleAnnotationVisibility = class ToggleAnnotationVisibility ext this.tooltip = "toggle visibility"; } + pairWith(annotation){ + + if(annotation.visible){ + this.setIcon(Potree.resourcePath + "/icons/eye.svg"); + }else{ + this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + } + + annotation.addEventListener("visibility_changed", e => { + let annotation = e.annotation; + + if(annotation.visible){ + this.setIcon(Potree.resourcePath + "/icons/eye.svg"); + }else{ + this.setIcon(Potree.resourcePath + "/icons/eye_crossed.svg"); + } + }); + } + onclick(event){ let annotation = event.annotation; diff --git a/src/Annotation.js b/src/Annotation.js index 02273562..d736f48a 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -71,6 +71,10 @@ Potree.Annotation = class extends THREE.EventDispatcher{ return new Potree.Action(a); } }); + + for(let action of this.actions){ + action.pairWith(this); + } let actions = this.actions.filter( a => a.showIn === undefined || a.showIn.includes("scene")); @@ -277,6 +281,10 @@ Potree.Annotation = class extends THREE.EventDispatcher{ } set visible(value){ + if(this._visible === value){ + return; + } + this._visible = value; if(!value){ @@ -287,9 +295,13 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }else{ this.traverse(node => { node.__visible = true; - //node.domElement.css("display", "inline-block"); }); } + + this.dispatchEvent({ + type: "visibility_changed", + annotation: this + }); } toString(){ diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 2d5d2889..effb64b3 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -376,9 +376,9 @@ Potree.Viewer = class PotreeViewer extends THREE.EventDispatcher{ this.progressBar = new ProgressBar(); this.stats = new Stats(); - this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom - document.body.appendChild( this.stats.dom ); - this.stats.dom.style.left = "100px"; + //this.stats.showPanel( 0 ); // 0: fps, 1: ms, 2: mb, 3+: custom + //document.body.appendChild( this.stats.dom ); + //this.stats.dom.style.left = "100px"; this.potreeRenderer = null; this.highQualityRenderer = null; From 448e37b2ea607731598c3d9899b922e456669341 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Fri, 31 Mar 2017 13:12:35 +0200 Subject: [PATCH 8/8] fix picking; improve annotations; cleanup css; put some greyhound loader utility functions into its own class/namespace --- libs/shapefile/shapefile.js | 469 +++++++++++++++++++++++ resources/shapefiles/south_sorvilier.dbf | Bin 0 -> 20751 bytes resources/shapefiles/south_sorvilier.shp | Bin 0 -> 1556 bytes src/Annotation.js | 87 +++-- src/PointCloudOctree.js | 14 +- src/Potree.js | 15 + src/loader/GreyhoundLoader.js | 255 ++++++------ src/viewer/potree.css | 34 +- 8 files changed, 690 insertions(+), 184 deletions(-) create mode 100644 libs/shapefile/shapefile.js create mode 100644 resources/shapefiles/south_sorvilier.dbf create mode 100644 resources/shapefiles/south_sorvilier.shp diff --git a/libs/shapefile/shapefile.js b/libs/shapefile/shapefile.js new file mode 100644 index 00000000..8c0713a1 --- /dev/null +++ b/libs/shapefile/shapefile.js @@ -0,0 +1,469 @@ +// https://github.com/mbostock/shapefile Version 0.6.2. Copyright 2017 Mike Bostock. +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.shapefile = global.shapefile || {}))); +}(this, (function (exports) { 'use strict'; + +var array_cancel = function() { + this._array = null; + return Promise.resolve(); +}; + +var array_read = function() { + var array = this._array; + this._array = null; + return Promise.resolve(array ? {done: false, value: array} : {done: true, value: undefined}); +}; + +function array(array) { + return new ArraySource(array instanceof Uint8Array ? array : new Uint8Array(array)); +} + +function ArraySource(array) { + this._array = array; +} + +ArraySource.prototype.read = array_read; +ArraySource.prototype.cancel = array_cancel; + +var fetchPath = function(url) { + return fetch(url).then(function(response) { + return response.body && response.body.getReader + ? response.body.getReader() + : response.arrayBuffer().then(array); + }); +}; + +var requestPath = function(url) { + return new Promise(function(resolve, reject) { + var request = new XMLHttpRequest; + request.responseType = "arraybuffer"; + request.onload = function() { resolve(array(request.response)); }; + request.onerror = reject; + request.ontimeout = reject; + request.open("GET", url, true); + request.send(); + }); +}; + +function path(path) { + return (typeof fetch === "function" ? fetchPath : requestPath)(path); +} + +function stream(source) { + return typeof source.read === "function" ? source : source.getReader(); +} + +var empty = new Uint8Array(0); + +var slice_cancel = function() { + return this._source.cancel(); +}; + +function concat(a, b) { + if (!a.length) return b; + if (!b.length) return a; + var c = new Uint8Array(a.length + b.length); + c.set(a); + c.set(b, a.length); + return c; +} + +var slice_read = function() { + var that = this, array = that._array.subarray(that._index); + return that._source.read().then(function(result) { + that._array = empty; + that._index = 0; + return result.done ? (array.length > 0 + ? {done: false, value: array} + : {done: true, value: undefined}) + : {done: false, value: concat(array, result.value)}; + }); +}; + +var slice_slice = function(length) { + if ((length |= 0) < 0) throw new Error("invalid length"); + var that = this, index = this._array.length - this._index; + + // If the request fits within the remaining buffer, resolve it immediately. + if (this._index + length <= this._array.length) { + return Promise.resolve(this._array.subarray(this._index, this._index += length)); + } + + // Otherwise, read chunks repeatedly until the request is fulfilled. + var array = new Uint8Array(length); + array.set(this._array.subarray(this._index)); + return (function read() { + return that._source.read().then(function(result) { + + // When done, it’s possible the request wasn’t fully fullfilled! + // If so, the pre-allocated array is too big and needs slicing. + if (result.done) { + that._array = empty; + that._index = 0; + return index > 0 ? array.subarray(0, index) : null; + } + + // If this chunk fulfills the request, return the resulting array. + if (index + result.value.length >= length) { + that._array = result.value; + that._index = length - index; + array.set(result.value.subarray(0, length - index), index); + return array; + } + + // Otherwise copy this chunk into the array, then read the next chunk. + array.set(result.value, index); + index += result.value.length; + return read(); + }); + })(); +}; + +function slice(source) { + return typeof source.slice === "function" ? source : + new SliceSource(typeof source.read === "function" ? source + : source.getReader()); +} + +function SliceSource(source) { + this._source = source; + this._array = empty; + this._index = 0; +} + +SliceSource.prototype.read = slice_read; +SliceSource.prototype.slice = slice_slice; +SliceSource.prototype.cancel = slice_cancel; + +var dbf_cancel = function() { + return this._source.cancel(); +}; + +var readBoolean = function(value) { + return /^[nf]$/i.test(value) ? false + : /^[yt]$/i.test(value) ? true + : null; +}; + +var readDate = function(value) { + return new Date(+value.substring(0, 4), value.substring(4, 6) - 1, +value.substring(6, 8)); +}; + +var readNumber = function(value) { + return !(value = value.trim()) || isNaN(value = +value) ? null : value; +}; + +var readString = function(value) { + return value.trim() || null; +}; + +var types = { + B: readNumber, + C: readString, + D: readDate, + F: readNumber, + L: readBoolean, + M: readNumber, + N: readNumber +}; + +var dbf_read = function() { + var that = this, i = 1; + return that._source.slice(that._recordLength).then(function(value) { + return value && (value[0] !== 0x1a) ? {done: false, value: that._fields.reduce(function(p, f) { + p[f.name] = types[f.type](that._decode(value.subarray(i, i += f.length))); + return p; + }, {})} : {done: true, value: undefined}; + }); +}; + +var view = function(array) { + return new DataView(array.buffer, array.byteOffset, array.byteLength); +}; + +var dbf = function(source, decoder) { + source = slice(source); + return source.slice(32).then(function(array) { + var head = view(array); + return source.slice(head.getUint16(8, true) - 32).then(function(array) { + return new Dbf(source, decoder, head, view(array)); + }); + }); +}; + +function Dbf(source, decoder, head, body) { + this._source = source; + this._decode = decoder.decode.bind(decoder); + this._recordLength = head.getUint16(10, true); + this._fields = []; + for (var n = 0; body.getUint8(n) !== 0x0d; n += 32) { + for (var j = 0; j < 11; ++j) if (body.getUint8(n + j) === 0) break; + this._fields.push({ + name: this._decode(new Uint8Array(body.buffer, body.byteOffset + n, j)), + type: String.fromCharCode(body.getUint8(n + 11)), + length: body.getUint8(n + 16) + }); + } +} + +var prototype = Dbf.prototype; +prototype.read = dbf_read; +prototype.cancel = dbf_cancel; + +function cancel() { + return this._source.cancel(); +} + +var readMultiPoint = function(record) { + var i = 40, j, n = record.getInt32(36, true), coordinates = new Array(n); + for (j = 0; j < n; ++j, i += 16) coordinates[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)]; + return {type: "MultiPoint", coordinates: coordinates}; +}; + +var readNull = function() { + return null; +}; + +var readPoint = function(record) { + return {type: "Point", coordinates: [record.getFloat64(4, true), record.getFloat64(12, true)]}; +}; + +var readPolygon = function(record) { + var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m), polygons = [], holes = []; + for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true); + for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)]; + + parts.forEach(function(i, j) { + var ring = points.slice(i, parts[j + 1]); + if (ringClockwise(ring)) polygons.push([ring]); + else holes.push(ring); + }); + + holes.forEach(function(hole) { + polygons.some(function(polygon) { + if (ringContainsSome(polygon[0], hole)) { + polygon.push(hole); + return true; + } + }) || polygons.push([hole]); + }); + + return polygons.length === 1 + ? {type: "Polygon", coordinates: polygons[0]} + : {type: "MultiPolygon", coordinates: polygons}; +}; + +function ringClockwise(ring) { + if ((n = ring.length) < 4) return false; + var i = 0, n, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1]; + while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1]; + return area >= 0; +} + +function ringContainsSome(ring, hole) { + var i = -1, n = hole.length, c; + while (++i < n) { + if (c = ringContains(ring, hole[i])) { + return c > 0; + } + } + return false; +} + +function ringContains(ring, point) { + var x = point[0], y = point[1], contains = -1; + for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) { + var pi = ring[i], xi = pi[0], yi = pi[1], + pj = ring[j], xj = pj[0], yj = pj[1]; + if (segmentContains(pi, pj, point)) { + return 0; + } + if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) { + contains = -contains; + } + } + return contains; +} + +function segmentContains(p0, p1, p2) { + var x20 = p2[0] - p0[0], y20 = p2[1] - p0[1]; + if (x20 === 0 && y20 === 0) return true; + var x10 = p1[0] - p0[0], y10 = p1[1] - p0[1]; + if (x10 === 0 && y10 === 0) return false; + var t = (x20 * x10 + y20 * y10) / (x10 * x10 + y10 * y10); + return t < 0 || t > 1 ? false : t === 0 || t === 1 ? true : t * x10 === x20 && t * y10 === y20; +} + +var readPolyLine = function(record) { + var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m); + for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true); + for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)]; + return n === 1 + ? {type: "LineString", coordinates: points} + : {type: "MultiLineString", coordinates: parts.map(function(i, j) { return points.slice(i, parts[j + 1]); })}; +}; + +var shp_read = function() { + var that = this; + return that._source.slice(8).then(function(array) { + if (array == null) return {done: true, value: undefined}; + var header = view(array); + return that._source.slice(header.getInt32(4, false) * 2).then(function(array) { + var record = view(array); + return {done: false, value: record.getInt32(0, true) ? that._type(record) : readNull()}; + }); + }); +}; + +var types$1 = { + 0: readNull, + 1: readPoint, + 3: readPolyLine, + 5: readPolygon, + 8: readMultiPoint, + 11: readPoint, + 13: readPolyLine, + 15: readPolygon, + 18: readMultiPoint +}; + +var shp = function(source) { + source = slice(source); + return source.slice(100).then(function(array) { + return new Shp(source, view(array)); + }); +}; + +function Shp(source, header) { + var type = header.getInt32(32, true); + if (!(type in types$1)) throw new Error("unsupported shape type: " + type); + this._source = source; + this._type = types$1[type]; + this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)]; +} + +var prototype$2 = Shp.prototype; +prototype$2.read = shp_read; +prototype$2.cancel = cancel; + +function noop() {} + +var shapefile_cancel = function() { + return Promise.all([ + this._dbf && this._dbf.cancel(), + this._shp.cancel() + ]).then(noop); +}; + +var shapefile_read = function() { + var that = this; + return Promise.all([ + that._dbf ? that._dbf.read() : {value: {}}, + that._shp.read() + ]).then(function(results) { + var dbf = results[0], shp = results[1]; + return shp.done ? shp : { + done: false, + value: { + type: "Feature", + properties: dbf.value, + geometry: shp.value + } + }; + }); +}; + +var shapefile = function(shpSource, dbfSource, decoder) { + return Promise.all([ + shp(shpSource), + dbfSource && dbf(dbfSource, decoder) + ]).then(function(sources) { + return new Shapefile(sources[0], sources[1]); + }); +}; + +function Shapefile(shp$$1, dbf$$1) { + this._shp = shp$$1; + this._dbf = dbf$$1; + this.bbox = shp$$1.bbox; +} + +var prototype$1 = Shapefile.prototype; +prototype$1.read = shapefile_read; +prototype$1.cancel = shapefile_cancel; + +function open(shp$$1, dbf$$1, options) { + if (typeof dbf$$1 === "string") { + if (!/\.dbf$/.test(dbf$$1)) dbf$$1 += ".dbf"; + dbf$$1 = path(dbf$$1, options); + } else if (dbf$$1 instanceof ArrayBuffer || dbf$$1 instanceof Uint8Array) { + dbf$$1 = array(dbf$$1); + } else if (dbf$$1 != null) { + dbf$$1 = stream(dbf$$1); + } + if (typeof shp$$1 === "string") { + if (!/\.shp$/.test(shp$$1)) shp$$1 += ".shp"; + if (dbf$$1 === undefined) dbf$$1 = path(shp$$1.substring(0, shp$$1.length - 4) + ".dbf", options).catch(function() {}); + shp$$1 = path(shp$$1, options); + } else if (shp$$1 instanceof ArrayBuffer || shp$$1 instanceof Uint8Array) { + shp$$1 = array(shp$$1); + } else { + shp$$1 = stream(shp$$1); + } + return Promise.all([shp$$1, dbf$$1]).then(function(sources) { + var shp$$1 = sources[0], dbf$$1 = sources[1], encoding = "windows-1252"; + if (options && options.encoding != null) encoding = options.encoding; + return shapefile(shp$$1, dbf$$1, dbf$$1 && new TextDecoder(encoding)); + }); +} + +function openShp(source, options) { + if (typeof source === "string") { + if (!/\.shp$/.test(source)) source += ".shp"; + source = path(source, options); + } else if (source instanceof ArrayBuffer || source instanceof Uint8Array) { + source = array(source); + } else { + source = stream(source); + } + return Promise.resolve(source).then(shp); +} + +function openDbf(source, options) { + var encoding = "windows-1252"; + if (options && options.encoding != null) encoding = options.encoding; + encoding = new TextDecoder(encoding); + if (typeof source === "string") { + if (!/\.dbf$/.test(source)) source += ".dbf"; + source = path(source, options); + } else if (source instanceof ArrayBuffer || source instanceof Uint8Array) { + source = array(source); + } else { + source = stream(source); + } + return Promise.resolve(source).then(function(source) { + return dbf(source, encoding); + }); +} + +function read(shp$$1, dbf$$1, options) { + return open(shp$$1, dbf$$1, options).then(function(source) { + var features = [], collection = {type: "FeatureCollection", features: features, bbox: source.bbox}; + return source.read().then(function read(result) { + if (result.done) return collection; + features.push(result.value); + return source.read().then(read); + }); + }); +} + +exports.open = open; +exports.openShp = openShp; +exports.openDbf = openDbf; +exports.read = read; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); \ No newline at end of file diff --git a/resources/shapefiles/south_sorvilier.dbf b/resources/shapefiles/south_sorvilier.dbf new file mode 100644 index 0000000000000000000000000000000000000000..d8d8f359248e19039832f4056153dcfb0a2570db GIT binary patch literal 20751 zcmeI3QES^U6opd;8w~azf}i`~$hK^6Y*6~VJ?%ZHwi0Wzr69}A+`m2;ladBX>Oqqf zhOOfVC(^yT=zKCh4p!cDS8w0XX0w~C-|y_lvqQDbQk1*yTX+6*lp$HeAG-$Ql~`9> z*1MF!_?8*2_X&e>#)-$Cr@mhZ9_oknd${P33<4nF2zYP(B+lcU&>WWo2!H?xfB*>iK>*gD<}{-5 z!jI)XQu$po+5YJ4*~d5Dg_5n&U15ZhM_|wd0T2LzDH8~Tr#Hah^OvAeM!Btf!F8Y{ zcVBF0&s*EpeB~N93u+ri)%77XUP2@yS(s!=GF}N6%>1_Ejga$_&%Y{Z)WZd(MmV&S zMa|k)tOPGdIDJeR1V8`;&Lt29ccSQvnjc*J+CB?3o0|U;rvF&jQ^B;0328U;H@p;f zQ@=I--I&Mc0;z0A+vyc6c4gL@-SherYd00EjeAOP`>9O7IYdiNZ0}Z-rgEjD;N00? zK90nMrfEXc%S)lc$OzzF|Hu{$(**$#cr60qfG;Qi(TZP7*Gua}QMO3KJcjkZl-P9g z@aMkitR<9y00^8!!1s6k5lsmtG0je*hU6&_*f3K~K?gK|00@A5oD~O`Q6@*0Y_yd3WA#`<>_a{GQAEyst>)Xet_W8JTt)iA4B` z+^2Y$SdZB8eyh(NE0J-0ZGV&6-@u+X3pz9Tgp%XObpQWP13(4Sny|jLZZ5Qr^x=3$9RJT($X(>#_tq1>A67)wT!e3WV(j5c;L<}EPX6?U zuQKMRi=Gx~+oznWGln)~4Y9AVJnrppI~gFd=MzlbhTUKj*2MC#z-H?(H!c4*xKwY^ zUF(I{fIY*wjw+txqn*Mq~UJB`ztdKr2>acJ~-VT?5eGm!0ukNX9>$!7G5(i3)r`~ za(z3nwamLSo5lCcjIqJ_##-ctB_UtxO;VT4SB!el64pW|_W9Daqozdf4CqWElXrjp z25r_y)^xVWM(0Jo#06y>wuI?sJ{+2558ahKpm{s~z5+&wE0J!ZO$%$AUA zRT0vr1~+Y=fuA|J5wHHV)&XaDm7lI2LkkjYed9`#O7$DI<+9?O#z#g>q}w0TYc9QX!(d?4+C?_y)K!9~Dc z-6dOGkyrGxk!?!gf==i7IN$_vaW}hz$0rR*@_>c05W)m|w14y#9Cpfu-Z11i5qorgqMOtDY{4ZPaRc5+pB4VglkNj?$wplAg(iEONACl@ w!Jz|j@t2{~VkxiKia4PMTiz?sJ61p42O(D&r`M_caR_{C^Y71RZ>~`5FAO65_5c6? literal 0 HcmV?d00001 diff --git a/src/Annotation.js b/src/Annotation.js index d736f48a..360364ce 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -224,10 +224,13 @@ Potree.Annotation = class extends THREE.EventDispatcher{ if(!this.hasView()){ return; } - + + let view = this.scene.view; + var animationDuration = 800; var easing = TWEEN.Easing.Quartic.Out; + let endTarget; if(this.cameraTarget){ endTarget = this.cameraTarget; @@ -236,37 +239,61 @@ Potree.Annotation = class extends THREE.EventDispatcher{ }else{ endTarget = this.boundingBox.getCenter(); } - let endPosition = this.cameraPosition; - if(!endPosition){ - let direction = this.scene.view.direction; - endPosition = endTarget.clone().add(direction.multiplyScalar(-this.radius)); - } - - { // animate camera position - let tween = new TWEEN.Tween(this.scene.view.position).to(endPosition, animationDuration); - tween.easing(easing); - tween.start(); - } - { // animate camera target - var camTargetDistance = camera.position.distanceTo(endTarget); - var target = new THREE.Vector3().addVectors( - camera.position, - camera.getWorldDirection().clone().multiplyScalar(camTargetDistance) - ); - var tween = new TWEEN.Tween(target).to(endTarget, animationDuration); - tween.easing(easing); - tween.onUpdate(() => { - this.scene.view.lookAt(target); - }); - tween.onComplete(() => { - this.scene.view.lookAt(target); - this.dispatchEvent({type: "focusing_finished", target: this}); - }); + if(this.cameraPosition){ + + let endPosition = this.cameraPosition; + + { // animate camera position + let tween = new TWEEN.Tween(view.position).to(endPosition, animationDuration); + tween.easing(easing); + tween.start(); + } + + { // animate camera target + var camTargetDistance = camera.position.distanceTo(endTarget); + var target = new THREE.Vector3().addVectors( + camera.position, + camera.getWorldDirection().clone().multiplyScalar(camTargetDistance) + ); + var tween = new TWEEN.Tween(target).to(endTarget, animationDuration); + tween.easing(easing); + tween.onUpdate(() => { + view.lookAt(target); + }); + tween.onComplete(() => { + view.lookAt(target); + this.dispatchEvent({type: "focusing_finished", target: this}); + }); + + this.dispatchEvent({type: "focusing_started", target: this}); + tween.start(); + } + }else if(this.radius){ + let direction = view.direction; + let endPosition = endTarget.clone().add(direction.multiplyScalar(-this.radius)); + let startRadius = view.radius; + let endRadius = this.radius; + + { // animate camera position + let tween = new TWEEN.Tween(view.position).to(endPosition, animationDuration); + tween.easing(easing); + tween.start(); + } + + { // animate radius + let t = {x: 0}; + + let tween = new TWEEN.Tween(t) + .to({x: 1}, animationDuration) + .onUpdate(function(){ + view.radius = this.x * endRadius + (1 - this.x) * startRadius; + }); + tween.easing(easing); + tween.start(); + } + } - - this.dispatchEvent({type: "focusing_started", target: this}); - tween.start(); }; dispose(){ diff --git a/src/PointCloudOctree.js b/src/PointCloudOctree.js index 394b805a..a5c80261 100644 --- a/src/PointCloudOctree.js +++ b/src/PointCloudOctree.js @@ -98,7 +98,12 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ toTreeNode(geometryNode, parent){ var node = new Potree.PointCloudOctreeNode(); + + //if(geometryNode.name === "r40206"){ + // console.log("creating node for r40206"); + //} var sceneNode = new THREE.Points(geometryNode.geometry, this.material); + sceneNode.name = geometryNode.name; node.geometryNode = geometryNode; node.sceneNode = sceneNode; @@ -857,6 +862,8 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ gl.enableVertexAttribArray( apIndices ); } + //renderer.resetGLState(); + for(let i = 0; i < nodes.length; i++){ let node = nodes[i]; let object = node.sceneNode; @@ -900,9 +907,10 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ gl.uniform1f(uniforms["pcIndex"], pickMaterial.pcIndex); - let numPoints = node.getNumPoints(); + //let numPoints = node.getNumPoints(); + let numPoints = geometry.attributes.position.count; if(numPoints > 0){ - gl.drawArrays( gl.POINTS, 0, node.getNumPoints()); + gl.drawArrays( gl.POINTS, 0, numPoints); } // TODO hack @@ -929,7 +937,7 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree{ // renderer.context.readPixels( 0, 0, width, height, // renderer.context.RGBA, renderer.context.UNSIGNED_BYTE, bp); // - // var img = pixelsArrayToImage(bp, width, height); + // var img = Potree.utils.pixelsArrayToImage(bp, width, height); // var screenshot = img.src; // // var w = window.open(); diff --git a/src/Potree.js b/src/Potree.js index 841ea5f2..a7975d19 100644 --- a/src/Potree.js +++ b/src/Potree.js @@ -375,6 +375,21 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){ unloadedGeometry[i].load(); } + for(let node of visibleNodes){ + //let allowedNodes = ["r", "r0", "r4", "r04", "r40", "r402", "r4020", "r4022", "r40206", "r40224", "r40202", "r40220", "r00", "r042"]; + //let allowedNodes = ["r", "r0", "r4", "r04", "r40", "r402", "r4020", "r4022", "r00", "r042"]; + //let allowedNodes = ["r", "r0", "r04", "r042"]; + let allowedNodes = ["r", "r4", "r40", "r402", "r4020", "r40206"]; + //let allowedNodes = ["r", "r4", "r40", "r402", "r4020"]; + 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 { diff --git a/src/loader/GreyhoundLoader.js b/src/loader/GreyhoundLoader.js index 223adca0..32cfb9f6 100644 --- a/src/loader/GreyhoundLoader.js +++ b/src/loader/GreyhoundLoader.js @@ -5,131 +5,136 @@ * @author Oscar Martinez Rubi * @author Connor Manning */ -var getQueryParam = function(name) { - name = name.replace(/[\[\]]/g, "\\$&"); - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), - results = regex.exec(window.location.href); - if (!results) return null; - if (!results[2]) return ''; - return decodeURIComponent(results[2].replace(/\+/g, " ")); -} + +class GreyhoundUtils{ + + static getQueryParam(name) { + name = name.replace(/[\[\]]/g, "\\$&"); + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), + results = regex.exec(window.location.href); + if (!results) return null; + if (!results[2]) return ''; + return decodeURIComponent(results[2].replace(/\+/g, " ")); + } + + static createSchema(attributes) { + var schema = [ + { "name": "X", "size": 4, "type": "signed" }, + { "name": "Y", "size": 4, "type": "signed" }, + { "name": "Z", "size": 4, "type": "signed" } + ]; + + // Once we include options in the UI to load a dynamic list of available + // attributes for visualization (f.e. Classification, Intensity etc.) + // we will be able to ask for that specific attribute from the server, + // where we are now requesting all attributes for all points all the time. + // If we do that though, we also need to tell Potree to redraw the points + // that are already loaded (with different attributes). + // This is not default behaviour. + attributes.forEach(function(item) { + if(item === 'COLOR_PACKED') { + schema.push({ "name": "Red", "size": 2, "type": "unsigned" }); + schema.push({ "name": "Green", "size": 2, "type": "unsigned" }); + schema.push({ "name": "Blue", "size": 2, "type": "unsigned" }); + } else if(item === 'INTENSITY'){ + schema.push({ "name": "Intensity", "size": 2, "type": "unsigned" }); + } else if(item === 'CLASSIFICATION') { + schema.push( + { "name": "Classification", "size": 1, "type": "unsigned" }); + } + }); + + return schema; + } + + static fetch(url, cb) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200 || xhr.status === 0) { + cb(null, xhr.responseText); + } + else { + cb(xhr.responseText); + } + } + }; + xhr.send(null); + }; + + static fetchBinary(url, cb) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200 || xhr.status === 0) { + cb(null, xhr.response); + } + else { + cb(xhr.responseText); + } + } + }; + xhr.send(null); + }; + + static pointSizeFrom(schema) { + return schema.reduce((p, c) => p + c.size, 0); + }; + + static getNormalization(serverURL, baseDepth, cb) { + var s = [ + { "name": "X", "size": 4, "type": "floating" }, + { "name": "Y", "size": 4, "type": "floating" }, + { "name": "Z", "size": 4, "type": "floating" }, + { "name": "Red", "size": 2, "type": "unsigned" }, + { "name": "Green", "size": 2, "type": "unsigned" }, + { "name": "Blue", "size": 2, "type": "unsigned" }, + { "name": "Intensity", "size": 2, "type": "unsigned" } + ]; + + var url = serverURL + 'read?depth=' + baseDepth + + '&schema=' + JSON.stringify(s); + + GreyhoundUtils.fetchBinary(url, function(err, buffer) { + if (err) throw new Error(err); + + var view = new DataView(buffer); + var numBytes = buffer.byteLength - 4; + var numPoints = view.getUint32(numBytes, true); + var pointSize = GreyhoundUtils.pointSizeFrom(s); + + var colorNorm = false, intensityNorm = false; + var v; + + for (var offset = 0; offset < numBytes; offset += pointSize) { + if (view.getUint16(offset + 12, true) > 255 || + view.getUint16(offset + 14, true) > 255 || + view.getUint16(offset + 16, true) > 255) { + colorNorm = true; + } + + if (view.getUint16(18, true) > 255) { + intensityNorm = true; + } + + if (colorNorm && intensityNorm) break; + } + + if (colorNorm) console.log('Normalizing color'); + if (intensityNorm) console.log('Normalizing intensity'); + + cb(null, { color: colorNorm, intensity: intensityNorm }); + }); + }; + +}; Potree.GreyhoundLoader = function() { }; Potree.GreyhoundLoader.loadInfoJSON = function load(url, callback) { } -var createSchema = function(attributes) { - var schema = [ - { "name": "X", "size": 4, "type": "signed" }, - { "name": "Y", "size": 4, "type": "signed" }, - { "name": "Z", "size": 4, "type": "signed" } - ]; - - // Once we include options in the UI to load a dynamic list of available - // attributes for visualization (f.e. Classification, Intensity etc.) - // we will be able to ask for that specific attribute from the server, - // where we are now requesting all attributes for all points all the time. - // If we do that though, we also need to tell Potree to redraw the points - // that are already loaded (with different attributes). - // This is not default behaviour. - attributes.forEach(function(item) { - if(item === 'COLOR_PACKED') { - schema.push({ "name": "Red", "size": 2, "type": "unsigned" }); - schema.push({ "name": "Green", "size": 2, "type": "unsigned" }); - schema.push({ "name": "Blue", "size": 2, "type": "unsigned" }); - } else if(item === 'INTENSITY'){ - schema.push({ "name": "Intensity", "size": 2, "type": "unsigned" }); - } else if(item === 'CLASSIFICATION') { - schema.push( - { "name": "Classification", "size": 1, "type": "unsigned" }); - } - }); - - return schema; -} - -var fetch = function(url, cb) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.onreadystatechange = function() { - if (xhr.readyState === 4) { - if (xhr.status === 200 || xhr.status === 0) { - cb(null, xhr.responseText); - } - else { - cb(xhr.responseText); - } - } - }; - xhr.send(null); -}; - -var fetchBinary = function(url, cb) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'arraybuffer'; - xhr.onreadystatechange = function() { - if (xhr.readyState === 4) { - if (xhr.status === 200 || xhr.status === 0) { - cb(null, xhr.response); - } - else { - cb(xhr.responseText); - } - } - }; - xhr.send(null); -}; - -var pointSizeFrom = function(schema) { - return schema.reduce((p, c) => p + c.size, 0); -}; - -var getNormalization = function(serverURL, baseDepth, cb) { - var s = [ - { "name": "X", "size": 4, "type": "floating" }, - { "name": "Y", "size": 4, "type": "floating" }, - { "name": "Z", "size": 4, "type": "floating" }, - { "name": "Red", "size": 2, "type": "unsigned" }, - { "name": "Green", "size": 2, "type": "unsigned" }, - { "name": "Blue", "size": 2, "type": "unsigned" }, - { "name": "Intensity", "size": 2, "type": "unsigned" } - ]; - - var url = serverURL + 'read?depth=' + baseDepth + - '&schema=' + JSON.stringify(s); - - fetchBinary(url, function(err, buffer) { - if (err) throw new Error(err); - - var view = new DataView(buffer); - var numBytes = buffer.byteLength - 4; - var numPoints = view.getUint32(numBytes, true); - var pointSize = pointSizeFrom(s); - - var colorNorm = false, intensityNorm = false; - var v; - - for (var offset = 0; offset < numBytes; offset += pointSize) { - if (view.getUint16(offset + 12, true) > 255 || - view.getUint16(offset + 14, true) > 255 || - view.getUint16(offset + 16, true) > 255) { - colorNorm = true; - } - - if (view.getUint16(18, true) > 255) { - intensityNorm = true; - } - - if (colorNorm && intensityNorm) break; - } - - if (colorNorm) console.log('Normalizing color'); - if (intensityNorm) console.log('Normalizing intensity'); - - cb(null, { color: colorNorm, intensity: intensityNorm }); - }); -}; - /** * @return a point cloud octree with the root node data loaded. * loading of descendants happens asynchronously when they're needed @@ -148,7 +153,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) { serverURL = 'http://' + serverURL; } - fetch(serverURL + 'info', function(err, data) { + GreyhoundUtils.fetch(serverURL + 'info', function(err, data) { if (err) throw new Error(err); /* We parse the result of the info query, which should be a JSON @@ -187,7 +192,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) { scale = Math.min(scale[0], scale[1], scale[2]); } - if (getQueryParam('scale')) { + if (GreyhoundUtils.getQueryParam('scale')) { scale = parseFloat(getQueryParam('scale')); } @@ -232,7 +237,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) { pgg.baseDepth = baseDepth; pgg.hierarchyStepSize = HIERARCHY_STEP_SIZE; - pgg.schema = createSchema(attributes); + pgg.schema = GreyhoundUtils.createSchema(attributes); var pointSize = pointSizeFrom(pgg.schema); pgg.pointAttributes = new Potree.PointAttributes(attributes); @@ -281,7 +286,7 @@ Potree.GreyhoundLoader.load = function load(url, callback) { pgg.nodes = nodes; - getNormalization(serverURL, greyhoundInfo.baseDepth, + GreyhoundUtils.getNormalization(serverURL, greyhoundInfo.baseDepth, function(err, normalize) { if (normalize.color) pgg.normalize.color = true; if (normalize.intensity) pgg.normalize.intensity = true; diff --git a/src/viewer/potree.css b/src/viewer/potree.css index 66c6a303..c781b958 100644 --- a/src/viewer/potree.css +++ b/src/viewer/potree.css @@ -89,7 +89,6 @@ #potree_sidebar_container a{ color: #8Aa1c4; - //color: red; } .potree_menu_toggle{ @@ -144,8 +143,6 @@ a:hover, a:visited, a:link, a:active{ } .annotation{ - //-webkit-transition: opacity .1s; - //transition: opacity .1s; position: absolute; padding: 10px; opacity: 0.5; @@ -158,14 +155,15 @@ a:hover, a:visited, a:link, a:active{ font-size: 1em; opacity: 1; margin: auto; - width: fit-content; + display: table; + /* width: fit-content; */ } .annotation-expand{ color: white; font-size: 0.6em; opacity: 1; - width: fit-content; + /* width: fit-content; */ } .annotation-action-icon{ @@ -206,22 +204,19 @@ a:hover, a:visited, a:link, a:active{ } .annotation-label{ - //position: relative; display: inline-block; height: 100%; flex-grow: 1; - //margin: 2px 8px; user-select: none; + -moz-user-select: none; z-index: 100; - width: fit-content; + /* width: fit-content; */ vertical-align: middle; line-height: 1.5em; - //text-align: center; font-family: Arial; font-weight: bold; padding: 1px 8px 0px 8px; cursor: default; - user-select: none; white-space: nowrap; } @@ -416,7 +411,7 @@ body{ } .ui-widget-content{ - background-color: none !important; + background-color: transparent !important; color: var(--font-color) !important; } @@ -488,22 +483,9 @@ body{ -/* no scrollbar styling in firefox, sadly */ -.navmenu::-webkit-scrollbar{ - height: 12px; -} - -.navmenu::-webkit-scrollbar-track{ - background: rgba(0, 0, 0, 0.1); -} - -.navmenu::-webkit-scrollbar-thumb{ - background: rgba(0, 0, 0, 0.5); -} - .pv-titlebar{ background-color: var(--color-1); - color: #var(--color-2); + color: var(--color-2); font-weight: 700; padding: 5px; } @@ -604,11 +586,11 @@ body{ border-radius: 100px; display: block; user-select: none; + -moz-user-select: none; } .hover_menu_icon{ position: absolute; - //border: 1px solid black; display: inline-block; width: 16px; height: 16px;
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - var value = parseInt(color[0]) - + ", " + parseInt(color[1]) - + ", " + parseInt(color[2]); - - elKey.html("rgb"); - elValue.html(value); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    rgb${text}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("intensity"); - elValue.html(intensity); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    intensity${intensity}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("classification"); - elValue.html(classification); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    classification${classification}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("return nr."); - elValue.html(returnNumber); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    return nr.${returnNumber}
    ').css("padding", "1px 5px"); - var elValue = $('').css("width", "100%").css("padding", "1px 5px"); - - elKey.html("source"); - elValue.html(source); - - elTable.append(elTr); - elTr.append(elKey); - elTr.append(elValue); + elTable.append($(` +
    source${source}