@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
|
@@ -1,41 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// loaders.gl, MIT license
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Tileset3D = void 0;
|
|
5
|
+
// This file is derived from the Cesium code base under Apache 2 license
|
|
6
|
+
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
7
|
+
/*
|
|
8
|
+
|
|
9
|
+
The Tileset loading and rendering flow is as below,
|
|
10
|
+
A rendered (i.e. deck.gl `Tile3DLayer`) triggers `tileset.update()` after a `tileset` is loaded
|
|
11
|
+
`tileset` starts traversing the tile tree and update `requestTiles` (tiles of which content need
|
|
12
|
+
to be fetched) and `selectedTiles` (tiles ready for rendering under the current viewport).
|
|
13
|
+
`Tile3DLayer` will update rendering based on `selectedTiles`.
|
|
14
|
+
`Tile3DLayer` also listens to `onTileLoad` callback and trigger another round of `update and then traversal`
|
|
15
|
+
when new tiles are loaded.
|
|
16
|
+
|
|
17
|
+
As I3S tileset have stored `tileHeader` file (metadata) and tile content files (geometry, texture, ...) separately.
|
|
18
|
+
During each traversal, it issues `tilHeader` requests if that `tileHeader` is not yet fetched,
|
|
19
|
+
after the tile header is fulfilled, it will resume the traversal starting from the tile just fetched (not root).
|
|
20
|
+
|
|
21
|
+
Tile3DLayer
|
|
22
|
+
|
|
|
23
|
+
await load(tileset)
|
|
24
|
+
|
|
|
25
|
+
tileset.update()
|
|
26
|
+
| async load tileHeader
|
|
27
|
+
tileset.traverse() -------------------------- Queued
|
|
28
|
+
| resume traversal after fetched |
|
|
29
|
+
|----------------------------------------|
|
|
30
|
+
|
|
|
31
|
+
| async load tile content
|
|
32
|
+
tilset.requestedTiles ----------------------------- RequestScheduler
|
|
33
|
+
|
|
|
34
|
+
tilset.selectedTiles (ready for rendering) |
|
|
35
|
+
| Listen to |
|
|
36
|
+
Tile3DLayer ----------- onTileLoad ----------------------|
|
|
37
|
+
| | notify new tile is available
|
|
38
|
+
updateLayers |
|
|
39
|
+
tileset.update // trigger another round of update
|
|
40
|
+
*/
|
|
41
|
+
const core_1 = require("@math.gl/core");
|
|
42
|
+
const geospatial_1 = require("@math.gl/geospatial");
|
|
43
|
+
const stats_1 = require("@probe.gl/stats");
|
|
44
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
45
|
+
const tileset_cache_1 = require("./tileset-cache");
|
|
46
|
+
const transform_utils_1 = require("./helpers/transform-utils");
|
|
47
|
+
const frame_state_1 = require("./helpers/frame-state");
|
|
48
|
+
const zoom_1 = require("./helpers/zoom");
|
|
49
|
+
const tile_3d_1 = require("./tile-3d");
|
|
50
|
+
const constants_1 = require("../constants");
|
|
51
|
+
const tileset_traverser_1 = require("./tileset-traverser");
|
|
52
|
+
// TODO - these should be moved into their respective modules
|
|
53
|
+
const tileset_3d_traverser_1 = require("./format-3d-tiles/tileset-3d-traverser");
|
|
54
|
+
const i3s_tileset_traverser_1 = require("./format-i3s/i3s-tileset-traverser");
|
|
15
55
|
const DEFAULT_PROPS = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
56
|
+
description: '',
|
|
57
|
+
ellipsoid: geospatial_1.Ellipsoid.WGS84,
|
|
58
|
+
// A 4x4 transformation matrix this transforms the entire tileset.
|
|
59
|
+
modelMatrix: new core_1.Matrix4(),
|
|
60
|
+
// Set to false to disable network request throttling
|
|
61
|
+
throttleRequests: true,
|
|
62
|
+
// Number of simultaneous requsts, if throttleRequests is true
|
|
63
|
+
maxRequests: 64,
|
|
64
|
+
maximumMemoryUsage: 32,
|
|
65
|
+
/** Maximum number limit of tiles selected for show. 0 means no limit */
|
|
66
|
+
maximumTilesSelected: 0,
|
|
67
|
+
/** Delay time before the tileset traversal. It prevents traversal requests spam.*/
|
|
68
|
+
debounceTime: 0,
|
|
69
|
+
/**
|
|
70
|
+
* Callback. Indicates this a tile's content was loaded
|
|
71
|
+
* @param tile {TileHeader}
|
|
72
|
+
*/
|
|
73
|
+
onTileLoad: () => { },
|
|
74
|
+
/**
|
|
75
|
+
* Callback. Indicates this a tile's content was unloaded
|
|
76
|
+
* @param tile {TileHeader}
|
|
77
|
+
*/
|
|
78
|
+
onTileUnload: () => { },
|
|
79
|
+
onTileError: () => { },
|
|
80
|
+
/**
|
|
81
|
+
* Callback. Allows post-process selectedTiles right after traversal.
|
|
82
|
+
* @param selectedTiles {TileHeader[]}
|
|
83
|
+
* @returns TileHeader[] - output array of tiles to return to deck.gl
|
|
84
|
+
*/
|
|
85
|
+
onTraversalComplete: (selectedTiles) => selectedTiles,
|
|
86
|
+
// Optional async tile content loader
|
|
87
|
+
contentLoader: undefined,
|
|
88
|
+
// View distance scale modifier
|
|
89
|
+
viewDistanceScale: 1.0,
|
|
90
|
+
// The maximum screen space error used to drive level of detail refinement.
|
|
91
|
+
maximumScreenSpaceError: 8,
|
|
92
|
+
loadTiles: true,
|
|
93
|
+
updateTransforms: true,
|
|
94
|
+
viewportTraversersMap: null,
|
|
95
|
+
loadOptions: { fetch: {} },
|
|
96
|
+
attributions: [],
|
|
97
|
+
basePath: '',
|
|
98
|
+
i3s: {}
|
|
38
99
|
};
|
|
100
|
+
// Tracked Stats
|
|
39
101
|
const TILES_TOTAL = 'Tiles In Tileset(s)';
|
|
40
102
|
const TILES_IN_MEMORY = 'Tiles In Memory';
|
|
41
103
|
const TILES_IN_VIEW = 'Tiles In View';
|
|
@@ -44,631 +106,628 @@ const TILES_LOADED = 'Tiles Loaded';
|
|
|
44
106
|
const TILES_LOADING = 'Tiles Loading';
|
|
45
107
|
const TILES_UNLOADED = 'Tiles Unloaded';
|
|
46
108
|
const TILES_LOAD_FAILED = 'Failed Tile Loads';
|
|
47
|
-
const POINTS_COUNT = 'Points';
|
|
109
|
+
const POINTS_COUNT = 'Points/Vertices';
|
|
48
110
|
const TILES_GPU_MEMORY = 'Tile Memory Use';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (this.traverseCounter > 0) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
if (!viewports && this.lastUpdatedVieports) {
|
|
256
|
-
viewports = this.lastUpdatedVieports;
|
|
257
|
-
} else {
|
|
258
|
-
this.lastUpdatedVieports = viewports;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (!(viewports instanceof Array)) {
|
|
262
|
-
viewports = [viewports];
|
|
111
|
+
class Tileset3D {
|
|
112
|
+
/**
|
|
113
|
+
* Create a new Tileset3D
|
|
114
|
+
* @param json
|
|
115
|
+
* @param props
|
|
116
|
+
*/
|
|
117
|
+
// eslint-disable-next-line max-statements
|
|
118
|
+
constructor(json, options) {
|
|
119
|
+
/** flags that contain information about data types in nested tiles */
|
|
120
|
+
this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
|
|
121
|
+
this.updatePromise = null;
|
|
122
|
+
(0, loader_utils_1.assert)(json);
|
|
123
|
+
// PUBLIC MEMBERS
|
|
124
|
+
this.options = { ...DEFAULT_PROPS, ...options };
|
|
125
|
+
// raw data
|
|
126
|
+
this.tileset = json;
|
|
127
|
+
this.loader = json.loader;
|
|
128
|
+
// could be 3d tiles, i3s
|
|
129
|
+
this.type = json.type;
|
|
130
|
+
// The url to a tileset JSON file.
|
|
131
|
+
this.url = json.url;
|
|
132
|
+
this.basePath = json.basePath || loader_utils_1.path.dirname(this.url);
|
|
133
|
+
this.modelMatrix = this.options.modelMatrix;
|
|
134
|
+
this.ellipsoid = this.options.ellipsoid;
|
|
135
|
+
// Geometric error when the tree is not rendered at all
|
|
136
|
+
this.lodMetricType = json.lodMetricType;
|
|
137
|
+
this.lodMetricValue = json.lodMetricValue;
|
|
138
|
+
this.refine = json.root.refine;
|
|
139
|
+
this.loadOptions = this.options.loadOptions || {};
|
|
140
|
+
this.root = null;
|
|
141
|
+
this.roots = {};
|
|
142
|
+
// view props
|
|
143
|
+
this.cartographicCenter = null;
|
|
144
|
+
this.cartesianCenter = null;
|
|
145
|
+
this.zoom = 1;
|
|
146
|
+
this.boundingVolume = null;
|
|
147
|
+
// TRAVERSAL
|
|
148
|
+
this.traverseCounter = 0;
|
|
149
|
+
this.geometricError = 0;
|
|
150
|
+
this._traverser = this._initializeTraverser();
|
|
151
|
+
this._cache = new tileset_cache_1.TilesetCache();
|
|
152
|
+
this._requestScheduler = new loader_utils_1.RequestScheduler({
|
|
153
|
+
throttleRequests: this.options.throttleRequests,
|
|
154
|
+
maxRequests: this.options.maxRequests
|
|
155
|
+
});
|
|
156
|
+
// update tracker
|
|
157
|
+
// increase in each update cycle
|
|
158
|
+
this._frameNumber = 0;
|
|
159
|
+
// counter for tracking tiles requests
|
|
160
|
+
this._pendingCount = 0;
|
|
161
|
+
// HOLD TRAVERSAL RESULTS
|
|
162
|
+
this._tiles = {};
|
|
163
|
+
this.selectedTiles = [];
|
|
164
|
+
this._emptyTiles = [];
|
|
165
|
+
this._requestedTiles = [];
|
|
166
|
+
this.frameStateData = {};
|
|
167
|
+
this.lastUpdatedVieports = null;
|
|
168
|
+
this._queryParams = {};
|
|
169
|
+
this._queryParamsString = '';
|
|
170
|
+
// METRICS
|
|
171
|
+
// The maximum amount of GPU memory (in MB) that may be used to cache tiles.
|
|
172
|
+
// Tiles not in view are unloaded to enforce this.
|
|
173
|
+
this.maximumMemoryUsage = this.options.maximumMemoryUsage || 32;
|
|
174
|
+
// The total amount of GPU memory in bytes used by the tileset.
|
|
175
|
+
this.gpuMemoryUsageInBytes = 0;
|
|
176
|
+
this.stats = new stats_1.Stats({ id: this.url });
|
|
177
|
+
this._initializeStats();
|
|
178
|
+
// EXTRACTED FROM TILESET
|
|
179
|
+
this._extensionsUsed = undefined;
|
|
180
|
+
this.dynamicScreenSpaceErrorComputedDensity = 0.0; // Updated based on the camera position and direction
|
|
181
|
+
// Metadata for the entire tileset
|
|
182
|
+
this.extras = null;
|
|
183
|
+
this.asset = {};
|
|
184
|
+
this.credits = {};
|
|
185
|
+
this.description = this.options.description || '';
|
|
186
|
+
this.tilesetInitializationPromise = this._initializeTileSet(json);
|
|
187
|
+
}
|
|
188
|
+
/** Release resources */
|
|
189
|
+
destroy() {
|
|
190
|
+
this._destroy();
|
|
191
|
+
}
|
|
192
|
+
/** Is the tileset loaded (update needs to have been called at least once) */
|
|
193
|
+
isLoaded() {
|
|
194
|
+
// Check that `_frameNumber !== 0` which means that update was called at least once
|
|
195
|
+
return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;
|
|
196
|
+
}
|
|
197
|
+
get tiles() {
|
|
198
|
+
return Object.values(this._tiles);
|
|
199
|
+
}
|
|
200
|
+
get frameNumber() {
|
|
201
|
+
return this._frameNumber;
|
|
202
|
+
}
|
|
203
|
+
get queryParams() {
|
|
204
|
+
if (!this._queryParamsString) {
|
|
205
|
+
this._queryParamsString = getQueryParamString(this._queryParams);
|
|
206
|
+
}
|
|
207
|
+
return this._queryParamsString;
|
|
208
|
+
}
|
|
209
|
+
setProps(props) {
|
|
210
|
+
this.options = { ...this.options, ...props };
|
|
211
|
+
}
|
|
212
|
+
/** @deprecated */
|
|
213
|
+
setOptions(options) {
|
|
214
|
+
this.options = { ...this.options, ...options };
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Return a loadable tile url for a specific tile subpath
|
|
218
|
+
* @param tilePath a tile subpath
|
|
219
|
+
*/
|
|
220
|
+
getTileUrl(tilePath) {
|
|
221
|
+
const isDataUrl = tilePath.startsWith('data:');
|
|
222
|
+
if (isDataUrl) {
|
|
223
|
+
return tilePath;
|
|
224
|
+
}
|
|
225
|
+
return `${tilePath}${this.queryParams}`;
|
|
226
|
+
}
|
|
227
|
+
// TODO CESIUM specific
|
|
228
|
+
hasExtension(extensionName) {
|
|
229
|
+
return Boolean(this._extensionsUsed && this._extensionsUsed.indexOf(extensionName) > -1);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Update visible tiles relying on a list of viewports
|
|
233
|
+
* @param viewports - list of viewports
|
|
234
|
+
* @deprecated
|
|
235
|
+
*/
|
|
236
|
+
update(viewports = null) {
|
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
238
|
+
this.tilesetInitializationPromise.then(() => {
|
|
239
|
+
if (!viewports && this.lastUpdatedVieports) {
|
|
240
|
+
viewports = this.lastUpdatedVieports;
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
this.lastUpdatedVieports = viewports;
|
|
244
|
+
}
|
|
245
|
+
if (viewports) {
|
|
246
|
+
this.doUpdate(viewports);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Update visible tiles relying on a list of viewports.
|
|
252
|
+
* Do it with debounce delay to prevent update spam
|
|
253
|
+
* @param viewports viewports
|
|
254
|
+
* @returns Promise of new frameNumber
|
|
255
|
+
*/
|
|
256
|
+
async selectTiles(viewports = null) {
|
|
257
|
+
await this.tilesetInitializationPromise;
|
|
258
|
+
if (viewports) {
|
|
259
|
+
this.lastUpdatedVieports = viewports;
|
|
260
|
+
}
|
|
261
|
+
if (!this.updatePromise) {
|
|
262
|
+
this.updatePromise = new Promise((resolve) => {
|
|
263
|
+
setTimeout(() => {
|
|
264
|
+
if (this.lastUpdatedVieports) {
|
|
265
|
+
this.doUpdate(this.lastUpdatedVieports);
|
|
266
|
+
}
|
|
267
|
+
resolve(this._frameNumber);
|
|
268
|
+
this.updatePromise = null;
|
|
269
|
+
}, this.options.debounceTime);
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return this.updatePromise;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Update visible tiles relying on a list of viewports
|
|
276
|
+
* @param viewports viewports
|
|
277
|
+
*/
|
|
278
|
+
// eslint-disable-next-line max-statements, complexity
|
|
279
|
+
doUpdate(viewports) {
|
|
280
|
+
if ('loadTiles' in this.options && !this.options.loadTiles) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (this.traverseCounter > 0) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
const preparedViewports = viewports instanceof Array ? viewports : [viewports];
|
|
287
|
+
this._cache.reset();
|
|
288
|
+
this._frameNumber++;
|
|
289
|
+
this.traverseCounter = preparedViewports.length;
|
|
290
|
+
const viewportsToTraverse = [];
|
|
291
|
+
// First loop to decrement traverseCounter
|
|
292
|
+
for (const viewport of preparedViewports) {
|
|
293
|
+
const id = viewport.id;
|
|
294
|
+
if (this._needTraverse(id)) {
|
|
295
|
+
viewportsToTraverse.push(id);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
this.traverseCounter--;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
// Second loop to traverse
|
|
302
|
+
for (const viewport of preparedViewports) {
|
|
303
|
+
const id = viewport.id;
|
|
304
|
+
if (!this.roots[id]) {
|
|
305
|
+
this.roots[id] = this._initializeTileHeaders(this.tileset, null);
|
|
306
|
+
}
|
|
307
|
+
if (!viewportsToTraverse.includes(id)) {
|
|
308
|
+
continue; // eslint-disable-line no-continue
|
|
309
|
+
}
|
|
310
|
+
const frameState = (0, frame_state_1.getFrameState)(viewport, this._frameNumber);
|
|
311
|
+
this._traverser.traverse(this.roots[id], frameState, this.options);
|
|
312
|
+
}
|
|
263
313
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
314
|
+
/**
|
|
315
|
+
* Check if traversal is needed for particular viewport
|
|
316
|
+
* @param {string} viewportId - id of a viewport
|
|
317
|
+
* @return {boolean}
|
|
318
|
+
*/
|
|
319
|
+
_needTraverse(viewportId) {
|
|
320
|
+
let traverserId = viewportId;
|
|
321
|
+
if (this.options.viewportTraversersMap) {
|
|
322
|
+
traverserId = this.options.viewportTraversersMap[viewportId];
|
|
323
|
+
}
|
|
324
|
+
if (traverserId !== viewportId) {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* The callback to post-process tiles after traversal procedure
|
|
331
|
+
* @param frameState - frame state for tile culling
|
|
332
|
+
*/
|
|
333
|
+
_onTraversalEnd(frameState) {
|
|
334
|
+
const id = frameState.viewport.id;
|
|
335
|
+
if (!this.frameStateData[id]) {
|
|
336
|
+
this.frameStateData[id] = { selectedTiles: [], _requestedTiles: [], _emptyTiles: [] };
|
|
337
|
+
}
|
|
338
|
+
const currentFrameStateData = this.frameStateData[id];
|
|
339
|
+
const selectedTiles = Object.values(this._traverser.selectedTiles);
|
|
340
|
+
const [filteredSelectedTiles, unselectedTiles] = (0, frame_state_1.limitSelectedTiles)(selectedTiles, frameState, this.options.maximumTilesSelected);
|
|
341
|
+
currentFrameStateData.selectedTiles = filteredSelectedTiles;
|
|
342
|
+
for (const tile of unselectedTiles) {
|
|
343
|
+
tile.unselect();
|
|
344
|
+
}
|
|
345
|
+
currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
|
|
346
|
+
currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
|
|
277
347
|
this.traverseCounter--;
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
for (const viewport of viewports) {
|
|
282
|
-
const id = viewport.id;
|
|
283
|
-
|
|
284
|
-
if (!this.roots[id]) {
|
|
285
|
-
this.roots[id] = this._initializeTileHeaders(this.tileset, null);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (!viewportsToTraverse.includes(id)) {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const frameState = getFrameState(viewport, this._frameNumber);
|
|
293
|
-
|
|
294
|
-
this._traverser.traverse(this.roots[id], frameState, this.options);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
_needTraverse(viewportId) {
|
|
299
|
-
let traverserId = viewportId;
|
|
300
|
-
|
|
301
|
-
if (this.options.viewportTraversersMap) {
|
|
302
|
-
traverserId = this.options.viewportTraversersMap[viewportId];
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (traverserId !== viewportId) {
|
|
306
|
-
return false;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return true;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
_onTraversalEnd(frameState) {
|
|
313
|
-
const id = frameState.viewport.id;
|
|
314
|
-
|
|
315
|
-
if (!this.frameStateData[id]) {
|
|
316
|
-
this.frameStateData[id] = {
|
|
317
|
-
selectedTiles: [],
|
|
318
|
-
_requestedTiles: [],
|
|
319
|
-
_emptyTiles: []
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
const currentFrameStateData = this.frameStateData[id];
|
|
324
|
-
const selectedTiles = Object.values(this._traverser.selectedTiles);
|
|
325
|
-
currentFrameStateData.selectedTiles = selectedTiles;
|
|
326
|
-
currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);
|
|
327
|
-
currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);
|
|
328
|
-
this.traverseCounter--;
|
|
329
|
-
|
|
330
|
-
if (this.traverseCounter > 0) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
this._updateTiles();
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
_updateTiles() {
|
|
338
|
-
this.selectedTiles = [];
|
|
339
|
-
this._requestedTiles = [];
|
|
340
|
-
this._emptyTiles = [];
|
|
341
|
-
|
|
342
|
-
for (const frameStateKey in this.frameStateData) {
|
|
343
|
-
const frameStateDataValue = this.frameStateData[frameStateKey];
|
|
344
|
-
this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);
|
|
345
|
-
this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);
|
|
346
|
-
this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
|
|
350
|
-
|
|
351
|
-
for (const tile of this.selectedTiles) {
|
|
352
|
-
this._tiles[tile.id] = tile;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
this._loadTiles();
|
|
356
|
-
|
|
357
|
-
this._unloadTiles();
|
|
358
|
-
|
|
359
|
-
this._updateStats();
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
_tilesChanged(oldSelectedTiles, selectedTiles) {
|
|
363
|
-
if (oldSelectedTiles.length !== selectedTiles.length) {
|
|
364
|
-
return true;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
const set1 = new Set(oldSelectedTiles.map(t => t.id));
|
|
368
|
-
const set2 = new Set(selectedTiles.map(t => t.id));
|
|
369
|
-
let changed = oldSelectedTiles.filter(x => !set2.has(x.id)).length > 0;
|
|
370
|
-
changed = changed || selectedTiles.filter(x => !set1.has(x.id)).length > 0;
|
|
371
|
-
return changed;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
_loadTiles() {
|
|
375
|
-
for (const tile of this._requestedTiles) {
|
|
376
|
-
if (tile.contentUnloaded) {
|
|
377
|
-
this._loadTile(tile);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
_unloadTiles() {
|
|
383
|
-
this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
_updateStats() {
|
|
387
|
-
let tilesRenderable = 0;
|
|
388
|
-
let pointsRenderable = 0;
|
|
389
|
-
|
|
390
|
-
for (const tile of this.selectedTiles) {
|
|
391
|
-
if (tile.contentAvailable && tile.content) {
|
|
392
|
-
tilesRenderable++;
|
|
393
|
-
|
|
394
|
-
if (tile.content.pointCount) {
|
|
395
|
-
pointsRenderable += tile.content.pointCount;
|
|
348
|
+
if (this.traverseCounter > 0) {
|
|
349
|
+
return;
|
|
396
350
|
}
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
if (this.type === TILESET_TYPE.I3S) {
|
|
413
|
-
this._initializeI3STileset();
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
this._calculateViewProps();
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
_calculateViewProps() {
|
|
420
|
-
const root = this.root;
|
|
421
|
-
assert(root);
|
|
422
|
-
const {
|
|
423
|
-
center
|
|
424
|
-
} = root.boundingVolume;
|
|
425
|
-
|
|
426
|
-
if (!center) {
|
|
427
|
-
console.warn('center was not pre-calculated for the root tile');
|
|
428
|
-
this.cartographicCenter = new Vector3();
|
|
429
|
-
this.zoom = 1;
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
this.cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(center, new Vector3());
|
|
434
|
-
this.cartesianCenter = center;
|
|
435
|
-
this.zoom = getZoomFromBoundingVolume(root.boundingVolume);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
_initializeStats() {
|
|
439
|
-
this.stats.get(TILES_TOTAL);
|
|
440
|
-
this.stats.get(TILES_LOADING);
|
|
441
|
-
this.stats.get(TILES_IN_MEMORY);
|
|
442
|
-
this.stats.get(TILES_IN_VIEW);
|
|
443
|
-
this.stats.get(TILES_RENDERABLE);
|
|
444
|
-
this.stats.get(TILES_LOADED);
|
|
445
|
-
this.stats.get(TILES_UNLOADED);
|
|
446
|
-
this.stats.get(TILES_LOAD_FAILED);
|
|
447
|
-
this.stats.get(POINTS_COUNT, 'memory');
|
|
448
|
-
this.stats.get(TILES_GPU_MEMORY, 'memory');
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
_initializeTileHeaders(tilesetJson, parentTileHeader) {
|
|
452
|
-
const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader);
|
|
453
|
-
|
|
454
|
-
if (parentTileHeader) {
|
|
455
|
-
parentTileHeader.children.push(rootTile);
|
|
456
|
-
rootTile.depth = parentTileHeader.depth + 1;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
if (this.type === TILESET_TYPE.TILES3D) {
|
|
460
|
-
const stack = [];
|
|
461
|
-
stack.push(rootTile);
|
|
462
|
-
|
|
463
|
-
while (stack.length > 0) {
|
|
464
|
-
const tile = stack.pop();
|
|
465
|
-
this.stats.get(TILES_TOTAL).incrementCount();
|
|
466
|
-
const children = tile.header.children || [];
|
|
467
|
-
|
|
468
|
-
for (const childHeader of children) {
|
|
469
|
-
const childTile = new Tile3D(this, childHeader, tile);
|
|
470
|
-
tile.children.push(childTile);
|
|
471
|
-
childTile.depth = tile.depth + 1;
|
|
472
|
-
stack.push(childTile);
|
|
351
|
+
this._updateTiles();
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Update tiles relying on data from all traversers
|
|
355
|
+
*/
|
|
356
|
+
_updateTiles() {
|
|
357
|
+
this.selectedTiles = [];
|
|
358
|
+
this._requestedTiles = [];
|
|
359
|
+
this._emptyTiles = [];
|
|
360
|
+
for (const frameStateKey in this.frameStateData) {
|
|
361
|
+
const frameStateDataValue = this.frameStateData[frameStateKey];
|
|
362
|
+
this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);
|
|
363
|
+
this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);
|
|
364
|
+
this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);
|
|
473
365
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
let TraverserClass;
|
|
482
|
-
const type = this.type;
|
|
483
|
-
|
|
484
|
-
switch (type) {
|
|
485
|
-
case TILESET_TYPE.TILES3D:
|
|
486
|
-
TraverserClass = Tileset3DTraverser;
|
|
487
|
-
break;
|
|
488
|
-
|
|
489
|
-
case TILESET_TYPE.I3S:
|
|
490
|
-
TraverserClass = I3SetTraverser;
|
|
491
|
-
break;
|
|
492
|
-
|
|
493
|
-
default:
|
|
494
|
-
TraverserClass = TilesetTraverser;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
return new TraverserClass({
|
|
498
|
-
basePath: this.basePath,
|
|
499
|
-
onTraversalEnd: this._onTraversalEnd.bind(this)
|
|
500
|
-
});
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
_destroyTileHeaders(parentTile) {
|
|
504
|
-
this._destroySubtree(parentTile);
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
async _loadTile(tile) {
|
|
508
|
-
let loaded;
|
|
509
|
-
|
|
510
|
-
try {
|
|
511
|
-
this._onStartTileLoading();
|
|
512
|
-
|
|
513
|
-
loaded = await tile.loadContent();
|
|
514
|
-
} catch (error) {
|
|
515
|
-
this._onTileLoadError(tile, error);
|
|
516
|
-
} finally {
|
|
517
|
-
this._onEndTileLoading();
|
|
518
|
-
|
|
519
|
-
this._onTileLoad(tile, loaded);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
_onTileLoadError(tile, error) {
|
|
524
|
-
this.stats.get(TILES_LOAD_FAILED).incrementCount();
|
|
525
|
-
const message = error.message || error.toString();
|
|
526
|
-
const url = tile.url;
|
|
527
|
-
console.error("A 3D tile failed to load: ".concat(tile.url, " ").concat(message));
|
|
528
|
-
this.options.onTileError(tile, message, url);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
_onTileLoad(tile, loaded) {
|
|
532
|
-
if (!loaded) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
if (tile && tile.content) {
|
|
537
|
-
calculateTransformProps(tile, tile.content);
|
|
366
|
+
this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);
|
|
367
|
+
for (const tile of this.selectedTiles) {
|
|
368
|
+
this._tiles[tile.id] = tile;
|
|
369
|
+
}
|
|
370
|
+
this._loadTiles();
|
|
371
|
+
this._unloadTiles();
|
|
372
|
+
this._updateStats();
|
|
538
373
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
_updateCacheStats(tile) {
|
|
560
|
-
this.stats.get(TILES_LOADED).incrementCount();
|
|
561
|
-
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
562
|
-
this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
|
|
563
|
-
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
_unloadTile(tile) {
|
|
567
|
-
this.gpuMemoryUsageInBytes -= tile.content && tile.content.byteLength || 0;
|
|
568
|
-
this.stats.get(TILES_IN_MEMORY).decrementCount();
|
|
569
|
-
this.stats.get(TILES_UNLOADED).incrementCount();
|
|
570
|
-
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
571
|
-
this.options.onTileUnload(tile);
|
|
572
|
-
tile.unloadContent();
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
_destroy() {
|
|
576
|
-
const stack = [];
|
|
577
|
-
|
|
578
|
-
if (this.root) {
|
|
579
|
-
stack.push(this.root);
|
|
374
|
+
_tilesChanged(oldSelectedTiles, selectedTiles) {
|
|
375
|
+
if (oldSelectedTiles.length !== selectedTiles.length) {
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
const set1 = new Set(oldSelectedTiles.map((t) => t.id));
|
|
379
|
+
const set2 = new Set(selectedTiles.map((t) => t.id));
|
|
380
|
+
let changed = oldSelectedTiles.filter((x) => !set2.has(x.id)).length > 0;
|
|
381
|
+
changed = changed || selectedTiles.filter((x) => !set1.has(x.id)).length > 0;
|
|
382
|
+
return changed;
|
|
383
|
+
}
|
|
384
|
+
_loadTiles() {
|
|
385
|
+
// Sort requests by priority before making any requests.
|
|
386
|
+
// This makes it less likely this requests will be cancelled after being issued.
|
|
387
|
+
// requestedTiles.sort((a, b) => a._priority - b._priority);
|
|
388
|
+
for (const tile of this._requestedTiles) {
|
|
389
|
+
if (tile.contentUnloaded) {
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
391
|
+
this._loadTile(tile);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
580
394
|
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
395
|
+
_unloadTiles() {
|
|
396
|
+
// unload tiles from cache when hit maximumMemoryUsage
|
|
397
|
+
this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));
|
|
398
|
+
}
|
|
399
|
+
_updateStats() {
|
|
400
|
+
let tilesRenderable = 0;
|
|
401
|
+
let pointsRenderable = 0;
|
|
402
|
+
for (const tile of this.selectedTiles) {
|
|
403
|
+
if (tile.contentAvailable && tile.content) {
|
|
404
|
+
tilesRenderable++;
|
|
405
|
+
if (tile.content.pointCount) {
|
|
406
|
+
pointsRenderable += tile.content.pointCount;
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
// Calculate vertices for non point cloud tiles.
|
|
410
|
+
pointsRenderable += tile.content.vertexCount;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;
|
|
415
|
+
this.stats.get(TILES_RENDERABLE).count = tilesRenderable;
|
|
416
|
+
this.stats.get(POINTS_COUNT).count = pointsRenderable;
|
|
417
|
+
}
|
|
418
|
+
async _initializeTileSet(tilesetJson) {
|
|
419
|
+
if (this.type === constants_1.TILESET_TYPE.I3S) {
|
|
420
|
+
this.calculateViewPropsI3S();
|
|
421
|
+
tilesetJson.root = await tilesetJson.root;
|
|
422
|
+
}
|
|
423
|
+
this.root = this._initializeTileHeaders(tilesetJson, null);
|
|
424
|
+
if (this.type === constants_1.TILESET_TYPE.TILES3D) {
|
|
425
|
+
this._initializeTiles3DTileset(tilesetJson);
|
|
426
|
+
this.calculateViewPropsTiles3D();
|
|
427
|
+
}
|
|
428
|
+
if (this.type === constants_1.TILESET_TYPE.I3S) {
|
|
429
|
+
this._initializeI3STileset();
|
|
430
|
+
}
|
|
590
431
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
this.
|
|
609
|
-
|
|
432
|
+
/**
|
|
433
|
+
* Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
|
|
434
|
+
* These metrics help apps center view on tileset
|
|
435
|
+
* For I3S there is extent (<1.8 version) or fullExtent (>=1.8 version) to calculate view props
|
|
436
|
+
* @returns
|
|
437
|
+
*/
|
|
438
|
+
calculateViewPropsI3S() {
|
|
439
|
+
// for I3S 1.8 try to calculate with fullExtent
|
|
440
|
+
const fullExtent = this.tileset.fullExtent;
|
|
441
|
+
if (fullExtent) {
|
|
442
|
+
const { xmin, xmax, ymin, ymax, zmin, zmax } = fullExtent;
|
|
443
|
+
this.cartographicCenter = new core_1.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);
|
|
444
|
+
this.cartesianCenter = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new core_1.Vector3());
|
|
445
|
+
this.zoom = (0, zoom_1.getZoomFromFullExtent)(fullExtent, this.cartographicCenter, this.cartesianCenter);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
// for I3S 1.6-1.7 try to calculate with extent
|
|
449
|
+
const extent = this.tileset.store?.extent;
|
|
450
|
+
if (extent) {
|
|
451
|
+
const [xmin, ymin, xmax, ymax] = extent;
|
|
452
|
+
this.cartographicCenter = new core_1.Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);
|
|
453
|
+
this.cartesianCenter = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, new core_1.Vector3());
|
|
454
|
+
this.zoom = (0, zoom_1.getZoomFromExtent)(extent, this.cartographicCenter, this.cartesianCenter);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
// eslint-disable-next-line no-console
|
|
458
|
+
console.warn('Extent is not defined in the tileset header');
|
|
459
|
+
this.cartographicCenter = new core_1.Vector3();
|
|
460
|
+
this.zoom = 1;
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
|
|
465
|
+
* These metrics help apps center view on tileset.
|
|
466
|
+
* For 3DTiles the root tile data is used to calculate view props.
|
|
467
|
+
* @returns
|
|
468
|
+
*/
|
|
469
|
+
calculateViewPropsTiles3D() {
|
|
470
|
+
const root = this.root;
|
|
471
|
+
(0, loader_utils_1.assert)(root);
|
|
472
|
+
const { center } = root.boundingVolume;
|
|
473
|
+
// TODO - handle all cases
|
|
474
|
+
if (!center) {
|
|
475
|
+
// eslint-disable-next-line no-console
|
|
476
|
+
console.warn('center was not pre-calculated for the root tile');
|
|
477
|
+
this.cartographicCenter = new core_1.Vector3();
|
|
478
|
+
this.zoom = 1;
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
// cartographic coordinates are undefined at the center of the ellipsoid
|
|
482
|
+
if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) {
|
|
483
|
+
this.cartographicCenter = geospatial_1.Ellipsoid.WGS84.cartesianToCartographic(center, new core_1.Vector3());
|
|
484
|
+
}
|
|
485
|
+
else {
|
|
486
|
+
this.cartographicCenter = new core_1.Vector3(0, 0, -geospatial_1.Ellipsoid.WGS84.radii[0]);
|
|
487
|
+
}
|
|
488
|
+
this.cartesianCenter = center;
|
|
489
|
+
this.zoom = (0, zoom_1.getZoomFromBoundingVolume)(root.boundingVolume, this.cartographicCenter);
|
|
490
|
+
}
|
|
491
|
+
_initializeStats() {
|
|
492
|
+
this.stats.get(TILES_TOTAL);
|
|
493
|
+
this.stats.get(TILES_LOADING);
|
|
494
|
+
this.stats.get(TILES_IN_MEMORY);
|
|
495
|
+
this.stats.get(TILES_IN_VIEW);
|
|
496
|
+
this.stats.get(TILES_RENDERABLE);
|
|
497
|
+
this.stats.get(TILES_LOADED);
|
|
498
|
+
this.stats.get(TILES_UNLOADED);
|
|
499
|
+
this.stats.get(TILES_LOAD_FAILED);
|
|
500
|
+
this.stats.get(POINTS_COUNT);
|
|
501
|
+
this.stats.get(TILES_GPU_MEMORY, 'memory');
|
|
502
|
+
}
|
|
503
|
+
// Installs the main tileset JSON file or a tileset JSON file referenced from a tile.
|
|
504
|
+
// eslint-disable-next-line max-statements
|
|
505
|
+
_initializeTileHeaders(tilesetJson, parentTileHeader) {
|
|
506
|
+
// A tileset JSON file referenced from a tile may exist in a different directory than the root tileset.
|
|
507
|
+
// Get the basePath relative to the external tileset.
|
|
508
|
+
const rootTile = new tile_3d_1.Tile3D(this, tilesetJson.root, parentTileHeader); // resource
|
|
509
|
+
// If there is a parentTileHeader, add the root of the currently loading tileset
|
|
510
|
+
// to parentTileHeader's children, and update its depth.
|
|
511
|
+
if (parentTileHeader) {
|
|
512
|
+
parentTileHeader.children.push(rootTile);
|
|
513
|
+
rootTile.depth = parentTileHeader.depth + 1;
|
|
514
|
+
}
|
|
515
|
+
// 3DTiles knows the hierarchy beforehand
|
|
516
|
+
if (this.type === constants_1.TILESET_TYPE.TILES3D) {
|
|
517
|
+
const stack = [];
|
|
518
|
+
stack.push(rootTile);
|
|
519
|
+
while (stack.length > 0) {
|
|
520
|
+
const tile = stack.pop();
|
|
521
|
+
this.stats.get(TILES_TOTAL).incrementCount();
|
|
522
|
+
const children = tile.header.children || [];
|
|
523
|
+
for (const childHeader of children) {
|
|
524
|
+
const childTile = new tile_3d_1.Tile3D(this, childHeader, tile);
|
|
525
|
+
tile.children.push(childTile);
|
|
526
|
+
childTile.depth = tile.depth + 1;
|
|
527
|
+
stack.push(childTile);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return rootTile;
|
|
532
|
+
}
|
|
533
|
+
_initializeTraverser() {
|
|
534
|
+
let TraverserClass;
|
|
535
|
+
const type = this.type;
|
|
536
|
+
switch (type) {
|
|
537
|
+
case constants_1.TILESET_TYPE.TILES3D:
|
|
538
|
+
TraverserClass = tileset_3d_traverser_1.Tileset3DTraverser;
|
|
539
|
+
break;
|
|
540
|
+
case constants_1.TILESET_TYPE.I3S:
|
|
541
|
+
TraverserClass = i3s_tileset_traverser_1.I3STilesetTraverser;
|
|
542
|
+
break;
|
|
543
|
+
default:
|
|
544
|
+
TraverserClass = tileset_traverser_1.TilesetTraverser;
|
|
545
|
+
}
|
|
546
|
+
return new TraverserClass({
|
|
547
|
+
basePath: this.basePath,
|
|
548
|
+
onTraversalEnd: this._onTraversalEnd.bind(this)
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
_destroyTileHeaders(parentTile) {
|
|
552
|
+
this._destroySubtree(parentTile);
|
|
553
|
+
}
|
|
554
|
+
async _loadTile(tile) {
|
|
555
|
+
let loaded;
|
|
556
|
+
try {
|
|
557
|
+
this._onStartTileLoading();
|
|
558
|
+
loaded = await tile.loadContent();
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
this._onTileLoadError(tile, error);
|
|
562
|
+
}
|
|
563
|
+
finally {
|
|
564
|
+
this._onEndTileLoading();
|
|
565
|
+
this._onTileLoad(tile, loaded);
|
|
566
|
+
}
|
|
610
567
|
}
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
568
|
+
_onTileLoadError(tile, error) {
|
|
569
|
+
this.stats.get(TILES_LOAD_FAILED).incrementCount();
|
|
570
|
+
const message = error.message || error.toString();
|
|
571
|
+
const url = tile.url;
|
|
572
|
+
// TODO - Allow for probe log to be injected instead of console?
|
|
573
|
+
console.error(`A 3D tile failed to load: ${tile.url} ${message}`); // eslint-disable-line
|
|
574
|
+
this.options.onTileError(tile, message, url);
|
|
575
|
+
}
|
|
576
|
+
_onTileLoad(tile, loaded) {
|
|
577
|
+
if (!loaded) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
if (this.type === constants_1.TILESET_TYPE.I3S) {
|
|
581
|
+
// We can't calculate tiles total in I3S in advance so we calculate it dynamically.
|
|
582
|
+
const nodesInNodePages = this.tileset?.nodePagesTile?.nodesInNodePages || 0;
|
|
583
|
+
this.stats.get(TILES_TOTAL).reset();
|
|
584
|
+
this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);
|
|
585
|
+
}
|
|
586
|
+
// add coordinateOrigin and modelMatrix to tile
|
|
587
|
+
if (tile && tile.content) {
|
|
588
|
+
(0, transform_utils_1.calculateTransformProps)(tile, tile.content);
|
|
589
|
+
}
|
|
590
|
+
this.updateContentTypes(tile);
|
|
591
|
+
this._addTileToCache(tile);
|
|
592
|
+
this.options.onTileLoad(tile);
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Update information about data types in nested tiles
|
|
596
|
+
* @param tile instance of a nested Tile3D
|
|
597
|
+
*/
|
|
598
|
+
updateContentTypes(tile) {
|
|
599
|
+
if (this.type === constants_1.TILESET_TYPE.I3S) {
|
|
600
|
+
if (tile.header.isDracoGeometry) {
|
|
601
|
+
this.contentFormats.draco = true;
|
|
602
|
+
}
|
|
603
|
+
switch (tile.header.textureFormat) {
|
|
604
|
+
case 'dds':
|
|
605
|
+
this.contentFormats.dds = true;
|
|
606
|
+
break;
|
|
607
|
+
case 'ktx2':
|
|
608
|
+
this.contentFormats.ktx2 = true;
|
|
609
|
+
break;
|
|
610
|
+
default:
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
else if (this.type === constants_1.TILESET_TYPE.TILES3D) {
|
|
614
|
+
const { extensionsRemoved = [] } = tile.content?.gltf || {};
|
|
615
|
+
if (extensionsRemoved.includes('KHR_draco_mesh_compression')) {
|
|
616
|
+
this.contentFormats.draco = true;
|
|
617
|
+
}
|
|
618
|
+
if (extensionsRemoved.includes('EXT_meshopt_compression')) {
|
|
619
|
+
this.contentFormats.meshopt = true;
|
|
620
|
+
}
|
|
621
|
+
if (extensionsRemoved.includes('KHR_texture_basisu')) {
|
|
622
|
+
this.contentFormats.ktx2 = true;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
628
625
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
626
|
+
_onStartTileLoading() {
|
|
627
|
+
this._pendingCount++;
|
|
628
|
+
this.stats.get(TILES_LOADING).incrementCount();
|
|
629
|
+
}
|
|
630
|
+
_onEndTileLoading() {
|
|
631
|
+
this._pendingCount--;
|
|
632
|
+
this.stats.get(TILES_LOADING).decrementCount();
|
|
633
|
+
}
|
|
634
|
+
_addTileToCache(tile) {
|
|
635
|
+
this._cache.add(this, tile, (tileset) => tileset._updateCacheStats(tile));
|
|
636
|
+
}
|
|
637
|
+
_updateCacheStats(tile) {
|
|
638
|
+
this.stats.get(TILES_LOADED).incrementCount();
|
|
639
|
+
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
640
|
+
// Good enough? Just use the raw binary ArrayBuffer's byte length.
|
|
641
|
+
this.gpuMemoryUsageInBytes += tile.content.byteLength || 0;
|
|
642
|
+
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
643
|
+
}
|
|
644
|
+
_unloadTile(tile) {
|
|
645
|
+
this.gpuMemoryUsageInBytes -= (tile.content && tile.content.byteLength) || 0;
|
|
646
|
+
this.stats.get(TILES_IN_MEMORY).decrementCount();
|
|
647
|
+
this.stats.get(TILES_UNLOADED).incrementCount();
|
|
648
|
+
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
649
|
+
this.options.onTileUnload(tile);
|
|
650
|
+
tile.unloadContent();
|
|
651
|
+
}
|
|
652
|
+
// Traverse the tree and destroy all tiles
|
|
653
|
+
_destroy() {
|
|
654
|
+
const stack = [];
|
|
655
|
+
if (this.root) {
|
|
656
|
+
stack.push(this.root);
|
|
657
|
+
}
|
|
658
|
+
while (stack.length > 0) {
|
|
659
|
+
const tile = stack.pop();
|
|
660
|
+
for (const child of tile.children) {
|
|
661
|
+
stack.push(child);
|
|
662
|
+
}
|
|
663
|
+
this._destroyTile(tile);
|
|
664
|
+
}
|
|
665
|
+
this.root = null;
|
|
666
|
+
}
|
|
667
|
+
// Traverse the tree and destroy all sub tiles
|
|
668
|
+
_destroySubtree(tile) {
|
|
669
|
+
const root = tile;
|
|
670
|
+
const stack = [];
|
|
671
|
+
stack.push(root);
|
|
672
|
+
while (stack.length > 0) {
|
|
673
|
+
tile = stack.pop();
|
|
674
|
+
for (const child of tile.children) {
|
|
675
|
+
stack.push(child);
|
|
676
|
+
}
|
|
677
|
+
if (tile !== root) {
|
|
678
|
+
this._destroyTile(tile);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
root.children = [];
|
|
632
682
|
}
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
683
|
+
_destroyTile(tile) {
|
|
684
|
+
this._cache.unloadTile(this, tile);
|
|
685
|
+
this._unloadTile(tile);
|
|
686
|
+
tile.destroy();
|
|
636
687
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
688
|
+
_initializeTiles3DTileset(tilesetJson) {
|
|
689
|
+
this.asset = tilesetJson.asset;
|
|
690
|
+
if (!this.asset) {
|
|
691
|
+
throw new Error('Tileset must have an asset property.');
|
|
692
|
+
}
|
|
693
|
+
if (this.asset.version !== '0.0' && this.asset.version !== '1.0') {
|
|
694
|
+
throw new Error('The tileset must be 3D Tiles version 0.0 or 1.0.');
|
|
695
|
+
}
|
|
696
|
+
// Note: `asset.tilesetVersion` is version of the tileset itself (not the version of the 3D TILES standard)
|
|
697
|
+
// We add this version as a `v=1.0` query param to fetch the right version and not get an older cached version
|
|
698
|
+
if ('tilesetVersion' in this.asset) {
|
|
699
|
+
this._queryParams.v = this.asset.tilesetVersion;
|
|
700
|
+
}
|
|
701
|
+
// TODO - ion resources have a credits property we can use for additional attribution.
|
|
702
|
+
this.credits = {
|
|
703
|
+
attributions: this.options.attributions || []
|
|
704
|
+
};
|
|
705
|
+
this.description = this.options.description || '';
|
|
706
|
+
// Gets the tileset's properties dictionary object, which contains metadata about per-feature properties.
|
|
707
|
+
this.properties = tilesetJson.properties;
|
|
708
|
+
this.geometricError = tilesetJson.geometricError;
|
|
709
|
+
this._extensionsUsed = tilesetJson.extensionsUsed;
|
|
710
|
+
// Returns the extras property at the top of the tileset JSON (application specific metadata).
|
|
711
|
+
this.extras = tilesetJson.extras;
|
|
712
|
+
}
|
|
713
|
+
_initializeI3STileset() {
|
|
714
|
+
if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {
|
|
715
|
+
this._queryParams.token = this.loadOptions.i3s.token;
|
|
716
|
+
}
|
|
651
717
|
}
|
|
652
|
-
}
|
|
653
|
-
|
|
654
718
|
}
|
|
655
|
-
|
|
719
|
+
exports.Tileset3D = Tileset3D;
|
|
656
720
|
function getQueryParamString(queryParams) {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
default:
|
|
671
|
-
return "?".concat(queryParamStrings.join('&'));
|
|
672
|
-
}
|
|
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
|
+
}
|
|
673
733
|
}
|
|
674
|
-
//# sourceMappingURL=tileset-3d.js.map
|