@loaders.gl/tiles 5.0.0-alpha.2 → 5.0.0-alpha.3

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 (109) hide show
  1. package/LICENSE +1 -1
  2. package/dist/dist.dev.js +17325 -5650
  3. package/dist/dist.min.js +4 -1
  4. package/dist/index.cjs +1924 -178
  5. package/dist/index.cjs.map +3 -3
  6. package/dist/index.d.ts +9 -1
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +6 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/point-cloud/point-cloud-tileset.d.ts +4 -0
  11. package/dist/point-cloud/point-cloud-tileset.d.ts.map +1 -1
  12. package/dist/point-cloud/point-cloud-tileset.js +51 -12
  13. package/dist/point-cloud/point-cloud-tileset.js.map +1 -1
  14. package/dist/point-cloud/types.d.ts +17 -0
  15. package/dist/point-cloud/types.d.ts.map +1 -1
  16. package/dist/raster-set.d.ts +10 -8
  17. package/dist/raster-set.d.ts.map +1 -1
  18. package/dist/raster-set.js +18 -1
  19. package/dist/raster-set.js.map +1 -1
  20. package/dist/spatial/format-spatial-reference.d.ts +67 -0
  21. package/dist/spatial/format-spatial-reference.d.ts.map +1 -0
  22. package/dist/spatial/format-spatial-reference.js +233 -0
  23. package/dist/spatial/format-spatial-reference.js.map +1 -0
  24. package/dist/spatial/get-spatial-coordinate-frame.d.ts +9 -0
  25. package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -0
  26. package/dist/spatial/get-spatial-coordinate-frame.js +58 -0
  27. package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -0
  28. package/dist/spatial/i3s-elevation.d.ts +20 -0
  29. package/dist/spatial/i3s-elevation.d.ts.map +1 -0
  30. package/dist/spatial/i3s-elevation.js +90 -0
  31. package/dist/spatial/i3s-elevation.js.map +1 -0
  32. package/dist/spatial/i3s-spatial-transformer.d.ts +189 -0
  33. package/dist/spatial/i3s-spatial-transformer.d.ts.map +1 -0
  34. package/dist/spatial/i3s-spatial-transformer.js +686 -0
  35. package/dist/spatial/i3s-spatial-transformer.js.map +1 -0
  36. package/dist/spatial/spatial-coordinate-transformer.d.ts +48 -0
  37. package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -0
  38. package/dist/spatial/spatial-coordinate-transformer.js +211 -0
  39. package/dist/spatial/spatial-coordinate-transformer.js.map +1 -0
  40. package/dist/spatial/spatial-resource-registry.d.ts +44 -0
  41. package/dist/spatial/spatial-resource-registry.d.ts.map +1 -0
  42. package/dist/spatial/spatial-resource-registry.js +67 -0
  43. package/dist/spatial/spatial-resource-registry.js.map +1 -0
  44. package/dist/spatial/spatial-types.d.ts +190 -0
  45. package/dist/spatial/spatial-types.d.ts.map +1 -0
  46. package/dist/spatial/spatial-types.js +192 -0
  47. package/dist/spatial/spatial-types.js.map +1 -0
  48. package/dist/tileset-3d/common/tile-3d.d.ts +49 -1
  49. package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
  50. package/dist/tileset-3d/common/tile-3d.js +132 -64
  51. package/dist/tileset-3d/common/tile-3d.js.map +1 -1
  52. package/dist/tileset-3d/common/tileset-3d.d.ts +25 -0
  53. package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
  54. package/dist/tileset-3d/common/tileset-3d.js +49 -7
  55. package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
  56. package/dist/tileset-3d/common/tileset-source.d.ts +14 -0
  57. package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
  58. package/dist/tileset-3d/common/tileset-source.js.map +1 -1
  59. package/dist/tileset-3d/common/tileset-traverser.d.ts +6 -1
  60. package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
  61. package/dist/tileset-3d/common/tileset-traverser.js +11 -6
  62. package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
  63. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +26 -1
  64. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
  65. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +62 -18
  66. package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
  67. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +1 -7
  68. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
  69. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +32 -55
  70. package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
  71. package/dist/tileset-3d/format-i3s/i3s-source.d.ts +14 -1
  72. package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
  73. package/dist/tileset-3d/format-i3s/i3s-source.js +107 -17
  74. package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
  75. package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
  76. package/dist/tileset-3d/helpers/bounding-volume.js +3 -33
  77. package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
  78. package/dist/tileset-3d/helpers/frame-state.d.ts +3 -1
  79. package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
  80. package/dist/tileset-3d/helpers/frame-state.js +1 -0
  81. package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
  82. package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +1 -1
  83. package/dist/tileset-3d/helpers/i3s-lod.js +20 -8
  84. package/dist/tileset-3d/helpers/i3s-lod.js.map +1 -1
  85. package/dist/types.d.ts +3 -0
  86. package/dist/types.d.ts.map +1 -1
  87. package/package.json +12 -9
  88. package/src/index.ts +42 -1
  89. package/src/point-cloud/point-cloud-tileset.ts +66 -12
  90. package/src/point-cloud/types.ts +17 -0
  91. package/src/raster-set.ts +46 -11
  92. package/src/spatial/format-spatial-reference.ts +311 -0
  93. package/src/spatial/get-spatial-coordinate-frame.ts +74 -0
  94. package/src/spatial/i3s-elevation.ts +96 -0
  95. package/src/spatial/i3s-spatial-transformer.ts +957 -0
  96. package/src/spatial/spatial-coordinate-transformer.ts +276 -0
  97. package/src/spatial/spatial-resource-registry.ts +79 -0
  98. package/src/spatial/spatial-types.ts +422 -0
  99. package/src/tileset-3d/common/tile-3d.ts +156 -69
  100. package/src/tileset-3d/common/tileset-3d.ts +77 -6
  101. package/src/tileset-3d/common/tileset-source.ts +15 -0
  102. package/src/tileset-3d/common/tileset-traverser.ts +11 -6
  103. package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +100 -22
  104. package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +36 -56
  105. package/src/tileset-3d/format-i3s/i3s-source.ts +119 -18
  106. package/src/tileset-3d/helpers/bounding-volume.ts +3 -55
  107. package/src/tileset-3d/helpers/frame-state.ts +3 -0
  108. package/src/tileset-3d/helpers/i3s-lod.ts +22 -8
  109. package/src/types.ts +3 -0
@@ -4,9 +4,9 @@
4
4
  // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
5
5
 
6
6
  /* eslint-disable */
7
- import {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';
7
+ import {Quaternion, Vector3, Matrix3, degrees} from '@math.gl/core';
8
8
  import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
9
- import {Ellipsoid} from '@math.gl/geospatial';
9
+ import {Ellipsoid, makeOBBFromRegion} from '@math.gl/geospatial';
10
10
  import {assert} from '@loaders.gl/loader-utils';
11
11
 
12
12
  // const scratchProjectedBoundingSphere = new BoundingSphere();
@@ -18,12 +18,6 @@ function defined(x) {
18
18
  // const scratchMatrix = new Matrix3();
19
19
  const scratchPoint = new Vector3();
20
20
  const scratchScale = new Vector3();
21
- const scratchNorthWest = new Vector3();
22
- const scratchSouthEast = new Vector3();
23
- const scratchCenter = new Vector3();
24
- const scratchXAxis = new Vector3();
25
- const scratchYAxis = new Vector3();
26
- const scratchZAxis = new Vector3();
27
21
  // const scratchRectangle = new Rectangle();
28
22
  // const scratchOrientedBoundingBox = new OrientedBoundingBox();
29
23
  // const scratchTransform = new Matrix4();
@@ -44,7 +38,7 @@ export function createBoundingVolume(boundingVolumeHeader, transform, result?) {
44
38
  return createBox(boundingVolumeHeader.box, transform, result);
45
39
  }
46
40
  if (boundingVolumeHeader.region) {
47
- return createObbFromRegion(boundingVolumeHeader.region);
41
+ return makeOBBFromRegion(boundingVolumeHeader.region);
48
42
  }
49
43
 
50
44
  if (boundingVolumeHeader.sphere) {
@@ -221,52 +215,6 @@ function createSphere(sphere, transform, result?) {
221
215
  return new BoundingSphere(center, radius);
222
216
  }
223
217
 
224
- /**
225
- * Create OrientedBoundingBox instance from region 3D tiles bounding volume
226
- * @param region - region 3D tiles bounding volume
227
- * @returns OrientedBoundingBox instance
228
- */
229
- function createObbFromRegion(region: number[]): OrientedBoundingBox {
230
- // [west, south, east, north, minimum height, maximum height]
231
- // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.
232
- // Heights are in meters above (or below) the WGS 84 ellipsoid.
233
- const [west, south, east, north, minHeight, maxHeight] = region;
234
-
235
- const northWest = Ellipsoid.WGS84.cartographicToCartesian(
236
- [degrees(west), degrees(north), minHeight],
237
- scratchNorthWest
238
- );
239
- const southEast = Ellipsoid.WGS84.cartographicToCartesian(
240
- [degrees(east), degrees(south), maxHeight],
241
- scratchSouthEast
242
- );
243
- const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);
244
- Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);
245
-
246
- Ellipsoid.WGS84.cartographicToCartesian(
247
- [degrees(east), scratchCenter[1], scratchCenter[2]],
248
- scratchXAxis
249
- );
250
- Ellipsoid.WGS84.cartographicToCartesian(
251
- [scratchCenter[0], degrees(north), scratchCenter[2]],
252
- scratchYAxis
253
- );
254
- Ellipsoid.WGS84.cartographicToCartesian(
255
- [scratchCenter[0], scratchCenter[1], maxHeight],
256
- scratchZAxis
257
- );
258
-
259
- return createBox(
260
- [
261
- ...centerInCartesian,
262
- ...scratchXAxis.subtract(centerInCartesian),
263
- ...scratchYAxis.subtract(centerInCartesian),
264
- ...scratchZAxis.subtract(centerInCartesian)
265
- ],
266
- new Matrix4()
267
- );
268
- }
269
-
270
218
  /**
271
219
  * Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds
272
220
  * @returns {CartographicBounds}
@@ -27,6 +27,8 @@ export type FrameState = {
27
27
  topDownViewport: GeospatialViewport; // Use it to calculate projected radius for a tile
28
28
  height: number;
29
29
  cullingVolume: CullingVolume;
30
+ /** Optional world-space clipping planes applied to render-content culling. */
31
+ clippingPlanes?: Plane[];
30
32
  frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?
31
33
  sseDenominator: number; // Assumes fovy = 60 degrees
32
34
  /** View-dependent density used by perspective dynamic screen-space error for this traversal. */
@@ -161,6 +163,7 @@ export function getFrameState(
161
163
  topDownViewport,
162
164
  height,
163
165
  cullingVolume,
166
+ clippingPlanes: viewport.clippingPlanes,
164
167
  frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?
165
168
  sseDenominator: 1.15, // Assumes fovy = 60 degrees
166
169
  // Tileset3D fills this immediately before traversal because it depends on the root volume.
@@ -32,12 +32,25 @@ export function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT
32
32
  if (screenSize < 2) {
33
33
  return 'OUT';
34
34
  }
35
- if (!tile.header.children || screenSize <= tile.lodMetricValue) {
35
+ if (!tile.header.children) {
36
36
  return 'DRAW';
37
- } else if (tile.header.children) {
38
- return 'DIG';
39
37
  }
40
- return 'OUT';
38
+
39
+ switch (tile.lodMetricType) {
40
+ case 'screenSpaceRelative': {
41
+ const viewportHeight = frameState.topDownViewport.height || 1;
42
+ return screenSize / viewportHeight <= tile.lodMetricValue ? 'DRAW' : 'DIG';
43
+ }
44
+ case 'distanceRangeFromDefaultCamera':
45
+ return tile.distanceToTile(frameState) >= tile.lodMetricValue ? 'DRAW' : 'DIG';
46
+ case 'maxScreenThresholdSQ': {
47
+ const diameterThreshold = Math.sqrt(tile.lodMetricValue / (Math.PI * 0.25));
48
+ return screenSize <= diameterThreshold ? 'DRAW' : 'DIG';
49
+ }
50
+ case 'maxScreenThreshold':
51
+ default:
52
+ return screenSize <= tile.lodMetricValue ? 'DRAW' : 'DIG';
53
+ }
41
54
  }
42
55
 
43
56
  /**
@@ -49,10 +62,11 @@ export function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT
49
62
  // eslint-disable-next-line max-statements
50
63
  export function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {
51
64
  const {topDownViewport: viewport} = frameState;
52
- const mbsLat = tile.header.mbs[1];
53
- const mbsLon = tile.header.mbs[0];
54
- const mbsZ = tile.header.mbs[2];
55
- const mbsR = tile.header.mbs[3];
65
+ const mbs = tile.header.i3sLodMbs || tile.header.mbs;
66
+ const mbsLat = mbs[1];
67
+ const mbsLon = mbs[0];
68
+ const mbsZ = mbs[2];
69
+ const mbsR = mbs[3];
56
70
  const mbsCenterCartesian = [...tile.boundingVolume.center];
57
71
  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
58
72
  Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);
package/src/types.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  import {Vector3} from '@math.gl/core';
6
+ import type {Plane} from '@math.gl/culling';
6
7
 
7
8
  export type BoundingRectangle = {
8
9
  width: number;
@@ -26,6 +27,8 @@ export type Viewport = {
26
27
  * Orthographic 3D Tiles traversal requires a positive, finite value to calculate SSE.
27
28
  */
28
29
  metersPerPixel?: number;
30
+ /** Optional world-space clipping planes used to cull renderable tile content. */
31
+ clippingPlanes?: Plane[];
29
32
  distanceScales: {
30
33
  unitsPerMeter: number[];
31
34
  metersPerUnit: number[];