itowns 2.44.3-next.4 → 2.44.3-next.41

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 (217) hide show
  1. package/README.md +3 -129
  2. package/examples/3dtiles_loader.html +123 -48
  3. package/examples/config.json +3 -10
  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/3dtiles_25d.html +0 -120
  43. package/examples/3dtiles_basic.html +0 -94
  44. package/examples/3dtiles_batch_table.html +0 -86
  45. package/examples/3dtiles_ion.html +0 -126
  46. package/examples/3dtiles_pointcloud.html +0 -95
  47. package/examples/jsm/.eslintrc.cjs +0 -38
  48. package/lib/Controls/FirstPersonControls.js +0 -308
  49. package/lib/Controls/FlyControls.js +0 -175
  50. package/lib/Controls/GlobeControls.js +0 -1162
  51. package/lib/Controls/PlanarControls.js +0 -1025
  52. package/lib/Controls/StateControl.js +0 -429
  53. package/lib/Controls/StreetControls.js +0 -392
  54. package/lib/Converter/Feature2Mesh.js +0 -608
  55. package/lib/Converter/Feature2Texture.js +0 -170
  56. package/lib/Converter/convertToTile.js +0 -75
  57. package/lib/Converter/textureConverter.js +0 -44
  58. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  59. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  60. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  61. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  62. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  63. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  64. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  65. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  66. package/lib/Core/AnimationPlayer.js +0 -142
  67. package/lib/Core/CopcNode.js +0 -174
  68. package/lib/Core/Deprecated/Undeprecator.js +0 -75
  69. package/lib/Core/EntwinePointTileNode.js +0 -126
  70. package/lib/Core/Feature.js +0 -490
  71. package/lib/Core/Geographic/CoordStars.js +0 -80
  72. package/lib/Core/Geographic/Coordinates.js +0 -320
  73. package/lib/Core/Geographic/Crs.js +0 -175
  74. package/lib/Core/Geographic/Extent.js +0 -726
  75. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  76. package/lib/Core/Label.js +0 -222
  77. package/lib/Core/MainLoop.js +0 -211
  78. package/lib/Core/Math/Ellipsoid.js +0 -144
  79. package/lib/Core/Picking.js +0 -255
  80. package/lib/Core/PointCloudNode.js +0 -42
  81. package/lib/Core/Potree2Node.js +0 -206
  82. package/lib/Core/Potree2PointAttributes.js +0 -139
  83. package/lib/Core/PotreeNode.js +0 -101
  84. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -299
  85. package/lib/Core/Prefab/Globe/BuilderEllipsoidTile.js +0 -110
  86. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -145
  87. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  88. package/lib/Core/Prefab/GlobeView.js +0 -161
  89. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -53
  90. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  91. package/lib/Core/Prefab/PlanarView.js +0 -62
  92. package/lib/Core/Prefab/TileBuilder.js +0 -80
  93. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -183
  94. package/lib/Core/Scheduler/Cache.js +0 -256
  95. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  96. package/lib/Core/Scheduler/Scheduler.js +0 -294
  97. package/lib/Core/Style.js +0 -1121
  98. package/lib/Core/System/Capabilities.js +0 -63
  99. package/lib/Core/TileGeometry.js +0 -40
  100. package/lib/Core/TileMesh.js +0 -108
  101. package/lib/Core/View.js +0 -1109
  102. package/lib/Layer/C3DTilesLayer.js +0 -455
  103. package/lib/Layer/ColorLayer.js +0 -128
  104. package/lib/Layer/CopcLayer.js +0 -58
  105. package/lib/Layer/ElevationLayer.js +0 -107
  106. package/lib/Layer/EntwinePointTileLayer.js +0 -64
  107. package/lib/Layer/FeatureGeometryLayer.js +0 -63
  108. package/lib/Layer/GeoidLayer.js +0 -80
  109. package/lib/Layer/GeometryLayer.js +0 -202
  110. package/lib/Layer/InfoLayer.js +0 -64
  111. package/lib/Layer/LabelLayer.js +0 -452
  112. package/lib/Layer/Layer.js +0 -304
  113. package/lib/Layer/LayerUpdateState.js +0 -89
  114. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  115. package/lib/Layer/OGC3DTilesLayer.js +0 -387
  116. package/lib/Layer/OrientedImageLayer.js +0 -222
  117. package/lib/Layer/PointCloudLayer.js +0 -359
  118. package/lib/Layer/Potree2Layer.js +0 -164
  119. package/lib/Layer/PotreeLayer.js +0 -65
  120. package/lib/Layer/RasterLayer.js +0 -27
  121. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  122. package/lib/Layer/TiledGeometryLayer.js +0 -403
  123. package/lib/Loader/LASLoader.js +0 -193
  124. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  125. package/lib/Loader/Potree2Loader.js +0 -207
  126. package/lib/Main.js +0 -115
  127. package/lib/MainBundle.js +0 -4
  128. package/lib/Parser/B3dmParser.js +0 -174
  129. package/lib/Parser/CameraCalibrationParser.js +0 -94
  130. package/lib/Parser/GDFParser.js +0 -72
  131. package/lib/Parser/GTXParser.js +0 -75
  132. package/lib/Parser/GeoJsonParser.js +0 -212
  133. package/lib/Parser/GpxParser.js +0 -25
  134. package/lib/Parser/ISGParser.js +0 -71
  135. package/lib/Parser/KMLParser.js +0 -25
  136. package/lib/Parser/LASParser.js +0 -137
  137. package/lib/Parser/MapBoxUrlParser.js +0 -83
  138. package/lib/Parser/PntsParser.js +0 -131
  139. package/lib/Parser/Potree2BinParser.js +0 -92
  140. package/lib/Parser/PotreeBinParser.js +0 -106
  141. package/lib/Parser/PotreeCinParser.js +0 -29
  142. package/lib/Parser/ShapefileParser.js +0 -78
  143. package/lib/Parser/VectorTileParser.js +0 -202
  144. package/lib/Parser/XbilParser.js +0 -108
  145. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  146. package/lib/Parser/iGLTFLoader.js +0 -168
  147. package/lib/Process/3dTilesProcessing.js +0 -304
  148. package/lib/Process/FeatureProcessing.js +0 -76
  149. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  150. package/lib/Process/ObjectRemovalHelper.js +0 -97
  151. package/lib/Process/handlerNodeError.js +0 -23
  152. package/lib/Provider/3dTilesProvider.js +0 -149
  153. package/lib/Provider/DataSourceProvider.js +0 -8
  154. package/lib/Provider/Fetcher.js +0 -229
  155. package/lib/Provider/PointCloudProvider.js +0 -45
  156. package/lib/Provider/TileProvider.js +0 -16
  157. package/lib/Provider/URLBuilder.js +0 -105
  158. package/lib/Renderer/Camera.js +0 -281
  159. package/lib/Renderer/Color.js +0 -56
  160. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  161. package/lib/Renderer/CommonMaterial.js +0 -31
  162. package/lib/Renderer/Label2DRenderer.js +0 -190
  163. package/lib/Renderer/LayeredMaterial.js +0 -243
  164. package/lib/Renderer/OBB.js +0 -153
  165. package/lib/Renderer/OrientedImageCamera.js +0 -118
  166. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  167. package/lib/Renderer/PointsMaterial.js +0 -485
  168. package/lib/Renderer/RasterTile.js +0 -209
  169. package/lib/Renderer/RenderMode.js +0 -31
  170. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  171. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  172. package/lib/Renderer/SphereHelper.js +0 -23
  173. package/lib/Renderer/WebXR.js +0 -51
  174. package/lib/Renderer/c3DEngine.js +0 -214
  175. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  176. package/lib/Source/C3DTilesIonSource.js +0 -54
  177. package/lib/Source/C3DTilesSource.js +0 -30
  178. package/lib/Source/CopcSource.js +0 -115
  179. package/lib/Source/EntwinePointTileSource.js +0 -62
  180. package/lib/Source/FileSource.js +0 -189
  181. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  182. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  183. package/lib/Source/OGC3DTilesSource.js +0 -21
  184. package/lib/Source/OrientedImageSource.js +0 -59
  185. package/lib/Source/Potree2Source.js +0 -167
  186. package/lib/Source/PotreeSource.js +0 -82
  187. package/lib/Source/Source.js +0 -223
  188. package/lib/Source/TMSSource.js +0 -143
  189. package/lib/Source/VectorTilesSource.js +0 -178
  190. package/lib/Source/WFSSource.js +0 -165
  191. package/lib/Source/WMSSource.js +0 -130
  192. package/lib/Source/WMTSSource.js +0 -86
  193. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  194. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -470
  195. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  196. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  197. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -399
  198. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2876
  199. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -625
  200. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  201. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  202. package/lib/Utils/CameraUtils.js +0 -555
  203. package/lib/Utils/DEMUtils.js +0 -350
  204. package/lib/Utils/FeaturesUtils.js +0 -156
  205. package/lib/Utils/Gradients.js +0 -16
  206. package/lib/Utils/OrientationUtils.js +0 -457
  207. package/lib/Utils/ThreeUtils.js +0 -115
  208. package/lib/Utils/gui/C3DTilesStyle.js +0 -216
  209. package/lib/Utils/gui/Main.js +0 -7
  210. package/lib/Utils/gui/Minimap.js +0 -154
  211. package/lib/Utils/gui/Navigation.js +0 -245
  212. package/lib/Utils/gui/Scale.js +0 -107
  213. package/lib/Utils/gui/Searchbar.js +0 -234
  214. package/lib/Utils/gui/Widget.js +0 -80
  215. package/lib/Utils/placeObjectOnGround.js +0 -137
  216. package/lib/Worker/LASLoaderWorker.js +0 -19
  217. package/lib/Worker/Potree2Worker.js +0 -21
@@ -1,403 +0,0 @@
1
- import * as THREE from 'three';
2
- import GeometryLayer from "./GeometryLayer.js";
3
- import { InfoTiledGeometryLayer } from "./InfoLayer.js";
4
- import Picking from "../Core/Picking.js";
5
- import convertToTile from "../Converter/convertToTile.js";
6
- import ObjectRemovalHelper from "../Process/ObjectRemovalHelper.js";
7
- import { ImageryLayers } from "./Layer.js";
8
- import { CACHE_POLICIES } from "../Core/Scheduler/Cache.js";
9
- const subdivisionVector = new THREE.Vector3();
10
- const boundingSphereCenter = new THREE.Vector3();
11
-
12
- /**
13
- * @property {InfoTiledGeometryLayer} info - Status information of layer
14
- * @property {boolean} isTiledGeometryLayer - Used to checkout whether this
15
- * layer is a TiledGeometryLayer. Default is true. You should not change this,
16
- * as it is used internally for optimisation.
17
- * @property {boolean} hideSkirt (default false) - Used to hide the skirt (tile borders).
18
- * Useful when the layer opacity < 1
19
- */
20
- class TiledGeometryLayer extends GeometryLayer {
21
- /**
22
- * A layer extending the {@link GeometryLayer}, but with a tiling notion.
23
- *
24
- * `TiledGeometryLayer` is the ground where `ColorLayer` and `ElevationLayer` are attached.
25
- * `TiledGeometryLayer` is a quadtree data structure. At zoom 0,
26
- * there is a single tile for the whole earth. At zoom level 1,
27
- * the single tile splits into 4 tiles (2x2 tile square).
28
- * Each zoom level quadtree divides the geometry tiles of the one before it.
29
- * The camera distance determines how the tiles are subdivided for optimal data display.
30
- *
31
- * Some `GeometryLayer` can also be attached to the `TiledGeometryLayer` if they want to take advantage of the quadtree.
32
- *
33
- * ![tiled geometry](/docs/static/images/tiledGeometry.jpeg)
34
- * _In `GlobeView`, **red lines** represents the **WGS84 grid** and **orange lines** the **Pseudo-mercator grid**._
35
- * _In this picture, there are tiles with 3 different zoom/levels._
36
- *
37
- * The zoom/level is based on [tiled web map](https://en.wikipedia.org/wiki/Tiled_web_map).
38
- * It corresponds at meters by pixel. If the projection tile exceeds a certain pixel size (on screen)
39
- * then it is subdivided into 4 tiles with a zoom greater than 1.
40
- *
41
- * @extends GeometryLayer
42
- *
43
- * @param {string} id - The id of the layer, that should be unique. It is
44
- * not mandatory, but an error will be emitted if this layer is added a
45
- * {@link View} that already has a layer going by that id.
46
- * @param {THREE.Object3d} object3d - The object3d used to contain the
47
- * geometry of the TiledGeometryLayer. It is usually a `THREE.Group`, but it
48
- * can be anything inheriting from a `THREE.Object3d`.
49
- * @param {Array} schemeTile - extents Array of root tiles
50
- * @param {Object} builder - builder geometry object
51
- * @param {Object} [config] - Optional configuration, all elements in it
52
- * will be merged as is in the layer. For example, if the configuration
53
- * contains three elements `name, protocol, extent`, these elements will be
54
- * available using `layer.name` or something else depending on the property
55
- * name.
56
- * @param {Source} [config.source] - Description and options of the source.
57
- *
58
- * @throws {Error} `object3d` must be a valid `THREE.Object3d`.
59
- */
60
- constructor(id, object3d, schemeTile, builder, config) {
61
- // cacheLifeTime = CACHE_POLICIES.INFINITE because the cache is handled by the builder
62
- config.cacheLifeTime = CACHE_POLICIES.INFINITE;
63
- config.source = false;
64
- super(id, object3d, config);
65
- this.isTiledGeometryLayer = true;
66
- // TODO : this should be add in a preprocess method specific to GeoidLayer.
67
- this.object3d.geoidHeight = 0;
68
- this.protocol = 'tile';
69
- this._hideSkirt = !!config.hideSkirt;
70
- this.sseSubdivisionThreshold = this.sseSubdivisionThreshold || 1.0;
71
- this.schemeTile = schemeTile;
72
- this.builder = builder;
73
- this.info = new InfoTiledGeometryLayer(this);
74
- if (!this.schemeTile) {
75
- throw new Error(`Cannot init tiled layer without schemeTile for layer ${this.id}`);
76
- }
77
- if (!this.builder) {
78
- throw new Error(`Cannot init tiled layer without builder for layer ${this.id}`);
79
- }
80
- if (config.maxDeltaElevationLevel) {
81
- console.warn('Config using maxDeltaElevationLevel is deprecated. The parameter maxDeltaElevationLevel is not longer used');
82
- }
83
- this.level0Nodes = [];
84
- const promises = [];
85
- for (const root of this.schemeTile) {
86
- promises.push(this.convert(undefined, root));
87
- }
88
- this._promises.push(Promise.all(promises).then(level0s => {
89
- this.level0Nodes = level0s;
90
- this.object3d.add(...level0s);
91
- this.object3d.updateMatrixWorld();
92
- }));
93
- this.maxScreenSizeNode = this.sseSubdivisionThreshold * (this.sizeDiagonalTexture * 2);
94
- }
95
- get hideSkirt() {
96
- return this._hideSkirt;
97
- }
98
- set hideSkirt(value) {
99
- if (!this.level0Nodes) {
100
- return;
101
- }
102
- this._hideSkirt = value;
103
- for (const node of this.level0Nodes) {
104
- node.traverse(obj => {
105
- if (obj.isTileMesh) {
106
- obj.geometry.hideSkirt = value;
107
- }
108
- });
109
- }
110
- }
111
- /**
112
- * Picking method for this layer. It uses the {@link Picking#pickTilesAt}
113
- * method.
114
- *
115
- * @param {View} view - The view instance.
116
- * @param {Object} coordinates - The coordinates to pick in the view. It
117
- * should have at least `x` and `y` properties.
118
- * @param {number} radius - Radius of the picking circle.
119
- * @param {Array} target - Array to push picking result.
120
- *
121
- * @return {Array} An array containing all targets picked under the
122
- * specified coordinates.
123
- */
124
- pickObjectsAt(view, coordinates) {
125
- let radius = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.options.defaultPickingRadius;
126
- let target = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
127
- return Picking.pickTilesAt(view, coordinates, radius, this, target);
128
- }
129
-
130
- /**
131
- * Does pre-update work on the context:
132
- * <ul>
133
- * <li>update the `colorLayers` and `elevationLayers`</li>
134
- * <li>update the `maxElevationLevel`</li>
135
- * </ul>
136
- *
137
- * Once this work is done, it returns a list of nodes to update. Depending
138
- * on the origin of `sources`, it can return a few things:
139
- * <ul>
140
- * <li>if `sources` is empty, it returns the first node of the layer
141
- * (stored as `level0Nodes`), which will trigger the update of the whole
142
- * tree</li>
143
- * <li>if the update is triggered by a camera move, the whole tree is
144
- * returned too</li>
145
- * <li>if `source.layer` is this layer, it means that `source` is a node; a
146
- * common ancestor will be found if there are multiple sources, with the
147
- * default common ancestor being the first source itself</li>
148
- * <li>else it returns the whole tree</li>
149
- * </ul>
150
- *
151
- * @param {Object} context - The context of the update; see the {@link
152
- * MainLoop} for more informations.
153
- * @param {Set<GeometryLayer|TileMesh>} sources - A list of sources to
154
- * generate a list of nodes to update.
155
- *
156
- * @return {TileMesh[]} The array of nodes to update.
157
- */
158
- preUpdate(context, sources) {
159
- if (sources.has(undefined) || sources.size == 0) {
160
- return this.level0Nodes;
161
- }
162
- context.colorLayers = context.view.getLayers((l, a) => a && a.id == this.id && l.isColorLayer);
163
- context.elevationLayers = context.view.getLayers((l, a) => a && a.id == this.id && l.isElevationLayer);
164
- context.maxElevationLevel = -1;
165
- for (const e of context.elevationLayers) {
166
- context.maxElevationLevel = Math.max(e.source.zoom.max, context.maxElevationLevel);
167
- }
168
- if (context.maxElevationLevel == -1) {
169
- context.maxElevationLevel = Infinity;
170
- }
171
-
172
- // Prepare ColorLayer sequence order
173
- // In this moment, there is only one color layers sequence, because they are attached to tileLayer.
174
- // In future, the sequence must be returned by parent geometry layer.
175
- this.colorLayersOrder = ImageryLayers.getColorLayersIdOrderedBySequence(context.colorLayers);
176
- let commonAncestor;
177
- for (const source of sources.values()) {
178
- if (source.isCamera) {
179
- // if the change is caused by a camera move, no need to bother
180
- // to find common ancestor: we need to update the whole tree:
181
- // some invisible tiles may now be visible
182
- return this.level0Nodes;
183
- }
184
- if (source.layer === this) {
185
- if (!commonAncestor) {
186
- commonAncestor = source;
187
- } else {
188
- commonAncestor = source.findCommonAncestor(commonAncestor);
189
- if (!commonAncestor) {
190
- return this.level0Nodes;
191
- }
192
- }
193
- if (commonAncestor.material == null) {
194
- commonAncestor = undefined;
195
- }
196
- }
197
- }
198
- if (commonAncestor) {
199
- return [commonAncestor];
200
- } else {
201
- return this.level0Nodes;
202
- }
203
- }
204
-
205
- /**
206
- * Update a node of this layer. The node will not be updated if:
207
- * <ul>
208
- * <li>it does not have a parent, then it is removed</li>
209
- * <li>its parent is being subdivided</li>
210
- * <li>is not visible in the camera</li>
211
- * </ul>
212
- *
213
- * @param {Object} context - The context of the update; see the {@link
214
- * MainLoop} for more informations.
215
- * @param {Layer} layer - Parameter to be removed once all update methods
216
- * have been aligned.
217
- * @param {TileMesh} node - The node to update.
218
- *
219
- * @returns {Object}
220
- */
221
- update(context, layer, node) {
222
- if (!node.parent) {
223
- return ObjectRemovalHelper.removeChildrenAndCleanup(this, node);
224
- }
225
- // early exit if parent' subdivision is in progress
226
- if (node.parent.pendingSubdivision) {
227
- node.visible = false;
228
- node.material.visible = false;
229
- this.info.update(node);
230
- return undefined;
231
- }
232
-
233
- // do proper culling
234
- node.visible = !this.culling(node, context.camera);
235
- if (node.visible) {
236
- let requestChildrenUpdate = false;
237
- node.material.visible = true;
238
- this.info.update(node);
239
- if (node.pendingSubdivision || TiledGeometryLayer.hasEnoughTexturesToSubdivide(context, node) && this.subdivision(context, this, node)) {
240
- this.subdivideNode(context, node);
241
- // display iff children aren't ready
242
- node.material.visible = node.pendingSubdivision;
243
- this.info.update(node);
244
- requestChildrenUpdate = true;
245
- }
246
- if (node.material.visible) {
247
- if (!requestChildrenUpdate) {
248
- return ObjectRemovalHelper.removeChildren(this, node);
249
- }
250
- }
251
- return requestChildrenUpdate ? node.children.filter(n => n.layer == this) : undefined;
252
- }
253
- node.material.visible = false;
254
- this.info.update(node);
255
- return ObjectRemovalHelper.removeChildren(this, node);
256
- }
257
- convert(requester, extent) {
258
- return convertToTile.convert(requester, extent, this);
259
- }
260
- countColorLayersTextures() {
261
- return arguments.length;
262
- }
263
-
264
- // eslint-disable-next-line
265
- culling(node, camera) {
266
- return !camera.isBox3Visible(node.obb.box3D, node.matrixWorld);
267
- }
268
-
269
- /**
270
- * Tell if a node has enough elevation or color textures to subdivide.
271
- * Subdivision is prevented if:
272
- * <ul>
273
- * <li>the node is covered by at least one elevation layer and if the node
274
- * doesn't have an elevation texture yet</li>
275
- * <li>a color texture is missing</li>
276
- * </ul>
277
- *
278
- * @param {Object} context - The context of the update; see the {@link
279
- * MainLoop} for more informations.
280
- * @param {TileMesh} node - The node to subdivide.
281
- *
282
- * @returns {boolean} False if the node can not be subdivided, true
283
- * otherwise.
284
- */
285
- static hasEnoughTexturesToSubdivide(context, node) {
286
- const layerUpdateState = node.layerUpdateState || {};
287
- let nodeLayer = node.material.getElevationLayer();
288
- for (const e of context.elevationLayers) {
289
- const extents = node.getExtentsByProjection(e.crs);
290
- const zoom = extents[0].zoom;
291
- if (zoom > e.zoom.max || zoom < e.zoom.min) {
292
- continue;
293
- }
294
- if (!e.frozen && e.ready && e.source.extentInsideLimit(node.extent, zoom) && (!nodeLayer || nodeLayer.level < 0)) {
295
- // no stop subdivision in the case of a loading error
296
- if (layerUpdateState[e.id] && layerUpdateState[e.id].inError()) {
297
- continue;
298
- }
299
- return false;
300
- }
301
- }
302
- for (const c of context.colorLayers) {
303
- if (c.frozen || !c.visible || !c.ready) {
304
- continue;
305
- }
306
- const extents = node.getExtentsByProjection(c.crs);
307
- const zoom = extents[0].zoom;
308
- if (zoom > c.zoom.max || zoom < c.zoom.min) {
309
- continue;
310
- }
311
- // no stop subdivision in the case of a loading error
312
- if (layerUpdateState[c.id] && layerUpdateState[c.id].inError()) {
313
- continue;
314
- }
315
- nodeLayer = node.material.getLayer(c.id);
316
- if (c.source.extentInsideLimit(node.extent, zoom) && (!nodeLayer || nodeLayer.level < 0)) {
317
- return false;
318
- }
319
- }
320
- return true;
321
- }
322
-
323
- /**
324
- * Subdivides a node of this layer. If the node is currently in the process
325
- * of subdivision, it will not do anything here. The subdivision of a node
326
- * will occur in four part, to create a quadtree. The extent of the node
327
- * will be divided in four parts: north-west, north-east, south-west and
328
- * south-east. Once all four nodes are created, they will be added to the
329
- * current node and the view of the context will be notified of this change.
330
- *
331
- * @param {Object} context - The context of the update; see the {@link
332
- * MainLoop} for more informations.
333
- * @param {TileMesh} node - The node to subdivide.
334
- * @return {Promise} { description_of_the_return_value }
335
- */
336
- subdivideNode(context, node) {
337
- if (!node.pendingSubdivision && !node.children.some(n => n.layer == this)) {
338
- const extents = node.extent.subdivision();
339
- // TODO: pendingSubdivision mechanism is fragile, get rid of it
340
- node.pendingSubdivision = true;
341
- const command = {
342
- /* mandatory */
343
- view: context.view,
344
- requester: node,
345
- layer: this,
346
- priority: 10000,
347
- /* specific params */
348
- extentsSource: extents,
349
- redraw: false
350
- };
351
- return context.scheduler.execute(command).then(children => {
352
- for (const child of children) {
353
- node.add(child);
354
- child.updateMatrixWorld(true);
355
- }
356
- node.pendingSubdivision = false;
357
- context.view.notifyChange(node, false);
358
- }, err => {
359
- node.pendingSubdivision = false;
360
- if (!err.isCancelledCommandException) {
361
- throw new Error(err);
362
- }
363
- });
364
- }
365
- }
366
-
367
- /**
368
- * Test the subdvision of a node, compared to this layer.
369
- *
370
- * @param {Object} context - The context of the update; see the {@link
371
- * MainLoop} for more informations.
372
- * @param {PlanarLayer} layer - This layer, parameter to be removed.
373
- * @param {TileMesh} node - The node to test.
374
- *
375
- * @return {boolean} - True if the node is subdivisable, otherwise false.
376
- */
377
- subdivision(context, layer, node) {
378
- if (node.level < this.minSubdivisionLevel) {
379
- return true;
380
- }
381
- if (this.maxSubdivisionLevel <= node.level) {
382
- return false;
383
- }
384
- subdivisionVector.setFromMatrixScale(node.matrixWorld);
385
- boundingSphereCenter.copy(node.boundingSphere.center).applyMatrix4(node.matrixWorld);
386
- const distance = Math.max(0.0, context.camera.camera3D.position.distanceTo(boundingSphereCenter) - node.boundingSphere.radius * subdivisionVector.x);
387
-
388
- // Size projection on pixel of bounding
389
- if (context.camera.camera3D.isOrthographicCamera) {
390
- const camera3D = context.camera.camera3D;
391
- const preSSE = context.camera._preSSE * 2 * camera3D.zoom / (camera3D.top - camera3D.bottom);
392
- node.screenSize = preSSE * node.boundingSphere.radius * subdivisionVector.x;
393
- } else {
394
- node.screenSize = context.camera._preSSE * (2 * node.boundingSphere.radius * subdivisionVector.x) / distance;
395
- }
396
-
397
- // The screen space error is calculated to have a correct texture display.
398
- // For the projection of a texture's texel to be less than or equal to one pixel
399
- const sse = node.screenSize / (this.sizeDiagonalTexture * 2);
400
- return this.sseSubdivisionThreshold < sse;
401
- }
402
- }
403
- export default TiledGeometryLayer;
@@ -1,193 +0,0 @@
1
- import { LazPerf } from 'laz-perf';
2
- import { Las } from 'copc';
3
-
4
- /**
5
- * @typedef {Object} Header - Partial LAS header.
6
- * @property {number} header.pointDataRecordFormat - Type of point data
7
- * records contained by the buffer.
8
- * @property {number} header.pointDataRecordLength - Size (in bytes) of the
9
- * point data records. If the specified size is larger than implied by the
10
- * point data record format (see above) the remaining bytes are user-specfic
11
- * "extra bytes". Those are described by an Extra Bytes VLR.
12
- * @property {number[]} header.scale - Scale factors (an array `[xScale,
13
- * yScale, zScale]`) multiplied to the X, Y, Z point record values.
14
- * @property {number[]} header.offset - Offsets (an array `[xOffset,
15
- * xOffset, zOffset]`) added to the scaled X, Y, Z point record values.
16
- */
17
-
18
- function defaultColorEncoding(header) {
19
- return header.majorVersion === 1 && header.minorVersion <= 2 ? 8 : 16;
20
- }
21
-
22
- /**
23
- * @classdesc
24
- * Loader for LAS and LAZ (LASZip) point clouds. It uses the copc.js library and
25
- * the laz-perf decoder under the hood.
26
- *
27
- * The laz-perf web assembly module is lazily fetched at runtime when a parsing
28
- * request is initiated. Location of laz-perf wasm defaults to the unpkg
29
- * repository.
30
- */
31
- class LASLoader {
32
- constructor() {
33
- this._wasmPath = 'https://cdn.jsdelivr.net/npm/laz-perf@0.0.6/lib';
34
- this._wasmPromise = null;
35
- }
36
- _initDecoder() {
37
- if (this._wasmPromise) {
38
- return this._wasmPromise;
39
- }
40
- this._wasmPromise = LazPerf.create({
41
- locateFile: file => `${this._wasmPath}/${file}`
42
- });
43
- return this._wasmPromise;
44
- }
45
- _parseView(view, options) {
46
- const colorDepth = options.colorDepth ?? 16;
47
- const getPosition = ['X', 'Y', 'Z'].map(view.getter);
48
- const getIntensity = view.getter('Intensity');
49
- const getReturnNumber = view.getter('ReturnNumber');
50
- const getNumberOfReturns = view.getter('NumberOfReturns');
51
- const getClassification = view.getter('Classification');
52
- const getPointSourceID = view.getter('PointSourceId');
53
- const getColor = view.dimensions.Red ? ['Red', 'Green', 'Blue'].map(view.getter) : undefined;
54
- const getScanAngle = view.getter('ScanAngle');
55
- const positions = new Float32Array(view.pointCount * 3);
56
- const intensities = new Uint16Array(view.pointCount);
57
- const returnNumbers = new Uint8Array(view.pointCount);
58
- const numberOfReturns = new Uint8Array(view.pointCount);
59
- const classifications = new Uint8Array(view.pointCount);
60
- const pointSourceIDs = new Uint16Array(view.pointCount);
61
- const colors = getColor ? new Uint8Array(view.pointCount * 4) : undefined;
62
- /*
63
- As described by the LAS spec, Scan Angle is encoded:
64
- - as signed char in a valid range from -90 to +90 (degrees) prior to the LAS 1.4 Point Data Record Formats (PDRF) 6
65
- - as a signed short in a valid range from -30 000 to +30 000. Those values represents scan angles from -180 to +180
66
- degrees with an increment of 0.006 for PDRF >= 6.
67
- The copc.js library does the degree convertion and stores it as a `Float32`.
68
- */
69
- const scanAngles = new Float32Array(view.pointCount);
70
-
71
- // For precision we take the first point that will be use as origin for a local referentiel.
72
- const origin = getPosition.map(f => f(0)).map(val => Math.floor(val));
73
- for (let i = 0; i < view.pointCount; i++) {
74
- // `getPosition` apply scale and offset transform to the X, Y, Z
75
- // values. See https://github.com/connormanning/copc.js/blob/master/src/las/extractor.ts.
76
- const [x, y, z] = getPosition.map(f => f(i));
77
- positions[i * 3] = x - origin[0];
78
- positions[i * 3 + 1] = y - origin[1];
79
- positions[i * 3 + 2] = z - origin[2];
80
- intensities[i] = getIntensity(i);
81
- returnNumbers[i] = getReturnNumber(i);
82
- numberOfReturns[i] = getNumberOfReturns(i);
83
- if (getColor) {
84
- // Note that we do not infer color depth as it is expensive
85
- // (i.e. traverse the whole view to check if there exists a red,
86
- // green or blue value > 255).
87
- let [r, g, b] = getColor.map(f => f(i));
88
- if (colorDepth === 16) {
89
- r /= 256;
90
- g /= 256;
91
- b /= 256;
92
- }
93
- colors[i * 4] = r;
94
- colors[i * 4 + 1] = g;
95
- colors[i * 4 + 2] = b;
96
- colors[i * 4 + 3] = 255;
97
- }
98
- classifications[i] = getClassification(i);
99
- pointSourceIDs[i] = getPointSourceID(i);
100
- scanAngles[i] = getScanAngle(i);
101
- }
102
- return {
103
- position: positions,
104
- intensity: intensities,
105
- returnNumber: returnNumbers,
106
- numberOfReturns,
107
- classification: classifications,
108
- pointSourceID: pointSourceIDs,
109
- color: colors,
110
- scanAngle: scanAngles,
111
- origin
112
- };
113
- }
114
-
115
- /**
116
- * Set LazPerf decoder path.
117
- * @param {string} path - path to `laz-perf.wasm` folder.
118
- */
119
- set lazPerf(path) {
120
- this._wasmPath = path;
121
- this._wasmPromise = null;
122
- }
123
-
124
- /**
125
- * Parses a LAS or LAZ (LASZip) chunk. Note that this function is
126
- * **CPU-bound** and shall be parallelised in a dedicated worker.
127
- * @param {Uint8Array} data - File chunk data.
128
- * @param {Object} options - Parsing options.
129
- * @param {Header} options.header - Partial LAS header.
130
- * @param {number} options.pointCount - Number of points encoded in this
131
- * data chunk.
132
- * @param {Las.ExtraBytes[]} [options.eb] - Extra bytes LAS VLRs
133
- * headers.
134
- * @param {8 | 16} [options.colorDepth] - Color depth encoding (in bits).
135
- * Either 8 or 16 bits. Defaults to 8 bits for LAS 1.2 and 16 bits for later
136
- * versions (as mandatory by the specification).
137
- */
138
- async parseChunk(data, options) {
139
- const {
140
- header,
141
- eb,
142
- pointCount
143
- } = options;
144
- const {
145
- pointDataRecordFormat,
146
- pointDataRecordLength
147
- } = header;
148
- const colorDepth = options.colorDepth ?? defaultColorEncoding(header);
149
- const bytes = new Uint8Array(data);
150
- const pointData = await Las.PointData.decompressChunk(bytes, {
151
- pointCount,
152
- pointDataRecordFormat,
153
- pointDataRecordLength
154
- }, this._initDecoder());
155
- const view = Las.View.create(pointData, header, eb);
156
- const attributes = this._parseView(view, {
157
- colorDepth
158
- });
159
- return {
160
- attributes
161
- };
162
- }
163
-
164
- /**
165
- * Parses a LAS or LAZ (LASZip) file. Note that this function is
166
- * **CPU-bound** and shall be parallelised in a dedicated worker.
167
- * @param {ArrayBuffer} data - Binary data to parse.
168
- * @param {Object} [options] - Parsing options.
169
- * @param {8 | 16} [options.colorDepth] - Color depth encoding (in bits).
170
- * Either 8 or 16 bits. Defaults to 8 bits for LAS 1.2 and 16 bits for later
171
- * versions (as mandatory by the specification)
172
- */
173
- async parseFile(data) {
174
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
175
- const bytes = new Uint8Array(data);
176
- const pointData = await Las.PointData.decompressFile(bytes, this._initDecoder());
177
- const header = Las.Header.parse(bytes);
178
- const colorDepth = options.colorDepth ?? defaultColorEncoding(header);
179
- const getter = async (begin, end) => bytes.slice(begin, end);
180
- const vlrs = await Las.Vlr.walk(getter, header);
181
- const ebVlr = Las.Vlr.find(vlrs, 'LASF_Spec', 4);
182
- const eb = ebVlr && Las.ExtraBytes.parse(await Las.Vlr.fetch(getter, ebVlr));
183
- const view = Las.View.create(pointData, header, eb);
184
- const attributes = this._parseView(view, {
185
- colorDepth
186
- });
187
- return {
188
- header,
189
- attributes
190
- };
191
- }
192
- }
193
- export default LASLoader;