From 9cb302d395f5c9d7dfd928339f8dfd8ea7f381f2 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Thu, 9 Mar 2017 13:19:48 +0100 Subject: [PATCH] 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;