@loaders.gl/tiles 4.0.0-alpha.4 → 4.0.0-alpha.6
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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2 -2
- package/dist/constants.d.ts +32 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +30 -26
- package/dist/dist.min.js +8921 -0
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/constants.js +44 -0
- package/dist/es5/constants.js.map +1 -0
- package/dist/es5/index.js +93 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js +70 -0
- package/dist/es5/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
- package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js +45 -0
- package/dist/es5/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
- package/dist/es5/tileset/format-i3s/i3s-tile-manager.js +84 -0
- package/dist/es5/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
- package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js +143 -0
- package/dist/es5/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
- package/dist/es5/tileset/helpers/3d-tiles-options.js +12 -0
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/es5/tileset/helpers/bounding-volume.js +176 -0
- package/dist/es5/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/es5/tileset/helpers/frame-state.js +129 -0
- package/dist/es5/tileset/helpers/frame-state.js.map +1 -0
- package/dist/es5/tileset/helpers/i3s-lod.js +60 -0
- package/dist/es5/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/es5/tileset/helpers/tiles-3d-lod.js +103 -0
- package/dist/es5/tileset/helpers/tiles-3d-lod.js.map +1 -0
- package/dist/es5/tileset/helpers/transform-utils.js +50 -0
- package/dist/es5/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/es5/tileset/helpers/zoom.js +63 -0
- package/dist/es5/tileset/helpers/zoom.js.map +1 -0
- package/dist/es5/tileset/tile-3d.js +565 -0
- package/dist/es5/tileset/tile-3d.js.map +1 -0
- package/dist/es5/tileset/tileset-3d.js +890 -0
- package/dist/es5/tileset/tileset-3d.js.map +1 -0
- package/dist/es5/tileset/tileset-cache.js +85 -0
- package/dist/es5/tileset/tileset-cache.js.map +1 -0
- package/dist/es5/tileset/tileset-traverser.js +328 -0
- package/dist/es5/tileset/tileset-traverser.js.map +1 -0
- package/dist/es5/types.js +2 -0
- package/dist/es5/types.js.map +1 -0
- package/dist/es5/utils/doubly-linked-list-node.js +21 -0
- package/dist/es5/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/es5/utils/doubly-linked-list.js +88 -0
- package/dist/es5/utils/doubly-linked-list.js.map +1 -0
- package/dist/es5/utils/managed-array.js +126 -0
- package/dist/es5/utils/managed-array.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/constants.js +32 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/{tileset/traversers → esm/tileset/format-3d-tiles}/tileset-3d-traverser.js +2 -13
- package/dist/esm/tileset/format-3d-tiles/tileset-3d-traverser.js.map +1 -0
- package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js +26 -0
- package/dist/esm/tileset/format-i3s/i3s-pending-tiles-register.js.map +1 -0
- package/dist/esm/tileset/format-i3s/i3s-tile-manager.js +79 -0
- package/dist/esm/tileset/format-i3s/i3s-tile-manager.js.map +1 -0
- package/dist/{tileset/traversers → esm/tileset/format-i3s}/i3s-tileset-traverser.js +16 -28
- package/dist/esm/tileset/format-i3s/i3s-tileset-traverser.js.map +1 -0
- package/dist/esm/tileset/helpers/3d-tiles-options.js +6 -0
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -0
- package/dist/esm/tileset/helpers/bounding-volume.js +155 -0
- package/dist/esm/tileset/helpers/bounding-volume.js.map +1 -0
- package/dist/esm/tileset/helpers/frame-state.js +109 -0
- package/dist/esm/tileset/helpers/frame-state.js.map +1 -0
- package/dist/esm/tileset/helpers/i3s-lod.js +53 -0
- package/dist/esm/tileset/helpers/i3s-lod.js.map +1 -0
- package/dist/esm/tileset/helpers/tiles-3d-lod.js +100 -0
- package/dist/{tileset → esm/tileset}/helpers/tiles-3d-lod.js.map +1 -1
- package/dist/esm/tileset/helpers/transform-utils.js +50 -0
- package/dist/esm/tileset/helpers/transform-utils.js.map +1 -0
- package/dist/esm/tileset/helpers/zoom.js +55 -0
- package/dist/esm/tileset/helpers/zoom.js.map +1 -0
- package/dist/esm/tileset/tile-3d.js +445 -0
- package/dist/esm/tileset/tile-3d.js.map +1 -0
- package/dist/esm/tileset/tileset-3d.js +637 -0
- package/dist/esm/tileset/tileset-3d.js.map +1 -0
- package/dist/esm/tileset/tileset-cache.js +60 -0
- package/dist/esm/tileset/tileset-cache.js.map +1 -0
- package/dist/{tileset/traversers → esm/tileset}/tileset-traverser.js +20 -72
- package/dist/esm/tileset/tileset-traverser.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/doubly-linked-list-node.js +12 -0
- package/dist/esm/utils/doubly-linked-list-node.js.map +1 -0
- package/dist/esm/utils/doubly-linked-list.js +65 -0
- package/dist/esm/utils/doubly-linked-list.js.map +1 -0
- package/dist/esm/utils/managed-array.js +87 -0
- package/dist/esm/utils/managed-array.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -9
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts +7 -0
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.d.ts.map +1 -0
- package/dist/tileset/format-3d-tiles/tileset-3d-traverser.js +54 -0
- package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts +27 -0
- package/dist/tileset/format-i3s/i3s-pending-tiles-register.d.ts.map +1 -0
- package/dist/tileset/format-i3s/i3s-pending-tiles-register.js +47 -0
- package/dist/tileset/format-i3s/i3s-tile-manager.d.ts +34 -0
- package/dist/tileset/format-i3s/i3s-tile-manager.d.ts.map +1 -0
- package/dist/tileset/format-i3s/i3s-tile-manager.js +80 -0
- package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts +25 -0
- package/dist/tileset/format-i3s/i3s-tileset-traverser.d.ts.map +1 -0
- package/dist/tileset/format-i3s/i3s-tileset-traverser.js +92 -0
- package/dist/tileset/helpers/3d-tiles-options.d.ts +4 -0
- package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -0
- package/dist/tileset/helpers/3d-tiles-options.js +8 -5
- package/dist/tileset/helpers/bounding-volume.d.ts +19 -0
- package/dist/tileset/helpers/bounding-volume.d.ts.map +1 -0
- package/dist/tileset/helpers/bounding-volume.js +274 -69
- package/dist/tileset/helpers/frame-state.d.ts +28 -0
- package/dist/tileset/helpers/frame-state.d.ts.map +1 -0
- package/dist/tileset/helpers/frame-state.js +131 -49
- package/dist/tileset/helpers/i3s-lod.d.ts +20 -0
- package/dist/tileset/helpers/i3s-lod.d.ts.map +1 -0
- package/dist/tileset/helpers/i3s-lod.js +82 -105
- package/dist/tileset/helpers/tiles-3d-lod.d.ts +8 -0
- package/dist/tileset/helpers/tiles-3d-lod.d.ts.map +1 -0
- package/dist/tileset/helpers/tiles-3d-lod.js +112 -100
- package/dist/tileset/helpers/transform-utils.d.ts +2 -0
- package/dist/tileset/helpers/transform-utils.d.ts.map +1 -0
- package/dist/tileset/helpers/transform-utils.js +51 -56
- package/dist/tileset/helpers/zoom.d.ts +46 -0
- package/dist/tileset/helpers/zoom.d.ts.map +1 -0
- package/dist/tileset/helpers/zoom.js +83 -30
- package/dist/tileset/tile-3d.d.ts +206 -0
- package/dist/tileset/tile-3d.d.ts.map +1 -0
- package/dist/tileset/tile-3d.js +593 -531
- package/dist/tileset/tileset-3d.d.ts +217 -0
- package/dist/tileset/tileset-3d.d.ts.map +1 -0
- package/dist/tileset/tileset-3d.js +707 -648
- package/dist/tileset/tileset-cache.d.ts +18 -0
- package/dist/tileset/tileset-cache.d.ts.map +1 -0
- package/dist/tileset/tileset-cache.js +70 -71
- package/dist/tileset/tileset-traverser.d.ts +46 -0
- package/dist/tileset/tileset-traverser.d.ts.map +1 -0
- package/dist/tileset/tileset-traverser.js +309 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/utils/doubly-linked-list-node.d.ts +11 -0
- package/dist/utils/doubly-linked-list-node.d.ts.map +1 -0
- package/dist/utils/doubly-linked-list-node.js +17 -8
- package/dist/utils/doubly-linked-list.d.ts +30 -0
- package/dist/utils/doubly-linked-list.d.ts.map +1 -0
- package/dist/utils/doubly-linked-list.js +91 -72
- package/dist/utils/managed-array.d.ts +85 -0
- package/dist/utils/managed-array.d.ts.map +1 -0
- package/dist/utils/managed-array.js +144 -103
- package/package.json +10 -10
- package/src/constants.ts +2 -0
- package/src/index.ts +7 -4
- package/src/tileset/{traversers → format-3d-tiles}/tileset-3d-traverser.ts +4 -2
- package/src/tileset/format-i3s/i3s-pending-tiles-register.ts +44 -0
- package/src/tileset/format-i3s/i3s-tile-manager.ts +101 -0
- package/src/tileset/{traversers → format-i3s}/i3s-tileset-traverser.ts +27 -15
- package/src/tileset/helpers/bounding-volume.ts +136 -0
- package/src/tileset/helpers/frame-state.ts +102 -18
- package/src/tileset/helpers/i3s-lod.ts +75 -96
- package/src/tileset/helpers/tiles-3d-lod.ts +2 -0
- package/src/tileset/helpers/transform-utils.ts +2 -0
- package/src/tileset/helpers/zoom.ts +84 -9
- package/src/tileset/tile-3d.ts +77 -20
- package/src/tileset/tileset-3d.ts +205 -43
- package/src/tileset/tileset-cache.ts +6 -2
- package/src/tileset/{traversers/tileset-traverser.ts → tileset-traverser.ts} +29 -17
- package/src/types.ts +36 -0
- package/src/utils/{doubly-linked-list-node.js → doubly-linked-list-node.ts} +7 -2
- package/src/utils/{doubly-linked-list.js → doubly-linked-list.ts} +5 -8
- package/src/utils/{managed-array.js → managed-array.ts} +5 -2
- package/dist/bundle.js.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tileset/helpers/3d-tiles-options.js.map +0 -1
- package/dist/tileset/helpers/bounding-volume.js.map +0 -1
- package/dist/tileset/helpers/frame-state.js.map +0 -1
- package/dist/tileset/helpers/i3s-lod.js.map +0 -1
- package/dist/tileset/helpers/transform-utils.js.map +0 -1
- package/dist/tileset/helpers/zoom.js.map +0 -1
- package/dist/tileset/tile-3d.js.map +0 -1
- package/dist/tileset/tileset-3d.js.map +0 -1
- package/dist/tileset/tileset-cache.js.map +0 -1
- package/dist/tileset/traversers/i3s-tile-manager.js +0 -45
- package/dist/tileset/traversers/i3s-tile-manager.js.map +0 -1
- package/dist/tileset/traversers/i3s-tileset-traverser.js.map +0 -1
- package/dist/tileset/traversers/tileset-3d-traverser.js.map +0 -1
- package/dist/tileset/traversers/tileset-traverser.js.map +0 -1
- package/dist/utils/doubly-linked-list-node.js.map +0 -1
- package/dist/utils/doubly-linked-list.js.map +0 -1
- package/dist/utils/managed-array.js.map +0 -1
- package/src/tileset/traversers/i3s-tile-manager.ts +0 -39
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
|
|
2
|
+
/**
|
|
3
|
+
* Create a bounding volume from the tile's bounding volume header.
|
|
4
|
+
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
5
|
+
* @param {Matrix4} transform The transform to apply to the bounding volume.
|
|
6
|
+
* @param [result] The object onto which to store the result.
|
|
7
|
+
* @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createBoundingVolume(boundingVolumeHeader: any, transform: any, result: any): any;
|
|
10
|
+
/** [min, max] each in [longitude, latitude, altitude] */
|
|
11
|
+
export type CartographicBounds = [min: number[], max: number[]];
|
|
12
|
+
/**
|
|
13
|
+
* Calculate the cartographic bounding box the tile's bounding volume.
|
|
14
|
+
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
15
|
+
* @param {BoundingVolume} boundingVolume The bounding volume.
|
|
16
|
+
* @returns {CartographicBounds}
|
|
17
|
+
*/
|
|
18
|
+
export declare function getCartographicBounds(boundingVolumeHeader: any, boundingVolume: OrientedBoundingBox | BoundingSphere): CartographicBounds;
|
|
19
|
+
//# sourceMappingURL=bounding-volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounding-volume.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/bounding-volume.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAmBrE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,oBAAoB,KAAA,EAAE,SAAS,KAAA,EAAE,MAAM,KAAA,OAsC3E;AAED,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,oBAAoB,KAAA,EACpB,cAAc,EAAE,mBAAmB,GAAG,cAAc,GACnD,kBAAkB,CAuBpB"}
|
|
@@ -1,88 +1,293 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
|
+
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getCartographicBounds = exports.createBoundingVolume = void 0;
|
|
6
|
+
/* eslint-disable */
|
|
7
|
+
const core_1 = require("@math.gl/core");
|
|
8
|
+
const culling_1 = require("@math.gl/culling");
|
|
9
|
+
const geospatial_1 = require("@math.gl/geospatial");
|
|
10
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
11
|
+
// const scratchProjectedBoundingSphere = new BoundingSphere();
|
|
6
12
|
function defined(x) {
|
|
7
|
-
|
|
13
|
+
return x !== undefined && x !== null;
|
|
8
14
|
}
|
|
15
|
+
// const scratchMatrix = new Matrix3();
|
|
16
|
+
const scratchPoint = new core_1.Vector3();
|
|
17
|
+
const scratchScale = new core_1.Vector3();
|
|
18
|
+
const scratchNorthWest = new core_1.Vector3();
|
|
19
|
+
const scratchSouthEast = new core_1.Vector3();
|
|
20
|
+
// const scratchRectangle = new Rectangle();
|
|
21
|
+
// const scratchOrientedBoundingBox = new OrientedBoundingBox();
|
|
22
|
+
// const scratchTransform = new Matrix4();
|
|
23
|
+
/**
|
|
24
|
+
* Create a bounding volume from the tile's bounding volume header.
|
|
25
|
+
* @param {Object} boundingVolumeHeader The tile's bounding volume header.
|
|
26
|
+
* @param {Matrix4} transform The transform to apply to the bounding volume.
|
|
27
|
+
* @param [result] The object onto which to store the result.
|
|
28
|
+
* @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.
|
|
29
|
+
*/
|
|
30
|
+
function createBoundingVolume(boundingVolumeHeader, transform, result) {
|
|
31
|
+
(0, loader_utils_1.assert)(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');
|
|
32
|
+
// boundingVolume schema:
|
|
33
|
+
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json
|
|
34
|
+
if (boundingVolumeHeader.box) {
|
|
35
|
+
return createBox(boundingVolumeHeader.box, transform, result);
|
|
36
|
+
}
|
|
37
|
+
if (boundingVolumeHeader.region) {
|
|
38
|
+
// [west, south, east, north, minimum height, maximum height]
|
|
39
|
+
// Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.
|
|
40
|
+
// Heights are in meters above (or below) the WGS 84 ellipsoid.
|
|
41
|
+
const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;
|
|
42
|
+
const northWest = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian([(0, core_1.degrees)(west), (0, core_1.degrees)(north), minHeight], scratchNorthWest);
|
|
43
|
+
const southEast = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian([(0, core_1.degrees)(east), (0, core_1.degrees)(south), maxHeight], scratchSouthEast);
|
|
44
|
+
const centerInCartesian = new core_1.Vector3().addVectors(northWest, southEast).multiplyScalar(0.5);
|
|
45
|
+
const radius = new core_1.Vector3().subVectors(northWest, southEast).len() / 2.0;
|
|
46
|
+
// TODO improve region boundingVolume
|
|
47
|
+
// for now, create a sphere as the boundingVolume instead of box
|
|
48
|
+
return createSphere([centerInCartesian[0], centerInCartesian[1], centerInCartesian[2], radius], new core_1.Matrix4());
|
|
49
|
+
}
|
|
50
|
+
if (boundingVolumeHeader.sphere) {
|
|
51
|
+
return createSphere(boundingVolumeHeader.sphere, transform, result);
|
|
52
|
+
}
|
|
53
|
+
throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');
|
|
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;
|
|
84
|
+
function createBox(box, transform, result) {
|
|
85
|
+
// https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box
|
|
86
|
+
// 1. A half-axes based representation.
|
|
87
|
+
// box: An array of 12 numbers that define an oriented bounding box.
|
|
88
|
+
// The first three elements define the x, y, and z values for the center of the box.
|
|
89
|
+
// The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.
|
|
90
|
+
// The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.
|
|
91
|
+
// The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.
|
|
92
|
+
// 2. A half-size-quaternion based representation.
|
|
93
|
+
// box: An array of 10 numbers that define an oriented bounding box.
|
|
94
|
+
// The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.
|
|
95
|
+
// The next three elements (with indices 3, 4, and 5) define the halfSize.
|
|
96
|
+
// The last four elements (indices 6, 7, 8 and 10) define the quaternion.
|
|
97
|
+
const center = new core_1.Vector3(box[0], box[1], box[2]);
|
|
98
|
+
transform.transform(center, center);
|
|
99
|
+
let origin = [];
|
|
100
|
+
if (box.length === 10) {
|
|
101
|
+
const halfSize = box.slice(3, 6);
|
|
102
|
+
const quaternion = new core_1.Quaternion();
|
|
103
|
+
quaternion.fromArray(box, 6);
|
|
104
|
+
const x = new core_1.Vector3([1, 0, 0]);
|
|
105
|
+
const y = new core_1.Vector3([0, 1, 0]);
|
|
106
|
+
const z = new core_1.Vector3([0, 0, 1]);
|
|
107
|
+
x.transformByQuaternion(quaternion);
|
|
108
|
+
x.scale(halfSize[0]);
|
|
109
|
+
y.transformByQuaternion(quaternion);
|
|
110
|
+
y.scale(halfSize[1]);
|
|
111
|
+
z.transformByQuaternion(quaternion);
|
|
112
|
+
z.scale(halfSize[2]);
|
|
113
|
+
origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];
|
|
117
|
+
}
|
|
118
|
+
const xAxis = transform.transformAsVector(origin.slice(0, 3));
|
|
119
|
+
const yAxis = transform.transformAsVector(origin.slice(3, 6));
|
|
120
|
+
const zAxis = transform.transformAsVector(origin.slice(6, 9));
|
|
121
|
+
const halfAxes = new core_1.Matrix3([
|
|
122
|
+
xAxis[0],
|
|
123
|
+
xAxis[1],
|
|
124
|
+
xAxis[2],
|
|
125
|
+
yAxis[0],
|
|
126
|
+
yAxis[1],
|
|
127
|
+
yAxis[2],
|
|
128
|
+
zAxis[0],
|
|
129
|
+
zAxis[1],
|
|
130
|
+
zAxis[2]
|
|
131
|
+
]);
|
|
132
|
+
if (defined(result)) {
|
|
133
|
+
result.center = center;
|
|
134
|
+
result.halfAxes = halfAxes;
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
return new culling_1.OrientedBoundingBox(center, halfAxes);
|
|
138
|
+
}
|
|
139
|
+
/*
|
|
140
|
+
function createBoxFromTransformedRegion(region, transform, initialTransform, result) {
|
|
141
|
+
const rectangle = Rectangle.unpack(region, 0, scratchRectangle);
|
|
142
|
+
const minimumHeight = region[4];
|
|
143
|
+
const maximumHeight = region[5];
|
|
9
144
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
145
|
+
const orientedBoundingBox = OrientedBoundingBox.fromRectangle(
|
|
146
|
+
rectangle,
|
|
147
|
+
minimumHeight,
|
|
148
|
+
maximumHeight,
|
|
149
|
+
Ellipsoid.WGS84,
|
|
150
|
+
scratchOrientedBoundingBox
|
|
151
|
+
);
|
|
152
|
+
const center = orientedBoundingBox.center;
|
|
153
|
+
const halfAxes = orientedBoundingBox.halfAxes;
|
|
19
154
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
155
|
+
// A region bounding volume is not transformed by the transform in the tileset JSON,
|
|
156
|
+
// but may be transformed by additional transforms applied in Cesium.
|
|
157
|
+
// This is why the transform is calculated as the difference between the initial transform and the current transform.
|
|
158
|
+
transform = Matrix4.multiplyTransformation(
|
|
159
|
+
transform,
|
|
160
|
+
Matrix4.inverseTransformation(initialTransform, scratchTransform),
|
|
161
|
+
scratchTransform
|
|
162
|
+
);
|
|
163
|
+
center = Matrix4.multiplyByPoint(transform, center, center);
|
|
164
|
+
const rotationScale = Matrix4.getRotation(transform, scratchMatrix);
|
|
165
|
+
halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);
|
|
28
166
|
|
|
29
|
-
if (
|
|
30
|
-
|
|
167
|
+
if (defined(result) && result instanceof TileOrientedBoundingBox) {
|
|
168
|
+
result.update(center, halfAxes);
|
|
169
|
+
return result;
|
|
31
170
|
}
|
|
32
171
|
|
|
33
|
-
|
|
172
|
+
return new TileOrientedBoundingBox(center, halfAxes);
|
|
34
173
|
}
|
|
35
174
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
let origin = [];
|
|
40
|
-
|
|
41
|
-
if (box.length === 10) {
|
|
42
|
-
const halfSize = box.slice(3, 6);
|
|
43
|
-
const quaternion = new Quaternion();
|
|
44
|
-
quaternion.fromArray(box, 6);
|
|
45
|
-
const x = new Vector3([1, 0, 0]);
|
|
46
|
-
const y = new Vector3([0, 1, 0]);
|
|
47
|
-
const z = new Vector3([0, 0, 1]);
|
|
48
|
-
x.transformByQuaternion(quaternion);
|
|
49
|
-
x.scale(halfSize[0]);
|
|
50
|
-
y.transformByQuaternion(quaternion);
|
|
51
|
-
y.scale(halfSize[1]);
|
|
52
|
-
z.transformByQuaternion(quaternion);
|
|
53
|
-
z.scale(halfSize[2]);
|
|
54
|
-
origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];
|
|
55
|
-
} else {
|
|
56
|
-
origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];
|
|
175
|
+
function createRegion(region, transform, initialTransform, result) {
|
|
176
|
+
if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {
|
|
177
|
+
return createBoxFromTransformedRegion(region, transform, initialTransform, result);
|
|
57
178
|
}
|
|
58
179
|
|
|
59
|
-
const xAxis = transform.transformAsVector(origin.slice(0, 3));
|
|
60
|
-
const yAxis = transform.transformAsVector(origin.slice(3, 6));
|
|
61
|
-
const zAxis = transform.transformAsVector(origin.slice(6, 9));
|
|
62
|
-
const halfAxes = new Matrix3([xAxis[0], xAxis[1], xAxis[2], yAxis[0], yAxis[1], yAxis[2], zAxis[0], zAxis[1], zAxis[2]]);
|
|
63
|
-
|
|
64
180
|
if (defined(result)) {
|
|
65
|
-
result.center = center;
|
|
66
|
-
result.halfAxes = halfAxes;
|
|
67
181
|
return result;
|
|
68
182
|
}
|
|
69
183
|
|
|
70
|
-
|
|
71
|
-
}
|
|
184
|
+
const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);
|
|
72
185
|
|
|
186
|
+
return new TileBoundingRegion({
|
|
187
|
+
rectangle: rectangleRegion,
|
|
188
|
+
minimumHeight: region[4],
|
|
189
|
+
maximumHeight: region[5]
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
*/
|
|
73
193
|
function createSphere(sphere, transform, result) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
194
|
+
// Find the transformed center
|
|
195
|
+
const center = new core_1.Vector3(sphere[0], sphere[1], sphere[2]);
|
|
196
|
+
transform.transform(center, center);
|
|
197
|
+
const scale = transform.getScale(scratchScale);
|
|
198
|
+
const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);
|
|
199
|
+
const radius = sphere[3] * uniformScale;
|
|
200
|
+
if (defined(result)) {
|
|
201
|
+
result.center = center;
|
|
202
|
+
result.radius = radius;
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
return new culling_1.BoundingSphere(center, radius);
|
|
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
|
+
}
|
|
83
232
|
return result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return new BoundingSphere(center, radius);
|
|
87
233
|
}
|
|
88
|
-
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Tile3D } from '@loaders.gl/tiles';
|
|
2
|
+
import { CullingVolume } from '@math.gl/culling';
|
|
3
|
+
import { GeospatialViewport } from '../../types';
|
|
4
|
+
export type FrameState = {
|
|
5
|
+
camera: {
|
|
6
|
+
position: number[];
|
|
7
|
+
direction: number[];
|
|
8
|
+
up: number[];
|
|
9
|
+
};
|
|
10
|
+
viewport: GeospatialViewport;
|
|
11
|
+
topDownViewport: GeospatialViewport;
|
|
12
|
+
height: number;
|
|
13
|
+
cullingVolume: CullingVolume;
|
|
14
|
+
frameNumber: number;
|
|
15
|
+
sseDenominator: number;
|
|
16
|
+
};
|
|
17
|
+
export declare function getFrameState(viewport: GeospatialViewport, frameNumber: number): FrameState;
|
|
18
|
+
/**
|
|
19
|
+
* Limit `tiles` array length with `maximumTilesSelected` number.
|
|
20
|
+
* The criteria for this filtering is distance of a tile center
|
|
21
|
+
* to the `frameState.viewport`'s longitude and latitude
|
|
22
|
+
* @param tiles - tiles array to filter
|
|
23
|
+
* @param frameState - frameState to calculate distances
|
|
24
|
+
* @param maximumTilesSelected - maximal amount of tiles in the output array
|
|
25
|
+
* @returns new tiles array
|
|
26
|
+
*/
|
|
27
|
+
export declare function limitSelectedTiles(tiles: Tile3D[], frameState: FrameState, maximumTilesSelected: number): [Tile3D[], Tile3D[]];
|
|
28
|
+
//# sourceMappingURL=frame-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-state.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/frame-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAC,aAAa,EAAQ,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAC,kBAAkB,EAAW,MAAM,aAAa,CAAC;AAEzD,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE;QACN,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,EAAE,EAAE,MAAM,EAAE,CAAC;KACd,CAAC;IACF,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,eAAe,EAAE,kBAAkB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAeF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CAwD3F;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,UAAU,EAAE,UAAU,EACtB,oBAAoB,EAAE,MAAM,GAC3B,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAyBtB"}
|
|
@@ -1,51 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.limitSelectedTiles = exports.getFrameState = void 0;
|
|
4
|
+
const core_1 = require("@math.gl/core");
|
|
5
|
+
const culling_1 = require("@math.gl/culling");
|
|
6
|
+
const geospatial_1 = require("@math.gl/geospatial");
|
|
7
|
+
const scratchVector = new core_1.Vector3();
|
|
8
|
+
const scratchPosition = new core_1.Vector3();
|
|
9
|
+
const cullingVolume = new culling_1.CullingVolume([
|
|
10
|
+
new culling_1.Plane(),
|
|
11
|
+
new culling_1.Plane(),
|
|
12
|
+
new culling_1.Plane(),
|
|
13
|
+
new culling_1.Plane(),
|
|
14
|
+
new culling_1.Plane(),
|
|
15
|
+
new culling_1.Plane()
|
|
16
|
+
]);
|
|
17
|
+
// Extracts a frame state appropriate for tile culling from a deck.gl viewport
|
|
18
|
+
// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios
|
|
19
|
+
function getFrameState(viewport, frameNumber) {
|
|
20
|
+
// Traverse and and request. Update _selectedTiles so that we know what to render.
|
|
21
|
+
// Traverse and and request. Update _selectedTiles so that we know what to render.
|
|
22
|
+
const { cameraDirection, cameraUp, height } = viewport;
|
|
23
|
+
const { metersPerUnit } = viewport.distanceScales;
|
|
24
|
+
// TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.
|
|
25
|
+
// TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?
|
|
26
|
+
const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);
|
|
27
|
+
const enuToFixedTransform = geospatial_1.Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);
|
|
28
|
+
const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);
|
|
29
|
+
const cameraPositionCartesian = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new core_1.Vector3());
|
|
30
|
+
// These should still be normalized as the transform has scale 1 (goes from meters to meters)
|
|
31
|
+
const cameraDirectionCartesian = new core_1.Vector3(
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
enuToFixedTransform.transformAsVector(new core_1.Vector3(cameraDirection).scale(metersPerUnit))).normalize();
|
|
34
|
+
const cameraUpCartesian = new core_1.Vector3(
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
enuToFixedTransform.transformAsVector(new core_1.Vector3(cameraUp).scale(metersPerUnit))).normalize();
|
|
37
|
+
commonSpacePlanesToWGS84(viewport);
|
|
38
|
+
const ViewportClass = viewport.constructor;
|
|
39
|
+
const { longitude, latitude, width, bearing, zoom } = viewport;
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
const topDownViewport = new ViewportClass({
|
|
42
|
+
longitude,
|
|
43
|
+
latitude,
|
|
44
|
+
height,
|
|
45
|
+
width,
|
|
46
|
+
bearing,
|
|
47
|
+
zoom,
|
|
48
|
+
pitch: 0
|
|
49
|
+
});
|
|
50
|
+
// TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function
|
|
51
|
+
return {
|
|
52
|
+
camera: {
|
|
53
|
+
position: cameraPositionCartesian,
|
|
54
|
+
direction: cameraDirectionCartesian,
|
|
55
|
+
up: cameraUpCartesian
|
|
56
|
+
},
|
|
57
|
+
viewport,
|
|
58
|
+
topDownViewport,
|
|
59
|
+
height,
|
|
60
|
+
cullingVolume,
|
|
61
|
+
frameNumber,
|
|
62
|
+
sseDenominator: 1.15 // Assumes fovy = 60 degrees
|
|
63
|
+
};
|
|
36
64
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
exports.getFrameState = getFrameState;
|
|
66
|
+
/**
|
|
67
|
+
* Limit `tiles` array length with `maximumTilesSelected` number.
|
|
68
|
+
* The criteria for this filtering is distance of a tile center
|
|
69
|
+
* to the `frameState.viewport`'s longitude and latitude
|
|
70
|
+
* @param tiles - tiles array to filter
|
|
71
|
+
* @param frameState - frameState to calculate distances
|
|
72
|
+
* @param maximumTilesSelected - maximal amount of tiles in the output array
|
|
73
|
+
* @returns new tiles array
|
|
74
|
+
*/
|
|
75
|
+
function limitSelectedTiles(tiles, frameState, maximumTilesSelected) {
|
|
76
|
+
if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {
|
|
77
|
+
return [tiles, []];
|
|
78
|
+
}
|
|
79
|
+
// Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]
|
|
80
|
+
const tuples = [];
|
|
81
|
+
const { longitude: viewportLongitude, latitude: viewportLatitude } = frameState.viewport;
|
|
82
|
+
for (const [index, tile] of tiles.entries()) {
|
|
83
|
+
const [longitude, latitude] = tile.header.mbs;
|
|
84
|
+
const deltaLon = Math.abs(viewportLongitude - longitude);
|
|
85
|
+
const deltaLat = Math.abs(viewportLatitude - latitude);
|
|
86
|
+
const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);
|
|
87
|
+
tuples.push([index, distance]);
|
|
88
|
+
}
|
|
89
|
+
const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);
|
|
90
|
+
const selectedTiles = [];
|
|
91
|
+
for (let i = 0; i < maximumTilesSelected; i++) {
|
|
92
|
+
selectedTiles.push(tiles[tuplesSorted[i][0]]);
|
|
93
|
+
}
|
|
94
|
+
const unselectedTiles = [];
|
|
95
|
+
for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {
|
|
96
|
+
unselectedTiles.push(tiles[tuplesSorted[i][0]]);
|
|
97
|
+
}
|
|
98
|
+
return [selectedTiles, unselectedTiles];
|
|
99
|
+
}
|
|
100
|
+
exports.limitSelectedTiles = limitSelectedTiles;
|
|
101
|
+
function commonSpacePlanesToWGS84(viewport) {
|
|
102
|
+
// Extract frustum planes based on current view.
|
|
103
|
+
const frustumPlanes = viewport.getFrustumPlanes();
|
|
104
|
+
// Get the near/far plane centers
|
|
105
|
+
const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);
|
|
106
|
+
const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);
|
|
107
|
+
const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);
|
|
108
|
+
let i = 0;
|
|
109
|
+
cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian));
|
|
110
|
+
for (const dir in frustumPlanes) {
|
|
111
|
+
if (dir === 'near') {
|
|
112
|
+
continue; // eslint-disable-line no-continue
|
|
113
|
+
}
|
|
114
|
+
const plane = frustumPlanes[dir];
|
|
115
|
+
const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);
|
|
116
|
+
const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);
|
|
117
|
+
cullingVolume.planes[i++].fromPointNormal(cartesianPos,
|
|
118
|
+
// Want the normal to point into the frustum since that's what culling expects
|
|
119
|
+
scratchVector.copy(nearCenterCartesian).subtract(cartesianPos));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
function closestPointOnPlane(plane, refPoint, out = new core_1.Vector3()) {
|
|
123
|
+
const distanceToRef = plane.normal.dot(refPoint);
|
|
124
|
+
out
|
|
125
|
+
.copy(plane.normal)
|
|
126
|
+
.scale(plane.distance - distanceToRef)
|
|
127
|
+
.add(refPoint);
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
function worldToCartesian(viewport, point, out = new core_1.Vector3()) {
|
|
131
|
+
const cartographicPos = viewport.unprojectPosition(point);
|
|
132
|
+
return geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);
|
|
50
133
|
}
|
|
51
|
-
//# sourceMappingURL=frame-state.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tile3D } from '../tile-3d';
|
|
2
|
+
import { FrameState } from './frame-state';
|
|
3
|
+
/**
|
|
4
|
+
* For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children
|
|
5
|
+
as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.
|
|
6
|
+
In this sense a value of 0 means you should always load it's children,
|
|
7
|
+
or if it's a leaf node, you should always display it.
|
|
8
|
+
* @param tile
|
|
9
|
+
* @param frameState
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW';
|
|
13
|
+
/**
|
|
14
|
+
* Calculate size of MBS radius projected on the screen plane
|
|
15
|
+
* @param tile
|
|
16
|
+
* @param frameState
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function getProjectedRadius(tile: Tile3D, frameState: FrameState): number;
|
|
20
|
+
//# sourceMappingURL=i3s-lod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i3s-lod.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/i3s-lod.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAUzC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAczF;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,MAAM,CA6C/E"}
|