@loaders.gl/tiles 4.0.0-alpha.6 → 4.0.0-alpha.8
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/constants.d.ts +24 -18
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +22 -19
- package/dist/dist.min.js +448 -206
- package/dist/es5/constants.js +22 -18
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/es5/tileset/tile-3d.js +42 -71
- package/dist/es5/tileset/tile-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-3d.js +69 -104
- package/dist/es5/tileset/tileset-3d.js.map +1 -1
- package/dist/es5/tileset/tileset-cache.js +4 -7
- package/dist/es5/tileset/tileset-cache.js.map +1 -1
- package/dist/es5/tileset/tileset-traverser.js +12 -19
- package/dist/es5/tileset/tileset-traverser.js.map +1 -1
- package/dist/esm/constants.js +22 -18
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
- package/dist/esm/tileset/tile-3d.js +40 -71
- package/dist/esm/tileset/tile-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-3d.js +65 -96
- package/dist/esm/tileset/tileset-3d.js.map +1 -1
- package/dist/esm/tileset/tileset-cache.js +4 -7
- package/dist/esm/tileset/tileset-cache.js.map +1 -1
- package/dist/esm/tileset/tileset-traverser.js +9 -16
- package/dist/esm/tileset/tileset-traverser.js.map +1 -1
- package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
- package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
- package/dist/tileset/tile-3d.d.ts +37 -21
- package/dist/tileset/tile-3d.d.ts.map +1 -1
- package/dist/tileset/tile-3d.js +57 -43
- package/dist/tileset/tileset-3d.d.ts +90 -43
- package/dist/tileset/tileset-3d.d.ts.map +1 -1
- package/dist/tileset/tileset-3d.js +111 -129
- package/dist/tileset/tileset-cache.d.ts +5 -4
- package/dist/tileset/tileset-cache.d.ts.map +1 -1
- package/dist/tileset/tileset-cache.js +4 -10
- package/dist/tileset/tileset-traverser.d.ts +32 -21
- package/dist/tileset/tileset-traverser.d.ts.map +1 -1
- package/dist/tileset/tileset-traverser.js +23 -32
- package/package.json +8 -5
- package/src/constants.ts +36 -18
- package/src/tileset/helpers/3d-tiles-options.ts +3 -1
- package/src/tileset/tile-3d.ts +68 -109
- package/src/tileset/tileset-3d.ts +183 -218
- package/src/tileset/tileset-cache.ts +20 -15
- package/src/tileset/tileset-traverser.ts +52 -65
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Matrix4, Vector3 } from '@math.gl/core';
|
|
2
2
|
import { Stats } from '@probe.gl/stats';
|
|
3
3
|
import { RequestScheduler, LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
4
|
+
import { TilesetCache } from './tileset-cache';
|
|
4
5
|
import { FrameState } from './helpers/frame-state';
|
|
6
|
+
import type { Viewport } from '../types';
|
|
5
7
|
import { Tile3D } from './tile-3d';
|
|
6
|
-
import { Viewport } from '../types';
|
|
7
8
|
import { TilesetTraverser } from './tileset-traverser';
|
|
9
|
+
export type TilesetJSON = any;
|
|
8
10
|
export type Tileset3DProps = {
|
|
9
11
|
throttleRequests?: boolean;
|
|
10
12
|
maxRequests?: number;
|
|
@@ -31,38 +33,78 @@ export type Tileset3DProps = {
|
|
|
31
33
|
type Props = {
|
|
32
34
|
description: string;
|
|
33
35
|
ellipsoid: object;
|
|
36
|
+
/** A 4x4 transformation matrix this transforms the entire tileset. */
|
|
34
37
|
modelMatrix: Matrix4;
|
|
38
|
+
/** Set to false to disable network request throttling */
|
|
35
39
|
throttleRequests: boolean;
|
|
40
|
+
/** Number of simultaneous requsts, if throttleRequests is true */
|
|
41
|
+
maxRequests: number;
|
|
36
42
|
maximumMemoryUsage: number;
|
|
43
|
+
/** Maximum number limit of tiles selected for show. 0 means no limit */
|
|
37
44
|
maximumTilesSelected: number;
|
|
45
|
+
/** Delay time before the tileset traversal. It prevents traversal requests spam.*/
|
|
38
46
|
debounceTime: number;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
/** Callback. Indicates this a tile's content was loaded */
|
|
48
|
+
onTileLoad: (tile: Tile3D) => void;
|
|
49
|
+
/** Callback. Indicates this a tile's content was unloaded (cache full) */
|
|
50
|
+
onTileUnload: (tile: Tile3D) => void;
|
|
51
|
+
/** Callback. Indicates this a tile's content failed to load */
|
|
52
|
+
onTileError: (tile: Tile3D, message: string, url: string) => void;
|
|
53
|
+
/** Callback. Allows post-process selectedTiles right after traversal. */
|
|
42
54
|
onTraversalComplete: (selectedTiles: Tile3D[]) => Tile3D[];
|
|
55
|
+
/** The maximum screen space error used to drive level of detail refinement. */
|
|
43
56
|
maximumScreenSpaceError: number;
|
|
44
|
-
viewportTraversersMap: any;
|
|
57
|
+
viewportTraversersMap: Record<string, any> | null;
|
|
45
58
|
attributions: string[];
|
|
46
|
-
maxRequests: number;
|
|
47
59
|
loadTiles: boolean;
|
|
48
60
|
loadOptions: LoaderOptions;
|
|
49
61
|
updateTransforms: boolean;
|
|
62
|
+
/** View distance scale modifier */
|
|
50
63
|
viewDistanceScale: number;
|
|
51
64
|
basePath: string;
|
|
65
|
+
/** Optional async tile content loader */
|
|
52
66
|
contentLoader?: (tile: Tile3D) => Promise<void>;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
67
|
+
/** @todo I3S specific knowledge should be moved to I3S module */
|
|
68
|
+
i3s: Record<string, any>;
|
|
56
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* The Tileset loading and rendering flow is as below,
|
|
72
|
+
* A rendered (i.e. deck.gl `Tile3DLayer`) triggers `tileset.update()` after a `tileset` is loaded
|
|
73
|
+
* `tileset` starts traversing the tile tree and update `requestTiles` (tiles of which content need
|
|
74
|
+
* to be fetched) and `selectedTiles` (tiles ready for rendering under the current viewport).
|
|
75
|
+
* `Tile3DLayer` will update rendering based on `selectedTiles`.
|
|
76
|
+
* `Tile3DLayer` also listens to `onTileLoad` callback and trigger another round of `update and then traversal`
|
|
77
|
+
* when new tiles are loaded.
|
|
78
|
+
|
|
79
|
+
* As I3S tileset have stored `tileHeader` file (metadata) and tile content files (geometry, texture, ...) separately.
|
|
80
|
+
* During each traversal, it issues `tilHeader` requests if that `tileHeader` is not yet fetched,
|
|
81
|
+
* after the tile header is fulfilled, it will resume the traversal starting from the tile just fetched (not root).
|
|
82
|
+
|
|
83
|
+
* Tile3DLayer
|
|
84
|
+
* |
|
|
85
|
+
* await load(tileset)
|
|
86
|
+
* |
|
|
87
|
+
* tileset.update()
|
|
88
|
+
* | async load tileHeader
|
|
89
|
+
* tileset.traverse() -------------------------- Queued
|
|
90
|
+
* | resume traversal after fetched |
|
|
91
|
+
* |----------------------------------------|
|
|
92
|
+
* |
|
|
93
|
+
* | async load tile content
|
|
94
|
+
* tilset.requestedTiles ----------------------------- RequestScheduler
|
|
95
|
+
* |
|
|
96
|
+
* tilset.selectedTiles (ready for rendering) |
|
|
97
|
+
* | Listen to |
|
|
98
|
+
* Tile3DLayer ----------- onTileLoad ----------------------|
|
|
99
|
+
* | | notify new tile is available
|
|
100
|
+
* updateLayers |
|
|
101
|
+
* tileset.update // trigger another round of update
|
|
102
|
+
*/
|
|
57
103
|
export declare class Tileset3D {
|
|
58
104
|
options: Props;
|
|
59
|
-
loadOptions:
|
|
60
|
-
[key: string]: any;
|
|
61
|
-
};
|
|
105
|
+
loadOptions: LoaderOptions;
|
|
62
106
|
type: string;
|
|
63
|
-
tileset:
|
|
64
|
-
[key: string]: any;
|
|
65
|
-
};
|
|
107
|
+
tileset: TilesetJSON;
|
|
66
108
|
loader: LoaderWithParser;
|
|
67
109
|
url: string;
|
|
68
110
|
basePath: string;
|
|
@@ -72,12 +114,9 @@ export declare class Tileset3D {
|
|
|
72
114
|
lodMetricValue: number;
|
|
73
115
|
refine: string;
|
|
74
116
|
root: Tile3D | null;
|
|
75
|
-
roots:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
asset: {
|
|
79
|
-
[key: string]: any;
|
|
80
|
-
};
|
|
117
|
+
roots: Record<string, Tile3D>;
|
|
118
|
+
/** @todo any->unknown */
|
|
119
|
+
asset: Record<string, any>;
|
|
81
120
|
description: string;
|
|
82
121
|
properties: any;
|
|
83
122
|
extras: any;
|
|
@@ -91,37 +130,45 @@ export declare class Tileset3D {
|
|
|
91
130
|
dds: boolean;
|
|
92
131
|
ktx2: boolean;
|
|
93
132
|
};
|
|
94
|
-
traverseCounter: number;
|
|
95
|
-
geometricError: number;
|
|
96
|
-
selectedTiles: Tile3D[];
|
|
97
|
-
private updatePromise;
|
|
98
|
-
tilesetInitializationPromise: Promise<void>;
|
|
99
133
|
cartographicCenter: Vector3 | null;
|
|
100
134
|
cartesianCenter: Vector3 | null;
|
|
101
135
|
zoom: number;
|
|
102
136
|
boundingVolume: any;
|
|
103
|
-
|
|
104
|
-
dynamicScreenSpaceErrorComputedDensity:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
137
|
+
/** Updated based on the camera position and direction */
|
|
138
|
+
dynamicScreenSpaceErrorComputedDensity: number;
|
|
139
|
+
/**
|
|
140
|
+
* The maximum amount of GPU memory (in MB) that may be used to cache tiles
|
|
141
|
+
* Tiles not in view are unloaded to enforce private
|
|
142
|
+
*/
|
|
143
|
+
maximumMemoryUsage: number;
|
|
144
|
+
/** The total amount of GPU memory in bytes used by the tileset. */
|
|
145
|
+
gpuMemoryUsageInBytes: number;
|
|
146
|
+
/** Update tracker. increase in each update cycle. */
|
|
108
147
|
_frameNumber: number;
|
|
109
|
-
private _queryParamsString;
|
|
110
148
|
private _queryParams;
|
|
111
149
|
private _extensionsUsed;
|
|
112
150
|
private _tiles;
|
|
151
|
+
/** counter for tracking tiles requests */
|
|
113
152
|
private _pendingCount;
|
|
153
|
+
/** Hold traversal results */
|
|
154
|
+
selectedTiles: Tile3D[];
|
|
155
|
+
traverseCounter: number;
|
|
156
|
+
geometricError: number;
|
|
114
157
|
private lastUpdatedVieports;
|
|
115
158
|
private _requestedTiles;
|
|
116
159
|
private _emptyTiles;
|
|
117
160
|
private frameStateData;
|
|
118
|
-
|
|
161
|
+
_traverser: TilesetTraverser;
|
|
162
|
+
_cache: TilesetCache;
|
|
163
|
+
_requestScheduler: RequestScheduler;
|
|
164
|
+
private updatePromise;
|
|
165
|
+
tilesetInitializationPromise: Promise<void>;
|
|
119
166
|
/**
|
|
120
167
|
* Create a new Tileset3D
|
|
121
168
|
* @param json
|
|
122
169
|
* @param props
|
|
123
170
|
*/
|
|
124
|
-
constructor(
|
|
171
|
+
constructor(tileset: TilesetJSON, options?: Tileset3DProps);
|
|
125
172
|
/** Release resources */
|
|
126
173
|
destroy(): void;
|
|
127
174
|
/** Is the tileset loaded (update needs to have been called at least once) */
|
|
@@ -171,11 +218,11 @@ export declare class Tileset3D {
|
|
|
171
218
|
* Update tiles relying on data from all traversers
|
|
172
219
|
*/
|
|
173
220
|
_updateTiles(): void;
|
|
174
|
-
_tilesChanged(oldSelectedTiles:
|
|
221
|
+
_tilesChanged(oldSelectedTiles: Tile3D[], selectedTiles: Tile3D[]): boolean;
|
|
175
222
|
_loadTiles(): void;
|
|
176
223
|
_unloadTiles(): void;
|
|
177
224
|
_updateStats(): void;
|
|
178
|
-
_initializeTileSet(tilesetJson:
|
|
225
|
+
_initializeTileSet(tilesetJson: TilesetJSON): Promise<void>;
|
|
179
226
|
/**
|
|
180
227
|
* Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.
|
|
181
228
|
* These metrics help apps center view on tileset
|
|
@@ -191,12 +238,12 @@ export declare class Tileset3D {
|
|
|
191
238
|
*/
|
|
192
239
|
private calculateViewPropsTiles3D;
|
|
193
240
|
_initializeStats(): void;
|
|
194
|
-
_initializeTileHeaders(tilesetJson:
|
|
195
|
-
_initializeTraverser():
|
|
196
|
-
_destroyTileHeaders(parentTile:
|
|
197
|
-
_loadTile(tile:
|
|
198
|
-
_onTileLoadError(tile:
|
|
199
|
-
_onTileLoad(tile:
|
|
241
|
+
_initializeTileHeaders(tilesetJson: TilesetJSON, parentTileHeader?: any): Tile3D;
|
|
242
|
+
_initializeTraverser(): TilesetTraverser;
|
|
243
|
+
_destroyTileHeaders(parentTile: Tile3D): void;
|
|
244
|
+
_loadTile(tile: Tile3D): Promise<void>;
|
|
245
|
+
_onTileLoadError(tile: Tile3D, error: Error): void;
|
|
246
|
+
_onTileLoad(tile: Tile3D, loaded: boolean): void;
|
|
200
247
|
/**
|
|
201
248
|
* Update information about data types in nested tiles
|
|
202
249
|
* @param tile instance of a nested Tile3D
|
|
@@ -204,7 +251,7 @@ export declare class Tileset3D {
|
|
|
204
251
|
private updateContentTypes;
|
|
205
252
|
_onStartTileLoading(): void;
|
|
206
253
|
_onEndTileLoading(): void;
|
|
207
|
-
_addTileToCache(tile:
|
|
254
|
+
_addTileToCache(tile: Tile3D): void;
|
|
208
255
|
_updateCacheStats(tile: any): void;
|
|
209
256
|
_unloadTile(tile: any): void;
|
|
210
257
|
_destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tileset-3d.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tileset-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tileset-3d.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,gBAAgB,EAAQ,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAC,UAAU,EAAoC,MAAM,uBAAuB,CAAC;AAGpF,OAAO,KAAK,EAAqB,QAAQ,EAAC,MAAM,UAAU,CAAC;AAC3D,OAAO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exports.Tileset3D = void 0;
|
|
5
5
|
// This file is derived from the Cesium code base under Apache 2 license
|
|
6
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
7
|
const core_1 = require("@math.gl/core");
|
|
42
8
|
const geospatial_1 = require("@math.gl/geospatial");
|
|
43
9
|
const stats_1 = require("@probe.gl/stats");
|
|
@@ -55,39 +21,18 @@ const i3s_tileset_traverser_1 = require("./format-i3s/i3s-tileset-traverser");
|
|
|
55
21
|
const DEFAULT_PROPS = {
|
|
56
22
|
description: '',
|
|
57
23
|
ellipsoid: geospatial_1.Ellipsoid.WGS84,
|
|
58
|
-
// A 4x4 transformation matrix this transforms the entire tileset.
|
|
59
24
|
modelMatrix: new core_1.Matrix4(),
|
|
60
|
-
// Set to false to disable network request throttling
|
|
61
25
|
throttleRequests: true,
|
|
62
|
-
// Number of simultaneous requsts, if throttleRequests is true
|
|
63
26
|
maxRequests: 64,
|
|
64
27
|
maximumMemoryUsage: 32,
|
|
65
|
-
/** Maximum number limit of tiles selected for show. 0 means no limit */
|
|
66
28
|
maximumTilesSelected: 0,
|
|
67
|
-
/** Delay time before the tileset traversal. It prevents traversal requests spam.*/
|
|
68
29
|
debounceTime: 0,
|
|
69
|
-
/**
|
|
70
|
-
* Callback. Indicates this a tile's content was loaded
|
|
71
|
-
* @param tile {TileHeader}
|
|
72
|
-
*/
|
|
73
30
|
onTileLoad: () => { },
|
|
74
|
-
/**
|
|
75
|
-
* Callback. Indicates this a tile's content was unloaded
|
|
76
|
-
* @param tile {TileHeader}
|
|
77
|
-
*/
|
|
78
31
|
onTileUnload: () => { },
|
|
79
32
|
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
33
|
onTraversalComplete: (selectedTiles) => selectedTiles,
|
|
86
|
-
// Optional async tile content loader
|
|
87
34
|
contentLoader: undefined,
|
|
88
|
-
// View distance scale modifier
|
|
89
35
|
viewDistanceScale: 1.0,
|
|
90
|
-
// The maximum screen space error used to drive level of detail refinement.
|
|
91
36
|
maximumScreenSpaceError: 8,
|
|
92
37
|
loadTiles: true,
|
|
93
38
|
updateTransforms: true,
|
|
@@ -108,6 +53,39 @@ const TILES_UNLOADED = 'Tiles Unloaded';
|
|
|
108
53
|
const TILES_LOAD_FAILED = 'Failed Tile Loads';
|
|
109
54
|
const POINTS_COUNT = 'Points/Vertices';
|
|
110
55
|
const TILES_GPU_MEMORY = 'Tile Memory Use';
|
|
56
|
+
/**
|
|
57
|
+
* The Tileset loading and rendering flow is as below,
|
|
58
|
+
* A rendered (i.e. deck.gl `Tile3DLayer`) triggers `tileset.update()` after a `tileset` is loaded
|
|
59
|
+
* `tileset` starts traversing the tile tree and update `requestTiles` (tiles of which content need
|
|
60
|
+
* to be fetched) and `selectedTiles` (tiles ready for rendering under the current viewport).
|
|
61
|
+
* `Tile3DLayer` will update rendering based on `selectedTiles`.
|
|
62
|
+
* `Tile3DLayer` also listens to `onTileLoad` callback and trigger another round of `update and then traversal`
|
|
63
|
+
* when new tiles are loaded.
|
|
64
|
+
|
|
65
|
+
* As I3S tileset have stored `tileHeader` file (metadata) and tile content files (geometry, texture, ...) separately.
|
|
66
|
+
* During each traversal, it issues `tilHeader` requests if that `tileHeader` is not yet fetched,
|
|
67
|
+
* after the tile header is fulfilled, it will resume the traversal starting from the tile just fetched (not root).
|
|
68
|
+
|
|
69
|
+
* Tile3DLayer
|
|
70
|
+
* |
|
|
71
|
+
* await load(tileset)
|
|
72
|
+
* |
|
|
73
|
+
* tileset.update()
|
|
74
|
+
* | async load tileHeader
|
|
75
|
+
* tileset.traverse() -------------------------- Queued
|
|
76
|
+
* | resume traversal after fetched |
|
|
77
|
+
* |----------------------------------------|
|
|
78
|
+
* |
|
|
79
|
+
* | async load tile content
|
|
80
|
+
* tilset.requestedTiles ----------------------------- RequestScheduler
|
|
81
|
+
* |
|
|
82
|
+
* tilset.selectedTiles (ready for rendering) |
|
|
83
|
+
* | Listen to |
|
|
84
|
+
* Tile3DLayer ----------- onTileLoad ----------------------|
|
|
85
|
+
* | | notify new tile is available
|
|
86
|
+
* updateLayers |
|
|
87
|
+
* tileset.update // trigger another round of update
|
|
88
|
+
*/
|
|
111
89
|
class Tileset3D {
|
|
112
90
|
/**
|
|
113
91
|
* Create a new Tileset3D
|
|
@@ -115,75 +93,80 @@ class Tileset3D {
|
|
|
115
93
|
* @param props
|
|
116
94
|
*/
|
|
117
95
|
// eslint-disable-next-line max-statements
|
|
118
|
-
constructor(
|
|
96
|
+
constructor(tileset, options) {
|
|
97
|
+
this.root = null;
|
|
98
|
+
this.roots = {};
|
|
99
|
+
/** @todo any->unknown */
|
|
100
|
+
this.asset = {};
|
|
101
|
+
// Metadata for the entire tileset
|
|
102
|
+
this.description = '';
|
|
103
|
+
this.extras = null;
|
|
104
|
+
this.attributions = {};
|
|
105
|
+
this.credits = {};
|
|
119
106
|
/** flags that contain information about data types in nested tiles */
|
|
120
107
|
this.contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };
|
|
108
|
+
// view props
|
|
109
|
+
this.cartographicCenter = null;
|
|
110
|
+
this.cartesianCenter = null;
|
|
111
|
+
this.zoom = 1;
|
|
112
|
+
this.boundingVolume = null;
|
|
113
|
+
/** Updated based on the camera position and direction */
|
|
114
|
+
this.dynamicScreenSpaceErrorComputedDensity = 0.0;
|
|
115
|
+
// METRICS
|
|
116
|
+
/**
|
|
117
|
+
* The maximum amount of GPU memory (in MB) that may be used to cache tiles
|
|
118
|
+
* Tiles not in view are unloaded to enforce private
|
|
119
|
+
*/
|
|
120
|
+
this.maximumMemoryUsage = 32;
|
|
121
|
+
/** The total amount of GPU memory in bytes used by the tileset. */
|
|
122
|
+
this.gpuMemoryUsageInBytes = 0;
|
|
123
|
+
/** Update tracker. increase in each update cycle. */
|
|
124
|
+
this._frameNumber = 0;
|
|
125
|
+
this._queryParams = {};
|
|
126
|
+
this._extensionsUsed = [];
|
|
127
|
+
this._tiles = {};
|
|
128
|
+
/** counter for tracking tiles requests */
|
|
129
|
+
this._pendingCount = 0;
|
|
130
|
+
/** Hold traversal results */
|
|
131
|
+
this.selectedTiles = [];
|
|
132
|
+
// TRAVERSAL
|
|
133
|
+
this.traverseCounter = 0;
|
|
134
|
+
this.geometricError = 0;
|
|
135
|
+
this.lastUpdatedVieports = null;
|
|
136
|
+
this._requestedTiles = [];
|
|
137
|
+
this._emptyTiles = [];
|
|
138
|
+
this.frameStateData = {};
|
|
139
|
+
this._cache = new tileset_cache_1.TilesetCache();
|
|
140
|
+
// Promise tracking
|
|
121
141
|
this.updatePromise = null;
|
|
122
|
-
(0, loader_utils_1.assert)(json);
|
|
123
142
|
// PUBLIC MEMBERS
|
|
124
143
|
this.options = { ...DEFAULT_PROPS, ...options };
|
|
125
144
|
// raw data
|
|
126
|
-
this.tileset =
|
|
127
|
-
this.loader =
|
|
145
|
+
this.tileset = tileset;
|
|
146
|
+
this.loader = tileset.loader;
|
|
128
147
|
// could be 3d tiles, i3s
|
|
129
|
-
this.type =
|
|
148
|
+
this.type = tileset.type;
|
|
130
149
|
// The url to a tileset JSON file.
|
|
131
|
-
this.url =
|
|
132
|
-
this.basePath =
|
|
150
|
+
this.url = tileset.url;
|
|
151
|
+
this.basePath = tileset.basePath || loader_utils_1.path.dirname(this.url);
|
|
133
152
|
this.modelMatrix = this.options.modelMatrix;
|
|
134
153
|
this.ellipsoid = this.options.ellipsoid;
|
|
135
154
|
// Geometric error when the tree is not rendered at all
|
|
136
|
-
this.lodMetricType =
|
|
137
|
-
this.lodMetricValue =
|
|
138
|
-
this.refine =
|
|
155
|
+
this.lodMetricType = tileset.lodMetricType;
|
|
156
|
+
this.lodMetricValue = tileset.lodMetricValue;
|
|
157
|
+
this.refine = tileset.root.refine;
|
|
139
158
|
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
159
|
// TRAVERSAL
|
|
148
|
-
this.traverseCounter = 0;
|
|
149
|
-
this.geometricError = 0;
|
|
150
160
|
this._traverser = this._initializeTraverser();
|
|
151
|
-
this._cache = new tileset_cache_1.TilesetCache();
|
|
152
161
|
this._requestScheduler = new loader_utils_1.RequestScheduler({
|
|
153
162
|
throttleRequests: this.options.throttleRequests,
|
|
154
163
|
maxRequests: this.options.maxRequests
|
|
155
164
|
});
|
|
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
165
|
// 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
166
|
// The total amount of GPU memory in bytes used by the tileset.
|
|
175
|
-
this.gpuMemoryUsageInBytes = 0;
|
|
176
167
|
this.stats = new stats_1.Stats({ id: this.url });
|
|
177
168
|
this._initializeStats();
|
|
178
|
-
|
|
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);
|
|
169
|
+
this.tilesetInitializationPromise = this._initializeTileSet(tileset);
|
|
187
170
|
}
|
|
188
171
|
/** Release resources */
|
|
189
172
|
destroy() {
|
|
@@ -201,10 +184,7 @@ class Tileset3D {
|
|
|
201
184
|
return this._frameNumber;
|
|
202
185
|
}
|
|
203
186
|
get queryParams() {
|
|
204
|
-
|
|
205
|
-
this._queryParamsString = getQueryParamString(this._queryParams);
|
|
206
|
-
}
|
|
207
|
-
return this._queryParamsString;
|
|
187
|
+
return new URLSearchParams(this._queryParams).toString();
|
|
208
188
|
}
|
|
209
189
|
setProps(props) {
|
|
210
190
|
this.options = { ...this.options, ...props };
|
|
@@ -222,11 +202,11 @@ class Tileset3D {
|
|
|
222
202
|
if (isDataUrl) {
|
|
223
203
|
return tilePath;
|
|
224
204
|
}
|
|
225
|
-
return `${tilePath}${this.queryParams}`;
|
|
205
|
+
return `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`;
|
|
226
206
|
}
|
|
227
207
|
// TODO CESIUM specific
|
|
228
208
|
hasExtension(extensionName) {
|
|
229
|
-
return Boolean(this._extensionsUsed
|
|
209
|
+
return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);
|
|
230
210
|
}
|
|
231
211
|
/**
|
|
232
212
|
* Update visible tiles relying on a list of viewports
|
|
@@ -468,7 +448,6 @@ class Tileset3D {
|
|
|
468
448
|
*/
|
|
469
449
|
calculateViewPropsTiles3D() {
|
|
470
450
|
const root = this.root;
|
|
471
|
-
(0, loader_utils_1.assert)(root);
|
|
472
451
|
const { center } = root.boundingVolume;
|
|
473
452
|
// TODO - handle all cases
|
|
474
453
|
if (!center) {
|
|
@@ -522,6 +501,15 @@ class Tileset3D {
|
|
|
522
501
|
const children = tile.header.children || [];
|
|
523
502
|
for (const childHeader of children) {
|
|
524
503
|
const childTile = new tile_3d_1.Tile3D(this, childHeader, tile);
|
|
504
|
+
// Special handling for Google
|
|
505
|
+
// A session key must be used for all tile requests
|
|
506
|
+
if (childTile.contentUrl?.includes('?session=')) {
|
|
507
|
+
const url = new URL(childTile.contentUrl);
|
|
508
|
+
const session = url.searchParams.get('session');
|
|
509
|
+
if (session) {
|
|
510
|
+
this._queryParams.session = session;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
525
513
|
tile.children.push(childTile);
|
|
526
514
|
childTile.depth = tile.depth + 1;
|
|
527
515
|
stack.push(childTile);
|
|
@@ -558,7 +546,7 @@ class Tileset3D {
|
|
|
558
546
|
loaded = await tile.loadContent();
|
|
559
547
|
}
|
|
560
548
|
catch (error) {
|
|
561
|
-
this._onTileLoadError(tile, error);
|
|
549
|
+
this._onTileLoadError(tile, error instanceof Error ? error : new Error('load failed'));
|
|
562
550
|
}
|
|
563
551
|
finally {
|
|
564
552
|
this._onEndTileLoading();
|
|
@@ -638,11 +626,11 @@ class Tileset3D {
|
|
|
638
626
|
this.stats.get(TILES_LOADED).incrementCount();
|
|
639
627
|
this.stats.get(TILES_IN_MEMORY).incrementCount();
|
|
640
628
|
// Good enough? Just use the raw binary ArrayBuffer's byte length.
|
|
641
|
-
this.gpuMemoryUsageInBytes += tile.
|
|
629
|
+
this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;
|
|
642
630
|
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
643
631
|
}
|
|
644
632
|
_unloadTile(tile) {
|
|
645
|
-
this.gpuMemoryUsageInBytes -=
|
|
633
|
+
this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;
|
|
646
634
|
this.stats.get(TILES_IN_MEMORY).decrementCount();
|
|
647
635
|
this.stats.get(TILES_UNLOADED).incrementCount();
|
|
648
636
|
this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;
|
|
@@ -686,12 +674,19 @@ class Tileset3D {
|
|
|
686
674
|
tile.destroy();
|
|
687
675
|
}
|
|
688
676
|
_initializeTiles3DTileset(tilesetJson) {
|
|
677
|
+
if (tilesetJson.queryString) {
|
|
678
|
+
const searchParams = new URLSearchParams(tilesetJson.queryString);
|
|
679
|
+
const queryParams = Object.fromEntries(searchParams.entries());
|
|
680
|
+
this._queryParams = { ...this._queryParams, ...queryParams };
|
|
681
|
+
}
|
|
689
682
|
this.asset = tilesetJson.asset;
|
|
690
683
|
if (!this.asset) {
|
|
691
684
|
throw new Error('Tileset must have an asset property.');
|
|
692
685
|
}
|
|
693
|
-
if (this.asset.version !== '0.0' &&
|
|
694
|
-
|
|
686
|
+
if (this.asset.version !== '0.0' &&
|
|
687
|
+
this.asset.version !== '1.0' &&
|
|
688
|
+
this.asset.version !== '1.1') {
|
|
689
|
+
throw new Error('The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.');
|
|
695
690
|
}
|
|
696
691
|
// Note: `asset.tilesetVersion` is version of the tileset itself (not the version of the 3D TILES standard)
|
|
697
692
|
// We add this version as a `v=1.0` query param to fetch the right version and not get an older cached version
|
|
@@ -706,28 +701,15 @@ class Tileset3D {
|
|
|
706
701
|
// Gets the tileset's properties dictionary object, which contains metadata about per-feature properties.
|
|
707
702
|
this.properties = tilesetJson.properties;
|
|
708
703
|
this.geometricError = tilesetJson.geometricError;
|
|
709
|
-
this._extensionsUsed = tilesetJson.extensionsUsed;
|
|
704
|
+
this._extensionsUsed = tilesetJson.extensionsUsed || [];
|
|
710
705
|
// Returns the extras property at the top of the tileset JSON (application specific metadata).
|
|
711
706
|
this.extras = tilesetJson.extras;
|
|
712
707
|
}
|
|
713
708
|
_initializeI3STileset() {
|
|
709
|
+
// @ts-expect-error
|
|
714
710
|
if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {
|
|
715
711
|
this._queryParams.token = this.loadOptions.i3s.token;
|
|
716
712
|
}
|
|
717
713
|
}
|
|
718
714
|
}
|
|
719
715
|
exports.Tileset3D = Tileset3D;
|
|
720
|
-
function getQueryParamString(queryParams) {
|
|
721
|
-
const queryParamStrings = [];
|
|
722
|
-
for (const key of Object.keys(queryParams)) {
|
|
723
|
-
queryParamStrings.push(`${key}=${queryParams[key]}`);
|
|
724
|
-
}
|
|
725
|
-
switch (queryParamStrings.length) {
|
|
726
|
-
case 0:
|
|
727
|
-
return '';
|
|
728
|
-
case 1:
|
|
729
|
-
return `?${queryParamStrings[0]}`;
|
|
730
|
-
default:
|
|
731
|
-
return `?${queryParamStrings.join('&')}`;
|
|
732
|
-
}
|
|
733
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Tileset3D } from './tileset-3d';
|
|
2
|
+
import type { Tile3D } from './tile-3d';
|
|
1
3
|
/**
|
|
2
4
|
* Stores tiles with content loaded.
|
|
3
|
-
*
|
|
4
5
|
* @private
|
|
5
6
|
*/
|
|
6
7
|
export declare class TilesetCache {
|
|
@@ -9,9 +10,9 @@ export declare class TilesetCache {
|
|
|
9
10
|
private _trimTiles;
|
|
10
11
|
constructor();
|
|
11
12
|
reset(): void;
|
|
12
|
-
touch(tile:
|
|
13
|
-
add(tileset:
|
|
14
|
-
unloadTile(tileset:
|
|
13
|
+
touch(tile: Tile3D): void;
|
|
14
|
+
add(tileset: Tileset3D, tile: Tile3D, addCallback?: (tileset: Tileset3D, tile: Tile3D) => void): void;
|
|
15
|
+
unloadTile(tileset: Tileset3D, tile: Tile3D, unloadCallback?: (tileset: Tileset3D, tile: Tile3D) => void): void;
|
|
15
16
|
unloadTiles(tileset: any, unloadCallback: any): void;
|
|
16
17
|
trim(): void;
|
|
17
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tileset-cache.d.ts","sourceRoot":"","sources":["../../src/tileset/tileset-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tileset-cache.d.ts","sourceRoot":"","sources":["../../src/tileset/tileset-cache.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AAGtC;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,UAAU,CAAU;;IAU5B,KAAK,IAAI,IAAI;IAOb,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAOzB,GAAG,CACD,OAAO,EAAE,SAAS,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GACvD,IAAI;IAUP,UAAU,CACR,OAAO,EAAE,SAAS,EAClB,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAC1D,IAAI;IAaP,WAAW,CAAC,OAAO,KAAA,EAAE,cAAc,KAAA,GAAG,IAAI;IA0B1C,IAAI,IAAI,IAAI;CAGb"}
|