@loaders.gl/tiles 3.3.2 → 3.3.4
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.min.js +99 -21
- package/dist/es5/tileset/helpers/bounding-volume.js +94 -0
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +11 -0
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +8 -17
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/esm/tileset/helpers/bounding-volume.js +88 -0
- package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -1
- package/dist/esm/tileset/tile-3d.js +9 -1
- package/dist/esm/tileset/tile-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-3d.js +8 -16
- package/dist/esm/tileset/tileset-3d.js.map +1 -1
- package/dist/tileset/helpers/bounding-volume.d.ts +10 -0
- package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -1
- package/dist/tileset/helpers/bounding-volume.js +117 -1
- package/dist/tileset/tile-3d.d.ts +7 -0
- package/dist/tileset/tile-3d.d.ts.map +1 -1
- package/dist/tileset/tile-3d.js +10 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/tileset/tileset-3d.js +8 -16
- package/package.json +4 -4
- package/src/tileset/helpers/bounding-volume.ts +136 -0
- package/src/tileset/tile-3d.ts +18 -1
- package/src/tileset/tileset-3d.ts +10 -17
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
3
|
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.createBoundingVolume = void 0;
|
|
5
|
+
exports.getCartographicBounds = exports.createBoundingVolume = void 0;
|
|
6
6
|
/* eslint-disable */
|
|
7
7
|
const core_1 = require("@math.gl/core");
|
|
8
8
|
const culling_1 = require("@math.gl/culling");
|
|
@@ -13,6 +13,7 @@ function defined(x) {
|
|
|
13
13
|
return x !== undefined && x !== null;
|
|
14
14
|
}
|
|
15
15
|
// const scratchMatrix = new Matrix3();
|
|
16
|
+
const scratchPoint = new core_1.Vector3();
|
|
16
17
|
const scratchScale = new core_1.Vector3();
|
|
17
18
|
const scratchNorthWest = new core_1.Vector3();
|
|
18
19
|
const scratchSouthEast = new core_1.Vector3();
|
|
@@ -52,6 +53,34 @@ function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
|
52
53
|
throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
|
|
53
54
|
}
|
|
54
55
|
exports.createBoundingVolume = createBoundingVolume;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate the cartographic bounding box the tile's bounding volume.
|
|
58
|
+
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
59
|
+
* @param {BoundingVolume} boundingVolume The bounding volume.
|
|
60
|
+
* @returns {CartographicBounds}
|
|
61
|
+
*/
|
|
62
|
+
function getCartographicBounds(boundingVolumeHeader, boundingVolume) {
|
|
63
|
+
// boundingVolume schema:
|
|
64
|
+
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json
|
|
65
|
+
if (boundingVolumeHeader.box) {
|
|
66
|
+
return orientedBoundingBoxToCartographicBounds(boundingVolume);
|
|
67
|
+
}
|
|
68
|
+
if (boundingVolumeHeader.region) {
|
|
69
|
+
// [west, south, east, north, minimum height, maximum height]
|
|
70
|
+
// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.
|
|
71
|
+
// Heights are in meters above (or below) the WGS 84 ellipsoid.
|
|
72
|
+
const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
|
|
73
|
+
return [
|
|
74
|
+
[(0, core_1.degrees)(west), (0, core_1.degrees)(south), minHeight],
|
|
75
|
+
[(0, core_1.degrees)(east), (0, core_1.degrees)(north), maxHeight]
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
if (boundingVolumeHeader.sphere) {
|
|
79
|
+
return boundingSphereToCartographicBounds(boundingVolume);
|
|
80
|
+
}
|
|
81
|
+
throw new Error('Unkown boundingVolume type');
|
|
82
|
+
}
|
|
83
|
+
exports.getCartographicBounds = getCartographicBounds;
|
|
55
84
|
function createBox(box, transform, result) {
|
|
56
85
|
// https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box
|
|
57
86
|
// 1. A half-axes based representation.
|
|
@@ -175,3 +204,90 @@ function createSphere(sphere, transform, result) {
|
|
|
175
204
|
}
|
|
176
205
|
return new culling_1.BoundingSphere(center, radius);
|
|
177
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds
|
|
209
|
+
* @returns {CartographicBounds}
|
|
210
|
+
*/
|
|
211
|
+
function orientedBoundingBoxToCartographicBounds(boundingVolume) {
|
|
212
|
+
const result = emptyCartographicBounds();
|
|
213
|
+
const { halfAxes } = boundingVolume;
|
|
214
|
+
const xAxis = new core_1.Vector3(halfAxes.getColumn(0));
|
|
215
|
+
const yAxis = new core_1.Vector3(halfAxes.getColumn(1));
|
|
216
|
+
const zAxis = new core_1.Vector3(halfAxes.getColumn(2));
|
|
217
|
+
// Test all 8 corners of the box
|
|
218
|
+
for (let x = 0; x < 2; x++) {
|
|
219
|
+
for (let y = 0; y < 2; y++) {
|
|
220
|
+
for (let z = 0; z < 2; z++) {
|
|
221
|
+
scratchPoint.copy(boundingVolume.center);
|
|
222
|
+
scratchPoint.add(xAxis);
|
|
223
|
+
scratchPoint.add(yAxis);
|
|
224
|
+
scratchPoint.add(zAxis);
|
|
225
|
+
addToCartographicBounds(result, scratchPoint);
|
|
226
|
+
zAxis.negate();
|
|
227
|
+
}
|
|
228
|
+
yAxis.negate();
|
|
229
|
+
}
|
|
230
|
+
xAxis.negate();
|
|
231
|
+
}
|
|
232
|
+
return result;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Convert a bounding volume defined by BoundingSphere to cartographic bounds
|
|
236
|
+
* @returns {CartographicBounds}
|
|
237
|
+
*/
|
|
238
|
+
function boundingSphereToCartographicBounds(boundingVolume) {
|
|
239
|
+
const result = emptyCartographicBounds();
|
|
240
|
+
const { center, radius } = boundingVolume;
|
|
241
|
+
const point = geospatial_1.Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);
|
|
242
|
+
let zAxis;
|
|
243
|
+
if (point) {
|
|
244
|
+
zAxis = geospatial_1.Ellipsoid.WGS84.geodeticSurfaceNormal(point);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
zAxis = new core_1.Vector3(0, 0, 1);
|
|
248
|
+
}
|
|
249
|
+
let xAxis = new core_1.Vector3(zAxis[2], -zAxis[1], 0);
|
|
250
|
+
if (xAxis.len() > 0) {
|
|
251
|
+
xAxis.normalize();
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
xAxis = new core_1.Vector3(0, 1, 0);
|
|
255
|
+
}
|
|
256
|
+
const yAxis = xAxis.clone().cross(zAxis);
|
|
257
|
+
// Test 6 end points of the 3 axes
|
|
258
|
+
for (const axis of [xAxis, yAxis, zAxis]) {
|
|
259
|
+
scratchScale.copy(axis).scale(radius);
|
|
260
|
+
for (let dir = 0; dir < 2; dir++) {
|
|
261
|
+
scratchPoint.copy(center);
|
|
262
|
+
scratchPoint.add(scratchScale);
|
|
263
|
+
addToCartographicBounds(result, scratchPoint);
|
|
264
|
+
// Flip the axis
|
|
265
|
+
scratchScale.negate();
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return result;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Create a new cartographic bounds that contains no points
|
|
272
|
+
* @returns {CartographicBounds}
|
|
273
|
+
*/
|
|
274
|
+
function emptyCartographicBounds() {
|
|
275
|
+
return [
|
|
276
|
+
[Infinity, Infinity, Infinity],
|
|
277
|
+
[-Infinity, -Infinity, -Infinity]
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Add a point to the target cartographic bounds
|
|
282
|
+
* @param {CartographicBounds} target
|
|
283
|
+
* @param {Vector3} cartesian coordinates of the point to add
|
|
284
|
+
*/
|
|
285
|
+
function addToCartographicBounds(target, cartesian) {
|
|
286
|
+
geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);
|
|
287
|
+
target[0][0] = Math.min(target[0][0], scratchPoint[0]);
|
|
288
|
+
target[0][1] = Math.min(target[0][1], scratchPoint[1]);
|
|
289
|
+
target[0][2] = Math.min(target[0][2], scratchPoint[2]);
|
|
290
|
+
target[1][0] = Math.max(target[1][0], scratchPoint[0]);
|
|
291
|
+
target[1][1] = Math.max(target[1][1], scratchPoint[1]);
|
|
292
|
+
target[1][2] = Math.max(target[1][2], scratchPoint[2]);
|
|
293
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Matrix4 } from '@math.gl/core';
|
|
2
2
|
import type { Tileset3D } from './tileset-3d';
|
|
3
3
|
import { FrameState } from './helpers/frame-state';
|
|
4
|
+
import { CartographicBounds } from './helpers/bounding-volume';
|
|
4
5
|
/**
|
|
5
6
|
* @param tileset - Tileset3D instance
|
|
6
7
|
* @param header - tile header - JSON loaded from a dataset
|
|
@@ -53,6 +54,7 @@ export declare class Tile3D {
|
|
|
53
54
|
private _expireDate;
|
|
54
55
|
private _expiredContent;
|
|
55
56
|
private _shouldRefine;
|
|
57
|
+
private _boundingBox?;
|
|
56
58
|
_distanceToCamera: number;
|
|
57
59
|
private _centerZDepth;
|
|
58
60
|
private _screenSpaceError;
|
|
@@ -121,6 +123,11 @@ export declare class Tile3D {
|
|
|
121
123
|
* Screen space error for LOD selection
|
|
122
124
|
*/
|
|
123
125
|
get screenSpaceError(): number;
|
|
126
|
+
/**
|
|
127
|
+
* Get bounding box in cartographic coordinates
|
|
128
|
+
* @returns [min, max] each in [longitude, latitude, altitude]
|
|
129
|
+
*/
|
|
130
|
+
get boundingBox(): CartographicBounds;
|
|
124
131
|
/** Get the tile's screen space error. */
|
|
125
132
|
getScreenSpaceError(frameState: any, useParentLodMetric: any): number;
|
|
126
133
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tile-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tile-3d.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,OAAO,EAAC,MAAM,eAAe,CAAC;AAM/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"tile-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tile-3d.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,OAAO,EAAC,MAAM,eAAe,CAAC;AAM/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAGL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAYnC;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,MAAM;IACjB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,GAAG,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAA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;;OAIG;IACH,yBAAyB,CAAC,UAAU,EAAE,UAAU;IAUhD,gBAAgB;IAWhB,IAAI,MAAM,QAET;IAID,oBAAoB,CAAC,MAAM,KAAA;IAsB3B,qBAAqB,CAAC,UAAU,KAAA;IAkBhC,0BAA0B,CAAC,UAAU,KAAA;IAOrC,kBAAkB,CAAC,UAAU,KAAA;IAiB7B,yBAAyB,CAAC,MAAM,KAAA;IAwBhC,UAAU,CAAC,MAAM,KAAA;IAKjB,UAAU;IAIV,gBAAgB;IAiBhB,qBAAqB,CAAC,MAAM,KAAA;IAoC5B,gBAAgB,CAAC,eAAe,UAAgB;IAchD,yBAAyB,CAAC,QAAQ,KAAA;;;;;;;;;;;;;;;;;;;CA2BnC"}
|
package/dist/tileset/tile-3d.js
CHANGED
|
@@ -171,6 +171,16 @@ class Tile3D {
|
|
|
171
171
|
get screenSpaceError() {
|
|
172
172
|
return this._screenSpaceError;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Get bounding box in cartographic coordinates
|
|
176
|
+
* @returns [min, max] each in [longitude, latitude, altitude]
|
|
177
|
+
*/
|
|
178
|
+
get boundingBox() {
|
|
179
|
+
if (!this._boundingBox) {
|
|
180
|
+
this._boundingBox = (0, bounding_volume_1.getCartographicBounds)(this.header.boundingVolume, this.boundingVolume);
|
|
181
|
+
}
|
|
182
|
+
return this._boundingBox;
|
|
183
|
+
}
|
|
174
184
|
/** Get the tile's screen space error. */
|
|
175
185
|
getScreenSpaceError(frameState, useParentLodMetric) {
|
|
176
186
|
switch (this.tileset.type) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tileset-3d.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EACL,gBAAgB,EAGhB,gBAAgB,E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B,WAAW,CAAC,IAAI,KAAA;IAYhB,QAAQ;IAoBR,eAAe,CAAC,IAAI,KAAA;IAgBpB,YAAY,CAAC,IAAI,KAAA;IAMjB,yBAAyB,CAAC,WAAW,KAAA;IA6BrC,qBAAqB;CAKtB"}
|
|
@@ -202,7 +202,7 @@ class Tileset3D {
|
|
|
202
202
|
}
|
|
203
203
|
get queryParams() {
|
|
204
204
|
if (!this._queryParamsString) {
|
|
205
|
-
this._queryParamsString =
|
|
205
|
+
this._queryParamsString = new URLSearchParams(this._queryParams).toString();
|
|
206
206
|
}
|
|
207
207
|
return this._queryParamsString;
|
|
208
208
|
}
|
|
@@ -222,7 +222,7 @@ class Tileset3D {
|
|
|
222
222
|
if (isDataUrl) {
|
|
223
223
|
return tilePath;
|
|
224
224
|
}
|
|
225
|
-
return `${tilePath}${this.queryParams}`;
|
|
225
|
+
return `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`;
|
|
226
226
|
}
|
|
227
227
|
// TODO CESIUM specific
|
|
228
228
|
hasExtension(extensionName) {
|
|
@@ -522,6 +522,12 @@ class Tileset3D {
|
|
|
522
522
|
const children = tile.header.children || [];
|
|
523
523
|
for (const childHeader of children) {
|
|
524
524
|
const childTile = new tile_3d_1.Tile3D(this, childHeader, tile);
|
|
525
|
+
// Special handling for Google 3D tiles
|
|
526
|
+
// A session key must be used for all tile requests
|
|
527
|
+
if (childTile.contentUrl?.includes('?session=')) {
|
|
528
|
+
const url = new URL(childTile.contentUrl);
|
|
529
|
+
this._queryParams.session = url.searchParams.get('session');
|
|
530
|
+
}
|
|
525
531
|
tile.children.push(childTile);
|
|
526
532
|
childTile.depth = tile.depth + 1;
|
|
527
533
|
stack.push(childTile);
|
|
@@ -717,17 +723,3 @@ class Tileset3D {
|
|
|
717
723
|
}
|
|
718
724
|
}
|
|
719
725
|
exports.Tileset3D = Tileset3D;
|
|
720
|
-
function getQueryParamString(queryParams) {
|
|
721
|
-
const queryParamStrings = [];
|
|
722
|
-
for (const key of Object.keys(queryParams)) {
|
|
723
|
-
queryParamStrings.push(`${key}=${queryParams[key]}`);
|
|
724
|
-
}
|
|
725
|
-
switch (queryParamStrings.length) {
|
|
726
|
-
case 0:
|
|
727
|
-
return '';
|
|
728
|
-
case 1:
|
|
729
|
-
return `?${queryParamStrings[0]}`;
|
|
730
|
-
default:
|
|
731
|
-
return `?${queryParamStrings.join('&')}`;
|
|
732
|
-
}
|
|
733
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tiles",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"description": "Common components for different tiles loaders.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@loaders.gl/loader-utils": "3.3.
|
|
37
|
-
"@loaders.gl/math": "3.3.
|
|
36
|
+
"@loaders.gl/loader-utils": "3.3.4",
|
|
37
|
+
"@loaders.gl/math": "3.3.4",
|
|
38
38
|
"@math.gl/core": "^3.5.1",
|
|
39
39
|
"@math.gl/culling": "^3.5.1",
|
|
40
40
|
"@math.gl/geospatial": "^3.5.1",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@loaders.gl/core": "^3.2.0"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "1d1a722ea9a04665acbe41359dfd01bf6d43a214"
|
|
48
48
|
}
|
|
@@ -14,6 +14,7 @@ function defined(x) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
// const scratchMatrix = new Matrix3();
|
|
17
|
+
const scratchPoint = new Vector3();
|
|
17
18
|
const scratchScale = new Vector3();
|
|
18
19
|
const scratchNorthWest = new Vector3();
|
|
19
20
|
const scratchSouthEast = new Vector3();
|
|
@@ -68,6 +69,43 @@ export function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
|
68
69
|
throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
|
|
69
70
|
}
|
|
70
71
|
|
|
72
|
+
/** [min, max] each in [longitude, latitude, altitude] */
|
|
73
|
+
export type CartographicBounds = [min: number[], max: number[]];
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Calculate the cartographic bounding box the tile's bounding volume.
|
|
77
|
+
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
78
|
+
* @param {BoundingVolume} boundingVolume The bounding volume.
|
|
79
|
+
* @returns {CartographicBounds}
|
|
80
|
+
*/
|
|
81
|
+
export function getCartographicBounds(
|
|
82
|
+
boundingVolumeHeader,
|
|
83
|
+
boundingVolume: OrientedBoundingBox | BoundingSphere
|
|
84
|
+
): CartographicBounds {
|
|
85
|
+
// boundingVolume schema:
|
|
86
|
+
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json
|
|
87
|
+
if (boundingVolumeHeader.box) {
|
|
88
|
+
return orientedBoundingBoxToCartographicBounds(boundingVolume as OrientedBoundingBox);
|
|
89
|
+
}
|
|
90
|
+
if (boundingVolumeHeader.region) {
|
|
91
|
+
// [west, south, east, north, minimum height, maximum height]
|
|
92
|
+
// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.
|
|
93
|
+
// Heights are in meters above (or below) the WGS 84 ellipsoid.
|
|
94
|
+
const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
|
|
95
|
+
|
|
96
|
+
return [
|
|
97
|
+
[degrees(west), degrees(south), minHeight],
|
|
98
|
+
[degrees(east), degrees(north), maxHeight]
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (boundingVolumeHeader.sphere) {
|
|
103
|
+
return boundingSphereToCartographicBounds(boundingVolume as BoundingSphere);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
throw new Error('Unkown boundingVolume type');
|
|
107
|
+
}
|
|
108
|
+
|
|
71
109
|
function createBox(box, transform, result) {
|
|
72
110
|
// https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box
|
|
73
111
|
// 1. A half-axes based representation.
|
|
@@ -197,3 +235,101 @@ function createSphere(sphere, transform, result?) {
|
|
|
197
235
|
|
|
198
236
|
return new BoundingSphere(center, radius);
|
|
199
237
|
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds
|
|
241
|
+
* @returns {CartographicBounds}
|
|
242
|
+
*/
|
|
243
|
+
function orientedBoundingBoxToCartographicBounds(
|
|
244
|
+
boundingVolume: OrientedBoundingBox
|
|
245
|
+
): CartographicBounds {
|
|
246
|
+
const result = emptyCartographicBounds();
|
|
247
|
+
|
|
248
|
+
const {halfAxes} = boundingVolume as OrientedBoundingBox;
|
|
249
|
+
const xAxis = new Vector3(halfAxes.getColumn(0));
|
|
250
|
+
const yAxis = new Vector3(halfAxes.getColumn(1));
|
|
251
|
+
const zAxis = new Vector3(halfAxes.getColumn(2));
|
|
252
|
+
|
|
253
|
+
// Test all 8 corners of the box
|
|
254
|
+
for (let x = 0; x < 2; x++) {
|
|
255
|
+
for (let y = 0; y < 2; y++) {
|
|
256
|
+
for (let z = 0; z < 2; z++) {
|
|
257
|
+
scratchPoint.copy(boundingVolume.center);
|
|
258
|
+
scratchPoint.add(xAxis);
|
|
259
|
+
scratchPoint.add(yAxis);
|
|
260
|
+
scratchPoint.add(zAxis);
|
|
261
|
+
|
|
262
|
+
addToCartographicBounds(result, scratchPoint);
|
|
263
|
+
zAxis.negate();
|
|
264
|
+
}
|
|
265
|
+
yAxis.negate();
|
|
266
|
+
}
|
|
267
|
+
xAxis.negate();
|
|
268
|
+
}
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Convert a bounding volume defined by BoundingSphere to cartographic bounds
|
|
274
|
+
* @returns {CartographicBounds}
|
|
275
|
+
*/
|
|
276
|
+
function boundingSphereToCartographicBounds(boundingVolume: BoundingSphere): CartographicBounds {
|
|
277
|
+
const result = emptyCartographicBounds();
|
|
278
|
+
|
|
279
|
+
const {center, radius} = boundingVolume as BoundingSphere;
|
|
280
|
+
const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);
|
|
281
|
+
|
|
282
|
+
let zAxis: Vector3;
|
|
283
|
+
if (point) {
|
|
284
|
+
zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point) as Vector3;
|
|
285
|
+
} else {
|
|
286
|
+
zAxis = new Vector3(0, 0, 1);
|
|
287
|
+
}
|
|
288
|
+
let xAxis = new Vector3(zAxis[2], -zAxis[1], 0);
|
|
289
|
+
if (xAxis.len() > 0) {
|
|
290
|
+
xAxis.normalize();
|
|
291
|
+
} else {
|
|
292
|
+
xAxis = new Vector3(0, 1, 0);
|
|
293
|
+
}
|
|
294
|
+
const yAxis = xAxis.clone().cross(zAxis);
|
|
295
|
+
|
|
296
|
+
// Test 6 end points of the 3 axes
|
|
297
|
+
for (const axis of [xAxis, yAxis, zAxis]) {
|
|
298
|
+
scratchScale.copy(axis).scale(radius);
|
|
299
|
+
for (let dir = 0; dir < 2; dir++) {
|
|
300
|
+
scratchPoint.copy(center);
|
|
301
|
+
scratchPoint.add(scratchScale);
|
|
302
|
+
addToCartographicBounds(result, scratchPoint);
|
|
303
|
+
// Flip the axis
|
|
304
|
+
scratchScale.negate();
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return result;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Create a new cartographic bounds that contains no points
|
|
312
|
+
* @returns {CartographicBounds}
|
|
313
|
+
*/
|
|
314
|
+
function emptyCartographicBounds(): CartographicBounds {
|
|
315
|
+
return [
|
|
316
|
+
[Infinity, Infinity, Infinity],
|
|
317
|
+
[-Infinity, -Infinity, -Infinity]
|
|
318
|
+
];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Add a point to the target cartographic bounds
|
|
323
|
+
* @param {CartographicBounds} target
|
|
324
|
+
* @param {Vector3} cartesian coordinates of the point to add
|
|
325
|
+
*/
|
|
326
|
+
function addToCartographicBounds(target: CartographicBounds, cartesian: Readonly<Vector3>) {
|
|
327
|
+
Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);
|
|
328
|
+
target[0][0] = Math.min(target[0][0], scratchPoint[0]);
|
|
329
|
+
target[0][1] = Math.min(target[0][1], scratchPoint[1]);
|
|
330
|
+
target[0][2] = Math.min(target[0][2], scratchPoint[2]);
|
|
331
|
+
|
|
332
|
+
target[1][0] = Math.max(target[1][0], scratchPoint[0]);
|
|
333
|
+
target[1][1] = Math.max(target[1][1], scratchPoint[1]);
|
|
334
|
+
target[1][2] = Math.max(target[1][2], scratchPoint[2]);
|
|
335
|
+
}
|
package/src/tileset/tile-3d.ts
CHANGED
|
@@ -13,7 +13,11 @@ import type {Tileset3D} from './tileset-3d';
|
|
|
13
13
|
import {TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE} from '../constants';
|
|
14
14
|
|
|
15
15
|
import {FrameState} from './helpers/frame-state';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
createBoundingVolume,
|
|
18
|
+
getCartographicBounds,
|
|
19
|
+
CartographicBounds
|
|
20
|
+
} from './helpers/bounding-volume';
|
|
17
21
|
import {getTiles3DScreenSpaceError} from './helpers/tiles-3d-lod';
|
|
18
22
|
import {getProjectedRadius} from './helpers/i3s-lod';
|
|
19
23
|
import {get3dTilesOptions} from './helpers/3d-tiles-options';
|
|
@@ -86,6 +90,8 @@ export class Tile3D {
|
|
|
86
90
|
// @ts-ignore
|
|
87
91
|
private _shouldRefine: boolean;
|
|
88
92
|
|
|
93
|
+
private _boundingBox?: CartographicBounds;
|
|
94
|
+
|
|
89
95
|
// Members this are updated every frame for tree traversal and rendering optimizations:
|
|
90
96
|
public _distanceToCamera: number;
|
|
91
97
|
// @ts-ignore
|
|
@@ -303,6 +309,17 @@ export class Tile3D {
|
|
|
303
309
|
return this._screenSpaceError;
|
|
304
310
|
}
|
|
305
311
|
|
|
312
|
+
/**
|
|
313
|
+
* Get bounding box in cartographic coordinates
|
|
314
|
+
* @returns [min, max] each in [longitude, latitude, altitude]
|
|
315
|
+
*/
|
|
316
|
+
get boundingBox(): CartographicBounds {
|
|
317
|
+
if (!this._boundingBox) {
|
|
318
|
+
this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);
|
|
319
|
+
}
|
|
320
|
+
return this._boundingBox;
|
|
321
|
+
}
|
|
322
|
+
|
|
306
323
|
/** Get the tile's screen space error. */
|
|
307
324
|
getScreenSpaceError(frameState, useParentLodMetric) {
|
|
308
325
|
switch (this.tileset.type) {
|
|
@@ -366,7 +366,7 @@ export class Tileset3D {
|
|
|
366
366
|
|
|
367
367
|
get queryParams(): string {
|
|
368
368
|
if (!this._queryParamsString) {
|
|
369
|
-
this._queryParamsString =
|
|
369
|
+
this._queryParamsString = new URLSearchParams(this._queryParams).toString();
|
|
370
370
|
}
|
|
371
371
|
return this._queryParamsString;
|
|
372
372
|
}
|
|
@@ -389,7 +389,7 @@ export class Tileset3D {
|
|
|
389
389
|
if (isDataUrl) {
|
|
390
390
|
return tilePath;
|
|
391
391
|
}
|
|
392
|
-
return `${tilePath}${this.queryParams}`;
|
|
392
|
+
return `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
// TODO CESIUM specific
|
|
@@ -733,6 +733,14 @@ export class Tileset3D {
|
|
|
733
733
|
const children = tile.header.children || [];
|
|
734
734
|
for (const childHeader of children) {
|
|
735
735
|
const childTile = new Tile3D(this, childHeader, tile);
|
|
736
|
+
|
|
737
|
+
// Special handling for Google 3D tiles
|
|
738
|
+
// A session key must be used for all tile requests
|
|
739
|
+
if (childTile.contentUrl?.includes('?session=')) {
|
|
740
|
+
const url = new URL(childTile.contentUrl);
|
|
741
|
+
this._queryParams.session = url.searchParams.get('session');
|
|
742
|
+
}
|
|
743
|
+
|
|
736
744
|
tile.children.push(childTile);
|
|
737
745
|
childTile.depth = tile.depth + 1;
|
|
738
746
|
stack.push(childTile);
|
|
@@ -956,18 +964,3 @@ export class Tileset3D {
|
|
|
956
964
|
}
|
|
957
965
|
}
|
|
958
966
|
}
|
|
959
|
-
|
|
960
|
-
function getQueryParamString(queryParams): string {
|
|
961
|
-
const queryParamStrings: string[] = [];
|
|
962
|
-
for (const key of Object.keys(queryParams)) {
|
|
963
|
-
queryParamStrings.push(`${key}=${queryParams[key]}`);
|
|
964
|
-
}
|
|
965
|
-
switch (queryParamStrings.length) {
|
|
966
|
-
case 0:
|
|
967
|
-
return '';
|
|
968
|
-
case 1:
|
|
969
|
-
return `?${queryParamStrings[0]}`;
|
|
970
|
-
default:
|
|
971
|
-
return `?${queryParamStrings.join('&')}`;
|
|
972
|
-
}
|
|
973
|
-
}
|