diff --git a/examples/animation_paths.html b/examples/animation_paths.html index 318e1545..c9727ac4 100644 --- a/examples/animation_paths.html +++ b/examples/animation_paths.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/annotation_hierarchy.html b/examples/annotation_hierarchy.html index 41614909..2c875d50 100644 --- a/examples/annotation_hierarchy.html +++ b/examples/annotation_hierarchy.html @@ -36,7 +36,7 @@
-
+
diff --git a/examples/annotations.html b/examples/annotations.html index 85f374c9..1627ba64 100644 --- a/examples/annotations.html +++ b/examples/annotations.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/arena4d.html b/examples/arena4d.html index beea5bfa..d65b0ffd 100644 --- a/examples/arena4d.html +++ b/examples/arena4d.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/ca13.html b/examples/ca13.html index 3ce5a97c..0eb74b9a 100644 --- a/examples/ca13.html +++ b/examples/ca13.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/camera_animation.html b/examples/camera_animation.html index 874370f4..3775c5d0 100644 --- a/examples/camera_animation.html +++ b/examples/camera_animation.html @@ -31,7 +31,7 @@
-
+
diff --git a/examples/cesium_ca13.html b/examples/cesium_ca13.html index 592dd74b..3ae10bdb 100644 --- a/examples/cesium_ca13.html +++ b/examples/cesium_ca13.html @@ -38,7 +38,7 @@
-
+
diff --git a/examples/cesium_retz.html b/examples/cesium_retz.html index 46cb2c3b..9f6584d5 100644 --- a/examples/cesium_retz.html +++ b/examples/cesium_retz.html @@ -37,7 +37,7 @@
-
+
diff --git a/examples/cesium_sorvilier.html b/examples/cesium_sorvilier.html index 452b8ab0..c5cf18c4 100644 --- a/examples/cesium_sorvilier.html +++ b/examples/cesium_sorvilier.html @@ -37,7 +37,7 @@
-
+
diff --git a/examples/classifications.html b/examples/classifications.html index 4ebcd646..92da9bb7 100644 --- a/examples/classifications.html +++ b/examples/classifications.html @@ -62,7 +62,6 @@ viewer.setEDLEnabled(true); viewer.setFOV(60); viewer.setPointBudget(2 * 1000 * 1000); - viewer.setPointBudget(1000); viewer.loadGUI(() => { $("#menu_filters").next().show(); diff --git a/examples/clipping_volume.html b/examples/clipping_volume.html index 0c3ea2c0..10349bb3 100644 --- a/examples/clipping_volume.html +++ b/examples/clipping_volume.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/custom_sidebar_section.html b/examples/custom_sidebar_section.html index 83373b25..88d9d2f3 100644 --- a/examples/custom_sidebar_section.html +++ b/examples/custom_sidebar_section.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/deviceorientation.html b/examples/deviceorientation.html index 8e629ed3..5168316e 100644 --- a/examples/deviceorientation.html +++ b/examples/deviceorientation.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/elevation_profile.html b/examples/elevation_profile.html index 871a7a37..a32e56b9 100644 --- a/examples/elevation_profile.html +++ b/examples/elevation_profile.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/ept.html b/examples/ept.html index f4161d00..d66214f0 100644 --- a/examples/ept.html +++ b/examples/ept.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/ept_binary.html b/examples/ept_binary.html index 76cd3db0..92f82413 100644 --- a/examples/ept_binary.html +++ b/examples/ept_binary.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/ept_zstandard.html b/examples/ept_zstandard.html index fcf9972e..7375fac0 100644 --- a/examples/ept_zstandard.html +++ b/examples/ept_zstandard.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/features_ca13.html b/examples/features_ca13.html index 97d9a00f..881869a3 100644 --- a/examples/features_ca13.html +++ b/examples/features_ca13.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/features_sorvilier.html b/examples/features_sorvilier.html index 3abe8b11..c30c2f35 100644 --- a/examples/features_sorvilier.html +++ b/examples/features_sorvilier.html @@ -36,7 +36,7 @@
-
+
diff --git a/examples/gradient_colors.html b/examples/gradient_colors.html index facf2653..5a1f5f37 100644 --- a/examples/gradient_colors.html +++ b/examples/gradient_colors.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/heidentor.html b/examples/heidentor.html index 757335a5..eaf491b9 100644 --- a/examples/heidentor.html +++ b/examples/heidentor.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/light.html b/examples/light.html index 9417cfc5..4aa17392 100644 --- a/examples/light.html +++ b/examples/light.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/light_animated.html b/examples/light_animated.html index 156220cf..6ef3ccd0 100644 --- a/examples/light_animated.html +++ b/examples/light_animated.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/light_ca13.html b/examples/light_ca13.html index bc760263..765d3a07 100644 --- a/examples/light_ca13.html +++ b/examples/light_ca13.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/lines.html b/examples/lines.html index 8c361023..7ab82db7 100644 --- a/examples/lines.html +++ b/examples/lines.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/lion.html b/examples/lion.html index c6613386..a7cc2030 100644 --- a/examples/lion.html +++ b/examples/lion.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/lion_las.html b/examples/lion_las.html index 2f5328f5..477e799a 100644 --- a/examples/lion_las.html +++ b/examples/lion_las.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/lion_laz.html b/examples/lion_laz.html index 686646c3..9d23472e 100644 --- a/examples/lion_laz.html +++ b/examples/lion_laz.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/load_project.html b/examples/load_project.html new file mode 100644 index 00000000..7f147434 --- /dev/null +++ b/examples/load_project.html @@ -0,0 +1,57 @@ + + + + + + + + Potree Viewer + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+ + + + + + diff --git a/examples/matcap.html b/examples/matcap.html index 06ff8a91..9cc6f4a1 100644 --- a/examples/matcap.html +++ b/examples/matcap.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/measurements.html b/examples/measurements.html index 13c5afdb..98d3b219 100644 --- a/examples/measurements.html +++ b/examples/measurements.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/meshes.html b/examples/meshes.html index 01d9e8d0..b8f86c5e 100644 --- a/examples/meshes.html +++ b/examples/meshes.html @@ -36,7 +36,7 @@
-
+
diff --git a/examples/multiple_pointclouds.html b/examples/multiple_pointclouds.html index 1f062d62..dce44e18 100644 --- a/examples/multiple_pointclouds.html +++ b/examples/multiple_pointclouds.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/oriented_images.html b/examples/oriented_images.html index fdfdceb3..60345efa 100644 --- a/examples/oriented_images.html +++ b/examples/oriented_images.html @@ -32,7 +32,7 @@
-
+
diff --git a/examples/resources/sorvilier.json b/examples/resources/sorvilier.json new file mode 100644 index 00000000..9f194891 --- /dev/null +++ b/examples/resources/sorvilier.json @@ -0,0 +1,508 @@ +{ + "type": "Potree", + "version": 1.7, + "settings": { + "pointBudget": 1000000, + "fov": 60, + "edlEnabled": true, + "edlRadius": 1.4, + "edlStrength": 0.4, + "background": "gradient", + "minNodeSize": 30, + "showBoundingBoxes": false + }, + "view": { + "position": [ + 589974.341, + 231698.397, + 986.146 + ], + "target": [ + 589851.587, + 231428.213, + 715.634 + ] + }, + "classification": { + "0": { + "visible": true, + "name": "never classified", + "color": [ + 0.5, + 0.5, + 0.5, + 1 + ] + }, + "1": { + "visible": true, + "name": "unclassified", + "color": [ + 0.5, + 0.5, + 0.5, + 1 + ] + }, + "2": { + "visible": true, + "name": "ground", + "color": [ + 0.63, + 0.32, + 0.18, + 1 + ] + }, + "3": { + "visible": true, + "name": "low vegetation", + "color": [ + 0, + 1, + 0, + 1 + ] + }, + "4": { + "visible": true, + "name": "medium vegetation", + "color": [ + 0, + 0.8, + 0, + 1 + ] + }, + "5": { + "visible": true, + "name": "high vegetation", + "color": [ + 0, + 0.6, + 0, + 1 + ] + }, + "6": { + "visible": true, + "name": "building", + "color": [ + 1, + 0.66, + 0, + 1 + ] + }, + "7": { + "visible": true, + "name": "low point(noise)", + "color": [ + 1, + 0, + 1, + 1 + ] + }, + "8": { + "visible": true, + "name": "key-point", + "color": [ + 1, + 0, + 0, + 1 + ] + }, + "9": { + "visible": true, + "name": "water", + "color": [ + 0, + 0, + 1, + 1 + ] + }, + "12": { + "visible": true, + "name": "overlap", + "color": [ + 1, + 1, + 0, + 1 + ] + }, + "DEFAULT": { + "visible": true, + "name": "default", + "color": [ + 0.3, + 0.6, + 0.6, + 0.5 + ] + } + }, + "pointclouds": [ + { + "name": "sigeom.sa", + "url": "../pointclouds/vol_total/cloud.js", + "position": [ + 589500, + 231300, + 722.505 + ], + "rotation": [ + 0, + 0, + 0, + "XYZ" + ], + "scale": [ + 1, + 1, + 1 + ], + "activeAttributeName": "RGBA" + } + ], + "measurements": [ + { + "uuid": "CCFEDDB1-7CEE-4B2C-BBFD-64405DED63C3", + "name": "Measure_0", + "points": [ + [ + 589803.18, + 231357.35, + 745.38 + ], + [ + 589795.74, + 231323.42, + 746.21 + ], + [ + 589822.5, + 231315.9, + 744.45 + ] + ], + "showDistances": true, + "showCoordinates": false, + "showArea": false, + "closed": false, + "showAngles": false, + "showHeight": false, + "color": [ + 1, + 0, + 0 + ] + }, + { + "uuid": "92086379-896A-4608-9584-855A04B915D0", + "name": "Angle Sample", + "points": [ + [ + 589866.11, + 231372.25, + 737.41 + ], + [ + 589842.15, + 231366.82, + 743.61 + ], + [ + 589860.61, + 231348.01, + 740.33 + ] + ], + "showDistances": false, + "showCoordinates": false, + "showArea": false, + "closed": true, + "showAngles": true, + "showHeight": false, + "color": [ + 1, + 0, + 0 + ] + }, + { + "uuid": "D62705BF-C151-49FD-991B-9CEFD223FAFB", + "name": "Canopy", + "points": [ + [ + 589853.73, + 231300.24, + 775.48 + ] + ], + "showDistances": false, + "showCoordinates": true, + "showArea": false, + "closed": true, + "showAngles": false, + "showHeight": false, + "color": [ + 1, + 0, + 0 + ] + }, + { + "uuid": "19D13159-B509-4CB0-8CA2-A58FB60B6D50", + "name": "Tree Height", + "points": [ + [ + 589849.69, + 231327.26, + 766.32 + ], + [ + 589840.96, + 231329.53, + 744.52 + ] + ], + "showDistances": false, + "showCoordinates": false, + "showArea": false, + "closed": false, + "showAngles": false, + "showHeight": true, + "color": [ + 1, + 0, + 0 + ] + }, + { + "uuid": "E46A0D60-EA59-4589-88AA-788DE0A91DF4", + "name": "Area", + "points": [ + [ + 589899.37, + 231300.16, + 750.25 + ], + [ + 589874.6, + 231326.06, + 743.4 + ], + [ + 589911.61, + 231352.57, + 743.58 + ], + [ + 589943.5, + 231300.08, + 754.62 + ] + ], + "showDistances": true, + "showCoordinates": false, + "showArea": true, + "closed": true, + "showAngles": false, + "showHeight": false, + "color": [ + 1, + 0, + 0 + ] + } + ], + "volumes": [ + { + "uuid": "1A553B0B-D35B-4B26-84BD-F8CFD287A200", + "type": "BoxVolume", + "name": "Test Volume", + "position": [ + 589688.5173246722, + 231341.79786558595, + 792.7726157084892 + ], + "rotation": [ + 0, + 0, + 0.6338484063020134, + "XYZ" + ], + "scale": [ + 87.70990081104037, + 65.01472874807978, + 95.53770288101325 + ], + "visible": true, + "clip": true + } + ], + "cameraAnimations": [], + "profiles": [ + { + "uuid": "C08F6835-4E6E-47BB-8D13-7428BAEA48CE", + "name": "Profile_0", + "points": [ + [ + 589641.6098756103, + 231453.76974998094, + 760.4950016784668 + ], + [ + 589514.4799995422, + 231309.46000003815, + 775.6249989318848 + ], + [ + 589512.4600000381, + 231504.9597490845, + 764.6350010681152 + ] + ], + "height": 20, + "width": 6 + } + ], + "annotations": { + "items": [ + { + "uuid": "96E6ECB5-BED1-4903-B8C9-252AC78E864D", + "title": "Sorvilier", + "description": "", + "position": [ + 589847.17, + 231436.78, + 892.6 + ], + "offset": [ + 0, + 0, + 0 + ], + "cameraPosition": [ + 590034.03, + 231814.02, + 961.68 + ] + }, + { + "uuid": "D94E1D0B-7AA5-46FB-A513-A42282D3BD18", + "title": "Trees", + "description": "Point cloud of a small section in Sorvilier, Switzerland.
\n\t\t\t\tCourtesy of sigeom.sa", + "position": [ + 589850.15, + 231300.1, + 770.94 + ], + "offset": [ + 0, + 0, + 0 + ] + }, + { + "uuid": "8B6543FC-64CA-4FD6-9C8D-ACE446D4A711", + "title": "About Annotations", + "description": "
  • Click on the annotation label to move a predefined view.
  • \n\t\t\t\t
  • Click on the icon to execute the specified action.
  • \n\t\t\t\tIn this case, the action will bring you to another scene and point cloud.
", + "position": [ + 590043.63, + 231490.79, + 740.78 + ], + "offset": [ + 0, + 0, + 0 + ], + "cameraPosition": [ + 590105.53, + 231541.63, + 782.05 + ] + }, + { + "uuid": "EE329482-3EF6-448C-A12B-46BF95143F79", + "title": "About Annotations 2", + "description": "\n\t\t\t\tSuitable annotation positions and views can be obtained by \n\t\t\t\tlooking up the current camera position and target in the \"Scene\" panel, \n\t\t\t\tor by evaluating following lines in your browser's developer console:

\n\t\t\t\tviewer.scene.view.position
\n\t\t\t\tviewer.scene.view.getPivot()
\n\t\t\t\t", + "position": [ + 589621, + 231437, + 784 + ], + "offset": [ + 0, + 0, + 0 + ], + "cameraPosition": [ + 589585.81, + 231463.63, + 804 + ] + }, + { + "uuid": "B5B39D1C-7161-46DD-B3E0-F3FB41C32AB8", + "title": "About Annotations 1", + "description": "\n\t\t\t\tAnnotations mark and describe locations. \n\t\t\t\tThey can move users to a predefined location on click, \n\t\t\t\tand provide action buttons to offer easily accessible \n\t\t\t\tfunctionality at certain points of interest.\n\t\t\t\t", + "position": [ + 589980, + 231236.83, + 783.89 + ], + "offset": [ + 0, + 0, + 0 + ] + }, + { + "uuid": "8F6A7FC5-6BA0-4B48-9C06-2DE3063BC628", + "title": "About Annotations 2", + "description": "\n\t\t\t\tSuitable annotation positions and views can be obtained by \n\t\t\t\tlooking up the current camera position and target in the \"Scene\" panel, \n\t\t\t\tor by evaluating following lines in your browser's developer console:

\n\t\t\t\tviewer.scene.view.position
\n\t\t\t\tviewer.scene.view.getPivot()
\n\t\t\t\t", + "position": [ + 589880, + 231236.83, + 783.89 + ], + "offset": [ + 0, + 0, + 0 + ] + }, + { + "uuid": "E914DFBE-2C31-4100-B86F-97420B31B5C4", + "title": "Actions: ", + "description": "This annotation has actions that switch between elevation and color rendering modes.", + "position": [ + 589769.27, + 231236.83, + 783.89 + ], + "offset": [ + 0, + 0, + 0 + ] + } + ], + "hierarchy": { + "0": {}, + "1": {}, + "2": {}, + "3": {}, + "4": {}, + "5": {}, + "6": {} + } + }, + "objects": [] +} \ No newline at end of file diff --git a/examples/shapefiles.html b/examples/shapefiles.html index 77c11328..00f8d664 100644 --- a/examples/shapefiles.html +++ b/examples/shapefiles.html @@ -38,7 +38,7 @@
-
+
diff --git a/examples/viewer.html b/examples/viewer.html index 777593af..2d792938 100644 --- a/examples/viewer.html +++ b/examples/viewer.html @@ -34,7 +34,7 @@
-
+
diff --git a/examples/vr.html b/examples/vr.html index f15abe47..939605c7 100644 --- a/examples/vr.html +++ b/examples/vr.html @@ -38,7 +38,7 @@
-
+
diff --git a/examples/vr_dechen_cave.html b/examples/vr_dechen_cave.html index 06fbfc1c..4a627a77 100644 --- a/examples/vr_dechen_cave.html +++ b/examples/vr_dechen_cave.html @@ -38,7 +38,7 @@
-
+
diff --git a/examples/vr_heidentor.html b/examples/vr_heidentor.html index ab77a056..dbc1f7ed 100644 --- a/examples/vr_heidentor.html +++ b/examples/vr_heidentor.html @@ -38,7 +38,7 @@
-
+
diff --git a/src/Potree.js b/src/Potree.js index 0ee8a45b..6db6b0f9 100644 --- a/src/Potree.js +++ b/src/Potree.js @@ -53,10 +53,10 @@ export * from "./utils/Profile.js"; export * from "./utils/ProfileTool.js"; export * from "./utils/ScreenBoxSelectTool.js"; export * from "./utils/SpotLightHelper.js"; -export * from "./utils/toInterleavedBufferAttribute.js"; export * from "./utils/TransformationTool.js"; export * from "./utils/Volume.js"; export * from "./utils/VolumeTool.js"; +export * from "./utils/Compass.js"; export * from "./viewer/viewer.js"; export * from "./viewer/Scene.js"; diff --git a/src/materials/Gradients.js b/src/materials/Gradients.js index 396f8af6..520e87c6 100644 --- a/src/materials/Gradients.js +++ b/src/materials/Gradients.js @@ -36,15 +36,6 @@ // print(rgb) let Gradients = { - RAINBOW: [ - [0, new THREE.Color(0.278, 0, 0.714)], - [1 / 6, new THREE.Color(0, 0, 1)], - [2 / 6, new THREE.Color(0, 1, 1)], - [3 / 6, new THREE.Color(0, 1, 0)], - [4 / 6, new THREE.Color(1, 1, 0)], - [5 / 6, new THREE.Color(1, 0.64, 0)], - [1, new THREE.Color(1, 0, 0)] - ], // From chroma spectral http://gka.github.io/chroma.js/ SPECTRAL: [ [0, new THREE.Color(0.3686, 0.3098, 0.6353)], @@ -136,6 +127,15 @@ let Gradients = { [0.93, new THREE.Color(0.81608, 0.18462, 0.01809)], [1.00, new THREE.Color(0.66449, 0.08436, 0.00424)], ], + RAINBOW: [ + [0, new THREE.Color(0.278, 0, 0.714)], + [1 / 6, new THREE.Color(0, 0, 1)], + [2 / 6, new THREE.Color(0, 1, 1)], + [3 / 6, new THREE.Color(0, 1, 0)], + [4 / 6, new THREE.Color(1, 1, 0)], + [5 / 6, new THREE.Color(1, 0.64, 0)], + [1, new THREE.Color(1, 0, 0)] + ], CONTOUR: [ [0.00, new THREE.Color(0, 0, 0)], [0.03, new THREE.Color(0, 0, 0)], diff --git a/src/materials/shaders/pointcloud.vs b/src/materials/shaders/pointcloud.vs index fbc076cd..ccf50f02 100644 --- a/src/materials/shaders/pointcloud.vs +++ b/src/materials/shaders/pointcloud.vs @@ -814,23 +814,23 @@ void main() { // CLIPPING - // doClipping(); + doClipping(); - // #if defined(num_clipspheres) && num_clipspheres > 0 - // for(int i = 0; i < num_clipspheres; i++){ - // vec4 sphereLocal = uClipSpheres[i] * mvPosition; + #if defined(num_clipspheres) && num_clipspheres > 0 + for(int i = 0; i < num_clipspheres; i++){ + vec4 sphereLocal = uClipSpheres[i] * mvPosition; - // float distance = length(sphereLocal.xyz); + float distance = length(sphereLocal.xyz); - // if(distance < 1.0){ - // float w = distance; - // vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb; + if(distance < 1.0){ + float w = distance; + vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb; - // vColor = cGradient; - // //vColor = cGradient * 0.7 + vColor * 0.3; - // } - // } - // #endif + vColor = cGradient; + //vColor = cGradient * 0.7 + vColor * 0.3; + } + } + #endif #if defined(num_shadowmaps) && num_shadowmaps > 0 diff --git a/src/modules/CameraAnimation/CameraAnimation.js b/src/modules/CameraAnimation/CameraAnimation.js index 8e402207..9543e6ff 100644 --- a/src/modules/CameraAnimation/CameraAnimation.js +++ b/src/modules/CameraAnimation/CameraAnimation.js @@ -25,6 +25,8 @@ export class CameraAnimation extends EventDispatcher{ this.controlPoints = []; + this.uuid = THREE.Math.generateUUID(); + this.node = new THREE.Object3D(); this.node.name = "camera animation"; this.viewer.scene.scene.add(this.node); diff --git a/src/utils.js b/src/utils.js index e8fcbdbd..128768b8 100644 --- a/src/utils.js +++ b/src/utils.js @@ -911,7 +911,7 @@ export class Utils { const llP1 = transform.forward(p1.toArray()); const llP2 = transform.forward(p2.toArray()); const dir = [llP2[0] - llP1[0], llP2[1] - llP1[1]]; - const azimuth = -Math.atan2(dir[1], dir[0]) - Math.PI / 2; + const azimuth = Math.atan2(dir[1], dir[0]) - Math.PI / 2; return azimuth; }else{ @@ -948,6 +948,65 @@ export class Utils { }); } + static createSvgGradient(scheme){ + + // this is what we are creating: + // + // + // + // + // + // ... + // + // + // + // + // + // + + + const gradientId = `${Math.random()}_${Date.now()}`; + + const svgn = "http://www.w3.org/2000/svg"; + const svg = document.createElementNS(svgn, "svg"); + svg.setAttributeNS(null, "width", "2em"); + svg.setAttributeNS(null, "height", "3em"); + + { // + const defs = document.createElementNS(svgn, "defs"); + + const linearGradient = document.createElementNS(svgn, "linearGradient"); + linearGradient.setAttributeNS(null, "id", gradientId); + linearGradient.setAttributeNS(null, "gradientTransform", "rotate(90)"); + + for(let i = scheme.length - 1; i >= 0; i--){ + const stopVal = scheme[i]; + const percent = parseInt(100 - stopVal[0] * 100); + const [r, g, b] = stopVal[1].toArray().map(v => parseInt(v * 255)); + + const stop = document.createElementNS(svgn, "stop"); + stop.setAttributeNS(null, "offset", `${percent}%`); + stop.setAttributeNS(null, "stop-color", `rgb(${r}, ${g}, ${b})`); + + linearGradient.appendChild(stop); + } + + defs.appendChild(linearGradient); + svg.appendChild(defs); + } + + const rect = document.createElementNS(svgn, "rect"); + rect.setAttributeNS(null, "width", `100%`); + rect.setAttributeNS(null, "height", `100%`); + rect.setAttributeNS(null, "fill", `url("#${gradientId}")`); + rect.setAttributeNS(null, "stroke", `black`); + rect.setAttributeNS(null, "stroke-width", `0.1em`); + + svg.appendChild(rect); + + return svg; + } + } Utils.screenPass = new function () { diff --git a/src/utils/Compass.js b/src/utils/Compass.js new file mode 100644 index 00000000..38284efb --- /dev/null +++ b/src/utils/Compass.js @@ -0,0 +1,62 @@ + +import {Utils} from "../utils.js"; + +export class Compass{ + + constructor(viewer){ + this.viewer = viewer; + + this.visible = false; + this.dom = this.createElement(); + + viewer.addEventListener("update", () => { + const direction = viewer.scene.view.direction.clone(); + direction.z = 0; + direction.normalize(); + // const north = new THREE.Vector3(0, 1, 0); + + // const angleNorth = Math.atan2(north.y, north.x); + // const angleDir = Math.atan2(direction.y, direction.x); + // const azimuth = angleDir - angleNorth; + + + const camera = viewer.scene.getActiveCamera(); + + const p1 = camera.getWorldPosition(new THREE.Vector3()); + const p2 = p1.clone().add(direction); + + const projection = viewer.getProjection(); + const azimuth = Utils.computeAzimuth(p1, p2, projection); + + this.dom.css("transform", `rotateZ(${azimuth}rad)`); + }); + + this.dom.click( () => { + viewer.setTopView(); + }); + + const renderArea = $(viewer.renderArea); + renderArea.append(this.dom); + + this.setVisible(this.visible); + } + + setVisible(visible){ + this.visible = visible; + + const value = visible ? "" : "none"; + this.dom.css("display", value); + } + + isVisible(){ + return this.visible; + } + + createElement(){ + const style = `style="position: absolute; top: 10px; right: 10px; z-index: 10000; width: 64px;"`; + const img = $(``); + + return img; + } + +}; \ No newline at end of file diff --git a/src/utils/toInterleavedBufferAttribute.js b/src/utils/toInterleavedBufferAttribute.js deleted file mode 100644 index 6f48a5cb..00000000 --- a/src/utils/toInterleavedBufferAttribute.js +++ /dev/null @@ -1,31 +0,0 @@ - - -import {PointAttribute} from "../loader/PointAttributes.js"; - -export function toInterleavedBufferAttribute(pointAttribute){ - let att = null; - - if (pointAttribute.name === PointAttribute.POSITION_CARTESIAN.name) { - att = new Potree.InterleavedBufferAttribute("position", 12, 3, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.COLOR_PACKED.name) { - att = new Potree.InterleavedBufferAttribute("color", 4, 4, "UNSIGNED_BYTE", true); - } else if (pointAttribute.name === PointAttribute.INTENSITY.name) { - att = new Potree.InterleavedBufferAttribute("intensity", 4, 1, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.CLASSIFICATION.name) { - att = new Potree.InterleavedBufferAttribute("classification", 4, 1, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.RETURN_NUMBER.name) { - att = new Potree.InterleavedBufferAttribute("returnNumber", 4, 1, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.NUMBER_OF_RETURNS.name) { - att = new Potree.InterleavedBufferAttribute("numberOfReturns", 4, 1, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.SOURCE_ID.name) { - att = new Potree.InterleavedBufferAttribute("pointSourceID", 4, 1, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.NORMAL_SPHEREMAPPED.name) { - att = new Potree.InterleavedBufferAttribute("normal", 12, 3, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.NORMAL_OCT16.name) { - att = new Potree.InterleavedBufferAttribute("normal", 12, 3, "FLOAT", false); - } else if (pointAttribute.name === PointAttribute.NORMAL.name) { - att = new Potree.InterleavedBufferAttribute("normal", 12, 3, "FLOAT", false); - } - - return att; -}; diff --git a/src/viewer/LoadProject.js b/src/viewer/LoadProject.js index b6b65556..5a6a1334 100644 --- a/src/viewer/LoadProject.js +++ b/src/viewer/LoadProject.js @@ -26,8 +26,14 @@ function loadPointCloud(viewer, data){ function loadMeasurement(viewer, data){ + const duplicate = viewer.scene.measurements.find(measure => measure.uuid === data.uuid); + if(duplicate){ + return; + } + const measure = new Measure(); + measure.uuid = data.uuid; measure.name = data.name; measure.showDistances = data.showDistances; measure.showCoordinates = data.showCoordinates; @@ -47,8 +53,15 @@ function loadMeasurement(viewer, data){ } function loadVolume(viewer, data){ + + const duplicate = viewer.scene.volumes.find(volume => volume.uuid === data.uuid); + if(duplicate){ + return; + } + let volume = new Potree[data.type]; + volume.uuid = data.uuid; volume.name = data.name; volume.position.set(...data.position); volume.rotation.set(...data.rotation); @@ -61,8 +74,14 @@ function loadVolume(viewer, data){ function loadCameraAnimation(viewer, data){ + const duplicate = viewer.scene.cameraAnimations.find(a => a.uuid === data.uuid); + if(duplicate){ + return; + } + const animation = new CameraAnimation(viewer); + animation.uuid = data.uuid; animation.name = data.name; animation.duration = data.duration; animation.t = data.t; @@ -93,7 +112,6 @@ function loadSettings(viewer, data){ viewer.setBackground(data.background); viewer.setMinNodeSize(data.minNodeSize); viewer.setShowBoundingBox(data.showBoundingBoxes); - } function loadView(viewer, view){ @@ -102,11 +120,13 @@ function loadView(viewer, view){ } function loadAnnotationItem(item){ + const annotation = new Annotation({ position: item.position, title: item.title, }); + annotation.uuid = item.uuid; annotation.offset.set(...item.offset); return annotation; @@ -120,9 +140,19 @@ function loadAnnotations(viewer, data){ const {items, hierarchy} = data; - const annotations = items.map(loadAnnotationItem); + const existingAnnotations = []; + viewer.scene.annotations.traverseDescendants(annotation => { + existingAnnotations.push(annotation); + }); - for(const annotation of annotations){ + for(const item of items){ + + const duplicate = existingAnnotations.find(ann => ann.uuid === item.uuid); + if(duplicate){ + continue; + } + + const annotation = loadAnnotationItem(item); viewer.scene.annotations.add(annotation); } @@ -130,16 +160,24 @@ function loadAnnotations(viewer, data){ function loadProfile(viewer, data){ - // const {name, points} = data; + const {name, points} = data; - // let profile = new Potree.Profile(); - // profile.name = "Elevation Profile"; - // profile.setWidth(6) - // profile.addMarker(new THREE.Vector3(2561699.409, 1205164.310, 478.648)); - // profile.addMarker(new THREE.Vector3(2561659.311, 1205242.101, 491.235)); + const duplicate = viewer.scene.profiles.find(profile => profile.uuid === data.uuid); + if(duplicate){ + return; + } + + let profile = new Potree.Profile(); + profile.name = name; + profile.uuid = data.uuid; + + profile.setWidth(data.width); + + for(const point of points){ + profile.addMarker(new THREE.Vector3(...point)); + } - // viewer.scene.addProfile(profile); - + viewer.scene.addProfile(profile); } function loadClassification(viewer, data){ @@ -153,8 +191,7 @@ function loadClassification(viewer, data){ } - -export function loadSaveData(viewer, data){ +export function loadProject(viewer, data){ if(data.type !== "Potree"){ console.error("not a valid Potree project"); @@ -188,5 +225,4 @@ export function loadSaveData(viewer, data){ loadAnnotations(viewer, data.annotations); loadClassification(viewer, data.classification); - } \ No newline at end of file diff --git a/src/viewer/PropertyPanels/PropertiesPanel.js b/src/viewer/PropertyPanels/PropertiesPanel.js index 5639e407..68553e12 100644 --- a/src/viewer/PropertyPanels/PropertiesPanel.js +++ b/src/viewer/PropertyPanels/PropertiesPanel.js @@ -194,7 +194,7 @@ export class PropertiesPanel{
  • Gradient Scheme: -
    +
  • @@ -359,6 +359,11 @@ export class PropertiesPanel{ options.push(...attributes.map(a => a.name)); + const intensityIndex = options.indexOf("intensity"); + if(intensityIndex >= 0){ + options.splice(intensityIndex + 1, 0, "intensity gradient"); + } + options.push( "elevation", "color", @@ -386,7 +391,9 @@ export class PropertiesPanel{ const attribute = pointcloud.getAttribute(selectedValue); - if(attribute !== null && attribute.name === "intensity"){ + const isIntensity = attribute !== null + && (attribute.name === "intensity" || attribute.name === "intensity gradient"); + if(isIntensity){ if(pointcloud.material.intensityRange[0] === Infinity){ pointcloud.material.intensityRange = attribute.range; } @@ -458,7 +465,7 @@ export class PropertiesPanel{ blockColor.css('display', 'block'); } else if (selectedValue === 'intensity') { blockIntensity.css('display', 'block'); - } else if (selectedValue === 'Intensity Gradient') { + } else if (selectedValue === 'intensity gradient') { blockIntensity.css('display', 'block'); } else if (selectedValue === "indices" ){ blockIndex.css('display', 'block'); @@ -486,23 +493,21 @@ export class PropertiesPanel{ } { - let schemes = [ - {name: "SPECTRAL", icon: `${Potree.resourcePath}/icons/gradients_spectral.png`}, - {name: "YELLOW_GREEN", icon: `${Potree.resourcePath}/icons/gradients_yellow_green.png`}, - {name: "PLASMA", icon: `${Potree.resourcePath}/icons/gradients_plasma.png`}, - {name: "GRAYSCALE", icon: `${Potree.resourcePath}/icons/gradients_grayscale.png`}, - {name: "RAINBOW", icon: `${Potree.resourcePath}/icons/gradients_rainbow.png`}, - ]; + const schemes = Object.keys(Potree.Gradients).map(name => ({name: name, values: Gradients[name]})); let elSchemeContainer = panel.find("#elevation_gradient_scheme_selection"); for(let scheme of schemes){ let elScheme = $(` - `); + const svg = Potree.Utils.createSvgGradient(scheme.values); + svg.setAttributeNS(null, "class", `button-icon`); + + elScheme.append($(svg)); + elScheme.click( () => { material.gradient = Gradients[scheme.name]; }); diff --git a/src/viewer/SaveProject.js b/src/viewer/SaveProject.js index 77c33faf..841c382a 100644 --- a/src/viewer/SaveProject.js +++ b/src/viewer/SaveProject.js @@ -16,6 +16,7 @@ function createPointcloudData(pointcloud) { function createProfileData(profile){ const data = { + uuid: profile.uuid, name: profile.name, points: profile.points.map(p => p.toArray()), height: profile.height, @@ -27,6 +28,7 @@ function createProfileData(profile){ function createVolumeData(volume){ const data = { + uuid: volume.uuid, type: volume.constructor.name, name: volume.name, position: volume.position.toArray(), @@ -41,14 +43,6 @@ function createVolumeData(volume){ function createCameraAnimationData(animation){ - // const controlPoints = []; - - // for(const cp of animation.controlPoints){ - // const cpdata = {}; - - // control - // } - const controlPoints = animation.controlPoints.map( cp => { const cpdata = { position: cp.position.toArray(), @@ -59,6 +53,7 @@ function createCameraAnimationData(animation){ }); const data = { + uuid: animation.uuid, name: animation.name, duration: animation.duration, t: animation.t, @@ -71,7 +66,9 @@ function createCameraAnimationData(animation){ } function createMeasurementData(measurement){ + const data = { + uuid: measurement.uuid, name: measurement.name, points: measurement.points.map(p => p.position.toArray()), showDistances: measurement.showDistances, @@ -87,7 +84,9 @@ function createMeasurementData(measurement){ } function createAnnotationData(annotation){ + const data = { + uuid: annotation.uuid, title: annotation.title, description: annotation.description, position: annotation.position.toArray(), @@ -211,9 +210,6 @@ function createViewData(viewer){ } function createClassificationData(viewer){ - - //const data = {}; - const classifications = viewer.classifications; const data = classifications; @@ -221,7 +217,7 @@ function createClassificationData(viewer){ return data; } -export function createSaveData(viewer) { +export function saveProject(viewer) { const scene = viewer.scene; diff --git a/src/viewer/sidebar.js b/src/viewer/sidebar.js index 88f38a69..497e1d32 100644 --- a/src/viewer/sidebar.js +++ b/src/viewer/sidebar.js @@ -319,7 +319,7 @@ export class Sidebar{ let elDownloadPotree = elExport.find("img[name=potree_export_button]").parent(); elDownloadPotree.click( (event) => { - let data = Potree.createSaveData(this.viewer); + let data = Potree.saveProject(this.viewer); let dataString = JSON.stringify(data, null, "\t") let url = window.URL.createObjectURL(new Blob([dataString], {type: 'data:application/octet-stream'})); @@ -1334,14 +1334,22 @@ export class Sidebar{ () => { this.viewer.fitToScreen(); } )); - - elNavigation.append(this.createToolIcon( Potree.resourcePath + "/icons/navigation_cube.svg", "[title]tt.navigation_cube_control", () => {this.viewer.toggleNavigationCube()} )); + elNavigation.append(this.createToolIcon( + Potree.resourcePath + "/images/compas.svg", + "Compass", + () => { + const visible = !this.viewer.compass.isVisible(); + this.viewer.compass.setVisible(visible); + } + )); + + elNavigation.append("
    "); diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index a6acda81..9aebe954 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -22,6 +22,7 @@ import {VolumeTool} from "../utils/VolumeTool.js"; import {InputHandler} from "../navigation/InputHandler.js"; import {NavigationCube} from "./NavigationCube.js"; +import {Compass} from "../utils/Compass.js"; import {OrbitControls} from "../navigation/OrbitControls.js"; import {FirstPersonControls} from "../navigation/FirstPersonControls.js"; import {EarthControls} from "../navigation/EarthControls.js"; @@ -93,20 +94,8 @@ export class Viewer extends EventDispatcher{ this.edlRadius = 1.4; this.edlOpacity = 1.0; this.useEDL = false; + this.description = ""; - // this.classifications = { - // 0: { visible: true, name: 'never classified' , color: [0.5, 0.5, 0.5, 1.0] }, - // 1: { visible: true, name: 'unclassified' , color: [0.5, 0.5, 0.5, 1.0] }, - // 2: { visible: true, name: 'ground' , color: [0.63, 0.32, 0.18, 1.0] }, - // 3: { visible: true, name: 'low vegetation' , color: [0.0, 1.0, 0.0, 1.0] }, - // 4: { visible: true, name: 'medium vegetation' , color: [0.0, 0.8, 0.0, 1.0] }, - // 5: { visible: true, name: 'high vegetation' , color: [0.0, 0.6, 0.0, 1.0] }, - // 6: { visible: true, name: 'building' , color: [1.0, 0.66, 0.0, 1.0] }, - // 7: { visible: true, name: 'low point(noise)' , color: [1.0, 0.0, 1.0, 1.0] }, - // 8: { visible: true, name: 'key-point' , color: [1.0, 0.0, 0.0, 1.0] }, - // 9: { visible: true, name: 'water' , color: [0.0, 0.0, 1.0, 1.0] }, - // 12: { visible: true, name: 'overlap' , color: [1.0, 1.0, 0.0, 1.0] }, - // }; this.classifications = ClassificationScheme.DEFAULT; this.moveSpeed = 10; @@ -141,6 +130,7 @@ export class Viewer extends EventDispatcher{ this.clippingTool = null; this.transformationTool = null; this.navigationCube = null; + this.compass = null; this.skybox = null; this.clock = new THREE.Clock(); @@ -201,6 +191,8 @@ export class Viewer extends EventDispatcher{ this.transformationTool = new TransformationTool(this); this.navigationCube = new NavigationCube(this); this.navigationCube.visible = false; + + this.compass = new Compass(this); this.createControls(); @@ -395,7 +387,7 @@ export class Viewer extends EventDispatcher{ getBackground () { return this.background; - }; + } setBackground(bg){ if (this.background === bg) { @@ -411,8 +403,15 @@ export class Viewer extends EventDispatcher{ } setDescription (value) { - $('#potree_description')[0].innerHTML = value; - }; + this.description = value; + + $('#potree_description').html(value); + //$('#potree_description').text(value); + } + + getDescription(){ + return this.description; + } setShowBoundingBox (value) { if (this.showBoundingBox !== value) { @@ -904,6 +903,34 @@ export class Viewer extends EventDispatcher{ pointcloud.material.useOrthographicCamera = mode == CameraMode.ORTHOGRAPHIC; } } + + getProjection(){ + const pointcloud = this.scene.pointclouds[0]; + + if(pointcloud){ + return pointcloud.projection; + }else{ + return null; + } + } + + async loadProject(url){ + + const response = await fetch(url); + + const json = await response.json(); + // const json = JSON.parse(text); + + if(json.type === "Potree"){ + Potree.loadProject(viewer, json); + } + + Potree.loadProject(this, url); + } + + saveProject(){ + return Potree.saveProject(this); + } loadSettingsFromURL(){ if(Utils.getParameterByName("pointSize")){ @@ -1195,7 +1222,7 @@ export class Viewer extends EventDispatcher{ const json = JSON.parse(text); if(json.type === "Potree"){ - Potree.loadSaveData(viewer, json); + Potree.loadProject(viewer, json); } }catch(e){ console.error("failed to parse the dropped file as JSON"); diff --git a/src/workers/LASDecoderWorker.js b/src/workers/LASDecoderWorker.js index 2bda79e3..d74544b4 100644 --- a/src/workers/LASDecoderWorker.js +++ b/src/workers/LASDecoderWorker.js @@ -1,38 +1,3 @@ -// let pointFormatReaders = { -// 0: function(dv) { -// return { -// "position": [ dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)], -// "intensity": dv.getUint16(12, true), -// "classification": dv.getUint8(16, true) -// }; -// }, -// 1: function(dv) { -// return { -// "position": [ dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)], -// "intensity": dv.getUint16(12, true), -// "classification": dv.getUint8(16, true) -// }; -// }, -// 2: function(dv) { -// return { -// "position": [ dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)], -// "intensity": dv.getUint16(12, true), -// "classification": dv.getUint8(16, true), -// "color": [dv.getUint16(20, true), dv.getUint16(22, true), dv.getUint16(24, true)] -// }; -// }, -// 3: function(dv) { -// return { -// "position": [ dv.getInt32(0, true), dv.getInt32(4, true), dv.getInt32(8, true)], -// "intensity": dv.getUint16(12, true), -// "classification": dv.getUint8(16, true), -// "color": [dv.getUint16(28, true), dv.getUint16(30, true), dv.getUint16(32, true)] -// }; -// } -// }; -// -// - function readUsingTempArrays(event) {