@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.
- package/LICENSE +1 -1
- package/dist/dist.dev.js +17325 -5650
- package/dist/dist.min.js +4 -1
- package/dist/index.cjs +1924 -178
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.d.ts +4 -0
- package/dist/point-cloud/point-cloud-tileset.d.ts.map +1 -1
- package/dist/point-cloud/point-cloud-tileset.js +51 -12
- package/dist/point-cloud/point-cloud-tileset.js.map +1 -1
- package/dist/point-cloud/types.d.ts +17 -0
- package/dist/point-cloud/types.d.ts.map +1 -1
- package/dist/raster-set.d.ts +10 -8
- package/dist/raster-set.d.ts.map +1 -1
- package/dist/raster-set.js +18 -1
- package/dist/raster-set.js.map +1 -1
- package/dist/spatial/format-spatial-reference.d.ts +67 -0
- package/dist/spatial/format-spatial-reference.d.ts.map +1 -0
- package/dist/spatial/format-spatial-reference.js +233 -0
- package/dist/spatial/format-spatial-reference.js.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts +9 -0
- package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -0
- package/dist/spatial/get-spatial-coordinate-frame.js +58 -0
- package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -0
- package/dist/spatial/i3s-elevation.d.ts +20 -0
- package/dist/spatial/i3s-elevation.d.ts.map +1 -0
- package/dist/spatial/i3s-elevation.js +90 -0
- package/dist/spatial/i3s-elevation.js.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts +189 -0
- package/dist/spatial/i3s-spatial-transformer.d.ts.map +1 -0
- package/dist/spatial/i3s-spatial-transformer.js +686 -0
- package/dist/spatial/i3s-spatial-transformer.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +48 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.js +211 -0
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -0
- package/dist/spatial/spatial-resource-registry.d.ts +44 -0
- package/dist/spatial/spatial-resource-registry.d.ts.map +1 -0
- package/dist/spatial/spatial-resource-registry.js +67 -0
- package/dist/spatial/spatial-resource-registry.js.map +1 -0
- package/dist/spatial/spatial-types.d.ts +190 -0
- package/dist/spatial/spatial-types.d.ts.map +1 -0
- package/dist/spatial/spatial-types.js +192 -0
- package/dist/spatial/spatial-types.js.map +1 -0
- package/dist/tileset-3d/common/tile-3d.d.ts +49 -1
- package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tile-3d.js +132 -64
- package/dist/tileset-3d/common/tile-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +25 -0
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js +49 -7
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-source.d.ts +14 -0
- package/dist/tileset-3d/common/tileset-source.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-source.js.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts +6 -1
- package/dist/tileset-3d/common/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.js +11 -6
- package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +26 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js +62 -18
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts +1 -7
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js +32 -55
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts +14 -1
- package/dist/tileset-3d/format-i3s/i3s-source.d.ts.map +1 -1
- package/dist/tileset-3d/format-i3s/i3s-source.js +107 -17
- package/dist/tileset-3d/format-i3s/i3s-source.js.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.js +3 -33
- package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts +3 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.js +1 -0
- package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/i3s-lod.js +20 -8
- package/dist/tileset-3d/helpers/i3s-lod.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +12 -9
- package/src/index.ts +42 -1
- package/src/point-cloud/point-cloud-tileset.ts +66 -12
- package/src/point-cloud/types.ts +17 -0
- package/src/raster-set.ts +46 -11
- package/src/spatial/format-spatial-reference.ts +311 -0
- package/src/spatial/get-spatial-coordinate-frame.ts +74 -0
- package/src/spatial/i3s-elevation.ts +96 -0
- package/src/spatial/i3s-spatial-transformer.ts +957 -0
- package/src/spatial/spatial-coordinate-transformer.ts +276 -0
- package/src/spatial/spatial-resource-registry.ts +79 -0
- package/src/spatial/spatial-types.ts +422 -0
- package/src/tileset-3d/common/tile-3d.ts +156 -69
- package/src/tileset-3d/common/tileset-3d.ts +77 -6
- package/src/tileset-3d/common/tileset-source.ts +15 -0
- package/src/tileset-3d/common/tileset-traverser.ts +11 -6
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +100 -22
- package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +36 -56
- package/src/tileset-3d/format-i3s/i3s-source.ts +119 -18
- package/src/tileset-3d/helpers/bounding-volume.ts +3 -55
- package/src/tileset-3d/helpers/frame-state.ts +3 -0
- package/src/tileset-3d/helpers/i3s-lod.ts +22 -8
- 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,
|
|
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
|
|
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
|
|
35
|
+
if (!tile.header.children) {
|
|
36
36
|
return 'DRAW';
|
|
37
|
-
} else if (tile.header.children) {
|
|
38
|
-
return 'DIG';
|
|
39
37
|
}
|
|
40
|
-
|
|
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
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
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[];
|