@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.
Files changed (47) hide show
  1. package/dist/constants.d.ts +24 -18
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +22 -19
  4. package/dist/dist.min.js +448 -206
  5. package/dist/es5/constants.js +22 -18
  6. package/dist/es5/constants.js.map +1 -1
  7. package/dist/es5/tileset/helpers/3d-tiles-options.js.map +1 -1
  8. package/dist/es5/tileset/tile-3d.js +42 -71
  9. package/dist/es5/tileset/tile-3d.js.map +1 -1
  10. package/dist/es5/tileset/tileset-3d.js +69 -104
  11. package/dist/es5/tileset/tileset-3d.js.map +1 -1
  12. package/dist/es5/tileset/tileset-cache.js +4 -7
  13. package/dist/es5/tileset/tileset-cache.js.map +1 -1
  14. package/dist/es5/tileset/tileset-traverser.js +12 -19
  15. package/dist/es5/tileset/tileset-traverser.js.map +1 -1
  16. package/dist/esm/constants.js +22 -18
  17. package/dist/esm/constants.js.map +1 -1
  18. package/dist/esm/tileset/helpers/3d-tiles-options.js.map +1 -1
  19. package/dist/esm/tileset/tile-3d.js +40 -71
  20. package/dist/esm/tileset/tile-3d.js.map +1 -1
  21. package/dist/esm/tileset/tileset-3d.js +65 -96
  22. package/dist/esm/tileset/tileset-3d.js.map +1 -1
  23. package/dist/esm/tileset/tileset-cache.js +4 -7
  24. package/dist/esm/tileset/tileset-cache.js.map +1 -1
  25. package/dist/esm/tileset/tileset-traverser.js +9 -16
  26. package/dist/esm/tileset/tileset-traverser.js.map +1 -1
  27. package/dist/tileset/helpers/3d-tiles-options.d.ts +3 -2
  28. package/dist/tileset/helpers/3d-tiles-options.d.ts.map +1 -1
  29. package/dist/tileset/tile-3d.d.ts +37 -21
  30. package/dist/tileset/tile-3d.d.ts.map +1 -1
  31. package/dist/tileset/tile-3d.js +57 -43
  32. package/dist/tileset/tileset-3d.d.ts +90 -43
  33. package/dist/tileset/tileset-3d.d.ts.map +1 -1
  34. package/dist/tileset/tileset-3d.js +111 -129
  35. package/dist/tileset/tileset-cache.d.ts +5 -4
  36. package/dist/tileset/tileset-cache.d.ts.map +1 -1
  37. package/dist/tileset/tileset-cache.js +4 -10
  38. package/dist/tileset/tileset-traverser.d.ts +32 -21
  39. package/dist/tileset/tileset-traverser.d.ts.map +1 -1
  40. package/dist/tileset/tileset-traverser.js +23 -32
  41. package/package.json +8 -5
  42. package/src/constants.ts +36 -18
  43. package/src/tileset/helpers/3d-tiles-options.ts +3 -1
  44. package/src/tileset/tile-3d.ts +68 -109
  45. package/src/tileset/tileset-3d.ts +183 -218
  46. package/src/tileset/tileset-cache.ts +20 -15
  47. package/src/tileset/tileset-traverser.ts +52 -65
@@ -16,26 +16,19 @@ export class TilesetTraverser {
16
16
  }
17
17
  constructor(options) {
18
18
  _defineProperty(this, "options", void 0);
19
- _defineProperty(this, "root", void 0);
20
- _defineProperty(this, "requestedTiles", void 0);
21
- _defineProperty(this, "selectedTiles", void 0);
22
- _defineProperty(this, "emptyTiles", void 0);
19
+ _defineProperty(this, "root", null);
20
+ _defineProperty(this, "selectedTiles", {});
21
+ _defineProperty(this, "requestedTiles", {});
22
+ _defineProperty(this, "emptyTiles", {});
23
23
  _defineProperty(this, "lastUpdate", new Date().getTime());
24
24
  _defineProperty(this, "updateDebounceTime", 1000);
25
- _defineProperty(this, "_traversalStack", void 0);
26
- _defineProperty(this, "_emptyTraversalStack", void 0);
27
- _defineProperty(this, "_frameNumber", void 0);
25
+ _defineProperty(this, "_traversalStack", new ManagedArray());
26
+ _defineProperty(this, "_emptyTraversalStack", new ManagedArray());
27
+ _defineProperty(this, "_frameNumber", null);
28
28
  this.options = {
29
29
  ...DEFAULT_PROPS,
30
30
  ...options
31
31
  };
32
- this._traversalStack = new ManagedArray();
33
- this._emptyTraversalStack = new ManagedArray();
34
- this._frameNumber = null;
35
- this.root = null;
36
- this.selectedTiles = {};
37
- this.requestedTiles = {};
38
- this.emptyTiles = {};
39
32
  }
40
33
  traverse(root, frameState, options) {
41
34
  this.root = root;
@@ -98,7 +91,6 @@ export class TilesetTraverser {
98
91
  for (const child of children) {
99
92
  this.updateTile(child, frameState);
100
93
  }
101
- return true;
102
94
  }
103
95
  updateAndPushChildren(tile, frameState, stack, depth) {
104
96
  const {
@@ -182,7 +174,8 @@ export class TilesetTraverser {
182
174
  shouldSelectTile(tile) {
183
175
  return tile.contentAvailable && !this.options.skipLevelOfDetail;
184
176
  }
185
- shouldRefine(tile, frameState, useParentMetric) {
177
+ shouldRefine(tile, frameState) {
178
+ let useParentMetric = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
186
179
  let screenSpaceError = tile._screenSpaceError;
187
180
  if (useParentMetric) {
188
181
  screenSpaceError = tile.getScreenSpaceError(frameState, true);
@@ -1 +1 @@
1
- {"version":3,"file":"tileset-traverser.js","names":["ManagedArray","TILE_REFINEMENT","DEFAULT_PROPS","loadSiblings","skipLevelOfDetail","maximumScreenSpaceError","updateTransforms","onTraversalEnd","viewportTraversersMap","basePath","TilesetTraverser","traversalFinished","frameState","constructor","options","_defineProperty","Date","getTime","_traversalStack","_emptyTraversalStack","_frameNumber","root","selectedTiles","requestedTiles","emptyTiles","traverse","reset","updateTile","frameNumber","executeTraversal","stack","_selectionDepth","push","length","tile","pop","shouldRefine","canTraverse","updateChildTiles","updateAndPushChildren","hasRenderContent","parent","parentRefines","Boolean","_shouldRefine","stoppedRefining","id","loadTile","selectTile","refine","ADD","REPLACE","touchTile","newTime","lastUpdate","updateDebounceTime","children","child","depth","sort","compareDistanceToCamera","bind","checkRefines","hasVisibleChild","refines","isVisibleAndInRequestVolume","find","delete","childRefines","_inRequestVolume","executeEmptyTraversal","contentAvailable","updateTileVisibility","shouldSelectTile","_selectedFrame","shouldLoadTile","_requestedFrame","_priority","_getPriority","tileset","_cache","touch","_touchedFrame","useParentMetric","arguments","undefined","ignoreVisibility","hasChildren","hasTilesetContent","contentExpired","hasUnloadedContent","screenSpaceError","_screenSpaceError","getScreenSpaceError","viewportIds","key","value","viewport","updateVisibility","b","a","_distanceToCamera","anyChildrenVisible","anyVisible","allDescendantsLoaded"],"sources":["../../../src/tileset/tileset-traverser.ts"],"sourcesContent":["import {ManagedArray} from '../utils/managed-array';\nimport {TILE_REFINEMENT} from '../constants';\nimport {FrameState} from './helpers/frame-state';\n\nexport type TilesetTraverserProps = {\n loadSiblings?: boolean;\n skipLevelOfDetail?: boolean;\n maximumScreenSpaceError?: number;\n onTraversalEnd?: (frameState) => any;\n viewportTraversersMap?: {[key: string]: any};\n basePath?: string;\n updateTransforms?: boolean;\n};\n\n// export type Props = {\n// loadSiblings: boolean;\n// skipLevelOfDetail: boolean;\n// updateTransforms: boolean;\n// maximumScreenSpaceError: number;\n// onTraversalEnd: (frameState) => any;\n// viewportTraversersMap: {[key: string]: any};\n// basePath: string;\n// };\n\nexport const DEFAULT_PROPS: Required<TilesetTraverserProps> = {\n loadSiblings: false,\n skipLevelOfDetail: false,\n maximumScreenSpaceError: 2,\n updateTransforms: true,\n onTraversalEnd: () => {},\n viewportTraversersMap: {},\n basePath: ''\n};\n\nexport class TilesetTraverser {\n options: Required<TilesetTraverserProps>;\n\n root: any;\n requestedTiles: object;\n selectedTiles: object;\n emptyTiles: object;\n\n protected lastUpdate: number = new Date().getTime();\n protected readonly updateDebounceTime = 1000;\n protected _traversalStack: ManagedArray;\n protected _emptyTraversalStack: ManagedArray;\n protected _frameNumber: number | null;\n\n protected traversalFinished(frameState: FrameState): boolean {\n return true;\n }\n\n // TODO nested props\n constructor(options: TilesetTraverserProps) {\n this.options = {...DEFAULT_PROPS, ...options};\n // TRAVERSAL\n // temporary storage to hold the traversed tiles during a traversal\n this._traversalStack = new ManagedArray();\n this._emptyTraversalStack = new ManagedArray();\n\n // set in every traverse cycle\n this._frameNumber = null;\n\n // fulfill in traverse call\n this.root = null;\n\n // RESULT\n // tiles should be rendered\n this.selectedTiles = {};\n // tiles should be loaded from server\n this.requestedTiles = {};\n // tiles does not have render content\n this.emptyTiles = {};\n }\n\n // tiles should be visible\n traverse(root, frameState, options) {\n this.root = root; // for root screen space error\n this.options = {...this.options, ...options};\n\n // reset result\n this.reset();\n\n // update tile (visibility and expiration)\n this.updateTile(root, frameState);\n\n this._frameNumber = frameState.frameNumber;\n this.executeTraversal(root, frameState);\n }\n\n reset() {\n this.requestedTiles = {};\n this.selectedTiles = {};\n this.emptyTiles = {};\n this._traversalStack.reset();\n this._emptyTraversalStack.reset();\n }\n\n // execute traverse\n // Depth-first traversal that traverses all visible tiles and marks tiles for selection.\n // If skipLevelOfDetail is off then a tile does not refine until all children are loaded.\n // This is the traditional replacement refinement approach and is called the base traversal.\n // Tiles that have a greater screen space error than the base screen space error are part of the base traversal,\n // all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree\n // and rendering children and parent tiles simultaneously.\n /* eslint-disable-next-line complexity, max-statements */\n executeTraversal(root, frameState: FrameState) {\n // stack to store traversed tiles, only visible tiles should be added to stack\n // visible: visible in the current view frustum\n const stack = this._traversalStack;\n root._selectionDepth = 1;\n\n stack.push(root);\n while (stack.length > 0) {\n // 1. pop tile\n const tile = stack.pop();\n\n // 2. check if tile needs to be refine, needs refine if a tile's LoD is not sufficient and tile has available children (available content)\n let shouldRefine = false;\n if (this.canTraverse(tile, frameState)) {\n this.updateChildTiles(tile, frameState);\n shouldRefine = this.updateAndPushChildren(\n tile,\n frameState,\n stack,\n tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth\n );\n }\n\n // 3. decide if should render (select) this tile\n // - tile does not have render content\n // - tile has render content and tile is `add` type (pointcloud)\n // - tile has render content and tile is `replace` type (photogrammetry) and can't refine any further\n const parent = tile.parent;\n const parentRefines = Boolean(!parent || parent._shouldRefine);\n const stoppedRefining = !shouldRefine;\n\n if (!tile.hasRenderContent) {\n this.emptyTiles[tile.id] = tile;\n this.loadTile(tile, frameState);\n if (stoppedRefining) {\n this.selectTile(tile, frameState);\n }\n // additive tiles\n } else if (tile.refine === TILE_REFINEMENT.ADD) {\n // Additive tiles are always loaded and selected\n this.loadTile(tile, frameState);\n this.selectTile(tile, frameState);\n\n // replace tiles\n } else if (tile.refine === TILE_REFINEMENT.REPLACE) {\n // Always load tiles in the base traversal\n // Select tiles that can't refine further\n this.loadTile(tile, frameState);\n if (stoppedRefining) {\n this.selectTile(tile, frameState);\n }\n }\n\n // 3. update cache, most recent touched tiles have higher priority to be fetched from server\n this.touchTile(tile, frameState);\n\n // 4. update tile refine prop and parent refinement status to trickle down to the descendants\n tile._shouldRefine = shouldRefine && parentRefines;\n }\n\n const newTime = new Date().getTime();\n if (this.traversalFinished(frameState) || newTime - this.lastUpdate > this.updateDebounceTime) {\n this.lastUpdate = newTime;\n this.options.onTraversalEnd(frameState);\n }\n }\n\n updateChildTiles(tile, frameState) {\n const children = tile.children;\n for (const child of children) {\n this.updateTile(child, frameState);\n }\n return true;\n }\n\n /* eslint-disable complexity, max-statements */\n updateAndPushChildren(tile, frameState, stack, depth) {\n const {loadSiblings, skipLevelOfDetail} = this.options;\n\n const children = tile.children;\n\n // sort children tiles\n children.sort(this.compareDistanceToCamera.bind(this));\n\n // For traditional replacement refinement only refine if all children are loaded.\n // Empty tiles are exempt since it looks better if children stream in as they are loaded to fill the empty space.\n const checkRefines =\n tile.refine === TILE_REFINEMENT.REPLACE && tile.hasRenderContent && !skipLevelOfDetail;\n\n let hasVisibleChild = false;\n let refines = true;\n\n for (const child of children) {\n child._selectionDepth = depth;\n if (child.isVisibleAndInRequestVolume) {\n if (stack.find(child)) {\n stack.delete(child);\n }\n stack.push(child);\n hasVisibleChild = true;\n } else if (checkRefines || loadSiblings) {\n // Keep non-visible children loaded since they are still needed before the parent can refine.\n // Or loadSiblings is true so always load tiles regardless of visibility.\n this.loadTile(child, frameState);\n this.touchTile(child, frameState);\n }\n\n if (checkRefines) {\n let childRefines;\n if (!child._inRequestVolume) {\n childRefines = false;\n } else if (!child.hasRenderContent) {\n childRefines = this.executeEmptyTraversal(child, frameState);\n } else {\n childRefines = child.contentAvailable;\n }\n refines = refines && childRefines;\n\n if (!refines) {\n return false;\n }\n }\n }\n\n if (!hasVisibleChild) {\n refines = false;\n }\n return refines;\n }\n /* eslint-enable complexity, max-statements */\n\n updateTile(tile, frameState) {\n this.updateTileVisibility(tile, frameState);\n }\n\n // tile to render in the browser\n selectTile(tile, frameState) {\n if (this.shouldSelectTile(tile)) {\n // The tile can be selected right away and does not require traverseAndSelect\n tile._selectedFrame = frameState.frameNumber;\n this.selectedTiles[tile.id] = tile;\n }\n }\n\n // tile to load from server\n loadTile(tile, frameState) {\n if (this.shouldLoadTile(tile)) {\n tile._requestedFrame = frameState.frameNumber;\n tile._priority = tile._getPriority();\n this.requestedTiles[tile.id] = tile;\n }\n }\n\n // cache tile\n touchTile(tile, frameState) {\n tile.tileset._cache.touch(tile);\n tile._touchedFrame = frameState.frameNumber;\n }\n\n // tile should be visible\n // tile should have children\n // tile LoD (level of detail) is not sufficient under current viewport\n canTraverse(tile, frameState, useParentMetric = false, ignoreVisibility = false) {\n if (!tile.hasChildren) {\n return false;\n }\n\n // cesium specific\n if (tile.hasTilesetContent) {\n // Traverse external this to visit its root tile\n // Don't traverse if the subtree is expired because it will be destroyed\n return !tile.contentExpired;\n }\n\n if (!ignoreVisibility && !tile.isVisibleAndInRequestVolume) {\n return false;\n }\n\n return this.shouldRefine(tile, frameState, useParentMetric);\n }\n\n shouldLoadTile(tile) {\n // if request tile is in current frame\n // and has unexpired render content\n return tile.hasUnloadedContent || tile.contentExpired;\n }\n\n shouldSelectTile(tile) {\n // if select tile is in current frame\n // and content available\n return tile.contentAvailable && !this.options.skipLevelOfDetail;\n }\n\n // Decide if tile LoD (level of detail) is not sufficient under current viewport\n shouldRefine(tile, frameState, useParentMetric) {\n let screenSpaceError = tile._screenSpaceError;\n if (useParentMetric) {\n screenSpaceError = tile.getScreenSpaceError(frameState, true);\n }\n\n return screenSpaceError > this.options.maximumScreenSpaceError;\n }\n\n updateTileVisibility(tile, frameState) {\n const viewportIds: string[] = [];\n if (this.options.viewportTraversersMap) {\n for (const key in this.options.viewportTraversersMap) {\n const value = this.options.viewportTraversersMap[key];\n if (value === frameState.viewport.id) {\n viewportIds.push(key);\n }\n }\n } else {\n viewportIds.push(frameState.viewport.id);\n }\n tile.updateVisibility(frameState, viewportIds);\n }\n\n // UTILITIES\n\n compareDistanceToCamera(b, a) {\n return b._distanceToCamera - a._distanceToCamera;\n }\n\n anyChildrenVisible(tile, frameState) {\n let anyVisible = false;\n for (const child of tile.children) {\n child.updateVisibility(frameState);\n anyVisible = anyVisible || child.isVisibleAndInRequestVolume;\n }\n return anyVisible;\n }\n\n // Depth-first traversal that checks if all nearest descendants with content are loaded.\n // Ignores visibility.\n executeEmptyTraversal(root, frameState) {\n let allDescendantsLoaded = true;\n const stack = this._emptyTraversalStack;\n\n stack.push(root);\n\n while (stack.length > 0 && allDescendantsLoaded) {\n const tile = stack.pop();\n\n this.updateTile(tile, frameState);\n\n if (!tile.isVisibleAndInRequestVolume) {\n // Load tiles that aren't visible since they are still needed for the parent to refine\n this.loadTile(tile, frameState);\n }\n\n this.touchTile(tile, frameState);\n\n // Only traverse if the tile is empty - traversal stop at descendants with content\n const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);\n\n if (traverse) {\n const children = tile.children;\n for (const child of children) {\n // eslint-disable-next-line max-depth\n if (stack.find(child)) {\n stack.delete(child);\n }\n stack.push(child);\n }\n } else if (!tile.contentAvailable) {\n allDescendantsLoaded = false;\n }\n }\n\n return allDescendantsLoaded;\n }\n}\n\n// TODO\n// enable expiration\n// enable optimization hint\n"],"mappings":";AAAA,SAAQA,YAAY,QAAO,wBAAwB;AACnD,SAAQC,eAAe,QAAO,cAAc;AAuB5C,OAAO,MAAMC,aAA8C,GAAG;EAC5DC,YAAY,EAAE,KAAK;EACnBC,iBAAiB,EAAE,KAAK;EACxBC,uBAAuB,EAAE,CAAC;EAC1BC,gBAAgB,EAAE,I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AAQ,GAAG,CAACS,IAAI,CAACM,gBAAgB,IAAI,IAAI,CAACH,WAAW,CAACH,IAAI,EAAEtB,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC;MAE1F,IAAIa,QAAQ,EAAE;QACZ,MAAM+B,QAAQ,GAAGtB,IAAI,CAACsB,QAAQ;QAC9B,KAAK,MAAMC,KAAK,IAAID,QAAQ,EAAE;UAE5B,IAAI1B,KAAK,CAACoC,IAAI,CAACT,KAAK,CAAC,EAAE;YACrB3B,KAAK,CAACqC,MAAM,CAACV,KAAK,CAAC;UACrB;UACA3B,KAAK,CAACE,IAAI,CAACyB,KAAK,CAAC;QACnB;MACF,CAAC,MAAM,IAAI,CAACvB,IAAI,CAACqC,gBAAgB,EAAE;QACjCiC,oBAAoB,GAAG,KAAK;MAC9B;IACF;IAEA,OAAOA,oBAAoB;EAC7B;AACF"}
1
+ {"version":3,"file":"tileset-traverser.js","names":["ManagedArray","TILE_REFINEMENT","DEFAULT_PROPS","loadSiblings","skipLevelOfDetail","maximumScreenSpaceError","updateTransforms","onTraversalEnd","viewportTraversersMap","basePath","TilesetTraverser","traversalFinished","frameState","constructor","options","_defineProperty","Date","getTime","traverse","root","reset","updateTile","_frameNumber","frameNumber","executeTraversal","requestedTiles","selectedTiles","emptyTiles","_traversalStack","_emptyTraversalStack","stack","_selectionDepth","push","length","tile","pop","shouldRefine","canTraverse","updateChildTiles","updateAndPushChildren","hasRenderContent","parent","parentRefines","Boolean","_shouldRefine","stoppedRefining","id","loadTile","selectTile","refine","ADD","REPLACE","touchTile","newTime","lastUpdate","updateDebounceTime","children","child","depth","sort","compareDistanceToCamera","bind","checkRefines","hasVisibleChild","refines","isVisibleAndInRequestVolume","find","delete","childRefines","_inRequestVolume","executeEmptyTraversal","contentAvailable","updateTileVisibility","shouldSelectTile","_selectedFrame","shouldLoadTile","_requestedFrame","_priority","_getPriority","tileset","_cache","touch","_touchedFrame","useParentMetric","arguments","undefined","ignoreVisibility","hasChildren","hasTilesetContent","contentExpired","hasUnloadedContent","screenSpaceError","_screenSpaceError","getScreenSpaceError","viewportIds","key","value","viewport","updateVisibility","b","a","_distanceToCamera","anyChildrenVisible","anyVisible","allDescendantsLoaded"],"sources":["../../../src/tileset/tileset-traverser.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {Tile3D} from './tile-3d';\nimport {ManagedArray} from '../utils/managed-array';\nimport {TILE_REFINEMENT} from '../constants';\nimport {FrameState} from './helpers/frame-state';\n\nexport type TilesetTraverserProps = {\n loadSiblings?: boolean;\n skipLevelOfDetail?: boolean;\n updateTransforms?: boolean;\n maximumScreenSpaceError?: number;\n onTraversalEnd?: (frameState) => any;\n viewportTraversersMap?: Record<string, any>;\n basePath?: string;\n};\n\nexport const DEFAULT_PROPS: Required<TilesetTraverserProps> = {\n loadSiblings: false,\n skipLevelOfDetail: false,\n maximumScreenSpaceError: 2,\n updateTransforms: true,\n onTraversalEnd: () => {},\n viewportTraversersMap: {},\n basePath: ''\n};\n\nexport class TilesetTraverser {\n options: Required<TilesetTraverserProps>;\n\n // fulfill in traverse call\n root: any = null;\n\n // tiles should be rendered\n selectedTiles: Record<string, Tile3D> = {};\n // tiles should be loaded from server\n requestedTiles: Record<string, Tile3D> = {};\n // tiles does not have render content\n emptyTiles: Record<string, Tile3D> = {};\n\n protected lastUpdate: number = new Date().getTime();\n protected readonly updateDebounceTime = 1000;\n /** temporary storage to hold the traversed tiles during a traversal */\n protected _traversalStack = new ManagedArray();\n protected _emptyTraversalStack = new ManagedArray();\n /** set in every traverse cycle */\n protected _frameNumber: number | null = null;\n\n // RESULT\n protected traversalFinished(frameState: FrameState): boolean {\n return true;\n }\n\n // TODO nested props\n constructor(options: TilesetTraverserProps) {\n this.options = {...DEFAULT_PROPS, ...options};\n }\n\n // tiles should be visible\n traverse(root, frameState, options) {\n this.root = root; // for root screen space error\n this.options = {...this.options, ...options};\n\n // reset result\n this.reset();\n\n // update tile (visibility and expiration)\n this.updateTile(root, frameState);\n\n this._frameNumber = frameState.frameNumber;\n this.executeTraversal(root, frameState);\n }\n\n reset() {\n this.requestedTiles = {};\n this.selectedTiles = {};\n this.emptyTiles = {};\n this._traversalStack.reset();\n this._emptyTraversalStack.reset();\n }\n\n /**\n * Execute traverse\n * Depth-first traversal that traverses all visible tiles and marks tiles for selection.\n * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.\n * This is the traditional replacement refinement approach and is called the base traversal.\n * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,\n * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree\n * and rendering children and parent tiles simultaneously.\n */\n /* eslint-disable-next-line complexity, max-statements */\n executeTraversal(root, frameState: FrameState): void {\n // stack to store traversed tiles, only visible tiles should be added to stack\n // visible: visible in the current view frustum\n const stack = this._traversalStack;\n root._selectionDepth = 1;\n\n stack.push(root);\n while (stack.length > 0) {\n // 1. pop tile\n const tile = stack.pop();\n\n // 2. check if tile needs to be refine, needs refine if a tile's LoD is not sufficient and tile has available children (available content)\n let shouldRefine = false;\n if (this.canTraverse(tile, frameState)) {\n this.updateChildTiles(tile, frameState);\n shouldRefine = this.updateAndPushChildren(\n tile,\n frameState,\n stack,\n tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth\n );\n }\n\n // 3. decide if should render (select) this tile\n // - tile does not have render content\n // - tile has render content and tile is `add` type (pointcloud)\n // - tile has render content and tile is `replace` type (photogrammetry) and can't refine any further\n const parent = tile.parent;\n const parentRefines = Boolean(!parent || parent._shouldRefine);\n const stoppedRefining = !shouldRefine;\n\n if (!tile.hasRenderContent) {\n this.emptyTiles[tile.id] = tile;\n this.loadTile(tile, frameState);\n if (stoppedRefining) {\n this.selectTile(tile, frameState);\n }\n // additive tiles\n } else if (tile.refine === TILE_REFINEMENT.ADD) {\n // Additive tiles are always loaded and selected\n this.loadTile(tile, frameState);\n this.selectTile(tile, frameState);\n\n // replace tiles\n } else if (tile.refine === TILE_REFINEMENT.REPLACE) {\n // Always load tiles in the base traversal\n // Select tiles that can't refine further\n this.loadTile(tile, frameState);\n if (stoppedRefining) {\n this.selectTile(tile, frameState);\n }\n }\n\n // 3. update cache, most recent touched tiles have higher priority to be fetched from server\n this.touchTile(tile, frameState);\n\n // 4. update tile refine prop and parent refinement status to trickle down to the descendants\n tile._shouldRefine = shouldRefine && parentRefines;\n }\n\n const newTime = new Date().getTime();\n if (this.traversalFinished(frameState) || newTime - this.lastUpdate > this.updateDebounceTime) {\n this.lastUpdate = newTime;\n this.options.onTraversalEnd(frameState);\n }\n }\n\n updateChildTiles(tile: Tile3D, frameState: FrameState): void {\n const children = tile.children;\n for (const child of children) {\n this.updateTile(child, frameState);\n }\n }\n\n /* eslint-disable complexity, max-statements */\n updateAndPushChildren(tile: Tile3D, frameState: FrameState, stack, depth): boolean {\n const {loadSiblings, skipLevelOfDetail} = this.options;\n\n const children = tile.children;\n\n // sort children tiles\n children.sort(this.compareDistanceToCamera.bind(this));\n\n // For traditional replacement refinement only refine if all children are loaded.\n // Empty tiles are exempt since it looks better if children stream in as they are loaded to fill the empty space.\n const checkRefines =\n tile.refine === TILE_REFINEMENT.REPLACE && tile.hasRenderContent && !skipLevelOfDetail;\n\n let hasVisibleChild = false;\n let refines = true;\n\n for (const child of children) {\n child._selectionDepth = depth;\n if (child.isVisibleAndInRequestVolume) {\n if (stack.find(child)) {\n stack.delete(child);\n }\n stack.push(child);\n hasVisibleChild = true;\n } else if (checkRefines || loadSiblings) {\n // Keep non-visible children loaded since they are still needed before the parent can refine.\n // Or loadSiblings is true so always load tiles regardless of visibility.\n this.loadTile(child, frameState);\n this.touchTile(child, frameState);\n }\n\n if (checkRefines) {\n let childRefines;\n if (!child._inRequestVolume) {\n childRefines = false;\n } else if (!child.hasRenderContent) {\n childRefines = this.executeEmptyTraversal(child, frameState);\n } else {\n childRefines = child.contentAvailable;\n }\n refines = refines && childRefines;\n\n if (!refines) {\n return false;\n }\n }\n }\n\n if (!hasVisibleChild) {\n refines = false;\n }\n return refines;\n }\n /* eslint-enable complexity, max-statements */\n\n updateTile(tile: Tile3D, frameState: FrameState): void {\n this.updateTileVisibility(tile, frameState);\n }\n\n // tile to render in the browser\n selectTile(tile: Tile3D, frameState: FrameState): void {\n if (this.shouldSelectTile(tile)) {\n // The tile can be selected right away and does not require traverseAndSelect\n tile._selectedFrame = frameState.frameNumber;\n this.selectedTiles[tile.id] = tile;\n }\n }\n\n // tile to load from server\n loadTile(tile: Tile3D, frameState: FrameState): void {\n if (this.shouldLoadTile(tile)) {\n tile._requestedFrame = frameState.frameNumber;\n tile._priority = tile._getPriority();\n this.requestedTiles[tile.id] = tile;\n }\n }\n\n // cache tile\n touchTile(tile: Tile3D, frameState: FrameState): void {\n tile.tileset._cache.touch(tile);\n tile._touchedFrame = frameState.frameNumber;\n }\n\n // tile should be visible\n // tile should have children\n // tile LoD (level of detail) is not sufficient under current viewport\n canTraverse(\n tile: Tile3D,\n frameState: FrameState,\n useParentMetric: boolean = false,\n ignoreVisibility: boolean = false\n ): boolean {\n if (!tile.hasChildren) {\n return false;\n }\n\n // cesium specific\n if (tile.hasTilesetContent) {\n // Traverse external this to visit its root tile\n // Don't traverse if the subtree is expired because it will be destroyed\n return !tile.contentExpired;\n }\n\n if (!ignoreVisibility && !tile.isVisibleAndInRequestVolume) {\n return false;\n }\n\n return this.shouldRefine(tile, frameState, useParentMetric);\n }\n\n shouldLoadTile(tile: Tile3D): boolean {\n // if request tile is in current frame\n // and has unexpired render content\n return tile.hasUnloadedContent || tile.contentExpired;\n }\n\n shouldSelectTile(tile: Tile3D): boolean {\n // if select tile is in current frame\n // and content available\n return tile.contentAvailable && !this.options.skipLevelOfDetail;\n }\n\n /** Decide if tile LoD (level of detail) is not sufficient under current viewport */\n shouldRefine(tile: Tile3D, frameState: FrameState, useParentMetric: boolean = false): boolean {\n let screenSpaceError = tile._screenSpaceError;\n if (useParentMetric) {\n screenSpaceError = tile.getScreenSpaceError(frameState, true);\n }\n\n return screenSpaceError > this.options.maximumScreenSpaceError;\n }\n\n updateTileVisibility(tile: Tile3D, frameState: FrameState): void {\n const viewportIds: string[] = [];\n if (this.options.viewportTraversersMap) {\n for (const key in this.options.viewportTraversersMap) {\n const value = this.options.viewportTraversersMap[key];\n if (value === frameState.viewport.id) {\n viewportIds.push(key);\n }\n }\n } else {\n viewportIds.push(frameState.viewport.id);\n }\n tile.updateVisibility(frameState, viewportIds);\n }\n\n // UTILITIES\n\n compareDistanceToCamera(b: Tile3D, a: Tile3D): number {\n return b._distanceToCamera - a._distanceToCamera;\n }\n\n anyChildrenVisible(tile: Tile3D, frameState: FrameState): boolean {\n let anyVisible = false;\n for (const child of tile.children) {\n // @ts-expect-error\n child.updateVisibility(frameState);\n // @ts-expect-error\n anyVisible = anyVisible || child.isVisibleAndInRequestVolume;\n }\n return anyVisible;\n }\n\n // Depth-first traversal that checks if all nearest descendants with content are loaded.\n // Ignores visibility.\n executeEmptyTraversal(root: Tile3D, frameState: FrameState): boolean {\n let allDescendantsLoaded = true;\n const stack = this._emptyTraversalStack;\n\n stack.push(root);\n\n while (stack.length > 0 && allDescendantsLoaded) {\n const tile = stack.pop();\n\n this.updateTile(tile, frameState);\n\n if (!tile.isVisibleAndInRequestVolume) {\n // Load tiles that aren't visible since they are still needed for the parent to refine\n this.loadTile(tile, frameState);\n }\n\n this.touchTile(tile, frameState);\n\n // Only traverse if the tile is empty - traversal stop at descendants with content\n const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState, false, true);\n\n if (traverse) {\n const children = tile.children;\n for (const child of children) {\n // eslint-disable-next-line max-depth\n if (stack.find(child)) {\n stack.delete(child);\n }\n stack.push(child);\n }\n } else if (!tile.contentAvailable) {\n allDescendantsLoaded = false;\n }\n }\n\n return allDescendantsLoaded;\n }\n}\n"],"mappings":";AAGA,SAAQA,YAAY,QAAO,wBAAwB;AACnD,SAAQC,eAAe,QAAO,cAAc;AAa5C,OAAO,MAAMC,aAA8C,GAAG;EAC5DC,YAAY,EAAE,KAAK;EACnBC,iBAAiB,EAAE,KAAK;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gBAAgB,IAAI,IAAI,CAACH,WAAW,CAACH,IAAI,EAAEtB,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC;MAE1F,IAAIM,QAAQ,EAAE;QACZ,MAAMsC,QAAQ,GAAGtB,IAAI,CAACsB,QAAQ;QAC9B,KAAK,MAAMC,KAAK,IAAID,QAAQ,EAAE;UAE5B,IAAI1B,KAAK,CAACoC,IAAI,CAACT,KAAK,CAAC,EAAE;YACrB3B,KAAK,CAACqC,MAAM,CAACV,KAAK,CAAC;UACrB;UACA3B,KAAK,CAACE,IAAI,CAACyB,KAAK,CAAC;QACnB;MACF,CAAC,MAAM,IAAI,CAACvB,IAAI,CAACqC,gBAAgB,EAAE;QACjCiC,oBAAoB,GAAG,KAAK;MAC9B;IACF;IAEA,OAAOA,oBAAoB;EAC7B;AACF"}
@@ -1,4 +1,5 @@
1
- export declare function get3dTilesOptions(tileset: any): {
2
- assetGltfUpAxis: any;
1
+ import type { Tileset3D } from '../tileset-3d';
2
+ export declare function get3dTilesOptions(tileset: Tileset3D): {
3
+ assetGltfUpAxis: 'X' | 'Y' | 'Z';
3
4
  };
4
5
  //# sourceMappingURL=3d-tiles-options.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"3d-tiles-options.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/3d-tiles-options.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,OAAO,KAAA;;EAIxC"}
1
+ {"version":3,"file":"3d-tiles-options.d.ts","sourceRoot":"","sources":["../../../src/tileset/helpers/3d-tiles-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAE7C,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG;IAAC,eAAe,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;CAAC,CAIxF"}
@@ -1,7 +1,9 @@
1
1
  import { Matrix4 } from '@math.gl/core';
2
2
  import type { Tileset3D } from './tileset-3d';
3
+ import type { DoublyLinkedListNode } from '../utils/doubly-linked-list-node';
3
4
  import { FrameState } from './helpers/frame-state';
4
5
  import { CartographicBounds } from './helpers/bounding-volume';
6
+ import { TilesetTraverser } from './tileset-traverser';
5
7
  /**
6
8
  * @param tileset - Tileset3D instance
7
9
  * @param header - tile header - JSON loaded from a dataset
@@ -29,48 +31,58 @@ export declare class Tile3D {
29
31
  refine: number;
30
32
  type: string;
31
33
  contentUrl: string;
32
- lodMetricType: string;
34
+ /** Different refinement algorithms used by I3S and 3D tiles */
35
+ lodMetricType: 'geometricError' | 'maxScreenThreshold';
36
+ /** The error, in meters, introduced if this tile is rendered and its children are not. */
33
37
  lodMetricValue: number;
38
+ /** @todo math.gl is not exporting BoundingVolume base type? */
34
39
  boundingVolume: any;
40
+ /**
41
+ * The tile's content. This represents the actual tile's payload,
42
+ * not the content's metadata in the tileset JSON file.
43
+ */
35
44
  content: any;
36
- contentState: any;
45
+ contentState: number;
37
46
  gpuMemoryUsageInBytes: number;
47
+ /** The tile's children - an array of Tile3D objects. */
38
48
  children: Tile3D[];
39
49
  depth: number;
40
50
  viewportIds: any[];
41
51
  transform: Matrix4;
42
52
  extensions: any;
53
+ /** TODO Cesium 3d tiles specific */
43
54
  implicitTiling?: any;
44
- userData: {
45
- [key: string]: any;
46
- };
55
+ /** Container to store application specific data */
56
+ userData: Record<string, any>;
47
57
  computedTransform: any;
48
58
  hasEmptyContent: boolean;
49
59
  hasTilesetContent: boolean;
50
- traverser: object;
51
- private _cacheNode;
60
+ traverser: TilesetTraverser;
61
+ /** Used by TilesetCache */
62
+ _cacheNode: DoublyLinkedListNode | null;
52
63
  private _frameNumber;
53
- private _lodJudge;
54
64
  private _expireDate;
55
65
  private _expiredContent;
56
- private _shouldRefine;
57
66
  private _boundingBox?;
67
+ /** updated every frame for tree traversal and rendering optimizations: */
58
68
  _distanceToCamera: number;
59
- private _centerZDepth;
60
- private _screenSpaceError;
69
+ _screenSpaceError: number;
61
70
  private _visibilityPlaneMask;
62
- private _visible?;
63
- private _inRequestVolume;
64
- private _stackLength;
65
- private _selectionDepth;
66
- private _touchedFrame;
67
- private _visitedFrame;
68
- private _selectedFrame;
69
- private _requestedFrame;
70
- private _priority;
71
+ private _visible;
71
72
  private _contentBoundingVolume;
72
73
  private _viewerRequestVolume;
73
74
  _initialTransform: Matrix4;
75
+ _priority: number;
76
+ _selectedFrame: number;
77
+ _requestedFrame: number;
78
+ _selectionDepth: number;
79
+ _touchedFrame: number;
80
+ _centerZDepth: number;
81
+ _shouldRefine: boolean;
82
+ _stackLength: number;
83
+ _visitedFrame: number;
84
+ _inRequestVolume: boolean;
85
+ _lodJudge: any;
74
86
  /**
75
87
  * @constructs
76
88
  * Create a Tile3D instance
@@ -135,6 +147,10 @@ export declare class Tile3D {
135
147
  * but it can be still loaded in memory
136
148
  */
137
149
  unselect(): void;
150
+ /**
151
+ * Memory usage of tile on GPU
152
+ */
153
+ _getGpuMemoryUsageInBytes(): number;
138
154
  _getPriority(): number;
139
155
  /**
140
156
  * Requests the tile's content.
@@ -184,7 +200,7 @@ export declare class Tile3D {
184
200
  _updateBoundingVolume(header: any): void;
185
201
  _updateTransform(parentTransform?: Matrix4): void;
186
202
  _getLoaderSpecificOptions(loaderId: any): {
187
- assetGltfUpAxis: any;
203
+ assetGltfUpAxis: "X" | "Y" | "Z";
188
204
  } | {
189
205
  _tileOptions: {
190
206
  attributeUrls: any;
@@ -1 +1 @@
1
- {"version":3,"file":"tile-3d.d.ts","sourceRoot":"","sources":["../../src/tileset/tile-3d.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,OAAO,EAAC,MAAM,eAAe,CAAC;AAM/C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAGL,kBAAkB,EACnB,MAAM,2BAA2B,CAAC;AAYnC;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;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 class Tile3D {
34
34
  */
35
35
  // eslint-disable-next-line max-statements
36
36
  constructor(tileset, header, parentHeader, extendedId = '') {
37
- // PUBLIC MEMBERS
38
- // original tile data
39
- this.header = header;
40
- // The tileset containing this tile.
41
- this.tileset = tileset;
42
- this.id = extendedId || header.id;
43
- this.url = header.url;
44
- // This tile's parent or `undefined` if this tile is the root.
45
- // @ts-ignore
46
- this.parent = parentHeader;
47
- this.refine = this._getRefine(header.refine);
48
- this.type = header.type;
49
- this.contentUrl = header.contentUrl;
50
- // The error, in meters, introduced if this tile is rendered and its children are not.
37
+ /** Different refinement algorithms used by I3S and 3D tiles */
51
38
  this.lodMetricType = 'geometricError';
39
+ /** The error, in meters, introduced if this tile is rendered and its children are not. */
52
40
  this.lodMetricValue = 0;
53
- // Specifies the type of refine that is used when traversing this tile for rendering.
41
+ /** @todo math.gl is not exporting BoundingVolume base type? */
54
42
  this.boundingVolume = null;
55
- // The tile's content. This represents the actual tile's payload,
56
- // not the content's metadata in the tileset JSON file.
43
+ /**
44
+ * The tile's content. This represents the actual tile's payload,
45
+ * not the content's metadata in the tileset JSON file.
46
+ */
57
47
  this.content = null;
58
48
  this.contentState = constants_1.TILE_CONTENT_STATE.UNLOADED;
59
49
  this.gpuMemoryUsageInBytes = 0;
60
- // The tile's children - an array of Tile3D objects.
50
+ /** The tile's children - an array of Tile3D objects. */
61
51
  this.children = [];
62
- this.hasEmptyContent = false;
63
- this.hasTilesetContent = false;
64
52
  this.depth = 0;
65
53
  this.viewportIds = [];
66
- // Container to store application specific data
67
- this.userData = {};
54
+ this.transform = new core_1.Matrix4();
68
55
  this.extensions = null;
69
- // PRIVATE MEMBERS
70
- this._priority = 0;
71
- this._touchedFrame = 0;
72
- this._visitedFrame = 0;
73
- this._selectedFrame = 0;
74
- this._requestedFrame = 0;
75
- this._screenSpaceError = 0;
56
+ /** TODO Cesium 3d tiles specific */
57
+ this.implicitTiling = null;
58
+ /** Container to store application specific data */
59
+ this.userData = {};
60
+ this.hasEmptyContent = false;
61
+ this.hasTilesetContent = false;
62
+ this.traverser = new tileset_traverser_1.TilesetTraverser({});
63
+ /** Used by TilesetCache */
76
64
  this._cacheNode = null;
77
65
  this._frameNumber = null;
78
- this._cacheNode = null;
79
- this.traverser = new tileset_traverser_1.TilesetTraverser({});
80
- this._shouldRefine = false;
66
+ // TODO Cesium 3d tiles specific
67
+ this._expireDate = null;
68
+ this._expiredContent = null;
69
+ /** updated every frame for tree traversal and rendering optimizations: */
81
70
  this._distanceToCamera = 0;
82
- this._centerZDepth = 0;
71
+ this._screenSpaceError = 0;
83
72
  this._visible = undefined;
84
- this._inRequestVolume = false;
85
- this._stackLength = 0;
86
- this._selectionDepth = 0;
87
73
  this._initialTransform = new core_1.Matrix4();
88
- this.transform = new core_1.Matrix4();
74
+ // Used by traverser, cannot be marked private
75
+ this._priority = 0;
76
+ this._selectedFrame = 0;
77
+ this._requestedFrame = 0;
78
+ this._selectionDepth = 0;
79
+ this._touchedFrame = 0;
80
+ this._centerZDepth = 0;
81
+ this._shouldRefine = false;
82
+ this._stackLength = 0;
83
+ this._visitedFrame = 0;
84
+ this._inRequestVolume = false;
85
+ this._lodJudge = null; // TODO i3s specific, needs to remove
86
+ // PUBLIC MEMBERS
87
+ // original tile data
88
+ this.header = header;
89
+ // The tileset containing this tile.
90
+ this.tileset = tileset;
91
+ this.id = extendedId || header.id;
92
+ this.url = header.url;
93
+ // This tile's parent or `undefined` if this tile is the root.
94
+ // @ts-ignore
95
+ this.parent = parentHeader;
96
+ this.refine = this._getRefine(header.refine);
97
+ this.type = header.type;
98
+ this.contentUrl = header.contentUrl;
89
99
  this._initializeLodMetric(header);
90
100
  this._initializeTransforms(header);
91
101
  this._initializeBoundingVolumes(header);
92
102
  this._initializeContent(header);
93
103
  this._initializeRenderingState(header);
94
- // TODO i3s specific, needs to remove
95
- this._lodJudge = null;
96
- // TODO Cesium 3d tiles specific
97
- this._expireDate = null;
98
- this._expiredContent = null;
99
- this.implicitTiling = null;
100
104
  Object.seal(this);
101
105
  }
102
106
  destroy() {
@@ -200,6 +204,12 @@ class Tile3D {
200
204
  unselect() {
201
205
  this._selectedFrame = 0;
202
206
  }
207
+ /**
208
+ * Memory usage of tile on GPU
209
+ */
210
+ _getGpuMemoryUsageInBytes() {
211
+ return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;
212
+ }
203
213
  /*
204
214
  * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.
205
215
  * Tiles are prioritized by screen space error.
@@ -266,6 +276,7 @@ class Tile3D {
266
276
  const options = {
267
277
  ...this.tileset.loadOptions,
268
278
  [loader.id]: {
279
+ // @ts-expect-error
269
280
  ...this.tileset.loadOptions[loader.id],
270
281
  isTileset: this.type === 'json',
271
282
  ...this._getLoaderSpecificOptions(loader.id)
@@ -533,6 +544,9 @@ class Tile3D {
533
544
  if (this._isTileset()) {
534
545
  this.hasTilesetContent = true;
535
546
  }
547
+ else {
548
+ this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();
549
+ }
536
550
  }
537
551
  _updateBoundingVolume(header) {
538
552
  // Update the bounding volumes