From 6cc83dad28a1120152cdfd463bbed0275fdc5793 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Sat, 11 Feb 2017 23:17:42 +0100 Subject: [PATCH] annotations now accept [x, y, z] additionally to THREE.Vector3(x, y, z) --- README.md | 11 +++++------ examples/annotations.html | 24 ++++++++++++------------ examples/viewer.html | 2 +- src/Annotation.js | 6 ++++-- src/viewer/viewer.js | 7 ++++++- 5 files changed, 28 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 70b0e405..791d78ad 100644 --- a/README.md +++ b/README.md @@ -37,12 +37,11 @@ Take a look at the [potree showcase](http://potree.org/wp/demo/) for some live e | Browser | OS | Result | | -------------------- |:-------:|:-------------:| -| Chrome 42 | Win7 | works | -| Firefox 34 | Win7 | works | -| Internet Explorer 11 | Win7 | partially works; performance issues | -| Firefox | Android | partially works, GUI and stability issues | -| Opera | Android | partially works, GUI and stability issues and slow | -| Chrome | Android | works | +| Chrome 56 | Win7 | works | +| Firefox 51 | Win7 | works | +| Internet Explorer 11 | Win7 | not supported | +| Chrome | Android | works | +| Opera | Android | not supported | ## Credits diff --git a/examples/annotations.html b/examples/annotations.html index c20844ca..32336f18 100644 --- a/examples/annotations.html +++ b/examples/annotations.html @@ -88,22 +88,22 @@ sceneSG.view.position.set(590030, 231767, 1007); sceneSG.view.lookAt(new THREE.Vector3(589844, 231376, 710)); - sceneSG.addAnnotation(new THREE.Vector3(589847.17, 231436.78, 892.60), { - "title": "Sorvilier", - "cameraPosition": new THREE.Vector3(590034.03, 231814.02, 961.68), - "cameraTarget": new THREE.Vector3(589847.17, 231436.78, 742.60) + sceneSG.addAnnotation([589847.17, 231436.78, 892.60], { + "cameraPosition": [590034.03, 231814.02, 961.68], + "cameraTarget": [589847.17, 231436.78, 742.60], + "title": "Sorvilier" }); - sceneSG.addAnnotation(new THREE.Vector3(589850.15, 231300.10, 770.94), { + sceneSG.addAnnotation([589850.15, 231300.10, 770.94], { "title": "Trees", "description": `Point cloud of a small section in Sorvilier, Switzerland.
Courtesy of sigeom.sa` }); - sceneSG.addAnnotation(new THREE.Vector3(590043.63, 231490.79, 740.78), { + sceneSG.addAnnotation([590043.63, 231490.79, 740.78], { "title": "About Annotations", - "cameraPosition": new THREE.Vector3(590105.53, 231541.63, 782.05), - "cameraTarget": new THREE.Vector3(590043.63, 231488.79, 740.78), + "cameraPosition": [590105.53, 231541.63, 782.05], + "cameraTarget": [590043.63, 231488.79, 740.78], "description": ``, @@ -115,10 +115,10 @@ }] }); - sceneSG.addAnnotation(new THREE.Vector3(589621, 231437, 784), { + sceneSG.addAnnotation([589621, 231437, 784], { + "cameraPosition": [589585.81, 231463.63, 804.00], + "cameraTarget": [589625.86, 231439, 775.38], "title": "About Annotations 2", - "cameraPosition": new THREE.Vector3(589585.81, 231463.63, 804.00), - "cameraTarget": new THREE.Vector3(589625.86, 231439, 775.38), "description": ` Suitable annotation positions and views can be obtained by looking up the current camera position and target in the "Scene" panel, @@ -136,7 +136,7 @@ sceneLion.view.position.set(4.15, -6.12, 8.54); sceneLion.view.lookAt(new THREE.Vector3(0, -0.098, 4.23)); - sceneLion.addAnnotation(new THREE.Vector3(0.72, -1, 8), { + sceneLion.addAnnotation([0.72, -1, 8], { "title": "Chinese Guardian Lion", "actions": [{ "icon": Potree.resourcePath + "/icons/goto.svg", diff --git a/examples/viewer.html b/examples/viewer.html index 53e82d62..5cf6db45 100644 --- a/examples/viewer.html +++ b/examples/viewer.html @@ -79,7 +79,7 @@ }); // Sigeom - Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "sigeom.sa", function(e){ + Potree.loadPointCloud("../pointclouds/vol_total/cloud.js", "sigeom.sa", e => { let scene = viewer.scene; scene.addPointCloud(e.pointcloud); diff --git a/src/Annotation.js b/src/Annotation.js index e955b2cb..d0be579e 100644 --- a/src/Annotation.js +++ b/src/Annotation.js @@ -8,8 +8,10 @@ Potree.Annotation = function(scene, args = {}){ this.title = args.title || "No Title"; this.description = args.description || ""; this.position = args.position || new THREE.Vector3(0,0,0); - this.cameraPosition = args.cameraPosition; - this.cameraTarget = args.cameraTarget; + this.cameraPosition = (args.cameraPosition instanceof Array) ? + new THREE.Vector3().fromArray(args.cameraPosition) : args.cameraPosition; + this.cameraTarget = (args.cameraTarget instanceof Array) ? + new THREE.Vector3().fromArray(args.cameraTarget) : args.cameraTarget; this.view = args.view || null; this.keepOpen = false; this.descriptionVisible = false; diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 4ab7ce70..57ca8120 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -300,7 +300,12 @@ Potree.Scene = class extends THREE.EventDispatcher{ } addAnnotation(position, args = {}){ - args.position = position; + 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;