itowns 2.44.3-next.40 → 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 (199) hide show
  1. package/README.md +3 -129
  2. package/package.json +16 -72
  3. package/CODING.md +0 -120
  4. package/CONTRIBUTING.md +0 -150
  5. package/CONTRIBUTORS.md +0 -56
  6. package/LICENSE.md +0 -44
  7. package/changelog.md +0 -1361
  8. package/dist/455.js +0 -2
  9. package/dist/455.js.map +0 -1
  10. package/dist/debug.js +0 -3
  11. package/dist/debug.js.LICENSE.txt +0 -13
  12. package/dist/debug.js.map +0 -1
  13. package/dist/itowns.js +0 -3
  14. package/dist/itowns.js.LICENSE.txt +0 -5
  15. package/dist/itowns.js.map +0 -1
  16. package/dist/itowns_lasparser.js +0 -2
  17. package/dist/itowns_lasparser.js.map +0 -1
  18. package/dist/itowns_lasworker.js +0 -2
  19. package/dist/itowns_lasworker.js.map +0 -1
  20. package/dist/itowns_potree2worker.js +0 -2
  21. package/dist/itowns_potree2worker.js.map +0 -1
  22. package/dist/itowns_widgets.js +0 -2
  23. package/dist/itowns_widgets.js.map +0 -1
  24. package/examples/.eslintrc.cjs +0 -35
  25. package/examples/jsm/.eslintrc.cjs +0 -38
  26. package/lib/Controls/FirstPersonControls.js +0 -308
  27. package/lib/Controls/FlyControls.js +0 -175
  28. package/lib/Controls/GlobeControls.js +0 -1179
  29. package/lib/Controls/PlanarControls.js +0 -1025
  30. package/lib/Controls/StateControl.js +0 -432
  31. package/lib/Controls/StreetControls.js +0 -392
  32. package/lib/Converter/Feature2Mesh.js +0 -614
  33. package/lib/Converter/Feature2Texture.js +0 -175
  34. package/lib/Converter/convertToTile.js +0 -70
  35. package/lib/Converter/textureConverter.js +0 -43
  36. package/lib/Core/3DTiles/C3DTBatchTable.js +0 -131
  37. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +0 -96
  38. package/lib/Core/3DTiles/C3DTBoundingVolume.js +0 -157
  39. package/lib/Core/3DTiles/C3DTExtensions.js +0 -97
  40. package/lib/Core/3DTiles/C3DTFeature.js +0 -110
  41. package/lib/Core/3DTiles/C3DTilesEnums.js +0 -20
  42. package/lib/Core/3DTiles/C3DTileset.js +0 -99
  43. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +0 -100
  44. package/lib/Core/AnimationPlayer.js +0 -142
  45. package/lib/Core/CopcNode.js +0 -174
  46. package/lib/Core/Deprecated/Undeprecator.js +0 -74
  47. package/lib/Core/EntwinePointTileNode.js +0 -126
  48. package/lib/Core/Feature.js +0 -489
  49. package/lib/Core/Geographic/CoordStars.js +0 -80
  50. package/lib/Core/Geographic/Coordinates.js +0 -331
  51. package/lib/Core/Geographic/Crs.js +0 -170
  52. package/lib/Core/Geographic/Extent.js +0 -550
  53. package/lib/Core/Geographic/GeoidGrid.js +0 -109
  54. package/lib/Core/Label.js +0 -222
  55. package/lib/Core/MainLoop.js +0 -209
  56. package/lib/Core/Math/Ellipsoid.js +0 -185
  57. package/lib/Core/Picking.js +0 -255
  58. package/lib/Core/PointCloudNode.js +0 -42
  59. package/lib/Core/Potree2Node.js +0 -206
  60. package/lib/Core/Potree2PointAttributes.js +0 -139
  61. package/lib/Core/PotreeNode.js +0 -101
  62. package/lib/Core/Prefab/Globe/Atmosphere.js +0 -295
  63. package/lib/Core/Prefab/Globe/GlobeLayer.js +0 -152
  64. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +0 -111
  65. package/lib/Core/Prefab/Globe/SkyShader.js +0 -78
  66. package/lib/Core/Prefab/GlobeView.js +0 -156
  67. package/lib/Core/Prefab/Planar/PlanarLayer.js +0 -59
  68. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +0 -72
  69. package/lib/Core/Prefab/PlanarView.js +0 -62
  70. package/lib/Core/Prefab/TileBuilder.js +0 -82
  71. package/lib/Core/Prefab/computeBufferTileGeometry.js +0 -248
  72. package/lib/Core/Scheduler/Cache.js +0 -17
  73. package/lib/Core/Scheduler/CancelledCommandException.js +0 -15
  74. package/lib/Core/Scheduler/Scheduler.js +0 -294
  75. package/lib/Core/Style.js +0 -660
  76. package/lib/Core/StyleOptions.js +0 -486
  77. package/lib/Core/System/Capabilities.js +0 -63
  78. package/lib/Core/Tile/Tile.js +0 -207
  79. package/lib/Core/Tile/TileGrid.js +0 -49
  80. package/lib/Core/TileGeometry.js +0 -124
  81. package/lib/Core/TileMesh.js +0 -108
  82. package/lib/Core/View.js +0 -1116
  83. package/lib/Layer/C3DTilesLayer.js +0 -459
  84. package/lib/Layer/ColorLayer.js +0 -154
  85. package/lib/Layer/CopcLayer.js +0 -63
  86. package/lib/Layer/ElevationLayer.js +0 -139
  87. package/lib/Layer/EntwinePointTileLayer.js +0 -71
  88. package/lib/Layer/FeatureGeometryLayer.js +0 -77
  89. package/lib/Layer/GeoidLayer.js +0 -80
  90. package/lib/Layer/GeometryLayer.js +0 -233
  91. package/lib/Layer/InfoLayer.js +0 -64
  92. package/lib/Layer/LabelLayer.js +0 -470
  93. package/lib/Layer/Layer.js +0 -335
  94. package/lib/Layer/LayerUpdateState.js +0 -89
  95. package/lib/Layer/LayerUpdateStrategy.js +0 -80
  96. package/lib/Layer/OGC3DTilesLayer.js +0 -543
  97. package/lib/Layer/OrientedImageLayer.js +0 -228
  98. package/lib/Layer/PointCloudLayer.js +0 -405
  99. package/lib/Layer/Potree2Layer.js +0 -171
  100. package/lib/Layer/PotreeLayer.js +0 -72
  101. package/lib/Layer/RasterLayer.js +0 -37
  102. package/lib/Layer/ReferencingLayerProperties.js +0 -62
  103. package/lib/Layer/TiledGeometryLayer.js +0 -459
  104. package/lib/Loader/LASLoader.js +0 -193
  105. package/lib/Loader/Potree2BrotliLoader.js +0 -261
  106. package/lib/Loader/Potree2Loader.js +0 -207
  107. package/lib/Main.js +0 -115
  108. package/lib/MainBundle.js +0 -4
  109. package/lib/Parser/B3dmParser.js +0 -174
  110. package/lib/Parser/CameraCalibrationParser.js +0 -94
  111. package/lib/Parser/GDFParser.js +0 -72
  112. package/lib/Parser/GTXParser.js +0 -75
  113. package/lib/Parser/GeoJsonParser.js +0 -212
  114. package/lib/Parser/GpxParser.js +0 -25
  115. package/lib/Parser/ISGParser.js +0 -71
  116. package/lib/Parser/KMLParser.js +0 -25
  117. package/lib/Parser/LASParser.js +0 -137
  118. package/lib/Parser/MapBoxUrlParser.js +0 -83
  119. package/lib/Parser/PntsParser.js +0 -131
  120. package/lib/Parser/Potree2BinParser.js +0 -92
  121. package/lib/Parser/PotreeBinParser.js +0 -106
  122. package/lib/Parser/PotreeCinParser.js +0 -29
  123. package/lib/Parser/ShapefileParser.js +0 -78
  124. package/lib/Parser/VectorTileParser.js +0 -215
  125. package/lib/Parser/XbilParser.js +0 -120
  126. package/lib/Parser/deprecated/LegacyGLTFLoader.js +0 -1386
  127. package/lib/Parser/iGLTFLoader.js +0 -168
  128. package/lib/Process/3dTilesProcessing.js +0 -304
  129. package/lib/Process/FeatureProcessing.js +0 -76
  130. package/lib/Process/LayeredMaterialNodeProcessing.js +0 -221
  131. package/lib/Process/ObjectRemovalHelper.js +0 -97
  132. package/lib/Process/handlerNodeError.js +0 -23
  133. package/lib/Provider/3dTilesProvider.js +0 -149
  134. package/lib/Provider/DataSourceProvider.js +0 -8
  135. package/lib/Provider/Fetcher.js +0 -233
  136. package/lib/Provider/PointCloudProvider.js +0 -45
  137. package/lib/Provider/TileProvider.js +0 -16
  138. package/lib/Provider/URLBuilder.js +0 -116
  139. package/lib/Renderer/Camera.js +0 -281
  140. package/lib/Renderer/Color.js +0 -56
  141. package/lib/Renderer/ColorLayersOrdering.js +0 -115
  142. package/lib/Renderer/CommonMaterial.js +0 -31
  143. package/lib/Renderer/Label2DRenderer.js +0 -192
  144. package/lib/Renderer/LayeredMaterial.js +0 -243
  145. package/lib/Renderer/OBB.js +0 -151
  146. package/lib/Renderer/OrientedImageCamera.js +0 -118
  147. package/lib/Renderer/OrientedImageMaterial.js +0 -167
  148. package/lib/Renderer/PointsMaterial.js +0 -485
  149. package/lib/Renderer/RasterTile.js +0 -208
  150. package/lib/Renderer/RenderMode.js +0 -31
  151. package/lib/Renderer/Shader/ShaderChunk.js +0 -160
  152. package/lib/Renderer/Shader/ShaderUtils.js +0 -47
  153. package/lib/Renderer/SphereHelper.js +0 -17
  154. package/lib/Renderer/WebXR.js +0 -51
  155. package/lib/Renderer/c3DEngine.js +0 -214
  156. package/lib/Source/C3DTilesGoogleSource.js +0 -74
  157. package/lib/Source/C3DTilesIonSource.js +0 -54
  158. package/lib/Source/C3DTilesSource.js +0 -30
  159. package/lib/Source/CopcSource.js +0 -126
  160. package/lib/Source/EntwinePointTileSource.js +0 -72
  161. package/lib/Source/FileSource.js +0 -188
  162. package/lib/Source/OGC3DTilesGoogleSource.js +0 -29
  163. package/lib/Source/OGC3DTilesIonSource.js +0 -34
  164. package/lib/Source/OGC3DTilesSource.js +0 -21
  165. package/lib/Source/OrientedImageSource.js +0 -59
  166. package/lib/Source/Potree2Source.js +0 -167
  167. package/lib/Source/PotreeSource.js +0 -82
  168. package/lib/Source/Source.js +0 -203
  169. package/lib/Source/TMSSource.js +0 -144
  170. package/lib/Source/VectorTilesSource.js +0 -182
  171. package/lib/Source/WFSSource.js +0 -170
  172. package/lib/Source/WMSSource.js +0 -168
  173. package/lib/Source/WMTSSource.js +0 -92
  174. package/lib/ThreeExtended/capabilities/WebGL.js +0 -69
  175. package/lib/ThreeExtended/libs/ktx-parse.module.js +0 -506
  176. package/lib/ThreeExtended/libs/zstddec.module.js +0 -29
  177. package/lib/ThreeExtended/loaders/DDSLoader.js +0 -200
  178. package/lib/ThreeExtended/loaders/DRACOLoader.js +0 -400
  179. package/lib/ThreeExtended/loaders/GLTFLoader.js +0 -2879
  180. package/lib/ThreeExtended/loaders/KTX2Loader.js +0 -709
  181. package/lib/ThreeExtended/math/ColorSpaces.js +0 -59
  182. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +0 -846
  183. package/lib/ThreeExtended/utils/WorkerPool.js +0 -70
  184. package/lib/Utils/CameraUtils.js +0 -555
  185. package/lib/Utils/DEMUtils.js +0 -350
  186. package/lib/Utils/FeaturesUtils.js +0 -156
  187. package/lib/Utils/Gradients.js +0 -16
  188. package/lib/Utils/OrientationUtils.js +0 -457
  189. package/lib/Utils/ThreeUtils.js +0 -115
  190. package/lib/Utils/gui/C3DTilesStyle.js +0 -215
  191. package/lib/Utils/gui/Main.js +0 -7
  192. package/lib/Utils/gui/Minimap.js +0 -154
  193. package/lib/Utils/gui/Navigation.js +0 -245
  194. package/lib/Utils/gui/Scale.js +0 -107
  195. package/lib/Utils/gui/Searchbar.js +0 -234
  196. package/lib/Utils/gui/Widget.js +0 -80
  197. package/lib/Utils/placeObjectOnGround.js +0 -136
  198. package/lib/Worker/LASLoaderWorker.js +0 -19
  199. 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,74 +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
- if (options.crsOut || options.crsIn) {
17
- console.warn('Parsing options with crsIn and crsOut are deprecated, use { in, out } structure.');
18
- const newOptions = {
19
- in: {},
20
- out: {}
21
- };
22
- newOptions.in.crs = options.crsIn;
23
- newOptions.in.isInverted = options.isInverted;
24
- newOptions.in.styles = options.styles;
25
- newOptions.in.layers = options.layers;
26
- newOptions.in.filter = options.filter;
27
- newOptions.out.crs = options.crsOut;
28
- newOptions.out.mergeFeatures = options.mergeFeatures;
29
- if (options.withAltitude && options.withNormal) {
30
- console.warn('Parsing options withAltitude and withNormal is deprecated, use out.structure: 2d or 3d.');
31
- newOptions.out.structure = '3d';
32
- } else {
33
- newOptions.out.structure = '2d';
34
- }
35
- newOptions.out.filteringExtent = options.filteringExtent;
36
- newOptions.out.style = options.style;
37
- if (options.crsOut.overrideAltitudeInToZero !== undefined) {
38
- console.error('Parsing options out.overrideAltitudeInToZero is removed, use Style.xxx.base_altitude instead');
39
- }
40
- newOptions.out.filter = options.filter;
41
- return newOptions;
42
- }
43
- if (options.out) {
44
- if (options.out.withAltitude !== undefined || options.out.withNormal !== undefined) {
45
- console.warn('Parsing options out.withAltitude and out.withNormal is deprecated, use out.structure: 2d or 3d.');
46
- if (options.out.withAltitude && options.out.withNormal) {
47
- options.out.structure = '3d';
48
- } else {
49
- options.out.structure = '2d';
50
- }
51
- }
52
- if (options.out.overrideAltitudeInToZero !== undefined) {
53
- console.error('Parsing options out.overrideAltitudeInToZero is removed, use Style.xxx.base_altitude instead');
54
- }
55
- }
56
- return options;
57
- };
58
- export const deprecatedFeature2MeshOptions = options => {
59
- if (options.color) {
60
- console.error('Color convert option is removed, use Style.xxx.color');
61
- }
62
- if (options.extrude) {
63
- console.error('extrude convert option is removed, use Style.fill.extrusion_height instead');
64
- }
65
- if (options.altitude) {
66
- console.error('altitude convert option is removed, use Style.xxx.base_altitude instead');
67
- }
68
- };
69
- export const deprecatedC3DEngineWebGLOptions = options => {
70
- if (options.isWebGL2 === false) {
71
- console.error('WebGL1 support ended in 2.43.0. Falling-back to the WebGL2 renderer.');
72
- }
73
- };
74
- 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;