@rings-webgpu/core 1.0.14 → 1.0.16
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/rings.es.js +284 -248
- package/dist/rings.es.js.map +3 -3
- package/dist/rings.es.max.js +2337 -221
- package/dist/rings.umd.js +279 -243
- package/dist/rings.umd.js.map +3 -3
- package/dist/rings.umd.max.js +2358 -219
- package/dist/types/components/renderer/FatLineRenderer.d.ts +2 -0
- package/dist/types/core/bound/Frustum.d.ts +1 -0
- package/dist/types/index.d.ts +11 -1
- package/dist/types/loader/parser/gltf/utils/DracoUtils.d.ts +1 -0
- package/dist/types/loader/parser/tileRenderer/TilesRenderer.d.ts +327 -8
- package/dist/types/loader/parser/tileRenderer/core/BoundingVolume.d.ts +51 -0
- package/dist/types/loader/parser/tileRenderer/core/Tile.d.ts +61 -0
- package/dist/types/loader/parser/tileRenderer/core/TileSet.d.ts +91 -0
- package/dist/types/loader/parser/tileRenderer/core/constants.d.ts +20 -0
- package/dist/types/loader/parser/tileRenderer/core/priorityCallbacks.d.ts +27 -0
- package/dist/types/loader/parser/tileRenderer/core/traverseFunctions.d.ts +20 -0
- package/dist/types/loader/parser/tileRenderer/utils/LRUCache.d.ts +88 -0
- package/dist/types/loader/parser/tileRenderer/utils/PriorityQueue.d.ts +72 -0
- package/dist/types/loader/parser/tileRenderer/utils/TraversalUtils.d.ts +24 -0
- package/dist/types/loader/parser/tileRenderer/utils/throttle.d.ts +9 -0
- package/package.json +1 -1
- package/dist/types/loader/parser/tileRenderer/TileSet.d.ts +0 -45
|
@@ -1,12 +1,331 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tile } from './core/Tile';
|
|
2
|
+
import { TileSet, TileSetChild } from './core/TileSet';
|
|
3
|
+
import { LRUCache } from './utils/LRUCache';
|
|
4
|
+
import { PriorityQueue } from './utils/PriorityQueue';
|
|
5
|
+
import { Vector3 } from '../../../math/Vector3';
|
|
6
|
+
import { Object3D } from '../../../core/entities/Object3D';
|
|
7
|
+
import { BoundingBox } from '../../../core/bound/BoundingBox';
|
|
8
|
+
import { Camera3D } from '../../../core/Camera3D';
|
|
9
|
+
/**
|
|
10
|
+
* Plugin interface
|
|
11
|
+
*/
|
|
12
|
+
export interface TilesRendererPlugin {
|
|
13
|
+
name: string;
|
|
14
|
+
priority?: number;
|
|
15
|
+
init?(renderer: TilesRenderer): void;
|
|
16
|
+
dispose?(): void;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Statistics
|
|
21
|
+
*/
|
|
22
|
+
export interface TilesRendererStats {
|
|
23
|
+
parsing: number;
|
|
24
|
+
downloading: number;
|
|
25
|
+
failed: number;
|
|
26
|
+
inFrustum: number;
|
|
27
|
+
used: number;
|
|
28
|
+
active: number;
|
|
29
|
+
visible: number;
|
|
30
|
+
inCacheSinceLoad: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* View frustum and error calculation result interface
|
|
34
|
+
*/
|
|
35
|
+
export interface ViewErrorTarget {
|
|
36
|
+
inView: boolean;
|
|
37
|
+
error: number;
|
|
38
|
+
distanceFromCamera: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Memory statistics
|
|
42
|
+
*/
|
|
43
|
+
export interface MemoryStats {
|
|
44
|
+
totalTiles: number;
|
|
45
|
+
loadedTiles: number;
|
|
46
|
+
cachedTiles: number;
|
|
47
|
+
totalBytes: number;
|
|
48
|
+
usedBytes: number;
|
|
49
|
+
freeBytes: number;
|
|
50
|
+
cacheHitRate: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Performance statistics
|
|
54
|
+
*/
|
|
55
|
+
export interface PerformanceStats {
|
|
56
|
+
updateTime: number;
|
|
57
|
+
traverseTime: number;
|
|
58
|
+
markUsedTime: number;
|
|
59
|
+
markVisibleTime: number;
|
|
60
|
+
toggleTime: number;
|
|
61
|
+
queueProcessTime: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Performance configuration options
|
|
65
|
+
*/
|
|
66
|
+
export interface PerformanceOptions {
|
|
67
|
+
lruCacheMinSize?: number;
|
|
68
|
+
lruCacheMaxSize?: number;
|
|
69
|
+
lruCacheMinBytes?: number;
|
|
70
|
+
lruCacheMaxBytes?: number;
|
|
71
|
+
lruCacheUnloadPercent?: number;
|
|
72
|
+
downloadQueueMaxJobs?: number;
|
|
73
|
+
parseQueueMaxJobs?: number;
|
|
74
|
+
processQueueMaxJobs?: number;
|
|
75
|
+
enablePerformanceStats?: boolean;
|
|
76
|
+
enableCacheStats?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Root node loaded callback parameters
|
|
80
|
+
*/
|
|
81
|
+
export interface RootTileLoadedCallbackParams {
|
|
82
|
+
center: Vector3;
|
|
83
|
+
radius: number;
|
|
84
|
+
boundingBox?: BoundingBox;
|
|
85
|
+
rtcOffset?: Vector3;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Event listener type
|
|
89
|
+
*/
|
|
90
|
+
type EventListener = (event: any) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Event type
|
|
93
|
+
*/
|
|
94
|
+
type EventType = 'load-tile-set' | 'tiles-load-end' | 'load-error' | 'needs-update' | 'load-content';
|
|
95
|
+
/**
|
|
96
|
+
* TilesRenderer for Rings engine
|
|
97
|
+
* Contains all core algorithms and Rings-specific implementations
|
|
98
|
+
*/
|
|
2
99
|
export declare class TilesRenderer {
|
|
100
|
+
rootLoadingState: number;
|
|
101
|
+
rootTileSet: TileSet | null;
|
|
102
|
+
rootURL: string | null;
|
|
103
|
+
fetchOptions: RequestInit;
|
|
104
|
+
frameCount: number;
|
|
105
|
+
isLoading: boolean;
|
|
106
|
+
lruCache: LRUCache;
|
|
107
|
+
loadQueue: PriorityQueue;
|
|
108
|
+
processNodeQueue: PriorityQueue;
|
|
109
|
+
plugins: TilesRendererPlugin[];
|
|
110
|
+
protected _queuedTiles: Tile[];
|
|
111
|
+
protected _cachedSinceLoadComplete: Set<Tile>;
|
|
112
|
+
protected _processedTiles: WeakSet<Tile>;
|
|
113
|
+
protected _visibleTiles: Set<Tile>;
|
|
114
|
+
protected _usedSet: Set<Tile>;
|
|
115
|
+
protected _cacheHits: number;
|
|
116
|
+
protected _cacheMisses: number;
|
|
117
|
+
stats: TilesRendererStats;
|
|
118
|
+
errorTarget: number;
|
|
119
|
+
errorThreshold: number;
|
|
120
|
+
maxDepth: number;
|
|
121
|
+
displayActiveTiles: boolean;
|
|
122
|
+
onRootTileLoaded?: (params: RootTileLoadedCallbackParams) => void;
|
|
123
|
+
protected rtcOffset: Vector3 | null;
|
|
124
|
+
protected _root: Tile | null;
|
|
125
|
+
protected _activeTiles: Set<Tile>;
|
|
3
126
|
readonly group: Object3D;
|
|
4
|
-
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
|
|
127
|
+
cameras: Camera3D[];
|
|
128
|
+
private _cameraMap;
|
|
129
|
+
private _cameraInfo;
|
|
130
|
+
private _upRotationMatrix;
|
|
131
|
+
private _ellipsoid;
|
|
132
|
+
private _bytesUsed;
|
|
133
|
+
private _eventListeners;
|
|
134
|
+
performanceStats: PerformanceStats;
|
|
135
|
+
constructor(url?: string | null);
|
|
136
|
+
/**
|
|
137
|
+
* Get root tile
|
|
138
|
+
*/
|
|
139
|
+
get root(): Tile | null;
|
|
140
|
+
/**
|
|
141
|
+
* Get load progress (0-1)
|
|
142
|
+
*/
|
|
143
|
+
get loadProgress(): number;
|
|
144
|
+
/**
|
|
145
|
+
* Update method (main loop)
|
|
146
|
+
*/
|
|
147
|
+
update(): void;
|
|
148
|
+
/**
|
|
149
|
+
* Traverse tile tree
|
|
150
|
+
*/
|
|
151
|
+
traverse(beforeCb: ((tile: Tile, parent: Tile | null, depth: number) => boolean) | null, afterCb: ((tile: Tile, parent: Tile | null, depth: number) => boolean) | null, ensureFullyProcessed?: boolean): void;
|
|
152
|
+
/**
|
|
153
|
+
* Register plugin
|
|
154
|
+
*/
|
|
155
|
+
registerPlugin(plugin: TilesRendererPlugin): void;
|
|
156
|
+
/**
|
|
157
|
+
* Unregister plugin
|
|
158
|
+
*/
|
|
159
|
+
unregisterPlugin(plugin: TilesRendererPlugin | string): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Get plugin by name
|
|
162
|
+
*/
|
|
163
|
+
getPluginByName(name: string): TilesRendererPlugin | null;
|
|
164
|
+
/**
|
|
165
|
+
* Calculate tile view error and screen space error
|
|
166
|
+
*/
|
|
167
|
+
calculateTileViewError(tile: Tile, target: ViewErrorTarget): void;
|
|
168
|
+
/**
|
|
169
|
+
* Update camera information
|
|
170
|
+
*/
|
|
171
|
+
updateCameraInfo(): void;
|
|
172
|
+
private _updateCameraInfo;
|
|
173
|
+
/**
|
|
174
|
+
* Preprocess tile node
|
|
175
|
+
*/
|
|
176
|
+
preprocessNode(tileData: TileSetChild, tileSetDir: string, parentTile?: Tile | null): Tile;
|
|
177
|
+
/**
|
|
178
|
+
* Ensure children are preprocessed
|
|
179
|
+
*/
|
|
180
|
+
ensureChildrenArePreprocessed(tile: Tile, immediate?: boolean): void;
|
|
181
|
+
/**
|
|
182
|
+
* Record cache hit
|
|
183
|
+
*/
|
|
184
|
+
private _recordCacheHit;
|
|
185
|
+
/**
|
|
186
|
+
* Record cache miss
|
|
187
|
+
*/
|
|
188
|
+
private _recordCacheMiss;
|
|
189
|
+
/**
|
|
190
|
+
* Reset cache statistics
|
|
191
|
+
*/
|
|
192
|
+
resetCacheStats(): void;
|
|
193
|
+
/**
|
|
194
|
+
* Request tile content
|
|
195
|
+
*/
|
|
196
|
+
requestTileContents(tile: Tile): void;
|
|
197
|
+
/**
|
|
198
|
+
* Parse tile content
|
|
199
|
+
*/
|
|
200
|
+
parseTileContent(tile: Tile, uri: string, url: string): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Mark tile as used
|
|
203
|
+
*/
|
|
204
|
+
markTileUsed(tile: Tile): void;
|
|
205
|
+
/**
|
|
206
|
+
* Set tile active state
|
|
207
|
+
*/
|
|
208
|
+
setTileActive(tile: Tile, active: boolean): void;
|
|
209
|
+
/**
|
|
210
|
+
* Set tile visibility
|
|
211
|
+
*/
|
|
212
|
+
setTileVisible(tile: Tile, visible: boolean): void;
|
|
213
|
+
/**
|
|
214
|
+
* Add tile to download queue
|
|
215
|
+
*/
|
|
216
|
+
queueTileForDownload(tile: Tile): void;
|
|
217
|
+
/**
|
|
218
|
+
* Dispatch event
|
|
219
|
+
*/
|
|
220
|
+
dispatchEvent(event: {
|
|
221
|
+
type: string;
|
|
222
|
+
[key: string]: any;
|
|
223
|
+
}): void;
|
|
224
|
+
/**
|
|
225
|
+
* Load root Tileset
|
|
226
|
+
*/
|
|
227
|
+
protected _loadRootTileSet(): Promise<TileSet>;
|
|
228
|
+
/**
|
|
229
|
+
* Setup coordinate system adjustment matrix
|
|
230
|
+
*/
|
|
231
|
+
private _setupUpAxisRotation;
|
|
232
|
+
/**
|
|
233
|
+
* Apply local transform matrix to Transform
|
|
234
|
+
* Each scene only applies its own local transform, automatically accumulated through parent-child relationship
|
|
235
|
+
*/
|
|
236
|
+
private _applyLocalTransform;
|
|
237
|
+
/**
|
|
238
|
+
* Apply world transform matrix to Transform
|
|
239
|
+
* Since all tiles are directly mounted under group, no parent-child relationship,
|
|
240
|
+
* need to apply accumulated world transform
|
|
241
|
+
*/
|
|
242
|
+
private _applyWorldTransform;
|
|
243
|
+
/**
|
|
244
|
+
* Get base path
|
|
245
|
+
*/
|
|
246
|
+
protected _getBasePath(url: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Parse URL
|
|
249
|
+
*/
|
|
250
|
+
private _resolveURL;
|
|
251
|
+
/**
|
|
252
|
+
* Get URL extension
|
|
253
|
+
*/
|
|
254
|
+
private _getUrlExtension;
|
|
255
|
+
/**
|
|
256
|
+
* Get memory statistics
|
|
257
|
+
*/
|
|
258
|
+
getMemoryStats(): MemoryStats;
|
|
259
|
+
/**
|
|
260
|
+
* Get all loaded tiles
|
|
261
|
+
*/
|
|
262
|
+
getLoadedTiles(): Tile[];
|
|
263
|
+
/**
|
|
264
|
+
* Get all visible tiles
|
|
265
|
+
*/
|
|
266
|
+
getVisibleTiles(): Tile[];
|
|
267
|
+
/**
|
|
268
|
+
* Get all active tiles
|
|
269
|
+
*/
|
|
270
|
+
getActiveTiles(): Tile[];
|
|
271
|
+
/**
|
|
272
|
+
* Get tile tree statistics
|
|
273
|
+
*/
|
|
274
|
+
getTileTreeStats(): {
|
|
275
|
+
totalTiles: number;
|
|
276
|
+
loadedTiles: number;
|
|
277
|
+
visibleTiles: number;
|
|
278
|
+
activeTiles: number;
|
|
279
|
+
maxDepth: number;
|
|
280
|
+
averageDepth: number;
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Print debug information
|
|
284
|
+
*/
|
|
285
|
+
printDebugInfo(): void;
|
|
286
|
+
/**
|
|
287
|
+
* Set performance configuration
|
|
288
|
+
*/
|
|
289
|
+
setPerformanceOptions(options: PerformanceOptions): void;
|
|
290
|
+
/**
|
|
291
|
+
* Clean up resources
|
|
292
|
+
*/
|
|
293
|
+
dispose(): void;
|
|
294
|
+
/**
|
|
295
|
+
* Rings-specific: Add camera
|
|
296
|
+
*/
|
|
297
|
+
setCamera(camera: Camera3D, width: number, height: number): void;
|
|
298
|
+
/**
|
|
299
|
+
* Rings-specific: Delete camera
|
|
300
|
+
*/
|
|
301
|
+
deleteCamera(camera: Camera3D): void;
|
|
302
|
+
/**
|
|
303
|
+
* Rings-specific: Set camera resolution
|
|
304
|
+
*/
|
|
305
|
+
setResolution(camera: Camera3D, width: number, height: number): void;
|
|
306
|
+
/**
|
|
307
|
+
* Rings-specific: Traverse all loaded models
|
|
308
|
+
*/
|
|
309
|
+
forEachLoadedModel(callback: (scene: Object3D, tile: Tile) => void): void;
|
|
310
|
+
/**
|
|
311
|
+
* Rings-specific: Estimate object memory usage
|
|
312
|
+
*/
|
|
313
|
+
private _estimateBytesUsed;
|
|
314
|
+
/**
|
|
315
|
+
* Rings-specific: Add event listener
|
|
316
|
+
*/
|
|
317
|
+
addEventListener(type: EventType, listener: EventListener): void;
|
|
318
|
+
/**
|
|
319
|
+
* Rings-specific: Remove event listener
|
|
320
|
+
*/
|
|
321
|
+
removeEventListener(type: EventType, listener: EventListener): void;
|
|
322
|
+
/**
|
|
323
|
+
* Compatibility: Load tile set (legacy API)
|
|
324
|
+
*/
|
|
8
325
|
loadTileSet(rootPath: string, file: string): Promise<void>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Compatibility: Get model list (legacy API)
|
|
328
|
+
*/
|
|
329
|
+
get modelList(): Object3D[];
|
|
12
330
|
}
|
|
331
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Vector3 } from '../../../../math/Vector3';
|
|
2
|
+
import { Matrix4 } from '../../../../math/Matrix4';
|
|
3
|
+
import { BoundingBox } from '../../../../core/bound/BoundingBox';
|
|
4
|
+
import { BoundingSphere } from '../../../../core/bound/BoundingSphere';
|
|
5
|
+
import { Frustum } from '../../../../core/bound/Frustum';
|
|
6
|
+
import { BoundingVolumeData } from './TileSet';
|
|
7
|
+
export type BoundingVolumeType = 'box' | 'sphere' | 'region';
|
|
8
|
+
export declare class BoundingVolume {
|
|
9
|
+
private _type;
|
|
10
|
+
private _data;
|
|
11
|
+
private _box?;
|
|
12
|
+
private _sphere?;
|
|
13
|
+
private _matrix?;
|
|
14
|
+
constructor(data: BoundingVolumeData);
|
|
15
|
+
private _parseBox;
|
|
16
|
+
private _parseSphere;
|
|
17
|
+
private _parseRegion;
|
|
18
|
+
/**
|
|
19
|
+
* get the axis aligned bounding box
|
|
20
|
+
* @param target the target bounding box
|
|
21
|
+
* @param parentTransform the optional parent transform (accumulated transform)
|
|
22
|
+
*/
|
|
23
|
+
getAABB(target: BoundingBox, parentTransform?: Matrix4): BoundingBox;
|
|
24
|
+
/**
|
|
25
|
+
* get the oriented bounding box (OBB)
|
|
26
|
+
*/
|
|
27
|
+
getOBB(targetBox: BoundingBox, targetMatrix: Matrix4): void;
|
|
28
|
+
/**
|
|
29
|
+
* get the bounding sphere
|
|
30
|
+
*/
|
|
31
|
+
getSphere(target: BoundingSphere): BoundingSphere;
|
|
32
|
+
/**
|
|
33
|
+
* get the type of the bounding volume
|
|
34
|
+
*/
|
|
35
|
+
get type(): BoundingVolumeType;
|
|
36
|
+
/**
|
|
37
|
+
* calculate the distance to the point
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* calculate the distance to the point
|
|
41
|
+
* @param point the target point (world coordinate system)
|
|
42
|
+
* @param parentTransform the optional parent transform (accumulated transform)
|
|
43
|
+
*/
|
|
44
|
+
distanceToPoint(point: Vector3, parentTransform?: Matrix4): number;
|
|
45
|
+
/**
|
|
46
|
+
* check if intersects with the frustum
|
|
47
|
+
* @param frustum the frustum (world coordinate system)
|
|
48
|
+
* @param parentTransform the optional parent transform (accumulated transform)
|
|
49
|
+
*/
|
|
50
|
+
intersectsFrustum(frustum: Frustum, parentTransform?: Matrix4): boolean;
|
|
51
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { TileSetChild, BoundingVolumeData, TileContent, TileSetChildContent } from './TileSet';
|
|
2
|
+
import { Object3D } from '../../../../core/entities/Object3D';
|
|
3
|
+
import { BoundingVolume } from './BoundingVolume';
|
|
4
|
+
import { Matrix4 } from '../../../../math/Matrix4';
|
|
5
|
+
/**
|
|
6
|
+
* tile cache data
|
|
7
|
+
*/
|
|
8
|
+
export interface TileCache {
|
|
9
|
+
scene?: Object3D | null;
|
|
10
|
+
boundingVolume?: BoundingVolume | null;
|
|
11
|
+
transfrom?: Matrix4;
|
|
12
|
+
worldTransform?: Matrix4;
|
|
13
|
+
transformInverse?: Matrix4;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* runtime tile data structure
|
|
17
|
+
* based on TileSetChild, but added runtime state and cache
|
|
18
|
+
*/
|
|
19
|
+
export declare class Tile {
|
|
20
|
+
boundingVolume: BoundingVolumeData;
|
|
21
|
+
geometricError: number;
|
|
22
|
+
refine?: 'REPLACE' | 'ADD';
|
|
23
|
+
content?: TileContent;
|
|
24
|
+
contents?: TileSetChildContent[];
|
|
25
|
+
transform?: number[];
|
|
26
|
+
extensions?: Record<string, any>;
|
|
27
|
+
extras?: Record<string, any>;
|
|
28
|
+
parent: Tile | null;
|
|
29
|
+
children: Tile[];
|
|
30
|
+
loadingState: number;
|
|
31
|
+
used: boolean;
|
|
32
|
+
visible: boolean;
|
|
33
|
+
active: boolean;
|
|
34
|
+
inFrustum: boolean;
|
|
35
|
+
error: number;
|
|
36
|
+
distanceFromCamera: number;
|
|
37
|
+
depth: number;
|
|
38
|
+
depthFromRenderedParent: number;
|
|
39
|
+
lastFrameVisited: number;
|
|
40
|
+
isLeaf: boolean;
|
|
41
|
+
allChildrenReady: boolean;
|
|
42
|
+
hasContent: boolean;
|
|
43
|
+
hasRenderableContent: boolean;
|
|
44
|
+
hasUnrenderableContent: boolean;
|
|
45
|
+
childrenProcessed: number;
|
|
46
|
+
usedLastFrame: boolean;
|
|
47
|
+
priority?: number;
|
|
48
|
+
canTraverse: boolean;
|
|
49
|
+
canTraverseFrame: number;
|
|
50
|
+
basePath: string;
|
|
51
|
+
cached: TileCache;
|
|
52
|
+
constructor(tileData: TileSetChild, parent?: Tile | null);
|
|
53
|
+
/**
|
|
54
|
+
* add a child node
|
|
55
|
+
*/
|
|
56
|
+
addChild(child: Tile): void;
|
|
57
|
+
/**
|
|
58
|
+
* reset the frame state (called at the beginning of each frame)
|
|
59
|
+
*/
|
|
60
|
+
resetFrameState(frameCount: number): void;
|
|
61
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bounding volume data type
|
|
3
|
+
* support three types of bounding volumes: box, sphere, region
|
|
4
|
+
*/
|
|
5
|
+
export type BoundingVolumeData = {
|
|
6
|
+
/** 12 numbers: center(3) + x-axis direction + half-length(3) + y-axis direction + half-length(3) + z-axis direction + half-length(3) */
|
|
7
|
+
box?: number[];
|
|
8
|
+
/** 4 numbers: center(3) + radius(1) */
|
|
9
|
+
sphere?: number[];
|
|
10
|
+
/** 6 numbers: [west, south, east, north, minHeight, maxHeight] */
|
|
11
|
+
region?: number[];
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* tile content type
|
|
15
|
+
*/
|
|
16
|
+
export type TileContent = {
|
|
17
|
+
uri: string;
|
|
18
|
+
extensions?: Record<string, any>;
|
|
19
|
+
extras?: Record<string, any>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* asset information type
|
|
23
|
+
*/
|
|
24
|
+
export type TileSetAsset = {
|
|
25
|
+
generatetool?: string;
|
|
26
|
+
version: string;
|
|
27
|
+
tilesetVersion?: string;
|
|
28
|
+
gltfUpAxis?: 'x' | 'y' | 'z';
|
|
29
|
+
extensions?: Record<string, any>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* extend TileSet class
|
|
33
|
+
*/
|
|
34
|
+
export declare class TileSet {
|
|
35
|
+
asset: TileSetAsset;
|
|
36
|
+
extras?: {
|
|
37
|
+
scenetree?: string;
|
|
38
|
+
[key: string]: any;
|
|
39
|
+
};
|
|
40
|
+
geometricError: number;
|
|
41
|
+
properties?: Record<string, any>;
|
|
42
|
+
refine?: 'REPLACE' | 'ADD';
|
|
43
|
+
root: TileSetRoot;
|
|
44
|
+
extensionsUsed?: string[];
|
|
45
|
+
extensionsRequired?: string[];
|
|
46
|
+
extensions?: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* extend TileSetRoot class
|
|
50
|
+
*/
|
|
51
|
+
export declare class TileSetRoot {
|
|
52
|
+
boundingVolume: BoundingVolumeData;
|
|
53
|
+
children?: TileSetChild[];
|
|
54
|
+
geometricError: number;
|
|
55
|
+
transform?: number[];
|
|
56
|
+
content?: TileContent;
|
|
57
|
+
contents?: TileSetChildContent[];
|
|
58
|
+
refine?: 'REPLACE' | 'ADD';
|
|
59
|
+
extensions?: Record<string, any>;
|
|
60
|
+
extras?: Record<string, any>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* extend TileSetChild class
|
|
64
|
+
*/
|
|
65
|
+
export declare class TileSetChild {
|
|
66
|
+
boundingVolume: BoundingVolumeData;
|
|
67
|
+
geometricError: number;
|
|
68
|
+
refine?: 'REPLACE' | 'ADD';
|
|
69
|
+
content?: TileContent;
|
|
70
|
+
contents?: TileSetChildContent[];
|
|
71
|
+
children?: TileSetChild[];
|
|
72
|
+
transform?: number[];
|
|
73
|
+
extensions?: Record<string, any>;
|
|
74
|
+
extras?: Record<string, any>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* extend TileSetChildContent class
|
|
78
|
+
*/
|
|
79
|
+
export declare class TileSetChildContent {
|
|
80
|
+
uri: string;
|
|
81
|
+
group?: number;
|
|
82
|
+
metadata?: TileSetChildContentMetaData;
|
|
83
|
+
}
|
|
84
|
+
export declare class TileSetChildContentMetaData {
|
|
85
|
+
class?: string;
|
|
86
|
+
properties?: {
|
|
87
|
+
vertices?: number;
|
|
88
|
+
materials?: number;
|
|
89
|
+
[key: string]: any;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tile loading status constants
|
|
3
|
+
* FAILED is negative, ensure LRU cache unload failed tiles first
|
|
4
|
+
*/
|
|
5
|
+
export declare const FAILED = -1;
|
|
6
|
+
export declare const UNLOADED = 0;
|
|
7
|
+
export declare const LOADING = 1;
|
|
8
|
+
export declare const PARSING = 2;
|
|
9
|
+
export declare const LOADED = 3;
|
|
10
|
+
/**
|
|
11
|
+
* WGS84 ellipsoid parameters (for geospatial coordinate system calculation)
|
|
12
|
+
* 参考: https://en.wikipedia.org/wiki/World_Geodetic_System
|
|
13
|
+
*/
|
|
14
|
+
export declare const WGS84_RADIUS = 6378137;
|
|
15
|
+
export declare const WGS84_FLATTENING: number;
|
|
16
|
+
export declare const WGS84_HEIGHT: number;
|
|
17
|
+
/**
|
|
18
|
+
* plugin registered mark (Symbol, used to mark if the plugin is registered)
|
|
19
|
+
*/
|
|
20
|
+
export declare const PLUGIN_REGISTERED: unique symbol;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PriorityCallback } from '../utils/PriorityQueue';
|
|
2
|
+
import { UnloadPriorityCallback } from '../utils/LRUCache';
|
|
3
|
+
/**
|
|
4
|
+
* download/parse queue priority callback function
|
|
5
|
+
* return 1 means a has higher priority (load first), return -1 means b has higher priority, return 0 means equal
|
|
6
|
+
*
|
|
7
|
+
* priority rules:
|
|
8
|
+
* 1. priority value smaller is higher priority
|
|
9
|
+
* 2. tiles used in current frame are higher priority
|
|
10
|
+
* 3. tiles with larger screen space error are higher priority
|
|
11
|
+
* 4. tiles closer to the camera are higher priority
|
|
12
|
+
* 5. tiles with shallower depth are higher priority
|
|
13
|
+
*/
|
|
14
|
+
export declare const priorityCallback: PriorityCallback;
|
|
15
|
+
/**
|
|
16
|
+
* LRU cache unload priority callback function
|
|
17
|
+
* return 1 means a should be unloaded first, return -1 means b should be unloaded first, return 0 means equal
|
|
18
|
+
*
|
|
19
|
+
* unload priority rules:
|
|
20
|
+
* 1. priority value larger is higher priority
|
|
21
|
+
* 2. tiles not visited for a long time are higher priority
|
|
22
|
+
* 3. deeper nodes are higher priority (to avoid parent nodes being unloaded)
|
|
23
|
+
* 4. tiles in loading state are higher priority
|
|
24
|
+
* 5. external tilesets are unloaded last
|
|
25
|
+
* 6. tiles with smaller error are higher priority
|
|
26
|
+
*/
|
|
27
|
+
export declare const lruPriorityCallback: UnloadPriorityCallback;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Tile } from './Tile';
|
|
2
|
+
import { TilesRenderer } from '../TilesRenderer';
|
|
3
|
+
/**
|
|
4
|
+
* mark the tiles as used (main function)
|
|
5
|
+
*/
|
|
6
|
+
export declare function markUsedTiles(tile: Tile, renderer: TilesRenderer): void;
|
|
7
|
+
/**
|
|
8
|
+
* mark the leaves of the "used" tree
|
|
9
|
+
*/
|
|
10
|
+
export declare function markUsedSetLeaves(tile: Tile, renderer: TilesRenderer): void;
|
|
11
|
+
/**
|
|
12
|
+
* mark the visible tiles
|
|
13
|
+
* reference: 3DTilesRendererJS
|
|
14
|
+
*/
|
|
15
|
+
export declare function markVisibleTiles(tile: Tile, renderer: TilesRenderer): void;
|
|
16
|
+
/**
|
|
17
|
+
* toggle the visibility of the tiles
|
|
18
|
+
* reference: 3DTilesRendererJS
|
|
19
|
+
*/
|
|
20
|
+
export declare function toggleTiles(tile: Tile, renderer: TilesRenderer): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Tile } from '../core/Tile';
|
|
2
|
+
/**
|
|
3
|
+
* LRU Cache Unload Priority Callback Function Type
|
|
4
|
+
* Return 1 means a is unloaded first, return -1 means b is unloaded first, return 0 means equal
|
|
5
|
+
*/
|
|
6
|
+
export type UnloadPriorityCallback = (a: Tile, b: Tile) => number;
|
|
7
|
+
/**
|
|
8
|
+
* LRU Cache Item Remove Callback Function Type
|
|
9
|
+
*/
|
|
10
|
+
export type RemoveCallback = (item: Tile) => void;
|
|
11
|
+
/**
|
|
12
|
+
* LRU Cache Implementation
|
|
13
|
+
* Used to manage tile memory, supports limits based on quantity and byte size
|
|
14
|
+
*/
|
|
15
|
+
export declare class LRUCache {
|
|
16
|
+
minSize: number;
|
|
17
|
+
maxSize: number;
|
|
18
|
+
minBytesSize: number;
|
|
19
|
+
maxBytesSize: number;
|
|
20
|
+
unloadPercent: number;
|
|
21
|
+
autoMarkUnused: boolean;
|
|
22
|
+
private _itemSet;
|
|
23
|
+
private _itemList;
|
|
24
|
+
private _usedSet;
|
|
25
|
+
private _callbacks;
|
|
26
|
+
private _unloadingHandle;
|
|
27
|
+
private _cachedBytes;
|
|
28
|
+
private _bytesMap;
|
|
29
|
+
private _loadedSet;
|
|
30
|
+
private _unloadPriorityCallback;
|
|
31
|
+
/**
|
|
32
|
+
* Set unload priority callback
|
|
33
|
+
*/
|
|
34
|
+
set unloadPriorityCallback(cb: UnloadPriorityCallback | null);
|
|
35
|
+
get unloadPriorityCallback(): UnloadPriorityCallback | null;
|
|
36
|
+
/**
|
|
37
|
+
* Check if cache is full
|
|
38
|
+
*/
|
|
39
|
+
isFull(): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Get tile memory usage
|
|
42
|
+
*/
|
|
43
|
+
getMemoryUsage(item: Tile): number;
|
|
44
|
+
/**
|
|
45
|
+
* Set tile memory usage
|
|
46
|
+
*/
|
|
47
|
+
setMemoryUsage(item: Tile, bytes: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* Add tile to cache
|
|
50
|
+
*/
|
|
51
|
+
add(item: Tile, removeCb: RemoveCallback): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Check if tile is in cache
|
|
54
|
+
*/
|
|
55
|
+
has(item: Tile): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Remove tile from cache
|
|
58
|
+
*/
|
|
59
|
+
remove(item: Tile): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Mark tile as used
|
|
62
|
+
*/
|
|
63
|
+
markUsed(item: Tile): void;
|
|
64
|
+
/**
|
|
65
|
+
* Mark tile as unused
|
|
66
|
+
*/
|
|
67
|
+
markUnused(item: Tile): void;
|
|
68
|
+
/**
|
|
69
|
+
* Schedule unload operation
|
|
70
|
+
*/
|
|
71
|
+
scheduleUnload(): void;
|
|
72
|
+
/**
|
|
73
|
+
* Perform unload operation
|
|
74
|
+
*/
|
|
75
|
+
private _performUnload;
|
|
76
|
+
/**
|
|
77
|
+
* Clear cache
|
|
78
|
+
*/
|
|
79
|
+
clear(): void;
|
|
80
|
+
/**
|
|
81
|
+
* Get cache statistics
|
|
82
|
+
*/
|
|
83
|
+
getStats(): {
|
|
84
|
+
size: number;
|
|
85
|
+
bytes: number;
|
|
86
|
+
usedCount: number;
|
|
87
|
+
};
|
|
88
|
+
}
|