@loaders.gl/tiles 5.0.0-alpha.6 → 5.0.0-alpha.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/dist.dev.js +5160 -2896
- package/dist/dist.min.js +4 -2
- package/dist/index.cjs +1509 -454
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/spatial/format-spatial-reference.d.ts +1 -0
- package/dist/spatial/format-spatial-reference.d.ts.map +1 -1
- package/dist/spatial/format-spatial-reference.js +104 -46
- package/dist/spatial/format-spatial-reference.js.map +1 -1
- package/dist/spatial/get-spatial-coordinate-frame.d.ts +12 -1
- package/dist/spatial/get-spatial-coordinate-frame.d.ts.map +1 -1
- package/dist/spatial/get-spatial-coordinate-frame.js +105 -24
- package/dist/spatial/get-spatial-coordinate-frame.js.map +1 -1
- package/dist/spatial/normalize-crs-identifier.d.ts +15 -0
- package/dist/spatial/normalize-crs-identifier.d.ts.map +1 -0
- package/dist/spatial/normalize-crs-identifier.js +22 -0
- package/dist/spatial/normalize-crs-identifier.js.map +1 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts +4 -0
- package/dist/spatial/spatial-coordinate-transformer.d.ts.map +1 -1
- package/dist/spatial/spatial-coordinate-transformer.js +89 -12
- package/dist/spatial/spatial-coordinate-transformer.js.map +1 -1
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts +32 -0
- package/dist/spatial/tiles-3d-spatial-transformer.d.ts.map +1 -0
- package/dist/spatial/tiles-3d-spatial-transformer.js +175 -0
- package/dist/spatial/tiles-3d-spatial-transformer.js.map +1 -0
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts +63 -0
- package/dist/tileset-3d/common/tile-3d-contracts.d.ts.map +1 -0
- package/dist/tileset-3d/common/tile-3d-contracts.js +51 -0
- package/dist/tileset-3d/common/tile-3d-contracts.js.map +1 -0
- package/dist/tileset-3d/common/tile-3d.d.ts +29 -5
- package/dist/tileset-3d/common/tile-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tile-3d.js +147 -18
- package/dist/tileset-3d/common/tile-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.d.ts +14 -0
- package/dist/tileset-3d/common/tileset-3d.d.ts.map +1 -1
- package/dist/tileset-3d/common/tileset-3d.js +27 -1
- package/dist/tileset-3d/common/tileset-3d.js.map +1 -1
- package/dist/tileset-3d/common/tileset-observability.d.ts +60 -0
- package/dist/tileset-3d/common/tileset-observability.d.ts.map +1 -0
- package/dist/tileset-3d/common/tileset-observability.js +39 -0
- package/dist/tileset-3d/common/tileset-observability.js.map +1 -0
- package/dist/tileset-3d/common/tileset-source.d.ts +3 -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.map +1 -1
- package/dist/tileset-3d/common/tileset-traverser.js +4 -3
- package/dist/tileset-3d/common/tileset-traverser.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/implicit-tiling.d.ts +47 -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 +327 -30
- 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 +32 -0
- 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 +265 -14
- package/dist/tileset-3d/format-3d-tiles/tiles-3d-source.js.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts +5 -3
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -1
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js +7 -4
- package/dist/tileset-3d/format-3d-tiles/tileset-3d-traverser.js.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.d.ts +7 -3
- package/dist/tileset-3d/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/bounding-volume.js +19 -61
- package/dist/tileset-3d/helpers/bounding-volume.js.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.d.ts +4 -0
- package/dist/tileset-3d/helpers/frame-state.d.ts.map +1 -1
- package/dist/tileset-3d/helpers/frame-state.js +6 -1
- package/dist/tileset-3d/helpers/frame-state.js.map +1 -1
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts +17 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.d.ts.map +1 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.js +20 -0
- package/dist/tileset-3d/helpers/s2-bounding-volume.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/index.ts +13 -1
- package/src/spatial/format-spatial-reference.ts +127 -53
- package/src/spatial/get-spatial-coordinate-frame.ts +126 -31
- package/src/spatial/normalize-crs-identifier.ts +26 -0
- package/src/spatial/spatial-coordinate-transformer.ts +106 -15
- package/src/spatial/tiles-3d-spatial-transformer.ts +206 -0
- package/src/tileset-3d/common/tile-3d-contracts.ts +115 -0
- package/src/tileset-3d/common/tile-3d.ts +172 -18
- package/src/tileset-3d/common/tileset-3d.ts +29 -1
- package/src/tileset-3d/common/tileset-observability.ts +100 -0
- package/src/tileset-3d/common/tileset-source.ts +3 -0
- package/src/tileset-3d/common/tileset-traverser.ts +4 -3
- package/src/tileset-3d/format-3d-tiles/implicit-tiling.ts +481 -34
- package/src/tileset-3d/format-3d-tiles/tiles-3d-source.ts +387 -14
- package/src/tileset-3d/format-3d-tiles/tileset-3d-traverser.ts +7 -4
- package/src/tileset-3d/helpers/bounding-volume.ts +29 -62
- package/src/tileset-3d/helpers/frame-state.ts +6 -1
- package/src/tileset-3d/helpers/s2-bounding-volume.ts +35 -0
- package/src/types.ts +2 -0
|
@@ -4,7 +4,7 @@
|
|
|
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, degrees} from '@math.gl/core';
|
|
7
|
+
import {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';
|
|
8
8
|
import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
|
|
9
9
|
import {Ellipsoid, makeOBBFromRegion} from '@math.gl/geospatial';
|
|
10
10
|
import {assert} from '@loaders.gl/loader-utils';
|
|
@@ -18,6 +18,7 @@ function defined(x) {
|
|
|
18
18
|
// const scratchMatrix = new Matrix3();
|
|
19
19
|
const scratchPoint = new Vector3();
|
|
20
20
|
const scratchScale = new Vector3();
|
|
21
|
+
const identityTransform = new Matrix4();
|
|
21
22
|
// const scratchRectangle = new Rectangle();
|
|
22
23
|
// const scratchOrientedBoundingBox = new OrientedBoundingBox();
|
|
23
24
|
// const scratchTransform = new Matrix4();
|
|
@@ -25,20 +26,39 @@ const scratchScale = new Vector3();
|
|
|
25
26
|
/**
|
|
26
27
|
* Create a bounding volume from the tile's bounding volume header.
|
|
27
28
|
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
28
|
-
* @param {Matrix4} transform The
|
|
29
|
+
* @param {Matrix4} transform The current computed tile transform, including application transforms.
|
|
29
30
|
* @param [result] The object onto which to store the result.
|
|
31
|
+
* @param initialTransform The accumulated JSON tile transform, excluded from region transforms.
|
|
32
|
+
* Defaults to transform so callers without application transforms keep geospatial regions fixed.
|
|
30
33
|
* @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.
|
|
31
34
|
*/
|
|
32
|
-
export function createBoundingVolume(
|
|
35
|
+
export function createBoundingVolume(
|
|
36
|
+
boundingVolumeHeader,
|
|
37
|
+
transform: Matrix4,
|
|
38
|
+
result?,
|
|
39
|
+
initialTransform: Matrix4 = transform
|
|
40
|
+
) {
|
|
33
41
|
assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
|
|
34
42
|
|
|
35
43
|
// boundingVolume schema:
|
|
36
44
|
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json
|
|
37
45
|
if (boundingVolumeHeader.box) {
|
|
38
|
-
|
|
46
|
+
// S2 cells and regions are geospatially anchored. Their conservative ECEF boxes are already
|
|
47
|
+
// world-space volumes and must not receive the tile/node transform a second time.
|
|
48
|
+
const boxTransform = boundingVolumeHeader.s2VolumeInfo ? identityTransform : transform;
|
|
49
|
+
return createBox(boundingVolumeHeader.box, boxTransform, result);
|
|
39
50
|
}
|
|
40
51
|
if (boundingVolumeHeader.region) {
|
|
41
|
-
|
|
52
|
+
const boundingVolume = makeOBBFromRegion(boundingVolumeHeader.region);
|
|
53
|
+
// Regions are already in world coordinates. Apply only the change from the JSON transform.
|
|
54
|
+
const regionTransform = transform.equals(initialTransform)
|
|
55
|
+
? identityTransform
|
|
56
|
+
: transform.clone().multiplyRight(initialTransform.clone().invert());
|
|
57
|
+
return createBox(
|
|
58
|
+
[...boundingVolume.center, ...boundingVolume.halfAxes],
|
|
59
|
+
regionTransform,
|
|
60
|
+
result
|
|
61
|
+
);
|
|
42
62
|
}
|
|
43
63
|
|
|
44
64
|
if (boundingVolumeHeader.sphere) {
|
|
@@ -55,15 +75,17 @@ export type CartographicBounds = [min: number[], max: number[]];
|
|
|
55
75
|
* Calculate the cartographic bounding box the tile's bounding volume.
|
|
56
76
|
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
57
77
|
* @param {BoundingVolume} boundingVolume The bounding volume.
|
|
78
|
+
* @param isRegionTransformed Whether application transforms moved the region from its JSON bounds.
|
|
58
79
|
* @returns {CartographicBounds}
|
|
59
80
|
*/
|
|
60
81
|
export function getCartographicBounds(
|
|
61
82
|
boundingVolumeHeader,
|
|
62
|
-
boundingVolume: OrientedBoundingBox | BoundingSphere
|
|
83
|
+
boundingVolume: OrientedBoundingBox | BoundingSphere,
|
|
84
|
+
isRegionTransformed = false
|
|
63
85
|
): CartographicBounds {
|
|
64
86
|
// boundingVolume schema:
|
|
65
87
|
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json
|
|
66
|
-
if (boundingVolumeHeader.box) {
|
|
88
|
+
if (boundingVolumeHeader.box || (boundingVolumeHeader.region && isRegionTransformed)) {
|
|
67
89
|
return orientedBoundingBoxToCartographicBounds(boundingVolume as OrientedBoundingBox);
|
|
68
90
|
}
|
|
69
91
|
if (boundingVolumeHeader.region) {
|
|
@@ -142,61 +164,6 @@ function createBox(box, transform, result?) {
|
|
|
142
164
|
return new OrientedBoundingBox(center, halfAxes);
|
|
143
165
|
}
|
|
144
166
|
|
|
145
|
-
/*
|
|
146
|
-
function createBoxFromTransformedRegion(region, transform, initialTransform, result) {
|
|
147
|
-
const rectangle = Rectangle.unpack(region, 0, scratchRectangle);
|
|
148
|
-
const minimumHeight = region[4];
|
|
149
|
-
const maximumHeight = region[5];
|
|
150
|
-
|
|
151
|
-
const orientedBoundingBox = OrientedBoundingBox.fromRectangle(
|
|
152
|
-
rectangle,
|
|
153
|
-
minimumHeight,
|
|
154
|
-
maximumHeight,
|
|
155
|
-
Ellipsoid.WGS84,
|
|
156
|
-
scratchOrientedBoundingBox
|
|
157
|
-
);
|
|
158
|
-
const center = orientedBoundingBox.center;
|
|
159
|
-
const halfAxes = orientedBoundingBox.halfAxes;
|
|
160
|
-
|
|
161
|
-
// A region bounding volume is not transformed by the transform in the tileset JSON,
|
|
162
|
-
// but may be transformed by additional transforms applied in Cesium.
|
|
163
|
-
// This is why the transform is calculated as the difference between the initial transform and the current transform.
|
|
164
|
-
transform = Matrix4.multiplyTransformation(
|
|
165
|
-
transform,
|
|
166
|
-
Matrix4.inverseTransformation(initialTransform, scratchTransform),
|
|
167
|
-
scratchTransform
|
|
168
|
-
);
|
|
169
|
-
center = Matrix4.multiplyByPoint(transform, center, center);
|
|
170
|
-
const rotationScale = Matrix4.getRotation(transform, scratchMatrix);
|
|
171
|
-
halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);
|
|
172
|
-
|
|
173
|
-
if (defined(result) && result instanceof TileOrientedBoundingBox) {
|
|
174
|
-
result.update(center, halfAxes);
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
return new TileOrientedBoundingBox(center, halfAxes);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
function createRegion(region, transform, initialTransform, result) {
|
|
182
|
-
if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {
|
|
183
|
-
return createBoxFromTransformedRegion(region, transform, initialTransform, result);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (defined(result)) {
|
|
187
|
-
return result;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);
|
|
191
|
-
|
|
192
|
-
return new TileBoundingRegion({
|
|
193
|
-
rectangle: rectangleRegion,
|
|
194
|
-
minimumHeight: region[4],
|
|
195
|
-
maximumHeight: region[5]
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
*/
|
|
199
|
-
|
|
200
167
|
function createSphere(sphere, transform, result?) {
|
|
201
168
|
// Find the transformed center
|
|
202
169
|
const center = new Vector3(sphere[0], sphere[1], sphere[2]);
|
|
@@ -75,6 +75,10 @@ const cullingVolume = new CullingVolume([
|
|
|
75
75
|
/**
|
|
76
76
|
* Extracts a frame state appropriate for tile culling from a structural deck.gl viewport.
|
|
77
77
|
*
|
|
78
|
+
* The viewport must describe the render camera, including its elevation. Geographic heights
|
|
79
|
+
* returned by `unprojectPosition` are used directly; adding a terrain offset only to traversal
|
|
80
|
+
* would make visibility, camera distances, and screen-space error disagree with rendering.
|
|
81
|
+
*
|
|
78
82
|
* `options.timeSinceCameraMovement` can be supplied by a caller that retains camera pose across
|
|
79
83
|
* calls. It defaults to a stationary camera so standalone callers do not defer requests.
|
|
80
84
|
*
|
|
@@ -134,7 +138,7 @@ export function getFrameState(
|
|
|
134
138
|
commonSpacePlanesToWGS84(viewport);
|
|
135
139
|
|
|
136
140
|
const ViewportClass = viewport.constructor;
|
|
137
|
-
const {longitude, latitude, width, bearing, zoom} = viewport;
|
|
141
|
+
const {longitude, latitude, width, bearing, zoom, position} = viewport;
|
|
138
142
|
// @ts-ignore
|
|
139
143
|
const topDownViewport = new ViewportClass({
|
|
140
144
|
longitude,
|
|
@@ -143,6 +147,7 @@ export function getFrameState(
|
|
|
143
147
|
width,
|
|
144
148
|
bearing,
|
|
145
149
|
zoom,
|
|
150
|
+
position,
|
|
146
151
|
pitch: 0
|
|
147
152
|
});
|
|
148
153
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// TypeScript's legacy `node` resolution does not inspect package `exports`, but this public
|
|
6
|
+
// subpath is resolved by the package at runtime and avoids loading unrelated DGGS decoders.
|
|
7
|
+
// @ts-expect-error Conditional package subpath exports require a modern module resolver.
|
|
8
|
+
import {getS2Bounds} from '@math.gl/dggs/s2';
|
|
9
|
+
import {Ellipsoid, makeOBBFromRegion} from '@math.gl/geospatial';
|
|
10
|
+
|
|
11
|
+
/** Serialized S2 cell metadata used by 3D Tiles bounding-volume extensions. */
|
|
12
|
+
export type S2VolumeInfo = {
|
|
13
|
+
/** S2 key or token. */
|
|
14
|
+
token: string;
|
|
15
|
+
/** Minimum height in meters. */
|
|
16
|
+
minimumHeight: number;
|
|
17
|
+
/** Maximum height in meters. */
|
|
18
|
+
maximumHeight: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Converts an S2 cell and its vertical range to the runtime oriented-box representation.
|
|
23
|
+
*
|
|
24
|
+
* @param s2VolumeInfo - S2 cell token and height range.
|
|
25
|
+
* @returns A twelve-component center/half-axis oriented bounding box.
|
|
26
|
+
*/
|
|
27
|
+
export function convertS2BoundingVolumeToOBB(s2VolumeInfo: S2VolumeInfo): number[] {
|
|
28
|
+
const [[west, south], [east, north]] = getS2Bounds(s2VolumeInfo.token);
|
|
29
|
+
const orientedBoundingBox = makeOBBFromRegion(
|
|
30
|
+
[west, south, east, north, s2VolumeInfo.minimumHeight, s2VolumeInfo.maximumHeight],
|
|
31
|
+
Ellipsoid.WGS84,
|
|
32
|
+
{units: 'degrees'}
|
|
33
|
+
);
|
|
34
|
+
return [...orientedBoundingBox.center, ...orientedBoundingBox.halfAxes];
|
|
35
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -46,6 +46,8 @@ export type GeospatialViewport = Viewport & {
|
|
|
46
46
|
cameraDirection: [number, number, number];
|
|
47
47
|
/** @todo This field is not represented in Deck.gl viewports. Can be removed in the next version */
|
|
48
48
|
cameraUp: [number, number, number];
|
|
49
|
+
/** Camera target offset in meters from longitude/latitude, including elevation. */
|
|
50
|
+
position?: number[];
|
|
49
51
|
longitude: number;
|
|
50
52
|
latitude: number;
|
|
51
53
|
bearing: number;
|