annotations now accept [x, y, z] additionally to THREE.Vector3(x, y, z)

This commit is contained in:
mschuetz 2017-02-11 23:17:42 +01:00
parent 7992f12f54
commit 6cc83dad28
5 changed files with 28 additions and 22 deletions

View File

@ -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

View File

@ -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. <br>
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": `<ul><li>Click on the annotation label to move a predefined view.</li>
<li>Click on the icon to execute the specified action.</li>
In this case, the action will bring you to another scene and point cloud.</ul>`,
@ -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",

View File

@ -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);

View File

@ -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;

View File

@ -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;