@loaders.gl/3d-tiles 3.1.3 → 3.1.7

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.
package/dist/types.d.ts CHANGED
@@ -40,9 +40,10 @@ export declare type Node3D = {
40
40
  boundingVolume: BoundingVolume;
41
41
  };
42
42
  };
43
- declare type BoundingVolume = {
43
+ export declare type BoundingVolume = {
44
44
  box?: number[];
45
45
  sphere?: number[];
46
+ region?: number[];
46
47
  };
47
48
  /**
48
49
  * 3DTILES_implicit_tiling types
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,CAAC,MAAM,E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AE,MAAM,CAAC;CACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/3d-tiles",
3
- "version": "3.1.3",
3
+ "version": "3.1.7",
4
4
  "description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,16 +34,16 @@
34
34
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
35
35
  },
36
36
  "dependencies": {
37
- "@loaders.gl/draco": "3.1.3",
38
- "@loaders.gl/gltf": "3.1.3",
39
- "@loaders.gl/loader-utils": "3.1.3",
40
- "@loaders.gl/math": "3.1.3",
41
- "@loaders.gl/tiles": "3.1.3",
37
+ "@loaders.gl/draco": "3.1.7",
38
+ "@loaders.gl/gltf": "3.1.7",
39
+ "@loaders.gl/loader-utils": "3.1.7",
40
+ "@loaders.gl/math": "3.1.7",
41
+ "@loaders.gl/tiles": "3.1.7",
42
42
  "@math.gl/core": "^3.5.1",
43
43
  "@math.gl/geospatial": "^3.5.1"
44
44
  },
45
45
  "peerDependencies": {
46
- "@loaders.gl/core": "3.1.0"
46
+ "@loaders.gl/core": "^3.1.0"
47
47
  },
48
- "gitHead": "4a690c369779346d73c9a27395d1c08d77d279a4"
48
+ "gitHead": "e48d29e426e9f23879875763e73efc5c58345be1"
49
49
  }
@@ -1,4 +1,4 @@
1
- import type {Availability, Subtree} from '../../../types';
1
+ import type {Availability, BoundingVolume, Subtree} from '../../../types';
2
2
  import {Tile3DSubtreeLoader} from '../../../tile-3d-subtree-loader';
3
3
  import {load} from '@loaders.gl/core';
4
4
 
@@ -143,7 +143,8 @@ export async function parseImplicitTiles(
143
143
 
144
144
  if (currentTile.contentUrl || currentTile.children.length) {
145
145
  const globalLevel = lev + 1;
146
- const formattedTile = formatTileData(currentTile, globalLevel, options);
146
+ const childCoordinates = {childTileX, childTileY, childTileZ};
147
+ const formattedTile = formatTileData(currentTile, globalLevel, childCoordinates, options);
147
148
  // @ts-ignore
148
149
  tile.children.push(formattedTile);
149
150
  }
@@ -172,11 +173,29 @@ function getAvailabilityResult(availabilityData: Availability, index: number): b
172
173
  * @param options
173
174
  * @returns
174
175
  */
175
- function formatTileData(tile, level: number, options: any) {
176
- const {basePath, refine, getRefine, lodMetricType, getTileType, rootLodMetricValue} = options;
176
+ function formatTileData(
177
+ tile,
178
+ level: number,
179
+ childCoordinates: {childTileX: number; childTileY: number; childTileZ: number},
180
+ options: any
181
+ ) {
182
+ const {
183
+ basePath,
184
+ refine,
185
+ getRefine,
186
+ lodMetricType,
187
+ getTileType,
188
+ rootLodMetricValue,
189
+ rootBoundingVolume
190
+ } = options;
177
191
  const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');
178
192
  const lodMetricValue = rootLodMetricValue / 2 ** level;
179
- // TODO handle bounding volume
193
+ const boundingVolume = calculateBoundingVolumeForChildTile(
194
+ level,
195
+ rootBoundingVolume,
196
+ childCoordinates
197
+ );
198
+
180
199
  return {
181
200
  children: tile.children,
182
201
  contentUrl: tile.contentUrl,
@@ -185,7 +204,8 @@ function formatTileData(tile, level: number, options: any) {
185
204
  refine: getRefine(refine),
186
205
  type: getTileType(tile),
187
206
  lodMetricType,
188
- lodMetricValue
207
+ lodMetricValue,
208
+ boundingVolume
189
209
  // Temp debug values. Remove when real implicit tileset will be tested.
190
210
  // x: tile.x,
191
211
  // y: tile.y,
@@ -194,6 +214,44 @@ function formatTileData(tile, level: number, options: any) {
194
214
  };
195
215
  }
196
216
 
217
+ /**
218
+ * Calculate child bounding volume.
219
+ * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-rules
220
+ * @param level
221
+ * @param rootBoundingVolume
222
+ * @param childCoordinates
223
+ */
224
+ function calculateBoundingVolumeForChildTile(
225
+ level: number,
226
+ rootBoundingVolume: BoundingVolume,
227
+ childCoordinates: {childTileX: number; childTileY: number; childTileZ: number}
228
+ ): BoundingVolume | null {
229
+ if (rootBoundingVolume.region) {
230
+ const {childTileX, childTileY, childTileZ} = childCoordinates;
231
+ const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
232
+ const boundingVolumesCount = 2 ** level;
233
+
234
+ const sizeX = (east - west) / boundingVolumesCount;
235
+ const sizeY = (north - south) / boundingVolumesCount;
236
+ const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
237
+
238
+ const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];
239
+ const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];
240
+ const [childMinimumHeight, childMaximumHeight] = [
241
+ minimumHeight + sizeZ * childTileZ,
242
+ minimumHeight + sizeZ * (childTileZ + 1)
243
+ ];
244
+
245
+ return {
246
+ region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
247
+ };
248
+ }
249
+
250
+ // eslint-disable-next-line no-console
251
+ console.warn('Unsupported bounding volume type: ', rootBoundingVolume);
252
+ return null;
253
+ }
254
+
197
255
  /**
198
256
  * Do binary concatenation
199
257
  * @param first
@@ -100,6 +100,7 @@ export async function normalizeImplicitTileHeaders(tileset: Tileset3D) {
100
100
  const refine = tileset.root.refine;
101
101
  // @ts-ignore
102
102
  const rootLodMetricValue = tileset.root.geometricError;
103
+ const rootBoundingVolume = tileset.root.boundingVolume;
103
104
 
104
105
  const options = {
105
106
  contentUrlTemplate,
@@ -111,6 +112,7 @@ export async function normalizeImplicitTileHeaders(tileset: Tileset3D) {
111
112
  basePath,
112
113
  lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
113
114
  rootLodMetricValue,
115
+ rootBoundingVolume,
114
116
  getTileType,
115
117
  getRefine
116
118
  };
package/src/types.ts CHANGED
@@ -45,9 +45,10 @@ export type Node3D = {
45
45
  };
46
46
  };
47
47
 
48
- type BoundingVolume = {
48
+ export type BoundingVolume = {
49
49
  box?: number[];
50
50
  sphere?: number[];
51
+ region?: number[];
51
52
  };
52
53
 
53
54
  /**