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,174 +0,0 @@
1
- import * as THREE from 'three';
2
- import { Hierarchy } from 'copc';
3
- import PointCloudNode from "./PointCloudNode.js";
4
- const size = new THREE.Vector3();
5
- const position = new THREE.Vector3();
6
- const translation = new THREE.Vector3();
7
- function buildId(depth, x, y, z) {
8
- return `${depth}-${x}-${y}-${z}`;
9
- }
10
- class CopcNode extends PointCloudNode {
11
- /**
12
- * Constructs a new instance of a COPC Octree node
13
- *
14
- * @param {number} depth - Depth within the octree
15
- * @param {number} x - X position within the octree
16
- * @param {number} y - Y position within the octree
17
- * @param {number} z - Z position with the octree
18
- * @param {number} entryOffset - Offset from the beginning of the file of
19
- * the node entry
20
- * @param {number} entryLength - Size of the node entry
21
- * @param {CopcLayer} layer - Parent COPC layer
22
- * @param {number} [numPoints=0] - Number of points given by this entry
23
- */
24
- constructor(depth, x, y, z, entryOffset, entryLength, layer) {
25
- let numPoints = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 0;
26
- super(numPoints, layer);
27
- this.isCopcNode = true;
28
- this.entryOffset = entryOffset;
29
- this.entryLength = entryLength;
30
- this.layer = layer;
31
- this.depth = depth;
32
- this.x = x;
33
- this.y = y;
34
- this.z = z;
35
- }
36
- get id() {
37
- return buildId(this.depth, this.x, this.y, this.z);
38
- }
39
- get octreeIsLoaded() {
40
- return this.numPoints >= 0;
41
- }
42
-
43
- /**
44
- * @param {number} offset
45
- * @param {number} size
46
- */
47
- async _fetch(offset, size) {
48
- return this.layer.source.fetcher(this.layer.source.url, {
49
- ...this.layer.source.networkOptions,
50
- headers: {
51
- ...this.layer.source.networkOptions.headers,
52
- range: `bytes=${offset}-${offset + size - 1}`
53
- }
54
- });
55
- }
56
-
57
- /**
58
- * Create an (A)xis (A)ligned (B)ounding (B)ox for the given node given
59
- * `this` is its parent.
60
- * @param {CopcNode} node - The child node
61
- */
62
- createChildAABB(node) {
63
- // factor to apply, based on the depth difference (can be > 1)
64
- const f = 2 ** (node.depth - this.depth);
65
-
66
- // size of the child node bbox (Vector3), based on the size of the
67
- // parent node, and divided by the factor
68
- this.bbox.getSize(size).divideScalar(f);
69
-
70
- // initialize the child node bbox at the location of the parent node bbox
71
- node.bbox.min.copy(this.bbox.min);
72
-
73
- // position of the parent node, if it was at the same depth as the
74
- // child, found by multiplying the tree position by the factor
75
- position.copy(this).multiplyScalar(f);
76
-
77
- // difference in position between the two nodes, at child depth, and
78
- // scale it using the size
79
- translation.subVectors(node, position).multiply(size);
80
-
81
- // apply the translation to the child node bbox
82
- node.bbox.min.add(translation);
83
-
84
- // use the size computed above to set the max
85
- node.bbox.max.copy(node.bbox.min).add(size);
86
- }
87
-
88
- /**
89
- * Create a CopcNode from the provided subtree and add it as child
90
- * of the current node.
91
- * @param {number} depth - Child node depth in the octree
92
- * @param {number} x - Child node x position in the octree
93
- * @param {number} y - Child node y position in the octree
94
- * @param {number} z - Child node z position in the octree
95
- * @param {Hierarchy.Subtree} hierarchy - Octree's subtree
96
- * @param {CopcNode[]} stack - Stack of node candidates for traversal
97
- */
98
- findAndCreateChild(depth, x, y, z, hierarchy, stack) {
99
- const id = buildId(depth, x, y, z);
100
- let pointCount;
101
- let offset;
102
- let byteSize;
103
- const node = hierarchy.nodes[id];
104
- if (node) {
105
- pointCount = node.pointCount;
106
- offset = node.pointDataOffset;
107
- byteSize = node.pointDataLength;
108
- } else {
109
- const page = hierarchy.pages[id];
110
- if (!page) {
111
- return;
112
- }
113
- pointCount = -1;
114
- offset = page.pageOffset;
115
- byteSize = page.pageLength;
116
- }
117
- const child = new CopcNode(depth, x, y, z, offset, byteSize, this.layer, pointCount);
118
- this.add(child);
119
- stack.push(child);
120
- }
121
- async loadOctree() {
122
- // Load hierarchy
123
- const buffer = await this._fetch(this.entryOffset, this.entryLength);
124
- const hierarchy = await Hierarchy.parse(new Uint8Array(buffer));
125
-
126
- // Update current node entry from loaded subtree
127
- const node = hierarchy.nodes[this.id];
128
- if (!node) {
129
- return Promise.reject('[CopcNode]: Ill-formed data, entry not found in hierarchy.');
130
- }
131
- this.numPoints = node.pointCount;
132
- this.entryOffset = node.pointDataOffset;
133
- this.entryLength = node.pointDataLength;
134
-
135
- // Load subtree entries
136
- const stack = [];
137
- stack.push(this);
138
- while (stack.length) {
139
- const node = stack.shift();
140
- const depth = node.depth + 1;
141
- const x = node.x * 2;
142
- const y = node.y * 2;
143
- const z = node.z * 2;
144
- node.findAndCreateChild(depth, x, y, z, hierarchy, stack);
145
- node.findAndCreateChild(depth, x + 1, y, z, hierarchy, stack);
146
- node.findAndCreateChild(depth, x, y + 1, z, hierarchy, stack);
147
- node.findAndCreateChild(depth, x + 1, y + 1, z, hierarchy, stack);
148
- node.findAndCreateChild(depth, x, y, z + 1, hierarchy, stack);
149
- node.findAndCreateChild(depth, x + 1, y, z + 1, hierarchy, stack);
150
- node.findAndCreateChild(depth, x, y + 1, z + 1, hierarchy, stack);
151
- node.findAndCreateChild(depth, x + 1, y + 1, z + 1, hierarchy, stack);
152
- }
153
- }
154
-
155
- /**
156
- * Load the COPC Buffer geometry for this node.
157
- * @returns {Promise<THREE.BufferGeometry>}
158
- */
159
- async load() {
160
- if (!this.octreeIsLoaded) {
161
- await this.loadOctree();
162
- }
163
- const buffer = await this._fetch(this.entryOffset, this.entryLength);
164
- const geometry = await this.layer.source.parser(buffer, {
165
- in: {
166
- ...this.layer.source,
167
- pointCount: this.numPoints
168
- },
169
- out: this.layer
170
- });
171
- return geometry;
172
- }
173
- }
174
- export default CopcNode;
@@ -1,75 +0,0 @@
1
- import { colorLayerEffects } from "../../Renderer/LayeredMaterial.js";
2
- export const deprecatedColorLayerOptions = options => {
3
- if (options.fx) {
4
- console.warn('ColorLayer fx is deprecated, use ColorLayer.effect_type and ColorLayer.effect_parameter instead.');
5
- if (options.fx > 2.0) {
6
- options.effect_parameter = options.fx;
7
- options.effect_type = colorLayerEffects.removeLightColor;
8
- } else if (options.fx > 0.0) {
9
- options.effect_parameter = options.fx;
10
- options.effect_type = colorLayerEffects.removeWhiteColor;
11
- }
12
- }
13
- return options;
14
- };
15
- export const deprecatedParsingOptionsToNewOne = options => {
16
- /* istanbul ignore next */
17
- if (options.crsOut || options.crsIn) {
18
- console.warn('Parsing options with crsIn and crsOut are deprecated, use { in, out } structure.');
19
- const newOptions = {
20
- in: {},
21
- out: {}
22
- };
23
- newOptions.in.crs = options.crsIn;
24
- newOptions.in.isInverted = options.isInverted;
25
- newOptions.in.styles = options.styles;
26
- newOptions.in.layers = options.layers;
27
- newOptions.in.filter = options.filter;
28
- newOptions.out.crs = options.crsOut;
29
- newOptions.out.mergeFeatures = options.mergeFeatures;
30
- if (options.withAltitude && options.withNormal) {
31
- console.warn('Parsing options withAltitude and withNormal is deprecated, use out.structure: 2d or 3d.');
32
- newOptions.out.structure = '3d';
33
- } else {
34
- newOptions.out.structure = '2d';
35
- }
36
- newOptions.out.filteringExtent = options.filteringExtent;
37
- newOptions.out.style = options.style;
38
- if (options.crsOut.overrideAltitudeInToZero !== undefined) {
39
- console.error('Parsing options out.overrideAltitudeInToZero is removed, use Style.xxx.base_altitude instead');
40
- }
41
- newOptions.out.filter = options.filter;
42
- return newOptions;
43
- }
44
- if (options.out) {
45
- if (options.out.withAltitude !== undefined || options.out.withNormal !== undefined) {
46
- console.warn('Parsing options out.withAltitude and out.withNormal is deprecated, use out.structure: 2d or 3d.');
47
- if (options.out.withAltitude && options.out.withNormal) {
48
- options.out.structure = '3d';
49
- } else {
50
- options.out.structure = '2d';
51
- }
52
- }
53
- if (options.out.overrideAltitudeInToZero !== undefined) {
54
- console.error('Parsing options out.overrideAltitudeInToZero is removed, use Style.xxx.base_altitude instead');
55
- }
56
- }
57
- return options;
58
- };
59
- export const deprecatedFeature2MeshOptions = options => {
60
- if (options.color) {
61
- console.error('Color convert option is removed, use Style.xxx.color');
62
- }
63
- if (options.extrude) {
64
- console.error('extrude convert option is removed, use Style.fill.extrusion_height instead');
65
- }
66
- if (options.altitude) {
67
- console.error('altitude convert option is removed, use Style.xxx.base_altitude instead');
68
- }
69
- };
70
- export const deprecatedC3DEngineWebGLOptions = options => {
71
- if (options.isWebGL2 === false) {
72
- console.error('WebGL1 support ended in 2.43.0. Falling-back to the WebGL2 renderer.');
73
- }
74
- };
75
- export default {};
@@ -1,126 +0,0 @@
1
- import * as THREE from 'three';
2
- import Fetcher from "../Provider/Fetcher.js";
3
- import PointCloudNode from "./PointCloudNode.js";
4
- const size = new THREE.Vector3();
5
- const position = new THREE.Vector3();
6
- const translation = new THREE.Vector3();
7
- function buildId(depth, x, y, z) {
8
- return `${depth}-${x}-${y}-${z}`;
9
- }
10
-
11
- /**
12
- * @extends PointCloudNode
13
- *
14
- * @property {boolean} isEntwinePointTileNode - Used to checkout whether this
15
- * node is a EntwinePointTileNode. Default is `true`. You should not change
16
- * this, as it is used internally for optimisation.
17
- * @property {number} depth - The depth of the node in the tree - see the
18
- * [Entwine
19
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
20
- * @property {number} x - The x coordinate of the node in the tree - see the
21
- * [Entwine
22
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
23
- * @property {number} y - The x coordinate of the node in the tree - see the
24
- * [Entwine
25
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
26
- * @property {number} z - The x coordinate of the node in the tree - see the
27
- * [Entwine
28
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
29
- * @property {string} id - The id of the node, constituted of the four
30
- * components: `depth-x-y-z`.
31
- */
32
- class EntwinePointTileNode extends PointCloudNode {
33
- /**
34
- * Constructs a new instance of EntwinePointTileNode.
35
- *
36
- * @constructor
37
- *
38
- * @param {number} depth - The depth of the node in the tree - see the
39
- * [Entwine
40
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
41
- * @param {number} x - The x coordinate of the node in the tree - see the
42
- * [Entwine
43
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
44
- * @param {number} y - The x coordinate of the node in the tree - see the
45
- * [Entwine
46
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
47
- * @param {number} z - The x coordinate of the node in the tree - see the
48
- * [Entwine
49
- * documentation](https://entwine.io/entwine-point-tile.html#ept-data)
50
- * @param {EntwinePointTileLayer} layer - The layer the node is attached to.
51
- * @param {number} [numPoints=0] - The number of points in this node. If
52
- * `-1`, it means that the octree hierarchy associated to this node needs to
53
- * be loaded.
54
- */
55
- constructor(depth, x, y, z, layer) {
56
- let numPoints = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
57
- super(numPoints, layer);
58
- this.isEntwinePointTileNode = true;
59
- this.depth = depth;
60
- this.x = x;
61
- this.y = y;
62
- this.z = z;
63
- this.id = buildId(depth, x, y, z);
64
- this.url = `${this.layer.source.url}/ept-data/${this.id}.${this.layer.source.extension}`;
65
- }
66
- createChildAABB(node) {
67
- // factor to apply, based on the depth difference (can be > 1)
68
- const f = 2 ** (node.depth - this.depth);
69
-
70
- // size of the child node bbox (Vector3), based on the size of the
71
- // parent node, and divided by the factor
72
- this.bbox.getSize(size).divideScalar(f);
73
-
74
- // initialize the child node bbox at the location of the parent node bbox
75
- node.bbox.min.copy(this.bbox.min);
76
-
77
- // position of the parent node, if it was at the same depth than the
78
- // child, found by multiplying the tree position by the factor
79
- position.copy(this).multiplyScalar(f);
80
-
81
- // difference in position between the two nodes, at child depth, and
82
- // scale it using the size
83
- translation.subVectors(node, position).multiply(size);
84
-
85
- // apply the translation to the child node bbox
86
- node.bbox.min.add(translation);
87
-
88
- // use the size computed above to set the max
89
- node.bbox.max.copy(node.bbox.min).add(size);
90
- }
91
- get octreeIsLoaded() {
92
- return this.numPoints >= 0;
93
- }
94
- loadOctree() {
95
- return Fetcher.json(`${this.layer.source.url}/ept-hierarchy/${this.id}.json`, this.layer.source.networkOptions).then(hierarchy => {
96
- this.numPoints = hierarchy[this.id];
97
- const stack = [];
98
- stack.push(this);
99
- while (stack.length) {
100
- const node = stack.shift();
101
- const depth = node.depth + 1;
102
- const x = node.x * 2;
103
- const y = node.y * 2;
104
- const z = node.z * 2;
105
- node.findAndCreateChild(depth, x, y, z, hierarchy, stack);
106
- node.findAndCreateChild(depth, x + 1, y, z, hierarchy, stack);
107
- node.findAndCreateChild(depth, x, y + 1, z, hierarchy, stack);
108
- node.findAndCreateChild(depth, x + 1, y + 1, z, hierarchy, stack);
109
- node.findAndCreateChild(depth, x, y, z + 1, hierarchy, stack);
110
- node.findAndCreateChild(depth, x + 1, y, z + 1, hierarchy, stack);
111
- node.findAndCreateChild(depth, x, y + 1, z + 1, hierarchy, stack);
112
- node.findAndCreateChild(depth, x + 1, y + 1, z + 1, hierarchy, stack);
113
- }
114
- });
115
- }
116
- findAndCreateChild(depth, x, y, z, hierarchy, stack) {
117
- const id = buildId(depth, x, y, z);
118
- const numPoints = hierarchy[id];
119
- if (typeof numPoints == 'number') {
120
- const child = new EntwinePointTileNode(depth, x, y, z, this.layer, numPoints);
121
- this.add(child);
122
- stack.push(child);
123
- }
124
- }
125
- }
126
- export default EntwinePointTileNode;