itowns 2.44.3-next.9 → 2.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +20 -6
  3. package/examples/config.json +1 -0
  4. package/examples/copc_simple_loader.html +15 -5
  5. package/examples/effects_stereo.html +2 -2
  6. package/examples/entwine_3d_loader.html +3 -1
  7. package/examples/entwine_simple_loader.html +1 -1
  8. package/examples/images/itowns_logo.svg +123 -0
  9. package/examples/js/plugins/COGParser.js +1 -1
  10. package/examples/jsm/OGC3DTilesHelper.js +6 -1
  11. package/examples/layers/JSONLayers/GeoidMNT.json +3 -1
  12. package/examples/misc_collada.html +2 -2
  13. package/examples/source_file_geojson_3d.html +0 -1
  14. package/examples/source_file_kml_raster_usgs.html +0 -1
  15. package/examples/source_stream_wfs_raster.html +0 -7
  16. package/examples/vector_tile_mapbox_raster.html +91 -0
  17. package/examples/view_3d_map_webxr.html +3 -1
  18. package/examples/view_multi_25d.html +2 -2
  19. package/package.json +21 -75
  20. package/CODING.md +0 -120
  21. package/CONTRIBUTING.md +0 -150
  22. package/CONTRIBUTORS.md +0 -55
  23. package/LICENSE.md +0 -44
  24. package/changelog.md +0 -1361
  25. package/dist/455.js +0 -2
  26. package/dist/455.js.map +0 -1
  27. package/dist/debug.js +0 -3
  28. package/dist/debug.js.LICENSE.txt +0 -13
  29. package/dist/debug.js.map +0 -1
  30. package/dist/itowns.js +0 -3
  31. package/dist/itowns.js.LICENSE.txt +0 -7
  32. package/dist/itowns.js.map +0 -1
  33. package/dist/itowns_lasparser.js +0 -2
  34. package/dist/itowns_lasparser.js.map +0 -1
  35. package/dist/itowns_lasworker.js +0 -2
  36. package/dist/itowns_lasworker.js.map +0 -1
  37. package/dist/itowns_potree2worker.js +0 -2
  38. package/dist/itowns_potree2worker.js.map +0 -1
  39. package/dist/itowns_widgets.js +0 -2
  40. package/dist/itowns_widgets.js.map +0 -1
  41. package/examples/.eslintrc.cjs +0 -35
  42. package/examples/jsm/.eslintrc.cjs +0 -38
  43. package/lib/Controls/FirstPersonControls.js +0 -308
  44. package/lib/Controls/FlyControls.js +0 -175
  45. package/lib/Controls/GlobeControls.js +0 -1162
  46. package/lib/Controls/PlanarControls.js +0 -1025
  47. package/lib/Controls/StateControl.js +0 -429
  48. package/lib/Controls/StreetControls.js +0 -392
  49. package/lib/Converter/Feature2Mesh.js +0 -615
  50. package/lib/Converter/Feature2Texture.js +0 -170
  51. package/lib/Converter/convertToTile.js +0 -75
  52. package/lib/Converter/textureConverter.js +0 -44
  53. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  54. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  55. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  56. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  57. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  58. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  59. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  60. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  61. package/lib/Core/AnimationPlayer.js +0 -142
  62. package/lib/Core/CopcNode.js +0 -174
  63. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  64. package/lib/Core/EntwinePointTileNode.js +0 -126
  65. package/lib/Core/Feature.js +0 -490
  66. package/lib/Core/Geographic/CoordStars.js +0 -80
  67. package/lib/Core/Geographic/Coordinates.js +0 -320
  68. package/lib/Core/Geographic/Crs.js +0 -175
  69. package/lib/Core/Geographic/Extent.js +0 -534
  70. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  71. package/lib/Core/Label.js +0 -222
  72. package/lib/Core/MainLoop.js +0 -211
  73. package/lib/Core/Math/Ellipsoid.js +0 -144
  74. package/lib/Core/Picking.js +0 -255
  75. package/lib/Core/PointCloudNode.js +0 -42
  76. package/lib/Core/Potree2Node.js +0 -206
  77. package/lib/Core/Potree2PointAttributes.js +0 -139
  78. package/lib/Core/PotreeNode.js +0 -101
  79. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  80. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  81. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  82. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  83. package/lib/Core/Prefab/GlobeView.js +0 -161
  84. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  85. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  86. package/lib/Core/Prefab/PlanarView.js +0 -62
  87. package/lib/Core/Prefab/TileBuilder.js +0 -80
  88. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  89. package/lib/Core/Scheduler/Cache.js +0 -256
  90. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  91. package/lib/Core/Scheduler/Scheduler.js +0 -294
  92. package/lib/Core/Style.js +0 -1121
  93. package/lib/Core/System/Capabilities.js +0 -63
  94. package/lib/Core/Tile/Tile.js +0 -219
  95. package/lib/Core/Tile/TileGrid.js +0 -46
  96. package/lib/Core/TileGeometry.js +0 -40
  97. package/lib/Core/TileMesh.js +0 -109
  98. package/lib/Core/View.js +0 -1109
  99. package/lib/Layer/C3DTilesLayer.js +0 -456
  100. package/lib/Layer/ColorLayer.js +0 -128
  101. package/lib/Layer/CopcLayer.js +0 -58
  102. package/lib/Layer/ElevationLayer.js +0 -107
  103. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  104. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  105. package/lib/Layer/GeoidLayer.js +0 -80
  106. package/lib/Layer/GeometryLayer.js +0 -202
  107. package/lib/Layer/InfoLayer.js +0 -64
  108. package/lib/Layer/LabelLayer.js +0 -456
  109. package/lib/Layer/Layer.js +0 -304
  110. package/lib/Layer/LayerUpdateState.js +0 -89
  111. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  112. package/lib/Layer/OGC3DTilesLayer.js +0 -412
  113. package/lib/Layer/OrientedImageLayer.js +0 -222
  114. package/lib/Layer/PointCloudLayer.js +0 -359
  115. package/lib/Layer/Potree2Layer.js +0 -164
  116. package/lib/Layer/PotreeLayer.js +0 -65
  117. package/lib/Layer/RasterLayer.js +0 -27
  118. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  119. package/lib/Layer/TiledGeometryLayer.js +0 -403
  120. package/lib/Loader/LASLoader.js +0 -193
  121. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  122. package/lib/Loader/Potree2Loader.js +0 -207
  123. package/lib/Main.js +0 -115
  124. package/lib/MainBundle.js +0 -4
  125. package/lib/Parser/B3dmParser.js +0 -174
  126. package/lib/Parser/CameraCalibrationParser.js +0 -94
  127. package/lib/Parser/GDFParser.js +0 -72
  128. package/lib/Parser/GTXParser.js +0 -75
  129. package/lib/Parser/GeoJsonParser.js +0 -212
  130. package/lib/Parser/GpxParser.js +0 -25
  131. package/lib/Parser/ISGParser.js +0 -71
  132. package/lib/Parser/KMLParser.js +0 -25
  133. package/lib/Parser/LASParser.js +0 -137
  134. package/lib/Parser/MapBoxUrlParser.js +0 -83
  135. package/lib/Parser/PntsParser.js +0 -131
  136. package/lib/Parser/Potree2BinParser.js +0 -92
  137. package/lib/Parser/PotreeBinParser.js +0 -106
  138. package/lib/Parser/PotreeCinParser.js +0 -29
  139. package/lib/Parser/ShapefileParser.js +0 -78
  140. package/lib/Parser/VectorTileParser.js +0 -202
  141. package/lib/Parser/XbilParser.js +0 -119
  142. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  143. package/lib/Parser/iGLTFLoader.js +0 -168
  144. package/lib/Process/3dTilesProcessing.js +0 -304
  145. package/lib/Process/FeatureProcessing.js +0 -76
  146. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  147. package/lib/Process/ObjectRemovalHelper.js +0 -97
  148. package/lib/Process/handlerNodeError.js +0 -23
  149. package/lib/Provider/3dTilesProvider.js +0 -149
  150. package/lib/Provider/DataSourceProvider.js +0 -8
  151. package/lib/Provider/Fetcher.js +0 -229
  152. package/lib/Provider/PointCloudProvider.js +0 -45
  153. package/lib/Provider/TileProvider.js +0 -16
  154. package/lib/Provider/URLBuilder.js +0 -116
  155. package/lib/Renderer/Camera.js +0 -281
  156. package/lib/Renderer/Color.js +0 -56
  157. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  158. package/lib/Renderer/CommonMaterial.js +0 -31
  159. package/lib/Renderer/Label2DRenderer.js +0 -190
  160. package/lib/Renderer/LayeredMaterial.js +0 -243
  161. package/lib/Renderer/OBB.js +0 -153
  162. package/lib/Renderer/OrientedImageCamera.js +0 -118
  163. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  164. package/lib/Renderer/PointsMaterial.js +0 -485
  165. package/lib/Renderer/RasterTile.js +0 -209
  166. package/lib/Renderer/RenderMode.js +0 -31
  167. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  168. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  169. package/lib/Renderer/SphereHelper.js +0 -23
  170. package/lib/Renderer/WebXR.js +0 -51
  171. package/lib/Renderer/c3DEngine.js +0 -214
  172. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  173. package/lib/Source/C3DTilesIonSource.js +0 -54
  174. package/lib/Source/C3DTilesSource.js +0 -30
  175. package/lib/Source/CopcSource.js +0 -115
  176. package/lib/Source/EntwinePointTileSource.js +0 -62
  177. package/lib/Source/FileSource.js +0 -189
  178. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  179. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  180. package/lib/Source/OGC3DTilesSource.js +0 -21
  181. package/lib/Source/OrientedImageSource.js +0 -59
  182. package/lib/Source/Potree2Source.js +0 -167
  183. package/lib/Source/PotreeSource.js +0 -82
  184. package/lib/Source/Source.js +0 -223
  185. package/lib/Source/TMSSource.js +0 -145
  186. package/lib/Source/VectorTilesSource.js +0 -178
  187. package/lib/Source/WFSSource.js +0 -168
  188. package/lib/Source/WMSSource.js +0 -133
  189. package/lib/Source/WMTSSource.js +0 -86
  190. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  191. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  192. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  193. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  194. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  195. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  196. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  197. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  198. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  199. package/lib/Utils/CameraUtils.js +0 -555
  200. package/lib/Utils/DEMUtils.js +0 -350
  201. package/lib/Utils/FeaturesUtils.js +0 -156
  202. package/lib/Utils/Gradients.js +0 -16
  203. package/lib/Utils/OrientationUtils.js +0 -457
  204. package/lib/Utils/ThreeUtils.js +0 -115
  205. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  206. package/lib/Utils/gui/Main.js +0 -7
  207. package/lib/Utils/gui/Minimap.js +0 -154
  208. package/lib/Utils/gui/Navigation.js +0 -245
  209. package/lib/Utils/gui/Scale.js +0 -107
  210. package/lib/Utils/gui/Searchbar.js +0 -234
  211. package/lib/Utils/gui/Widget.js +0 -80
  212. package/lib/Utils/placeObjectOnGround.js +0 -137
  213. package/lib/Worker/LASLoaderWorker.js +0 -19
  214. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,359 +0,0 @@
1
- import * as THREE from 'three';
2
- import GeometryLayer from "./GeometryLayer.js";
3
- import PointsMaterial, { PNTS_MODE } from "../Renderer/PointsMaterial.js";
4
- import Picking from "../Core/Picking.js";
5
- const point = new THREE.Vector3();
6
- const bboxMesh = new THREE.Mesh();
7
- const box3 = new THREE.Box3();
8
- bboxMesh.geometry.boundingBox = box3;
9
- function initBoundingBox(elt, layer) {
10
- elt.tightbbox.getSize(box3.max);
11
- box3.max.multiplyScalar(0.5);
12
- box3.min.copy(box3.max).negate();
13
- elt.obj.boxHelper = new THREE.BoxHelper(bboxMesh);
14
- elt.obj.boxHelper.geometry = elt.obj.boxHelper.geometry.toNonIndexed();
15
- elt.obj.boxHelper.computeLineDistances();
16
- elt.obj.boxHelper.material = elt.childrenBitField ? new THREE.LineDashedMaterial({
17
- dashSize: 0.25,
18
- gapSize: 0.25
19
- }) : new THREE.LineBasicMaterial();
20
- elt.obj.boxHelper.material.color.setHex(0);
21
- elt.obj.boxHelper.material.linewidth = 2;
22
- elt.obj.boxHelper.frustumCulled = false;
23
- elt.obj.boxHelper.position.copy(elt.tightbbox.min).add(box3.max);
24
- elt.obj.boxHelper.autoUpdateMatrix = false;
25
- layer.bboxes.add(elt.obj.boxHelper);
26
- elt.obj.boxHelper.updateMatrix();
27
- elt.obj.boxHelper.updateMatrixWorld();
28
- }
29
- function computeSSEPerspective(context, pointSize, spacing, elt, distance) {
30
- if (distance <= 0) {
31
- return Infinity;
32
- }
33
- const pointSpacing = spacing / 2 ** elt.depth;
34
- // Estimate the onscreen distance between 2 points
35
- const onScreenSpacing = context.camera.preSSE * pointSpacing / distance;
36
- // [ P1 ]--------------[ P2 ]
37
- // <---------------------> = pointsSpacing (in world coordinates)
38
- // ~ onScreenSpacing (in pixels)
39
- // <------> = pointSize (in pixels)
40
- return Math.max(0.0, onScreenSpacing - pointSize);
41
- }
42
- function computeSSEOrthographic(context, pointSize, spacing, elt) {
43
- const pointSpacing = spacing / 2 ** elt.depth;
44
-
45
- // Given an identity view matrix, project pointSpacing from world space to
46
- // clip space. v' = vVP = vP
47
- const v = new THREE.Vector4(pointSpacing);
48
- v.applyMatrix4(context.camera.camera3D.projectionMatrix);
49
-
50
- // We map v' to the screen space and calculate the distance to the origin.
51
- const dx = v.x * 0.5 * context.camera.width;
52
- const dy = v.y * 0.5 * context.camera.height;
53
- const distance = Math.sqrt(dx * dx + dy * dy);
54
- return Math.max(0.0, distance - pointSize);
55
- }
56
- function computeScreenSpaceError(context, pointSize, spacing, elt, distance) {
57
- if (context.camera.camera3D.isOrthographicCamera) {
58
- return computeSSEOrthographic(context, pointSize, spacing, elt);
59
- }
60
- return computeSSEPerspective(context, pointSize, spacing, elt, distance);
61
- }
62
- function markForDeletion(elt) {
63
- if (elt.obj) {
64
- elt.obj.visible = false;
65
- }
66
- if (!elt.notVisibleSince) {
67
- elt.notVisibleSince = Date.now();
68
- // Set .sse to an invalid value
69
- elt.sse = -1;
70
- }
71
- for (const child of elt.children) {
72
- markForDeletion(child);
73
- }
74
- }
75
- function changeIntensityRange(layer) {
76
- layer.material.intensityRange?.set(layer.minIntensityRange, layer.maxIntensityRange);
77
- }
78
- function changeElevationRange(layer) {
79
- layer.material.elevationRange?.set(layer.minElevationRange, layer.maxElevationRange);
80
- }
81
- function changeAngleRange(layer) {
82
- layer.material.angleRange?.set(layer.minAngleRange, layer.maxAngleRange);
83
- }
84
-
85
- /**
86
- * The basis for all point clouds related layers.
87
- *
88
- * @property {boolean} isPointCloudLayer - Used to checkout whether this layer
89
- * is a PointCloudLayer. Default is `true`. You should not change this, as it is
90
- * used internally for optimisation.
91
- * @property {THREE.Group|THREE.Object3D} group - Contains the created
92
- * `THREE.Points` meshes, usually with an instance of a `THREE.Points` per node.
93
- * @property {THREE.Group|THREE.Object3D} bboxes - Contains the bounding boxes
94
- * (`THREE.Box3`) of the tree, usually one per node.
95
- * @property {number} octreeDepthLimit - The depth limit at which to stop
96
- * browsing the octree. Can be used to limit the browsing, without having to
97
- * edit manually the source of the point cloud. No limit by default (`-1`).
98
- * @property {number} [pointBudget=2000000] - Maximum number of points to
99
- * display at the same time. This influences the performance of rendering.
100
- * Default to two millions points.
101
- * @property {number} [sseThreshold=2] - Threshold of the **S**creen **S**pace
102
- * **E**rror. Default to `2`.
103
- * @property {number} [pointSize=4] - The size (in pixels) of the points.
104
- * Default to `4`.
105
- * @property {THREE.Material|PointsMaterial} [material=new PointsMaterial] - The
106
- * material to use to display the points of the cloud. Be default it is a new
107
- * `PointsMaterial`.
108
- * @property {number} [mode=PNTS_MODE.COLOR] - The displaying mode of the points.
109
- * Values are specified in `PointsMaterial`.
110
- * @property {number} [minIntensityRange=0] - The minimal intensity of the
111
- * layer. Changing this value will affect the material, if it has the
112
- * corresponding uniform. The value is normalized between 0 and 1.
113
- * @property {number} [maxIntensityRange=1] - The maximal intensity of the
114
- * layer. Changing this value will affect the material, if it has the
115
- * corresponding uniform. The value is normalized between 0 and 1.
116
- */
117
- class PointCloudLayer extends GeometryLayer {
118
- /**
119
- * Constructs a new instance of point cloud layer.
120
- * Constructs a new instance of a Point Cloud Layer. This should not be used
121
- * directly, but rather implemented using `extends`.
122
- *
123
- * @extends GeometryLayer
124
- *
125
- * @param {string} id - The id of the layer, that should be unique. It is
126
- * not mandatory, but an error will be emitted if this layer is added a
127
- * {@link View} that already has a layer going by that id.
128
- * @param {Object} [config] - Optional configuration, all elements in it
129
- * will be merged as is in the layer. For example, if the configuration
130
- * contains three elements `name, protocol, extent`, these elements will be
131
- * available using `layer.name` or something else depending on the property
132
- * name. See the list of properties to know which one can be specified.
133
- */
134
- constructor(id) {
135
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
136
- super(id, config.object3d || new THREE.Group(), config);
137
- this.isPointCloudLayer = true;
138
- this.protocol = 'pointcloud';
139
- this.group = config.group || new THREE.Group();
140
- this.object3d.add(this.group);
141
- this.bboxes = config.bboxes || new THREE.Group();
142
- this.bboxes.visible = false;
143
- this.object3d.add(this.bboxes);
144
- this.group.updateMatrixWorld();
145
-
146
- // default config
147
- this.octreeDepthLimit = config.octreeDepthLimit || -1;
148
- this.pointBudget = config.pointBudget || 2000000;
149
- this.pointSize = config.pointSize === 0 || !isNaN(config.pointSize) ? config.pointSize : 4;
150
- this.sseThreshold = config.sseThreshold || 2;
151
- this.defineLayerProperty('minIntensityRange', config.minIntensityRange || 1, changeIntensityRange);
152
- this.defineLayerProperty('maxIntensityRange', config.maxIntensityRange || 65536, changeIntensityRange);
153
- this.defineLayerProperty('minElevationRange', config.minElevationRange || 0, changeElevationRange);
154
- this.defineLayerProperty('maxElevationRange', config.maxElevationRange || 1000, changeElevationRange);
155
- this.defineLayerProperty('minAngleRange', config.minAngleRange || -90, changeAngleRange);
156
- this.defineLayerProperty('maxAngleRange', config.maxAngleRange || 90, changeAngleRange);
157
- this.material = config.material || {};
158
- if (!this.material.isMaterial) {
159
- config.material = config.material || {};
160
- config.material.intensityRange = new THREE.Vector2(this.minIntensityRange, this.maxIntensityRange);
161
- config.material.elevationRange = new THREE.Vector2(this.minElevationRange, this.maxElevationRange);
162
- config.material.angleRange = new THREE.Vector2(this.minAngleRange, this.maxAngleRange);
163
- this.material = new PointsMaterial(config.material);
164
- }
165
- this.material.defines = this.material.defines || {};
166
- this.mode = config.mode || PNTS_MODE.COLOR;
167
- }
168
- preUpdate(context, changeSources) {
169
- // See https://cesiumjs.org/hosted-apps/massiveworlds/downloads/Ring/WorldScaleTerrainRendering.pptx
170
- // slide 17
171
- context.camera.preSSE = context.camera.height / (2 * Math.tan(THREE.MathUtils.degToRad(context.camera.camera3D.fov) * 0.5));
172
- if (this.material) {
173
- this.material.visible = this.visible;
174
- this.material.opacity = this.opacity;
175
- this.material.transparent = this.opacity < 1 || this.material.userData.needTransparency[this.material.mode];
176
- this.material.size = this.pointSize;
177
- this.material.scale = context.camera.preSSE;
178
- if (this.material.updateUniforms) {
179
- this.material.updateUniforms();
180
- }
181
- }
182
-
183
- // lookup lowest common ancestor of changeSources
184
- let commonAncestor;
185
- for (const source of changeSources.values()) {
186
- if (source.isCamera || source == this) {
187
- // if the change is caused by a camera move, no need to bother
188
- // to find common ancestor: we need to update the whole tree:
189
- // some invisible tiles may now be visible
190
- return [this.root];
191
- }
192
- if (source.obj === undefined) {
193
- continue;
194
- }
195
- // filter sources that belong to our layer
196
- if (source.obj.isPoints && source.obj.layer == this) {
197
- if (!commonAncestor) {
198
- commonAncestor = source;
199
- } else {
200
- commonAncestor = source.findCommonAncestor(commonAncestor);
201
- if (!commonAncestor) {
202
- return [this.root];
203
- }
204
- }
205
- }
206
- }
207
- if (commonAncestor) {
208
- return [commonAncestor];
209
- }
210
-
211
- // Start updating from hierarchy root
212
- return [this.root];
213
- }
214
- update(context, layer, elt) {
215
- elt.visible = false;
216
- if (this.octreeDepthLimit >= 0 && this.octreeDepthLimit < elt.depth) {
217
- markForDeletion(elt);
218
- return;
219
- }
220
-
221
- // pick the best bounding box
222
- const bbox = elt.tightbbox ? elt.tightbbox : elt.bbox;
223
- elt.visible = context.camera.isBox3Visible(bbox, this.object3d.matrixWorld);
224
- if (!elt.visible) {
225
- markForDeletion(elt);
226
- return;
227
- }
228
- elt.notVisibleSince = undefined;
229
- point.copy(context.camera.camera3D.position).sub(this.object3d.getWorldPosition(new THREE.Vector3()));
230
- point.applyQuaternion(this.object3d.getWorldQuaternion(new THREE.Quaternion()).invert());
231
-
232
- // only load geometry if this elements has points
233
- if (elt.numPoints !== 0) {
234
- if (elt.obj) {
235
- elt.obj.visible = true;
236
- } else if (!elt.promise) {
237
- const distance = Math.max(0.001, bbox.distanceToPoint(point));
238
- // Increase priority of nearest node
239
- const priority = computeScreenSpaceError(context, layer.pointSize, layer.spacing, elt, distance) / distance;
240
- elt.promise = context.scheduler.execute({
241
- layer,
242
- requester: elt,
243
- view: context.view,
244
- priority,
245
- redraw: true,
246
- earlyDropFunction: cmd => !cmd.requester.visible || !this.visible
247
- }).then(pts => {
248
- if (this.onPointsCreated) {
249
- this.onPointsCreated(layer, pts);
250
- }
251
- elt.obj = pts;
252
- // store tightbbox to avoid ping-pong (bbox = larger => visible, tight => invisible)
253
- elt.tightbbox = pts.tightbbox;
254
-
255
- // make sure to add it here, otherwise it might never
256
- // be added nor cleaned
257
- this.group.add(elt.obj);
258
- elt.obj.updateMatrixWorld(true);
259
- elt.promise = null;
260
- }, err => {
261
- if (err.isCancelledCommandException) {
262
- elt.promise = null;
263
- }
264
- });
265
- }
266
- }
267
- if (elt.children && elt.children.length) {
268
- const distance = bbox.distanceToPoint(point);
269
- elt.sse = computeScreenSpaceError(context, layer.pointSize, layer.spacing, elt, distance) / this.sseThreshold;
270
- if (elt.sse >= 1) {
271
- return elt.children;
272
- } else {
273
- for (const child of elt.children) {
274
- markForDeletion(child);
275
- }
276
- }
277
- }
278
- }
279
- postUpdate() {
280
- this.displayedCount = 0;
281
- for (const pts of this.group.children) {
282
- if (pts.visible) {
283
- const count = pts.geometry.attributes.position.count;
284
- pts.geometry.setDrawRange(0, count);
285
- this.displayedCount += count;
286
- }
287
- }
288
- if (this.displayedCount > this.pointBudget) {
289
- // 2 different point count limit implementation, depending on the potree source
290
- if (this.supportsProgressiveDisplay) {
291
- // In this format, points are evenly distributed within a node,
292
- // so we can draw a percentage of each node and still get a correct
293
- // representation
294
- const reduction = this.pointBudget / this.displayedCount;
295
- for (const pts of this.group.children) {
296
- if (pts.visible) {
297
- const count = Math.floor(pts.geometry.drawRange.count * reduction);
298
- if (count > 0) {
299
- pts.geometry.setDrawRange(0, count);
300
- } else {
301
- pts.visible = false;
302
- }
303
- }
304
- }
305
- this.displayedCount *= reduction;
306
- } else {
307
- // This format doesn't require points to be evenly distributed, so
308
- // we're going to sort the nodes by "importance" (= on screen size)
309
- // and display only the first N nodes
310
- this.group.children.sort((p1, p2) => p2.userData.node.sse - p1.userData.node.sse);
311
- let limitHit = false;
312
- this.displayedCount = 0;
313
- for (const pts of this.group.children) {
314
- const count = pts.geometry.attributes.position.count;
315
- if (limitHit || this.displayedCount + count > this.pointBudget) {
316
- pts.visible = false;
317
- limitHit = true;
318
- } else {
319
- this.displayedCount += count;
320
- }
321
- }
322
- }
323
- }
324
- const now = Date.now();
325
- for (let i = this.group.children.length - 1; i >= 0; i--) {
326
- const obj = this.group.children[i];
327
- if (!obj.visible && now - obj.userData.node.notVisibleSince > 10000) {
328
- // remove from group
329
- this.group.children.splice(i, 1);
330
-
331
- // no need to dispose obj.material, as it is shared by all objects of this layer
332
- obj.geometry.dispose();
333
- obj.material = null;
334
- obj.geometry = null;
335
- obj.userData.node.obj = null;
336
- }
337
- }
338
- }
339
- pickObjectsAt(view, mouse, radius) {
340
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
341
- return Picking.pickPointsAt(view, mouse, radius, this, target);
342
- }
343
- getObjectToUpdateForAttachedLayers(meta) {
344
- if (meta.obj) {
345
- const p = meta.parent;
346
- if (p && p.obj) {
347
- return {
348
- element: meta.obj,
349
- parent: p.obj
350
- };
351
- } else {
352
- return {
353
- element: meta.obj
354
- };
355
- }
356
- }
357
- }
358
- }
359
- export default PointCloudLayer;
@@ -1,164 +0,0 @@
1
- /*
2
- ============
3
- == POTREE ==
4
- ============
5
-
6
- http://potree.org
7
-
8
- Copyright (c) 2011-2020, Markus Schütz
9
- All rights reserved.
10
-
11
- Redistribution and use in source and binary forms, with or without
12
- modification, are permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions of source code must retain the above copyright notice, this
15
- list of conditions and the following disclaimer.
16
- 2. Redistributions in binary form must reproduce the above copyright notice,
17
- this list of conditions and the following disclaimer in the documentation
18
- and/or other materials provided with the distribution.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
24
- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
-
31
- The views and conclusions contained in the software and documentation are those
32
- of the authors and should not be interpreted as representing official policies,
33
- either expressed or implied, of the FreeBSD Project.
34
- */
35
-
36
- import * as THREE from 'three';
37
- import PointCloudLayer from "./PointCloudLayer.js";
38
- import Potree2Node from "../Core/Potree2Node.js";
39
- import Extent from "../Core/Geographic/Extent.js";
40
- import { PointAttribute, Potree2PointAttributes, PointAttributeTypes } from "../Core/Potree2PointAttributes.js";
41
- const bboxMesh = new THREE.Mesh();
42
- const box3 = new THREE.Box3();
43
- bboxMesh.geometry.boundingBox = box3;
44
- const typeNameAttributeMap = {
45
- double: PointAttributeTypes.DATA_TYPE_DOUBLE,
46
- float: PointAttributeTypes.DATA_TYPE_FLOAT,
47
- int8: PointAttributeTypes.DATA_TYPE_INT8,
48
- uint8: PointAttributeTypes.DATA_TYPE_UINT8,
49
- int16: PointAttributeTypes.DATA_TYPE_INT16,
50
- uint16: PointAttributeTypes.DATA_TYPE_UINT16,
51
- int32: PointAttributeTypes.DATA_TYPE_INT32,
52
- uint32: PointAttributeTypes.DATA_TYPE_UINT32,
53
- int64: PointAttributeTypes.DATA_TYPE_INT64,
54
- uint64: PointAttributeTypes.DATA_TYPE_UINT64
55
- };
56
- function parseAttributes(jsonAttributes) {
57
- const attributes = new Potree2PointAttributes();
58
- const replacements = {
59
- rgb: 'rgba'
60
- };
61
- for (const jsonAttribute of jsonAttributes) {
62
- const {
63
- name,
64
- numElements,
65
- min,
66
- max
67
- } = jsonAttribute;
68
- const type = typeNameAttributeMap[jsonAttribute.type];
69
- const potreeAttributeName = replacements[name] ? replacements[name] : name;
70
- const attribute = new PointAttribute(potreeAttributeName, type, numElements);
71
- if (numElements === 1) {
72
- attribute.range = [min[0], max[0]];
73
- } else {
74
- attribute.range = [min, max];
75
- }
76
- if (name === 'gps-time') {
77
- // HACK: Guard against bad gpsTime range in metadata, see potree/potree#909
78
- if (attribute.range[0] === attribute.range[1]) {
79
- attribute.range[1] += 1;
80
- }
81
- }
82
- attribute.initialRange = attribute.range;
83
- attributes.add(attribute);
84
- }
85
- {
86
- // check if it has normals
87
- const hasNormals = attributes.attributes.find(a => a.name === 'NormalX') !== undefined && attributes.attributes.find(a => a.name === 'NormalY') !== undefined && attributes.attributes.find(a => a.name === 'NormalZ') !== undefined;
88
- if (hasNormals) {
89
- attributes.addVector({
90
- name: 'NORMAL',
91
- attributes: ['NormalX', 'NormalY', 'NormalZ']
92
- });
93
- }
94
- }
95
- return attributes;
96
- }
97
-
98
- /**
99
- * @property {boolean} isPotreeLayer - Used to checkout whether this layer
100
- * is a Potree2Layer. Default is `true`. You should not change this, as it is
101
- * used internally for optimisation.
102
- */
103
- class Potree2Layer extends PointCloudLayer {
104
- /**
105
- * Constructs a new instance of Potree2 layer.
106
- *
107
- * @extends PointCloudLayer
108
- *
109
- * @example
110
- * // Create a new point cloud layer
111
- * const points = new Potree2Layer('points',
112
- * {
113
- * source: new Potree2Source({
114
- * url: 'https://pointsClouds/',
115
- * file: 'metadata.json',
116
- * }
117
- * });
118
- *
119
- * View.prototype.addLayer.call(view, points);
120
- *
121
- * @param {string} id - The id of the layer, that should be unique. It is
122
- * not mandatory, but an error will be emitted if this layer is added a
123
- * {@link View} that already has a layer going by that id.
124
- * @param {Object} config - Configuration, all elements in it
125
- * will be merged as is in the layer. For example, if the configuration
126
- * contains three elements `name, protocol, extent`, these elements will be
127
- * available using `layer.name` or something else depending on the property
128
- * name. See the list of properties to know which one can be specified.
129
- * @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
130
- * layer will be attached to. This is used to determine the extent of this
131
- * layer. Default to `EPSG:4326`.
132
- */
133
- constructor(id, config) {
134
- super(id, config);
135
- this.isPotreeLayer = true;
136
- const resolve = this.addInitializationStep();
137
- this.source.whenReady.then(metadata => {
138
- this.scale = new THREE.Vector3(1, 1, 1);
139
- this.metadata = metadata;
140
- this.pointAttributes = parseAttributes(metadata.attributes);
141
- this.spacing = metadata.spacing;
142
- const normal = Array.isArray(this.pointAttributes.attributes) && this.pointAttributes.attributes.find(elem => elem.name.startsWith('NORMAL'));
143
- if (normal) {
144
- this.material.defines[normal.name] = 1;
145
- }
146
- const min = new THREE.Vector3(...metadata.boundingBox.min);
147
- const max = new THREE.Vector3(...metadata.boundingBox.max);
148
- const boundingBox = new THREE.Box3(min, max);
149
- const root = new Potree2Node(0, 0, this);
150
- root.bbox = boundingBox;
151
- root.boundingSphere = boundingBox.getBoundingSphere(new THREE.Sphere());
152
- root.id = 'r';
153
- root.depth = 0;
154
- root.nodeType = 2;
155
- root.hierarchyByteOffset = 0n;
156
- root.hierarchyByteSize = BigInt(metadata.hierarchy.firstChunkSize);
157
- root.byteOffset = 0;
158
- this.root = root;
159
- this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', boundingBox);
160
- return this.root.loadOctree().then(resolve);
161
- });
162
- }
163
- }
164
- export default Potree2Layer;
@@ -1,65 +0,0 @@
1
- import * as THREE from 'three';
2
- import PointCloudLayer from "./PointCloudLayer.js";
3
- import PotreeNode from "../Core/PotreeNode.js";
4
- import Extent from "../Core/Geographic/Extent.js";
5
- const bboxMesh = new THREE.Mesh();
6
- const box3 = new THREE.Box3();
7
- bboxMesh.geometry.boundingBox = box3;
8
-
9
- /**
10
- * @property {boolean} isPotreeLayer - Used to checkout whether this layer
11
- * is a PotreeLayer. Default is `true`. You should not change this, as it is
12
- * used internally for optimisation.
13
- */
14
- class PotreeLayer extends PointCloudLayer {
15
- /**
16
- * Constructs a new instance of Potree layer.
17
- *
18
- * @extends PointCloudLayer
19
- *
20
- * @example
21
- * // Create a new point cloud layer
22
- * const points = new PotreeLayer('points',
23
- * {
24
- * source: new PotreeLayer({
25
- * url: 'https://pointsClouds/',
26
- * file: 'points.js',
27
- * }
28
- * });
29
- *
30
- * View.prototype.addLayer.call(view, points);
31
- *
32
- * @param {string} id - The id of the layer, that should be unique. It is
33
- * not mandatory, but an error will be emitted if this layer is added a
34
- * {@link View} that already has a layer going by that id.
35
- * @param {Object} config - Configuration, all elements in it
36
- * will be merged as is in the layer. For example, if the configuration
37
- * contains three elements `name, protocol, extent`, these elements will be
38
- * available using `layer.name` or something else depending on the property
39
- * name. See the list of properties to know which one can be specified.
40
- * @param {string} [config.crs=ESPG:4326] - The CRS of the {@link View} this
41
- * layer will be attached to. This is used to determine the extent of this
42
- * layer. Default to `EPSG:4326`.
43
- */
44
- constructor(id, config) {
45
- super(id, config);
46
- this.isPotreeLayer = true;
47
- const resolve = this.addInitializationStep();
48
- this.source.whenReady.then(cloud => {
49
- this.scale = new THREE.Vector3().addScalar(cloud.scale);
50
- this.spacing = cloud.spacing;
51
- this.hierarchyStepSize = cloud.hierarchyStepSize;
52
- const normal = Array.isArray(cloud.pointAttributes) && cloud.pointAttributes.find(elem => elem.startsWith('NORMAL'));
53
- if (normal) {
54
- this.material.defines[normal] = 1;
55
- }
56
- this.supportsProgressiveDisplay = this.source.extension === 'cin';
57
- this.root = new PotreeNode(0, 0, this);
58
- this.root.bbox.min.set(cloud.boundingBox.lx, cloud.boundingBox.ly, cloud.boundingBox.lz);
59
- this.root.bbox.max.set(cloud.boundingBox.ux, cloud.boundingBox.uy, cloud.boundingBox.uz);
60
- this.extent = Extent.fromBox3(this.source.crs || 'EPSG:4326', this.root.bbox);
61
- return this.root.loadOctree().then(resolve);
62
- });
63
- }
64
- }
65
- export default PotreeLayer;
@@ -1,27 +0,0 @@
1
- import Layer from "./Layer.js";
2
- import { removeLayeredMaterialNodeLayer } from "../Process/LayeredMaterialNodeProcessing.js";
3
- import textureConverter from "../Converter/textureConverter.js";
4
- import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
5
- class RasterLayer extends Layer {
6
- constructor(id, config) {
7
- config.cacheLifeTime = config.cacheLifeTime ?? CACHE_POLICIES.TEXTURE;
8
- super(id, config);
9
- }
10
- convert(data, extentDestination) {
11
- return textureConverter.convert(data, extentDestination, this);
12
- }
13
-
14
- /**
15
- * All layer's textures are removed from scene and disposed from video device.
16
- * @param {boolean} [clearCache=false] Whether to clear the layer cache or not
17
- */
18
- delete(clearCache) {
19
- if (clearCache) {
20
- this.cache.clear();
21
- }
22
- for (const root of this.parent.level0Nodes) {
23
- root.traverse(removeLayeredMaterialNodeLayer(this.id));
24
- }
25
- }
26
- }
27
- export default RasterLayer;
@@ -1,62 +0,0 @@
1
- // next step is move these properties to Style class
2
- // and hide transparent mechanism
3
- function ReferLayerProperties(material, layer) {
4
- if (layer && layer.isGeometryLayer) {
5
- let transparent = material.transparent;
6
- material.layer = layer;
7
- if (material.uniforms && material.uniforms.opacity != undefined) {
8
- Object.defineProperty(material.uniforms.opacity, 'value', {
9
- get: () => material.layer.opacity
10
- });
11
- } else if (material.opacity != undefined) {
12
- Object.defineProperty(material, 'opacity', {
13
- get: () => material.layer.opacity
14
- });
15
- }
16
- if (material.uniforms && material.uniforms.mode != undefined) {
17
- Object.defineProperty(material.uniforms.mode, 'value', {
18
- get: () => material.layer.pntsMode
19
- });
20
- }
21
- if (material.uniforms && material.uniforms.shape != undefined) {
22
- Object.defineProperty(material.uniforms.shape, 'value', {
23
- get: () => material.layer.pntsShape
24
- });
25
- }
26
- if (material.uniforms && material.uniforms.sizeMode != undefined) {
27
- Object.defineProperty(material.uniforms.sizeMode, 'value', {
28
- get: () => material.layer.pntsSizeMode
29
- });
30
- }
31
- if (material.uniforms && material.uniforms.minAttenuatedSize != undefined) {
32
- Object.defineProperty(material.uniforms.minAttenuatedSize, 'value', {
33
- get: () => material.layer.pntsMinAttenuatedSize
34
- });
35
- }
36
- if (material.uniforms && material.uniforms.maxAttenuatedSize != undefined) {
37
- Object.defineProperty(material.uniforms.maxAttenuatedSize, 'value', {
38
- get: () => material.layer.pntsMaxAttenuatedSize
39
- });
40
- }
41
- if (material.uniforms && material.uniforms.scale != undefined) {
42
- Object.defineProperty(material.uniforms.scale, 'value', {
43
- get: () => material.layer.scale
44
- });
45
- }
46
- Object.defineProperty(material, 'wireframe', {
47
- get: () => material.layer.wireframe
48
- });
49
- Object.defineProperty(material, 'transparent', {
50
- get: () => {
51
- const needTransparency = material.userData.needTransparency?.[material.mode] || material.layer.opacity < 1.0;
52
- if (transparent != needTransparency) {
53
- material.needsUpdate = true;
54
- transparent = needTransparency;
55
- }
56
- return transparent;
57
- }
58
- });
59
- }
60
- return material;
61
- }
62
- export default ReferLayerProperties;