@loaders.gl/tiles 4.0.0-alpha.6 → 4.0.0-alpha.7

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.
Files changed (45) hide show
  1. package/dist/constants.d.ts +6 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +0 -1
  4. package/dist/dist.min.js +429 -187
  5. package/dist/es5/constants.js.map +1 -1
  6. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
  7. package/dist/es5/tileset/tile-3d.js +42 -71
  8. package/dist/es5/tileset/tile-3d.js.map +1 -1
  9. package/dist/es5/tileset/tileset-3d.js +68 -103
  10. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  11. package/dist/es5/tileset/tileset-cache.js +4 -7
  12. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  13. package/dist/es5/tileset/tileset-traverser.js +12 -19
  14. package/dist/es5/tileset/tileset-traverser.js.map +1 -1
  15. package/dist/esm/constants.js.map +1 -1
  16. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
  17. package/dist/esm/tileset/tile-3d.js +40 -71
  18. package/dist/esm/tileset/tile-3d.js.map +1 -1
  19. package/dist/esm/tileset/tileset-3d.js +64 -95
  20. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  21. package/dist/esm/tileset/tileset-cache.js +4 -7
  22. package/dist/esm/tileset/tileset-cache.js.map +1 -1
  23. package/dist/esm/tileset/tileset-traverser.js +9 -16
  24. package/dist/esm/tileset/tileset-traverser.js.map +1 -1
  25. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
  26. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  27. package/dist/tileset/tile-3d.d.ts +37 -21
  28. package/dist/tileset/tile-3d.d.ts.map +1 -1
  29. package/dist/tileset/tile-3d.js +57 -43
  30. package/dist/tileset/tileset-3d.d.ts +90 -43
  31. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  32. package/dist/tileset/tileset-3d.js +110 -128
  33. package/dist/tileset/tileset-cache.d.ts +5 -4
  34. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  35. package/dist/tileset/tileset-cache.js +4 -10
  36. package/dist/tileset/tileset-traverser.d.ts +32 -21
  37. package/dist/tileset/tileset-traverser.d.ts.map +1 -1
  38. package/dist/tileset/tileset-traverser.js +23 -32
  39. package/package.json +8 -5
  40. package/src/constants.ts +18 -0
  41. package/src/tileset/helpers/3d-tiles-options.ts +3 -1
  42. package/src/tileset/tile-3d.ts +68 -109
  43. package/src/tileset/tileset-3d.ts +182 -217
  44. package/src/tileset/tileset-cache.ts +20 -15
  45. package/src/tileset/tileset-traverser.ts +52 -65
@@ -2,15 +2,9 @@
2
2
  // loaders.gl, MIT license
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.TilesetCache = 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
5
  const doubly_linked_list_1 = require("../utils/doubly-linked-list");
8
- function defined(x) {
9
- return x !== undefined && x !== null;
10
- }
11
6
  /**
12
7
  * Stores tiles with content loaded.
13
- *
14
8
  * @private
15
9
  */
16
10
  class TilesetCache {
@@ -29,12 +23,12 @@ class TilesetCache {
29
23
  }
30
24
  touch(tile) {
31
25
  const node = tile._cacheNode;
32
- if (defined(node)) {
26
+ if (node) {
33
27
  this._list.splice(this._sentinel, node);
34
28
  }
35
29
  }
36
30
  add(tileset, tile, addCallback) {
37
- if (!defined(tile._cacheNode)) {
31
+ if (!tile._cacheNode) {
38
32
  tile._cacheNode = this._list.add(tile);
39
33
  if (addCallback) {
40
34
  addCallback(tileset, tile);
@@ -43,11 +37,11 @@ class TilesetCache {
43
37
  }
44
38
  unloadTile(tileset, tile, unloadCallback) {
45
39
  const node = tile._cacheNode;
46
- if (!defined(node)) {
40
+ if (!node) {
47
41
  return;
48
42
  }
49
43
  this._list.remove(node);
50
- tile._cacheNode = undefined;
44
+ tile._cacheNode = null;
51
45
  if (unloadCallback) {
52
46
  unloadCallback(tileset, tile);
53
47
  }
@@ -1,46 +1,57 @@
1
+ import type { Tile3D } from './tile-3d';
1
2
  import { ManagedArray } from '../utils/managed-array';
2
3
  import { FrameState } from './helpers/frame-state';
3
4
  export type TilesetTraverserProps = {
4
5
  loadSiblings?: boolean;
5
6
  skipLevelOfDetail?: boolean;
7
+ updateTransforms?: boolean;
6
8
  maximumScreenSpaceError?: number;
7
9
  onTraversalEnd?: (frameState: any) => any;
8
- viewportTraversersMap?: {
9
- [key: string]: any;
10
- };
10
+ viewportTraversersMap?: Record<string, any>;
11
11
  basePath?: string;
12
- updateTransforms?: boolean;
13
12
  };
14
13
  export declare const DEFAULT_PROPS: Required<TilesetTraverserProps>;
15
14
  export declare class TilesetTraverser {
16
15
  options: Required<TilesetTraverserProps>;
17
16
  root: any;
18
- requestedTiles: object;
19
- selectedTiles: object;
20
- emptyTiles: object;
17
+ selectedTiles: Record<string, Tile3D>;
18
+ requestedTiles: Record<string, Tile3D>;
19
+ emptyTiles: Record<string, Tile3D>;
21
20
  protected lastUpdate: number;
22
21
  protected readonly updateDebounceTime = 1000;
22
+ /** temporary storage to hold the traversed tiles during a traversal */
23
23
  protected _traversalStack: ManagedArray;
24
24
  protected _emptyTraversalStack: ManagedArray;
25
+ /** set in every traverse cycle */
25
26
  protected _frameNumber: number | null;
26
27
  protected traversalFinished(frameState: FrameState): boolean;
27
28
  constructor(options: TilesetTraverserProps);
28
29
  traverse(root: any, frameState: any, options: any): void;
29
30
  reset(): void;
31
+ /**
32
+ * Execute traverse
33
+ * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
34
+ * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
35
+ * This is the traditional replacement refinement approach and is called the base traversal.
36
+ * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
37
+ * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
38
+ * and rendering children and parent tiles simultaneously.
39
+ */
30
40
  executeTraversal(root: any, frameState: FrameState): void;
31
- updateChildTiles(tile: any, frameState: any): boolean;
32
- updateAndPushChildren(tile: any, frameState: any, stack: any, depth: any): boolean;
33
- updateTile(tile: any, frameState: any): void;
34
- selectTile(tile: any, frameState: any): void;
35
- loadTile(tile: any, frameState: any): void;
36
- touchTile(tile: any, frameState: any): void;
37
- canTraverse(tile: any, frameState: any, useParentMetric?: boolean, ignoreVisibility?: boolean): boolean;
38
- shouldLoadTile(tile: any): any;
39
- shouldSelectTile(tile: any): any;
40
- shouldRefine(tile: any, frameState: any, useParentMetric: any): boolean;
41
- updateTileVisibility(tile: any, frameState: any): void;
42
- compareDistanceToCamera(b: any, a: any): number;
43
- anyChildrenVisible(tile: any, frameState: any): boolean;
44
- executeEmptyTraversal(root: any, frameState: any): boolean;
41
+ updateChildTiles(tile: Tile3D, frameState: FrameState): void;
42
+ updateAndPushChildren(tile: Tile3D, frameState: FrameState, stack: any, depth: any): boolean;
43
+ updateTile(tile: Tile3D, frameState: FrameState): void;
44
+ selectTile(tile: Tile3D, frameState: FrameState): void;
45
+ loadTile(tile: Tile3D, frameState: FrameState): void;
46
+ touchTile(tile: Tile3D, frameState: FrameState): void;
47
+ canTraverse(tile: Tile3D, frameState: FrameState, useParentMetric?: boolean, ignoreVisibility?: boolean): boolean;
48
+ shouldLoadTile(tile: Tile3D): boolean;
49
+ shouldSelectTile(tile: Tile3D): boolean;
50
+ /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
51
+ shouldRefine(tile: Tile3D, frameState: FrameState, useParentMetric?: boolean): boolean;
52
+ updateTileVisibility(tile: Tile3D, frameState: FrameState): void;
53
+ compareDistanceToCamera(b: Tile3D, a: Tile3D): number;
54
+ anyChildrenVisible(tile: Tile3D, frameState: FrameState): boolean;
55
+ executeEmptyTraversal(root: Tile3D, frameState: FrameState): boolean;
45
56
  }
46
57
  //# sourceMappingURL=tileset-traverser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,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A,EAAE,KAAK,KAAA,GAAG,OAAO;IAuDlF,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAKtD,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAStD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IASpD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAQrD,WAAW,CACT,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,UAAU,EACtB,eAAe,GAAE,OAAe,EAChC,gBAAgB,GAAE,OAAe,GAChC,OAAO;IAmBV,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMrC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAMvC,oFAAoF;IACpF,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,GAAE,OAAe,GAAG,OAAO;IAS7F,oBAAoB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI;IAiBhE,uBAAuB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrD,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO;IAajE,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO;CAqCrE"}
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
+ // loaders.gl, MIT license
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.TilesetTraverser = exports.DEFAULT_PROPS = void 0;
4
5
  const managed_array_1 = require("../utils/managed-array");
5
6
  const constants_1 = require("../constants");
6
- // export type Props = {
7
- // loadSiblings: boolean;
8
- // skipLevelOfDetail: boolean;
9
- // updateTransforms: boolean;
10
- // maximumScreenSpaceError: number;
11
- // onTraversalEnd: (frameState) => any;
12
- // viewportTraversersMap: {[key: string]: any};
13
- // basePath: string;
14
- // };
15
7
  exports.DEFAULT_PROPS = {
16
8
  loadSiblings: false,
17
9
  skipLevelOfDetail: false,
@@ -22,29 +14,28 @@ exports.DEFAULT_PROPS = {
22
14
  basePath: ''
23
15
  };
24
16
  class TilesetTraverser {
17
+ // RESULT
25
18
  traversalFinished(frameState) {
26
19
  return true;
27
20
  }
28
21
  // TODO nested props
29
22
  constructor(options) {
30
- this.lastUpdate = new Date().getTime();
31
- this.updateDebounceTime = 1000;
32
- this.options = { ...exports.DEFAULT_PROPS, ...options };
33
- // TRAVERSAL
34
- // temporary storage to hold the traversed tiles during a traversal
35
- this._traversalStack = new managed_array_1.ManagedArray();
36
- this._emptyTraversalStack = new managed_array_1.ManagedArray();
37
- // set in every traverse cycle
38
- this._frameNumber = null;
39
23
  // fulfill in traverse call
40
24
  this.root = null;
41
- // RESULT
42
25
  // tiles should be rendered
43
26
  this.selectedTiles = {};
44
27
  // tiles should be loaded from server
45
28
  this.requestedTiles = {};
46
29
  // tiles does not have render content
47
30
  this.emptyTiles = {};
31
+ this.lastUpdate = new Date().getTime();
32
+ this.updateDebounceTime = 1000;
33
+ /** temporary storage to hold the traversed tiles during a traversal */
34
+ this._traversalStack = new managed_array_1.ManagedArray();
35
+ this._emptyTraversalStack = new managed_array_1.ManagedArray();
36
+ /** set in every traverse cycle */
37
+ this._frameNumber = null;
38
+ this.options = { ...exports.DEFAULT_PROPS, ...options };
48
39
  }
49
40
  // tiles should be visible
50
41
  traverse(root, frameState, options) {
@@ -64,13 +55,15 @@ class TilesetTraverser {
64
55
  this._traversalStack.reset();
65
56
  this._emptyTraversalStack.reset();
66
57
  }
67
- // execute traverse
68
- // Depth-first traversal that traverses all visible tiles and marks tiles for selection.
69
- // If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
70
- // This is the traditional replacement refinement approach and is called the base traversal.
71
- // Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
72
- // all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
73
- // and rendering children and parent tiles simultaneously.
58
+ /**
59
+ * Execute traverse
60
+ * Depth-first traversal that traverses all visible tiles and marks tiles for selection.
61
+ * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.
62
+ * This is the traditional replacement refinement approach and is called the base traversal.
63
+ * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,
64
+ * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree
65
+ * and rendering children and parent tiles simultaneously.
66
+ */
74
67
  /* eslint-disable-next-line complexity, max-statements */
75
68
  executeTraversal(root, frameState) {
76
69
  // stack to store traversed tiles, only visible tiles should be added to stack
@@ -132,7 +125,6 @@ class TilesetTraverser {
132
125
  for (const child of children) {
133
126
  this.updateTile(child, frameState);
134
127
  }
135
- return true;
136
128
  }
137
129
  /* eslint-disable complexity, max-statements */
138
130
  updateAndPushChildren(tile, frameState, stack, depth) {
@@ -235,8 +227,8 @@ class TilesetTraverser {
235
227
  // and content available
236
228
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
237
229
  }
238
- // Decide if tile LoD (level of detail) is not sufficient under current viewport
239
- shouldRefine(tile, frameState, useParentMetric) {
230
+ /** Decide if tile LoD (level of detail) is not sufficient under current viewport */
231
+ shouldRefine(tile, frameState, useParentMetric = false) {
240
232
  let screenSpaceError = tile._screenSpaceError;
241
233
  if (useParentMetric) {
242
234
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -265,7 +257,9 @@ class TilesetTraverser {
265
257
  anyChildrenVisible(tile, frameState) {
266
258
  let anyVisible = false;
267
259
  for (const child of tile.children) {
260
+ // @ts-expect-error
268
261
  child.updateVisibility(frameState);
262
+ // @ts-expect-error
269
263
  anyVisible = anyVisible || child.isVisibleAndInRequestVolume;
270
264
  }
271
265
  return anyVisible;
@@ -304,6 +298,3 @@ class TilesetTraverser {
304
298
  }
305
299
  }
306
300
  exports.TilesetTraverser = TilesetTraverser;
307
- // TODO
308
- // enable expiration
309
- // enable optimization hint
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/tiles",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-alpha.7",
4
4
  "description": "Common components for different tiles loaders.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -33,8 +33,8 @@
33
33
  "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
34
34
  },
35
35
  "dependencies": {
36
- "@loaders.gl/loader-utils": "4.0.0-alpha.6",
37
- "@loaders.gl/math": "4.0.0-alpha.6",
36
+ "@loaders.gl/loader-utils": "4.0.0-alpha.7",
37
+ "@loaders.gl/math": "4.0.0-alpha.7",
38
38
  "@math.gl/core": "^3.5.1",
39
39
  "@math.gl/culling": "^3.5.1",
40
40
  "@math.gl/geospatial": "^3.5.1",
@@ -42,7 +42,10 @@
42
42
  "@probe.gl/stats": "^4.0.2"
43
43
  },
44
44
  "peerDependencies": {
45
- "@loaders.gl/core": "4.0.0-alpha.5"
45
+ "@loaders.gl/core": "4.0.0-alpha.6"
46
46
  },
47
- "gitHead": "acc1985050dfaa0f1f0c066f8da5bce7454a046c"
47
+ "devDependencies": {
48
+ "@deck.gl/core": "^8.9.0"
49
+ },
50
+ "gitHead": "afb59c4d8e5d8ebb9c28f111cb0c96c5527d0ffd"
48
51
  }
package/src/constants.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  // loaders.gl, MIT license
2
2
 
3
+ export type TileContentState =
4
+ | 'unloaded' // Has never been requested
5
+ | 'loading' // Is waiting on a pending request
6
+ | 'processing' // Request received. Contents are being processed for rendering. Depending on the content, it might make its own requests for external data.
7
+ | 'ready' // Ready to render.
8
+ | 'expired' // Is expired and will be unloaded once new content is loaded.
9
+ | 'failed'; // Request failed.
10
+
3
11
  export const TILE_CONTENT_STATE = {
4
12
  UNLOADED: 0, // Has never been requested
5
13
  LOADING: 1, // Is waiting on a pending request
@@ -9,11 +17,15 @@ export const TILE_CONTENT_STATE = {
9
17
  FAILED: 5 // Request failed.
10
18
  };
11
19
 
20
+ export type TileRefinement = 'add' | 'replace';
21
+
12
22
  export const TILE_REFINEMENT = {
13
23
  ADD: 1, // Render tile and, if screen space error exceeded, also refine to its children.
14
24
  REPLACE: 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.
15
25
  };
16
26
 
27
+ export type TileType = 'empty' | 'scenegraph' | 'pointcloud' | 'mesh';
28
+
17
29
  export const TILE_TYPE = {
18
30
  EMPTY: 'empty',
19
31
  SCENEGRAPH: 'scenegraph',
@@ -21,17 +33,23 @@ export const TILE_TYPE = {
21
33
  MESH: 'mesh'
22
34
  };
23
35
 
36
+ export type TilesetType = 'I3S' | 'TILES3D';
37
+
24
38
  export const TILESET_TYPE = {
25
39
  I3S: 'I3S',
26
40
  TILES3D: 'TILES3D'
27
41
  };
28
42
 
43
+ export type LODMetricType = 'geometricError' | 'maxScreenThreshold';
44
+
29
45
  export const LOD_METRIC_TYPE = {
30
46
  GEOMETRIC_ERROR: 'geometricError',
31
47
  MAX_SCREEN_THRESHOLD: 'maxScreenThreshold'
32
48
  };
33
49
 
34
50
  // Cesium 3D Tiles Specific
51
+ export type Tile3DOptimizationHint = 'NOT_COMPUTED' | 'USE_OPTIMIZATION' | 'SKIP_OPTIMIZATION';
52
+
35
53
  export const TILE3D_OPTIMIZATION_HINT = {
36
54
  NOT_COMPUTED: -1,
37
55
  USE_OPTIMIZATION: 1,
@@ -1,4 +1,6 @@
1
- export function get3dTilesOptions(tileset) {
1
+ import type {Tileset3D} from '../tileset-3d';
2
+
3
+ export function get3dTilesOptions(tileset: Tileset3D): {assetGltfUpAxis: 'X' | 'Y' | 'Z'} {
2
4
  return {
3
5
  assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'
4
6
  };
@@ -10,6 +10,7 @@ import {load} from '@loaders.gl/core';
10
10
 
11
11
  // Note: circular dependency
12
12
  import type {Tileset3D} from './tileset-3d';
13
+ import type {DoublyLinkedListNode} from '../utils/doubly-linked-list-node';
13
14
  import {TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE} from '../constants';
14
15
 
15
16
  import {FrameState} from './helpers/frame-state';
@@ -54,73 +55,78 @@ export class Tile3D {
54
55
  id: string;
55
56
  url: string;
56
57
  parent: Tile3D;
58
+ /* Specifies the type of refine that is used when traversing this tile for rendering. */
57
59
  refine: number;
58
60
  type: string;
59
61
  contentUrl: string;
60
- lodMetricType: string;
61
- lodMetricValue: number;
62
- boundingVolume: any;
63
- content: any;
64
- contentState: any;
65
- gpuMemoryUsageInBytes: number;
66
- children: Tile3D[];
67
- depth: number;
68
- viewportIds: any[];
69
- transform: Matrix4;
70
- extensions: any;
71
- implicitTiling?: any;
72
-
73
- // Container to store application specific data
74
- userData: {[key: string]: any};
62
+ /** Different refinement algorithms used by I3S and 3D tiles */
63
+ lodMetricType: 'geometricError' | 'maxScreenThreshold' = 'geometricError';
64
+ /** The error, in meters, introduced if this tile is rendered and its children are not. */
65
+ lodMetricValue: number = 0;
66
+
67
+ /** @todo math.gl is not exporting BoundingVolume base type? */
68
+ boundingVolume: any = null;
69
+
70
+ /**
71
+ * The tile's content. This represents the actual tile's payload,
72
+ * not the content's metadata in the tileset JSON file.
73
+ */
74
+ content: any = null;
75
+ contentState: number = TILE_CONTENT_STATE.UNLOADED;
76
+ gpuMemoryUsageInBytes: number = 0;
77
+
78
+ /** The tile's children - an array of Tile3D objects. */
79
+ children: Tile3D[] = [];
80
+ depth: number = 0;
81
+ viewportIds: any[] = [];
82
+ transform = new Matrix4();
83
+ extensions: any = null;
84
+ /** TODO Cesium 3d tiles specific */
85
+ implicitTiling?: any = null;
86
+
87
+ /** Container to store application specific data */
88
+ userData: Record<string, any> = {};
89
+
75
90
  computedTransform: any;
76
- hasEmptyContent: boolean;
77
- hasTilesetContent: boolean;
91
+ hasEmptyContent: boolean = false;
92
+ hasTilesetContent: boolean = false;
93
+
94
+ traverser = new TilesetTraverser({});
78
95
 
79
- traverser: object;
96
+ /** Used by TilesetCache */
97
+ _cacheNode: DoublyLinkedListNode | null = null;
98
+
99
+ private _frameNumber: any = null;
80
100
 
81
- // @ts-ignore
82
- private _cacheNode: any;
83
- private _frameNumber: any;
84
- // TODO i3s specific, needs to remove
85
- // @ts-ignore
86
- private _lodJudge: any;
87
101
  // TODO Cesium 3d tiles specific
88
- private _expireDate: any;
89
- private _expiredContent: any;
90
- // @ts-ignore
91
- private _shouldRefine: boolean;
102
+ private _expireDate: any = null;
103
+ private _expiredContent: any = null;
92
104
 
93
105
  private _boundingBox?: CartographicBounds;
94
106
 
95
- // Members this are updated every frame for tree traversal and rendering optimizations:
96
- public _distanceToCamera: number;
97
- // @ts-ignore
98
- private _centerZDepth: number;
99
- private _screenSpaceError: number;
107
+ /** updated every frame for tree traversal and rendering optimizations: */
108
+ public _distanceToCamera: number = 0;
109
+ _screenSpaceError: number = 0;
100
110
  private _visibilityPlaneMask: any;
101
- private _visible?: boolean;
102
- private _inRequestVolume: boolean;
103
-
104
- // @ts-ignore
105
- private _stackLength: number;
106
- // @ts-ignore
107
- private _selectionDepth: number;
108
-
109
- // @ts-ignore
110
- private _touchedFrame: number;
111
- // @ts-ignore
112
- private _visitedFrame: number;
113
- private _selectedFrame: number;
114
- // @ts-ignore
115
- private _requestedFrame: number;
116
-
117
- // @ts-ignore
118
- private _priority: number;
111
+ private _visible: boolean | undefined = undefined;
119
112
 
120
113
  private _contentBoundingVolume: any;
121
114
  private _viewerRequestVolume: any;
122
115
 
123
- _initialTransform: Matrix4;
116
+ _initialTransform: Matrix4 = new Matrix4();
117
+
118
+ // Used by traverser, cannot be marked private
119
+ _priority: number = 0;
120
+ _selectedFrame: number = 0;
121
+ _requestedFrame: number = 0;
122
+ _selectionDepth: number = 0;
123
+ _touchedFrame: number = 0;
124
+ _centerZDepth: number = 0;
125
+ _shouldRefine: boolean = false;
126
+ _stackLength: number = 0;
127
+ _visitedFrame: number = 0;
128
+ _inRequestVolume: boolean = false;
129
+ _lodJudge: any = null; // TODO i3s specific, needs to remove
124
130
 
125
131
  /**
126
132
  * @constructs
@@ -154,69 +160,12 @@ export class Tile3D {
154
160
  this.type = header.type;
155
161
  this.contentUrl = header.contentUrl;
156
162
 
157
- // The error, in meters, introduced if this tile is rendered and its children are not.
158
- this.lodMetricType = 'geometricError';
159
- this.lodMetricValue = 0;
160
-
161
- // Specifies the type of refine that is used when traversing this tile for rendering.
162
- this.boundingVolume = null;
163
-
164
- // The tile's content. This represents the actual tile's payload,
165
- // not the content's metadata in the tileset JSON file.
166
- this.content = null;
167
- this.contentState = TILE_CONTENT_STATE.UNLOADED;
168
- this.gpuMemoryUsageInBytes = 0;
169
-
170
- // The tile's children - an array of Tile3D objects.
171
- this.children = [];
172
-
173
- this.hasEmptyContent = false;
174
- this.hasTilesetContent = false;
175
-
176
- this.depth = 0;
177
- this.viewportIds = [];
178
-
179
- // Container to store application specific data
180
- this.userData = {};
181
- this.extensions = null;
182
-
183
- // PRIVATE MEMBERS
184
- this._priority = 0;
185
- this._touchedFrame = 0;
186
- this._visitedFrame = 0;
187
- this._selectedFrame = 0;
188
- this._requestedFrame = 0;
189
- this._screenSpaceError = 0;
190
-
191
- this._cacheNode = null;
192
- this._frameNumber = null;
193
- this._cacheNode = null;
194
-
195
- this.traverser = new TilesetTraverser({});
196
- this._shouldRefine = false;
197
- this._distanceToCamera = 0;
198
- this._centerZDepth = 0;
199
- this._visible = undefined;
200
- this._inRequestVolume = false;
201
- this._stackLength = 0;
202
- this._selectionDepth = 0;
203
- this._initialTransform = new Matrix4();
204
- this.transform = new Matrix4();
205
-
206
163
  this._initializeLodMetric(header);
207
164
  this._initializeTransforms(header);
208
165
  this._initializeBoundingVolumes(header);
209
166
  this._initializeContent(header);
210
167
  this._initializeRenderingState(header);
211
168
 
212
- // TODO i3s specific, needs to remove
213
- this._lodJudge = null;
214
-
215
- // TODO Cesium 3d tiles specific
216
- this._expireDate = null;
217
- this._expiredContent = null;
218
- this.implicitTiling = null;
219
-
220
169
  Object.seal(this);
221
170
  }
222
171
 
@@ -341,6 +290,13 @@ export class Tile3D {
341
290
  this._selectedFrame = 0;
342
291
  }
343
292
 
293
+ /**
294
+ * Memory usage of tile on GPU
295
+ */
296
+ _getGpuMemoryUsageInBytes(): number {
297
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
298
+ }
299
+
344
300
  /*
345
301
  * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.
346
302
  * Tiles are prioritized by screen space error.
@@ -424,6 +380,7 @@ export class Tile3D {
424
380
  const options = {
425
381
  ...this.tileset.loadOptions,
426
382
  [loader.id]: {
383
+ // @ts-expect-error
427
384
  ...this.tileset.loadOptions[loader.id],
428
385
  isTileset: this.type === 'json',
429
386
  ...this._getLoaderSpecificOptions(loader.id)
@@ -734,6 +691,8 @@ export class Tile3D {
734
691
  // The content may be tileset json
735
692
  if (this._isTileset()) {
736
693
  this.hasTilesetContent = true;
694
+ } else {
695
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
737
696
  }
738
697
  }
739
698