itowns 2.45.1-next.0 → 2.45.1-next.1

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 (185) hide show
  1. package/dist/455.js +2 -0
  2. package/dist/455.js.map +1 -0
  3. package/dist/debug.js +3 -0
  4. package/dist/debug.js.LICENSE.txt +13 -0
  5. package/dist/debug.js.map +1 -0
  6. package/dist/itowns.js +3 -0
  7. package/dist/itowns.js.LICENSE.txt +5 -0
  8. package/dist/itowns.js.map +1 -0
  9. package/dist/itowns_lasparser.js +2 -0
  10. package/dist/itowns_lasparser.js.map +1 -0
  11. package/dist/itowns_lasworker.js +2 -0
  12. package/dist/itowns_lasworker.js.map +1 -0
  13. package/dist/itowns_potree2worker.js +2 -0
  14. package/dist/itowns_potree2worker.js.map +1 -0
  15. package/dist/itowns_widgets.js +2 -0
  16. package/dist/itowns_widgets.js.map +1 -0
  17. package/lib/Controls/FirstPersonControls.js +308 -0
  18. package/lib/Controls/FlyControls.js +175 -0
  19. package/lib/Controls/GlobeControls.js +1178 -0
  20. package/lib/Controls/PlanarControls.js +1025 -0
  21. package/lib/Controls/StateControl.js +432 -0
  22. package/lib/Controls/StreetControls.js +392 -0
  23. package/lib/Converter/Feature2Mesh.js +612 -0
  24. package/lib/Converter/Feature2Texture.js +174 -0
  25. package/lib/Converter/convertToTile.js +70 -0
  26. package/lib/Converter/textureConverter.js +43 -0
  27. package/lib/Core/3DTiles/C3DTBatchTable.js +131 -0
  28. package/lib/Core/3DTiles/C3DTBatchTableHierarchyExtension.js +96 -0
  29. package/lib/Core/3DTiles/C3DTBoundingVolume.js +156 -0
  30. package/lib/Core/3DTiles/C3DTExtensions.js +97 -0
  31. package/lib/Core/3DTiles/C3DTFeature.js +110 -0
  32. package/lib/Core/3DTiles/C3DTilesEnums.js +20 -0
  33. package/lib/Core/3DTiles/C3DTileset.js +99 -0
  34. package/lib/Core/3DTiles/utils/BinaryPropertyAccessor.js +100 -0
  35. package/lib/Core/AnimationPlayer.js +142 -0
  36. package/lib/Core/CopcNode.js +174 -0
  37. package/lib/Core/Deprecated/Undeprecator.js +74 -0
  38. package/lib/Core/EntwinePointTileNode.js +126 -0
  39. package/lib/Core/Feature.js +488 -0
  40. package/lib/Core/Geographic/GeoidGrid.js +108 -0
  41. package/lib/Core/Label.js +222 -0
  42. package/lib/Core/MainLoop.js +209 -0
  43. package/lib/Core/Picking.js +255 -0
  44. package/lib/Core/PointCloudNode.js +42 -0
  45. package/lib/Core/Potree2Node.js +206 -0
  46. package/lib/Core/Potree2PointAttributes.js +139 -0
  47. package/lib/Core/PotreeNode.js +101 -0
  48. package/lib/Core/Prefab/Globe/Atmosphere.js +293 -0
  49. package/lib/Core/Prefab/Globe/GlobeLayer.js +152 -0
  50. package/lib/Core/Prefab/Globe/GlobeTileBuilder.js +110 -0
  51. package/lib/Core/Prefab/Globe/SkyShader.js +78 -0
  52. package/lib/Core/Prefab/GlobeView.js +155 -0
  53. package/lib/Core/Prefab/Planar/PlanarLayer.js +59 -0
  54. package/lib/Core/Prefab/Planar/PlanarTileBuilder.js +71 -0
  55. package/lib/Core/Prefab/PlanarView.js +62 -0
  56. package/lib/Core/Prefab/TileBuilder.js +82 -0
  57. package/lib/Core/Prefab/computeBufferTileGeometry.js +248 -0
  58. package/lib/Core/Scheduler/Cache.js +17 -0
  59. package/lib/Core/Scheduler/CancelledCommandException.js +15 -0
  60. package/lib/Core/Scheduler/Scheduler.js +294 -0
  61. package/lib/Core/Style.js +660 -0
  62. package/lib/Core/StyleOptions.js +486 -0
  63. package/lib/Core/System/Capabilities.js +63 -0
  64. package/lib/Core/Tile/Tile.js +205 -0
  65. package/lib/Core/Tile/TileGrid.js +49 -0
  66. package/lib/Core/TileGeometry.js +124 -0
  67. package/lib/Core/TileMesh.js +108 -0
  68. package/lib/Core/View.js +1115 -0
  69. package/lib/Layer/C3DTilesLayer.js +459 -0
  70. package/lib/Layer/ColorLayer.js +154 -0
  71. package/lib/Layer/CopcLayer.js +63 -0
  72. package/lib/Layer/ElevationLayer.js +139 -0
  73. package/lib/Layer/EntwinePointTileLayer.js +71 -0
  74. package/lib/Layer/FeatureGeometryLayer.js +77 -0
  75. package/lib/Layer/GeoidLayer.js +80 -0
  76. package/lib/Layer/GeometryLayer.js +233 -0
  77. package/lib/Layer/InfoLayer.js +64 -0
  78. package/lib/Layer/LabelLayer.js +469 -0
  79. package/lib/Layer/Layer.js +335 -0
  80. package/lib/Layer/LayerUpdateState.js +89 -0
  81. package/lib/Layer/LayerUpdateStrategy.js +80 -0
  82. package/lib/Layer/OGC3DTilesLayer.js +543 -0
  83. package/lib/Layer/OrientedImageLayer.js +227 -0
  84. package/lib/Layer/PointCloudLayer.js +405 -0
  85. package/lib/Layer/Potree2Layer.js +171 -0
  86. package/lib/Layer/PotreeLayer.js +72 -0
  87. package/lib/Layer/RasterLayer.js +37 -0
  88. package/lib/Layer/ReferencingLayerProperties.js +62 -0
  89. package/lib/Layer/TiledGeometryLayer.js +459 -0
  90. package/lib/Loader/LASLoader.js +193 -0
  91. package/lib/Loader/Potree2BrotliLoader.js +261 -0
  92. package/lib/Loader/Potree2Loader.js +207 -0
  93. package/lib/Main.js +113 -0
  94. package/lib/MainBundle.js +4 -0
  95. package/lib/Parser/B3dmParser.js +174 -0
  96. package/lib/Parser/CameraCalibrationParser.js +94 -0
  97. package/lib/Parser/GDFParser.js +72 -0
  98. package/lib/Parser/GTXParser.js +75 -0
  99. package/lib/Parser/GeoJsonParser.js +212 -0
  100. package/lib/Parser/GpxParser.js +25 -0
  101. package/lib/Parser/ISGParser.js +71 -0
  102. package/lib/Parser/KMLParser.js +25 -0
  103. package/lib/Parser/LASParser.js +137 -0
  104. package/lib/Parser/MapBoxUrlParser.js +83 -0
  105. package/lib/Parser/PntsParser.js +131 -0
  106. package/lib/Parser/Potree2BinParser.js +92 -0
  107. package/lib/Parser/PotreeBinParser.js +106 -0
  108. package/lib/Parser/PotreeCinParser.js +29 -0
  109. package/lib/Parser/ShapefileParser.js +78 -0
  110. package/lib/Parser/VectorTileParser.js +215 -0
  111. package/lib/Parser/XbilParser.js +120 -0
  112. package/lib/Parser/deprecated/LegacyGLTFLoader.js +1386 -0
  113. package/lib/Parser/iGLTFLoader.js +168 -0
  114. package/lib/Process/3dTilesProcessing.js +304 -0
  115. package/lib/Process/FeatureProcessing.js +76 -0
  116. package/lib/Process/LayeredMaterialNodeProcessing.js +229 -0
  117. package/lib/Process/ObjectRemovalHelper.js +97 -0
  118. package/lib/Process/handlerNodeError.js +23 -0
  119. package/lib/Provider/3dTilesProvider.js +149 -0
  120. package/lib/Provider/DataSourceProvider.js +24 -0
  121. package/lib/Provider/Fetcher.js +233 -0
  122. package/lib/Provider/PointCloudProvider.js +45 -0
  123. package/lib/Provider/TileProvider.js +16 -0
  124. package/lib/Provider/URLBuilder.js +116 -0
  125. package/lib/Renderer/Camera.js +281 -0
  126. package/lib/Renderer/Color.js +56 -0
  127. package/lib/Renderer/ColorLayersOrdering.js +115 -0
  128. package/lib/Renderer/CommonMaterial.js +31 -0
  129. package/lib/Renderer/Label2DRenderer.js +192 -0
  130. package/lib/Renderer/LayeredMaterial.js +243 -0
  131. package/lib/Renderer/OBB.js +150 -0
  132. package/lib/Renderer/OrientedImageCamera.js +118 -0
  133. package/lib/Renderer/OrientedImageMaterial.js +167 -0
  134. package/lib/Renderer/PointsMaterial.js +485 -0
  135. package/lib/Renderer/RasterTile.js +243 -0
  136. package/lib/Renderer/RenderMode.js +31 -0
  137. package/lib/Renderer/Shader/ShaderChunk.js +160 -0
  138. package/lib/Renderer/Shader/ShaderUtils.js +47 -0
  139. package/lib/Renderer/SphereHelper.js +17 -0
  140. package/lib/Renderer/WebXR.js +51 -0
  141. package/lib/Renderer/c3DEngine.js +214 -0
  142. package/lib/Source/C3DTilesGoogleSource.js +74 -0
  143. package/lib/Source/C3DTilesIonSource.js +54 -0
  144. package/lib/Source/C3DTilesSource.js +30 -0
  145. package/lib/Source/CopcSource.js +126 -0
  146. package/lib/Source/EntwinePointTileSource.js +72 -0
  147. package/lib/Source/FileSource.js +188 -0
  148. package/lib/Source/OGC3DTilesGoogleSource.js +29 -0
  149. package/lib/Source/OGC3DTilesIonSource.js +34 -0
  150. package/lib/Source/OGC3DTilesSource.js +21 -0
  151. package/lib/Source/OrientedImageSource.js +59 -0
  152. package/lib/Source/Potree2Source.js +167 -0
  153. package/lib/Source/PotreeSource.js +82 -0
  154. package/lib/Source/Source.js +202 -0
  155. package/lib/Source/TMSSource.js +144 -0
  156. package/lib/Source/VectorTilesSource.js +182 -0
  157. package/lib/Source/WFSSource.js +170 -0
  158. package/lib/Source/WMSSource.js +167 -0
  159. package/lib/Source/WMTSSource.js +92 -0
  160. package/lib/ThreeExtended/capabilities/WebGL.js +69 -0
  161. package/lib/ThreeExtended/libs/ktx-parse.module.js +506 -0
  162. package/lib/ThreeExtended/libs/zstddec.module.js +29 -0
  163. package/lib/ThreeExtended/loaders/DDSLoader.js +200 -0
  164. package/lib/ThreeExtended/loaders/DRACOLoader.js +400 -0
  165. package/lib/ThreeExtended/loaders/GLTFLoader.js +2879 -0
  166. package/lib/ThreeExtended/loaders/KTX2Loader.js +709 -0
  167. package/lib/ThreeExtended/math/ColorSpaces.js +59 -0
  168. package/lib/ThreeExtended/utils/BufferGeometryUtils.js +846 -0
  169. package/lib/ThreeExtended/utils/WorkerPool.js +70 -0
  170. package/lib/Utils/CameraUtils.js +554 -0
  171. package/lib/Utils/DEMUtils.js +350 -0
  172. package/lib/Utils/FeaturesUtils.js +156 -0
  173. package/lib/Utils/Gradients.js +16 -0
  174. package/lib/Utils/ThreeUtils.js +115 -0
  175. package/lib/Utils/gui/C3DTilesStyle.js +218 -0
  176. package/lib/Utils/gui/Main.js +7 -0
  177. package/lib/Utils/gui/Minimap.js +152 -0
  178. package/lib/Utils/gui/Navigation.js +245 -0
  179. package/lib/Utils/gui/Scale.js +104 -0
  180. package/lib/Utils/gui/Searchbar.js +234 -0
  181. package/lib/Utils/gui/Widget.js +80 -0
  182. package/lib/Utils/placeObjectOnGround.js +136 -0
  183. package/lib/Worker/LASLoaderWorker.js +19 -0
  184. package/lib/Worker/Potree2Worker.js +21 -0
  185. package/package.json +2 -2
@@ -0,0 +1,174 @@
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;
@@ -0,0 +1,74 @@
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 {};
@@ -0,0 +1,126 @@
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;