{
  "version": 3,
  "sources": ["../src/index.ts", "../src/tileset/tileset-3d.ts", "../src/utils/doubly-linked-list-node.ts", "../src/utils/doubly-linked-list.ts", "../src/tileset/tileset-cache.ts", "../src/tileset/helpers/transform-utils.ts", "../src/tileset/helpers/frame-state.ts", "../src/tileset/helpers/zoom.ts", "../src/tileset/tile-3d.ts", "../src/constants.ts", "../src/tileset/helpers/bounding-volume.ts", "../src/tileset/helpers/tiles-3d-lod.ts", "../src/tileset/helpers/i3s-lod.ts", "../src/tileset/helpers/3d-tiles-options.ts", "../src/utils/managed-array.ts", "../src/tileset/tileset-traverser.ts", "../src/tileset/format-3d-tiles/tileset-3d-traverser.ts", "../src/tileset/format-i3s/i3s-tileset-traverser.ts", "../src/tileset/format-i3s/i3s-pending-tiles-register.ts", "../src/tileset/format-i3s/i3s-tile-manager.ts"],
  "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type {Tileset3DProps} from './tileset/tileset-3d';\nexport {Tileset3D} from './tileset/tileset-3d';\nexport {Tile3D} from './tileset/tile-3d';\n\nexport {TilesetTraverser} from './tileset/tileset-traverser';\nexport {TilesetCache} from './tileset/tileset-cache';\n\nexport {createBoundingVolume} from './tileset/helpers/bounding-volume';\nexport {calculateTransformProps} from './tileset/helpers/transform-utils';\n\nexport {getFrameState} from './tileset/helpers/frame-state';\nexport {getLodStatus} from './tileset/helpers/i3s-lod';\n\nexport {\n  TILE_CONTENT_STATE,\n  TILE_REFINEMENT,\n  TILE_TYPE,\n  TILESET_TYPE,\n  LOD_METRIC_TYPE\n} from './constants';\n", "// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Stats} from '@probe.gl/stats';\nimport {RequestScheduler, path, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport {TilesetCache} from './tileset-cache';\nimport {calculateTransformProps} from './helpers/transform-utils';\nimport {FrameState, getFrameState, limitSelectedTiles} from './helpers/frame-state';\nimport {getZoomFromBoundingVolume, getZoomFromExtent, getZoomFromFullExtent} from './helpers/zoom';\n\nimport type {GeospatialViewport, Viewport} from '../types';\nimport {Tile3D} from './tile-3d';\nimport {TILESET_TYPE} from '../constants';\n\nimport {TilesetTraverser} from './tileset-traverser';\n\n// TODO - these should be moved into their respective modules\nimport {Tileset3DTraverser} from './format-3d-tiles/tileset-3d-traverser';\nimport {I3STilesetTraverser} from './format-i3s/i3s-tileset-traverser';\n\nexport type TilesetJSON = any;\n\n/*\nexport type TilesetJSON = {\n    loader;\n    // could be  3d tiles, i3s\n    type: 'I3S' | '3DTILES';\n    /** The url to the top level tileset JSON file. *\n    url: string;\n    basePath?: string;\n    // Geometric error when the tree is not rendered at all\n    lodMetricType: string;\n    lodMetricValue: number;\n    root: {\n      refine: string;\n      [key: string]: unknown;\n    },\n    [key: string]: unknown;\n};\n*/\n\nexport type Tileset3DProps = {\n  // loading\n  throttleRequests?: boolean;\n  maxRequests?: number;\n  loadOptions?: LoaderOptions;\n  loadTiles?: boolean;\n  basePath?: string;\n  maximumMemoryUsage?: number;\n  memoryCacheOverflow?: number;\n  maximumTilesSelected?: number;\n  debounceTime?: number;\n\n  // Metadata\n  description?: string;\n  attributions?: string[];\n\n  // Transforms\n  ellipsoid?: object;\n  modelMatrix?: Matrix4;\n\n  // Traversal\n  maximumScreenSpaceError?: number;\n  memoryAdjustedScreenSpaceError?: boolean;\n  viewportTraversersMap?: any;\n  updateTransforms?: boolean;\n  viewDistanceScale?: number;\n\n  // Callbacks\n  onTileLoad?: (tile: Tile3D) => any;\n  onTileUnload?: (tile: Tile3D) => any;\n  onTileError?: (tile: Tile3D, message: string, url: string) => any;\n  contentLoader?: (tile: Tile3D) => Promise<void>;\n  onTraversalComplete?: (selectedTiles: Tile3D[]) => Tile3D[];\n  onUpdate?: () => void;\n};\n\ntype Props = {\n  description: string;\n  ellipsoid: object;\n  /** A 4x4 transformation matrix this transforms the entire tileset. */\n  modelMatrix: Matrix4;\n  /** Set to false to disable network request throttling */\n  throttleRequests: boolean;\n  /** Number of simultaneous requsts, if throttleRequests is true */\n  maxRequests: number;\n  /* Maximum amount of GPU memory (in MB) that may be used to cache tiles. */\n  maximumMemoryUsage: number;\n  /* The maximum additional memory (in MB) to allow for cache headroom before adjusting the screen spacer error */\n  memoryCacheOverflow: number;\n  /** Maximum number limit of tiles selected for show. 0 means no limit */\n  maximumTilesSelected: number;\n  /** Delay time before the tileset traversal. It prevents traversal requests spam.*/\n  debounceTime: number;\n  /** Callback. Indicates this a tile's content was loaded */\n  onTileLoad: (tile: Tile3D) => void;\n  /** Callback. Indicates this a tile's content was unloaded (cache full) */\n  onTileUnload: (tile: Tile3D) => void;\n  /** Callback. Indicates this a tile's content failed to load */\n  onTileError: (tile: Tile3D, message: string, url: string) => void;\n  /** Callback. Allows post-process selectedTiles right after traversal. */\n  onTraversalComplete: (selectedTiles: Tile3D[]) => Tile3D[];\n  /** Callback. Called when the set of selected tiles changes. */\n  onUpdate: () => void;\n  /** The maximum screen space error used to drive level of detail refinement. */\n  maximumScreenSpaceError: number;\n  /** Whether to adjust the maximum screen space error to comply with the maximum memory limitation */\n  memoryAdjustedScreenSpaceError: boolean;\n  viewportTraversersMap: Record<string, any> | null;\n  attributions: string[];\n  loadTiles: boolean;\n  loadOptions: LoaderOptions;\n  updateTransforms: boolean;\n  /** View distance scale modifier */\n  viewDistanceScale: number;\n  basePath: string;\n  /** Optional async tile content loader */\n  contentLoader?: (tile: Tile3D) => Promise<void>;\n  /** @todo I3S specific knowledge should be moved to I3S module */\n  i3s: Record<string, any>;\n};\n\nconst DEFAULT_PROPS: Props = {\n  description: '',\n  ellipsoid: Ellipsoid.WGS84,\n  modelMatrix: new Matrix4(),\n  throttleRequests: true,\n  maxRequests: 64,\n  /** Default memory values optimized for viewing mesh-based 3D Tiles on both mobile and desktop devices */\n  maximumMemoryUsage: 32,\n  memoryCacheOverflow: 1,\n  maximumTilesSelected: 0,\n  debounceTime: 0,\n  onTileLoad: () => {},\n  onTileUnload: () => {},\n  onTileError: () => {},\n  onTraversalComplete: (selectedTiles: Tile3D[]) => selectedTiles,\n  onUpdate: () => {},\n  contentLoader: undefined,\n  viewDistanceScale: 1.0,\n  maximumScreenSpaceError: 8,\n  memoryAdjustedScreenSpaceError: false,\n  loadTiles: true,\n  updateTransforms: true,\n  viewportTraversersMap: null,\n  loadOptions: {fetch: {}},\n  attributions: [],\n  basePath: '',\n  i3s: {}\n};\n\n// Tracked Stats\nconst TILES_TOTAL = 'Tiles In Tileset(s)';\nconst TILES_IN_MEMORY = 'Tiles In Memory';\nconst TILES_IN_VIEW = 'Tiles In View';\nconst TILES_RENDERABLE = 'Tiles To Render';\nconst TILES_LOADED = 'Tiles Loaded';\nconst TILES_LOADING = 'Tiles Loading';\nconst TILES_UNLOADED = 'Tiles Unloaded';\nconst TILES_LOAD_FAILED = 'Failed Tile Loads';\nconst POINTS_COUNT = 'Points/Vertices';\nconst TILES_GPU_MEMORY = 'Tile Memory Use';\nconst MAXIMUM_SSE = 'Maximum Screen Space Error';\n\n/**\n * The Tileset loading and rendering flow is as below,\n * A rendered (i.e. deck.gl `Tile3DLayer`) triggers `tileset.update()` after a `tileset` is loaded\n * `tileset` starts traversing the tile tree and update `requestTiles` (tiles of which content need\n * to be fetched) and `selectedTiles` (tiles ready for rendering under the current viewport).\n * `Tile3DLayer` will update rendering based on `selectedTiles`.\n * `Tile3DLayer` also listens to `onTileLoad` callback and trigger another round of `update and then traversal`\n * when new tiles are loaded.\n\n * As I3S tileset have stored `tileHeader` file (metadata) and tile content files (geometry, texture, ...) separately.\n * During each traversal, it issues `tilHeader` requests if that `tileHeader` is not yet fetched,\n * after the tile header is fulfilled, it will resume the traversal starting from the tile just fetched (not root).\n\n * Tile3DLayer\n *      |\n *  await load(tileset)\n *      |\n *  tileset.update()\n *      |                async load tileHeader\n *  tileset.traverse() -------------------------- Queued\n *      |        resume traversal after fetched  |\n *      |----------------------------------------|\n *      |\n *      |                     async load tile content\n * tilset.requestedTiles  ----------------------------- RequestScheduler\n *                                                             |\n * tilset.selectedTiles (ready for rendering)                  |\n *      |         Listen to                                    |\n *   Tile3DLayer ----------- onTileLoad  ----------------------|\n *      |                         |   notify new tile is available\n *   updateLayers                 |\n *                       tileset.update // trigger another round of update\n*/\nexport class Tileset3D {\n  // props: Tileset3DProps;\n  options: Props;\n  loadOptions: LoaderOptions;\n\n  type: TILESET_TYPE;\n  tileset: TilesetJSON;\n  loader: LoaderWithParser;\n  url: string;\n  basePath: string;\n  modelMatrix: Matrix4;\n  ellipsoid: any;\n  lodMetricType: string;\n  lodMetricValue: number;\n  refine: string;\n  root: Tile3D | null = null;\n  roots: Record<string, Tile3D> = {};\n  /** @todo any->unknown */\n  asset: Record<string, any> = {};\n\n  // Metadata for the entire tileset\n  description: string = '';\n  properties: any;\n\n  extras: any = null;\n  attributions: any = {};\n  credits: any = {};\n\n  stats: Stats;\n\n  /** flags that contain information about data types in nested tiles */\n  contentFormats = {draco: false, meshopt: false, dds: false, ktx2: false};\n\n  // view props\n  cartographicCenter: Vector3 | null = null;\n  cartesianCenter: Vector3 | null = null;\n  zoom: number = 1;\n  boundingVolume: any = null;\n\n  /** Updated based on the camera position and direction */\n  dynamicScreenSpaceErrorComputedDensity: number = 0.0;\n\n  // METRICS\n\n  /**\n   * The maximum amount of GPU memory (in MB) that may be used to cache tiles\n   * Tiles not in view are unloaded to enforce private\n   */\n  maximumMemoryUsage: number = 32;\n\n  /** The total amount of GPU memory in bytes used by the tileset. */\n  gpuMemoryUsageInBytes: number = 0;\n\n  /**\n   * If loading the level of detail required by maximumScreenSpaceError\n   * results in the memory usage exceeding maximumMemoryUsage (GPU), level of detail refinement\n   * will instead use this (larger) adjusted screen space error to achieve the\n   * best possible visual quality within the available memory.\n   */\n  memoryAdjustedScreenSpaceError: number = 0.0;\n\n  private _cacheBytes: number = 0;\n  private _cacheOverflowBytes: number = 0;\n\n  /** Update tracker. increase in each update cycle. */\n  _frameNumber: number = 0;\n  private _queryParams: Record<string, string> = {};\n  private _extensionsUsed: string[] = [];\n  private _tiles: Record<string, Tile3D> = {};\n\n  /** counter for tracking tiles requests */\n  private _pendingCount: number = 0;\n\n  /** Hold traversal results */\n  selectedTiles: Tile3D[] = [];\n\n  // TRAVERSAL\n  traverseCounter: number = 0;\n  geometricError: number = 0;\n  private lastUpdatedVieports: Viewport[] | Viewport | null = null;\n  private _requestedTiles: Tile3D[] = [];\n  private _emptyTiles: Tile3D[] = [];\n  private frameStateData: any = {};\n\n  _traverser: TilesetTraverser;\n  _cache = new TilesetCache();\n  _requestScheduler: RequestScheduler;\n\n  /** Tile IDs held visible during transitions until replacements have drawn */\n  private _heldTiles: Set<string> = new Set();\n\n  // Promise tracking\n  private updatePromise: Promise<number> | null = null;\n  tilesetInitializationPromise: Promise<void>;\n\n  /**\n   * Create a new Tileset3D\n   * @param json\n   * @param props\n   */\n  // eslint-disable-next-line max-statements\n  constructor(tileset: TilesetJSON, options?: Tileset3DProps) {\n    // PUBLIC MEMBERS\n    this.options = {...DEFAULT_PROPS, ...options};\n    // raw data\n    this.tileset = tileset;\n    this.loader = tileset.loader;\n    // could be  3d tiles, i3s\n    this.type = tileset.type;\n    // The url to a tileset JSON file.\n    this.url = tileset.url;\n    this.basePath = tileset.basePath || path.dirname(this.url);\n    this.modelMatrix = this.options.modelMatrix;\n    this.ellipsoid = this.options.ellipsoid;\n\n    // Geometric error when the tree is not rendered at all\n    this.lodMetricType = tileset.lodMetricType;\n    this.lodMetricValue = tileset.lodMetricValue;\n    this.refine = tileset.root.refine;\n\n    this.loadOptions = this.options.loadOptions || {};\n\n    // TRAVERSAL\n    this._traverser = this._initializeTraverser();\n    this._requestScheduler = new RequestScheduler({\n      throttleRequests: this.options.throttleRequests,\n      maxRequests: this.options.maxRequests\n    });\n\n    this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;\n    this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;\n    this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;\n\n    // METRICS\n    // The total amount of GPU memory in bytes used by the tileset.\n    this.stats = new Stats({id: this.url});\n    this._initializeStats();\n\n    this.tilesetInitializationPromise = this._initializeTileSet(tileset);\n  }\n\n  /** Release resources */\n  destroy(): void {\n    this._destroy();\n  }\n\n  /** Is the tileset loaded (update needs to have been called at least once) */\n  isLoaded(): boolean {\n    // Check that `_frameNumber !== 0` which means that update was called at least once\n    return this._pendingCount === 0 && this._frameNumber !== 0 && this._requestedTiles.length === 0;\n  }\n\n  get tiles(): object[] {\n    return Object.values(this._tiles);\n  }\n\n  get frameNumber(): number {\n    return this._frameNumber;\n  }\n\n  get queryParams(): string {\n    return new URLSearchParams(this._queryParams).toString();\n  }\n\n  setProps(props: Tileset3DProps): void {\n    this.options = {...this.options, ...props};\n  }\n\n  /** @deprecated */\n  // setOptions(options: Tileset3DProps): void {\n  //   this.options = {...this.options, ...options};\n  // }\n\n  /**\n   * Return a loadable tile url for a specific tile subpath\n   * @param tilePath a tile subpath\n   */\n  getTileUrl(tilePath: string): string {\n    const isDataUrl = tilePath.startsWith('data:');\n    if (isDataUrl) {\n      return tilePath;\n    }\n\n    let tileUrl = tilePath;\n    if (this.queryParams.length) {\n      tileUrl = `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`;\n    }\n    return tileUrl;\n  }\n\n  // TODO CESIUM specific\n  hasExtension(extensionName: string): boolean {\n    return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);\n  }\n\n  /**\n   * Update visible tiles relying on a list of viewports\n   * @param viewports - list of viewports\n   * @deprecated\n   */\n  update(viewports: Viewport[] | Viewport | null = null) {\n    // eslint-disable-next-line @typescript-eslint/no-floating-promises\n    this.tilesetInitializationPromise.then(() => {\n      if (!viewports && this.lastUpdatedVieports) {\n        viewports = this.lastUpdatedVieports;\n      } else {\n        this.lastUpdatedVieports = viewports;\n      }\n      if (viewports) {\n        this.doUpdate(viewports);\n      }\n    });\n  }\n\n  /**\n   * Update visible tiles relying on a list of viewports.\n   * Do it with debounce delay to prevent update spam\n   * @param viewports viewports\n   * @returns Promise of new frameNumber\n   */\n  async selectTiles(viewports: Viewport[] | Viewport | null = null): Promise<number> {\n    await this.tilesetInitializationPromise;\n    if (viewports) {\n      this.lastUpdatedVieports = viewports;\n    }\n    if (!this.updatePromise) {\n      this.updatePromise = new Promise<number>((resolve) => {\n        setTimeout(() => {\n          if (this.lastUpdatedVieports) {\n            this.doUpdate(this.lastUpdatedVieports);\n          }\n          resolve(this._frameNumber);\n          this.updatePromise = null;\n        }, this.options.debounceTime);\n      });\n    }\n    return this.updatePromise;\n  }\n\n  adjustScreenSpaceError(): void {\n    if (this.gpuMemoryUsageInBytes < this._cacheBytes) {\n      this.memoryAdjustedScreenSpaceError = Math.max(\n        this.memoryAdjustedScreenSpaceError / 1.02,\n        this.options.maximumScreenSpaceError\n      );\n    } else if (this.gpuMemoryUsageInBytes > this._cacheBytes + this._cacheOverflowBytes) {\n      this.memoryAdjustedScreenSpaceError *= 1.02;\n    }\n  }\n  /**\n   * Update visible tiles relying on a list of viewports\n   * @param viewports viewports\n   */\n  // eslint-disable-next-line max-statements, complexity\n  private doUpdate(viewports: Viewport[] | Viewport): void {\n    if ('loadTiles' in this.options && !this.options.loadTiles) {\n      return;\n    }\n    if (this.traverseCounter > 0) {\n      return;\n    }\n    const preparedViewports = viewports instanceof Array ? viewports : [viewports];\n\n    this._cache.reset();\n    this._frameNumber++;\n    this.traverseCounter = preparedViewports.length;\n    const viewportsToTraverse: string[] = [];\n    // First loop to decrement traverseCounter\n    for (const viewport of preparedViewports) {\n      const id = viewport.id;\n      if (this._needTraverse(id)) {\n        viewportsToTraverse.push(id);\n      } else {\n        this.traverseCounter--;\n      }\n    }\n\n    // Second loop to traverse\n    for (const viewport of preparedViewports) {\n      const id = viewport.id;\n      if (!this.roots[id]) {\n        this.roots[id] = this._initializeTileHeaders(this.tileset, null);\n      }\n\n      if (!viewportsToTraverse.includes(id)) {\n        continue; // eslint-disable-line no-continue\n      }\n      const frameState = getFrameState(viewport as GeospatialViewport, this._frameNumber);\n      this._traverser.traverse(this.roots[id], frameState, this.options);\n    }\n  }\n\n  /**\n   * Check if traversal is needed for particular viewport\n   * @param {string} viewportId - id of a viewport\n   * @return {boolean}\n   */\n  _needTraverse(viewportId: string): boolean {\n    let traverserId = viewportId;\n    if (this.options.viewportTraversersMap) {\n      traverserId = this.options.viewportTraversersMap[viewportId];\n    }\n    if (traverserId !== viewportId) {\n      return false;\n    }\n\n    return true;\n  }\n\n  /**\n   * The callback to post-process tiles after traversal procedure\n   * @param frameState - frame state for tile culling\n   */\n  _onTraversalEnd(frameState: FrameState): void {\n    const id = frameState.viewport.id;\n    if (!this.frameStateData[id]) {\n      this.frameStateData[id] = {selectedTiles: [], _requestedTiles: [], _emptyTiles: []};\n    }\n    const currentFrameStateData = this.frameStateData[id];\n    const selectedTiles = Object.values(this._traverser.selectedTiles);\n    const [filteredSelectedTiles, unselectedTiles] = limitSelectedTiles(\n      selectedTiles,\n      frameState,\n      this.options.maximumTilesSelected\n    );\n    currentFrameStateData.selectedTiles = filteredSelectedTiles;\n    for (const tile of unselectedTiles) {\n      tile.unselect();\n    }\n\n    currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);\n    currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);\n\n    this.traverseCounter--;\n    if (this.traverseCounter > 0) {\n      return;\n    }\n\n    this._updateTiles();\n  }\n\n  /**\n   * Update tiles relying on data from all traversers\n   */\n  _updateTiles(): void {\n    const previousSelectedTiles = this.selectedTiles;\n    this.selectedTiles = [];\n    this._requestedTiles = [];\n    this._emptyTiles = [];\n\n    for (const frameStateKey in this.frameStateData) {\n      const frameStateDataValue = this.frameStateData[frameStateKey];\n      this.selectedTiles = this.selectedTiles.concat(frameStateDataValue.selectedTiles);\n      this._requestedTiles = this._requestedTiles.concat(frameStateDataValue._requestedTiles);\n      this._emptyTiles = this._emptyTiles.concat(frameStateDataValue._emptyTiles);\n    }\n\n    this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);\n\n    // Transition hold: keep recently-deselected tiles visible until all their\n    // replacements have been drawn by the renderer (e.g. deck.gl).\n    // Without this, there are single-frame flashes during REPLACE refinement transitions.\n    const selectedIds = new Set(this.selectedTiles.map((t) => t.id));\n    const hasUndrawnTiles = this.selectedTiles.some((t) => !t.tileDrawn);\n\n    // Keep recently-deselected tiles visible while new tiles haven't drawn yet\n    let heldBackCount = 0;\n    if (hasUndrawnTiles) {\n      for (const tileId of selectedIds) {\n        this._heldTiles.add(tileId);\n      }\n      for (const tileId of this._heldTiles) {\n        // Skip tiles that are already selected\n        if (selectedIds.has(tileId)) continue; // eslint-disable-line no-continue\n\n        // Keep tiles previously drawn selected\n        const tile = this._tiles[tileId];\n        if (tile && tile.contentAvailable) {\n          tile._selectedFrame = this._frameNumber;\n          this.selectedTiles.push(tile);\n          heldBackCount++;\n        } else {\n          this._heldTiles.delete(tileId);\n        }\n      }\n    } else {\n      // Store current selected ids for next frame\n      this._heldTiles = selectedIds;\n    }\n\n    if (heldBackCount > 0) {\n      // Schedule another update so that once all replacement tiles\n      // have drawn, the held tiles get released\n      setTimeout(() => {\n        this.selectTiles();\n      }, 0);\n    }\n\n    for (const tile of this.selectedTiles) {\n      this._tiles[tile.id] = tile;\n    }\n\n    this._loadTiles();\n    this._unloadTiles();\n    this._updateStats();\n\n    if (this._tilesChanged(previousSelectedTiles, this.selectedTiles)) {\n      this.options.onUpdate();\n    }\n  }\n\n  _tilesChanged(oldSelectedTiles: Tile3D[], selectedTiles: Tile3D[]): boolean {\n    if (oldSelectedTiles.length !== selectedTiles.length) {\n      return true;\n    }\n    const set1 = new Set(oldSelectedTiles.map((t) => t.id));\n    const set2 = new Set(selectedTiles.map((t) => t.id));\n    let changed = oldSelectedTiles.filter((x) => !set2.has(x.id)).length > 0;\n    changed = changed || selectedTiles.filter((x) => !set1.has(x.id)).length > 0;\n    return changed;\n  }\n\n  _loadTiles(): void {\n    // Sort requests by priority before making any requests.\n    // This makes it less likely this requests will be cancelled after being issued.\n    this._requestedTiles.sort((a, b) => a._priority - b._priority);\n    for (const tile of this._requestedTiles) {\n      if (tile.contentUnloaded) {\n        // eslint-disable-next-line @typescript-eslint/no-floating-promises\n        this._loadTile(tile);\n      }\n    }\n  }\n\n  _unloadTiles(): void {\n    // unload tiles from cache when hit maximumMemoryUsage\n    this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));\n  }\n\n  _updateStats(): void {\n    let tilesRenderable = 0;\n    let pointsRenderable = 0;\n    for (const tile of this.selectedTiles) {\n      if (tile.contentAvailable && tile.content) {\n        tilesRenderable++;\n        if (tile.content.pointCount) {\n          pointsRenderable += tile.content.pointCount;\n        } else {\n          // Calculate vertices for non point cloud tiles.\n          pointsRenderable += tile.content.vertexCount;\n        }\n      }\n    }\n\n    this.stats.get(TILES_IN_VIEW).count = this.selectedTiles.length;\n    this.stats.get(TILES_RENDERABLE).count = tilesRenderable;\n    this.stats.get(POINTS_COUNT).count = pointsRenderable;\n    this.stats.get(MAXIMUM_SSE).count = this.memoryAdjustedScreenSpaceError;\n  }\n\n  async _initializeTileSet(tilesetJson: TilesetJSON): Promise<void> {\n    if (this.type === TILESET_TYPE.I3S) {\n      this.calculateViewPropsI3S();\n      tilesetJson.root = await tilesetJson.root;\n    }\n    this.root = this._initializeTileHeaders(tilesetJson, null);\n\n    if (this.type === TILESET_TYPE.TILES3D) {\n      this._initializeTiles3DTileset(tilesetJson);\n      this.calculateViewPropsTiles3D();\n    }\n\n    if (this.type === TILESET_TYPE.I3S) {\n      this._initializeI3STileset();\n    }\n  }\n\n  /**\n   * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.\n   * These metrics help apps center view on tileset\n   * For I3S there is extent (<1.8 version) or fullExtent (>=1.8 version) to calculate view props\n   * @returns\n   */\n  private calculateViewPropsI3S(): void {\n    // for I3S 1.8 try to calculate with fullExtent\n    const fullExtent = this.tileset.fullExtent;\n    if (fullExtent) {\n      const {xmin, xmax, ymin, ymax, zmin, zmax} = fullExtent;\n      this.cartographicCenter = new Vector3(\n        xmin + (xmax - xmin) / 2,\n        ymin + (ymax - ymin) / 2,\n        zmin + (zmax - zmin) / 2\n      );\n      this.cartesianCenter = new Vector3();\n      Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, this.cartesianCenter);\n      this.zoom = getZoomFromFullExtent(fullExtent, this.cartographicCenter, this.cartesianCenter);\n      return;\n    }\n    // for I3S 1.6-1.7 try to calculate with extent\n    const extent = this.tileset.store?.extent;\n    if (extent) {\n      const [xmin, ymin, xmax, ymax] = extent;\n      this.cartographicCenter = new Vector3(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, 0);\n      this.cartesianCenter = new Vector3();\n      Ellipsoid.WGS84.cartographicToCartesian(this.cartographicCenter, this.cartesianCenter);\n      this.zoom = getZoomFromExtent(extent, this.cartographicCenter, this.cartesianCenter);\n      return;\n    }\n    // eslint-disable-next-line no-console\n    console.warn('Extent is not defined in the tileset header');\n    this.cartographicCenter = new Vector3();\n    this.zoom = 1;\n    return;\n  }\n\n  /**\n   * Called during initialize Tileset to initialize the tileset's cartographic center (longitude, latitude) and zoom.\n   * These metrics help apps center view on tileset.\n   * For 3DTiles the root tile data is used to calculate view props.\n   * @returns\n   */\n  private calculateViewPropsTiles3D() {\n    const root = this.root as Tile3D;\n    const {center} = root.boundingVolume;\n    // TODO - handle all cases\n    if (!center) {\n      // eslint-disable-next-line no-console\n      console.warn('center was not pre-calculated for the root tile');\n      this.cartographicCenter = new Vector3();\n      this.zoom = 1;\n      return;\n    }\n\n    // cartographic coordinates are undefined at the center of the ellipsoid\n    if (center[0] !== 0 || center[1] !== 0 || center[2] !== 0) {\n      this.cartographicCenter = new Vector3();\n      Ellipsoid.WGS84.cartesianToCartographic(center, this.cartographicCenter);\n    } else {\n      this.cartographicCenter = new Vector3(0, 0, -Ellipsoid.WGS84.radii[0]);\n    }\n    this.cartesianCenter = center;\n    this.zoom = getZoomFromBoundingVolume(root.boundingVolume, this.cartographicCenter);\n  }\n\n  _initializeStats() {\n    this.stats.get(TILES_TOTAL);\n    this.stats.get(TILES_LOADING);\n    this.stats.get(TILES_IN_MEMORY);\n    this.stats.get(TILES_IN_VIEW);\n    this.stats.get(TILES_RENDERABLE);\n    this.stats.get(TILES_LOADED);\n    this.stats.get(TILES_UNLOADED);\n    this.stats.get(TILES_LOAD_FAILED);\n    this.stats.get(POINTS_COUNT);\n    this.stats.get(TILES_GPU_MEMORY, 'memory');\n    this.stats.get(MAXIMUM_SSE);\n  }\n\n  // Installs the main tileset JSON file or a tileset JSON file referenced from a tile.\n  // eslint-disable-next-line max-statements\n  _initializeTileHeaders(tilesetJson: TilesetJSON, parentTileHeader?: any) {\n    // A tileset JSON file referenced from a tile may exist in a different directory than the root tileset.\n    // Get the basePath relative to the external tileset.\n    const rootTile = new Tile3D(this, tilesetJson.root, parentTileHeader); // resource\n\n    // If there is a parentTileHeader, add the root of the currently loading tileset\n    // to parentTileHeader's children, and update its depth.\n    if (parentTileHeader) {\n      parentTileHeader.children.push(rootTile);\n      rootTile.depth = parentTileHeader.depth + 1;\n    }\n\n    // 3DTiles knows the hierarchy beforehand\n    if (this.type === TILESET_TYPE.TILES3D) {\n      const stack: Tile3D[] = [];\n      stack.push(rootTile);\n\n      while (stack.length > 0) {\n        const tile = stack.pop() as Tile3D;\n        this.stats.get(TILES_TOTAL).incrementCount();\n        const children = tile.header.children || [];\n        for (const childHeader of children) {\n          const childTile = new Tile3D(this, childHeader, tile);\n\n          // Special handling for Google\n          // A session key must be used for all tile requests\n          if (childTile.contentUrl?.includes('?session=')) {\n            const url = new URL(childTile.contentUrl);\n            const session = url.searchParams.get('session');\n            // eslint-disable-next-line max-depth\n            if (session) {\n              this._queryParams.session = session;\n            }\n          }\n\n          tile.children.push(childTile);\n          childTile.depth = tile.depth + 1;\n          stack.push(childTile);\n        }\n      }\n    }\n\n    return rootTile;\n  }\n\n  _initializeTraverser(): TilesetTraverser {\n    let TraverserClass;\n    const type = this.type;\n    switch (type) {\n      case TILESET_TYPE.TILES3D:\n        TraverserClass = Tileset3DTraverser;\n        break;\n      case TILESET_TYPE.I3S:\n        TraverserClass = I3STilesetTraverser;\n        break;\n      default:\n        TraverserClass = TilesetTraverser;\n    }\n\n    return new TraverserClass({\n      basePath: this.basePath,\n      onTraversalEnd: this._onTraversalEnd.bind(this)\n    });\n  }\n\n  _destroyTileHeaders(parentTile: Tile3D): void {\n    this._destroySubtree(parentTile);\n  }\n\n  async _loadTile(tile: Tile3D): Promise<void> {\n    let loaded;\n    try {\n      this._onStartTileLoading();\n      loaded = await tile.loadContent();\n    } catch (error: unknown) {\n      this._onTileLoadError(tile, error instanceof Error ? error : new Error('load failed'));\n    } finally {\n      this._onEndTileLoading();\n      this._onTileLoad(tile, loaded);\n    }\n  }\n\n  _onTileLoadError(tile: Tile3D, error: Error): void {\n    this.stats.get(TILES_LOAD_FAILED).incrementCount();\n\n    const message = error.message || error.toString();\n    const url = tile.url;\n    // TODO - Allow for probe log to be injected instead of console?\n    console.error(`A 3D tile failed to load: ${tile.url} ${message}`); // eslint-disable-line\n    this.options.onTileError(tile, message, url);\n  }\n\n  _onTileLoad(tile: Tile3D, loaded: boolean): void {\n    if (!loaded) {\n      return;\n    }\n\n    if (this.type === TILESET_TYPE.I3S) {\n      // We can't calculate tiles total in I3S in advance so we calculate it dynamically.\n      const nodesInNodePages = this.tileset?.nodePagesTile?.nodesInNodePages || 0;\n      this.stats.get(TILES_TOTAL).reset();\n      this.stats.get(TILES_TOTAL).addCount(nodesInNodePages);\n    }\n\n    // add coordinateOrigin and modelMatrix to tile\n    if (tile && tile.content) {\n      calculateTransformProps(tile, tile.content);\n    }\n\n    this.updateContentTypes(tile);\n    this._addTileToCache(tile);\n    this.options.onTileLoad(tile);\n  }\n\n  /**\n   * Update information about data types in nested tiles\n   * @param tile instance of a nested Tile3D\n   */\n  private updateContentTypes(tile: Tile3D) {\n    if (this.type === TILESET_TYPE.I3S) {\n      if (tile.header.isDracoGeometry) {\n        this.contentFormats.draco = true;\n      }\n      switch (tile.header.textureFormat) {\n        case 'dds':\n          this.contentFormats.dds = true;\n          break;\n        case 'ktx2':\n          this.contentFormats.ktx2 = true;\n          break;\n        default:\n      }\n    } else if (this.type === TILESET_TYPE.TILES3D) {\n      const {extensionsRemoved = []} = tile.content?.gltf || {};\n      if (extensionsRemoved.includes('KHR_draco_mesh_compression')) {\n        this.contentFormats.draco = true;\n      }\n      if (extensionsRemoved.includes('EXT_meshopt_compression')) {\n        this.contentFormats.meshopt = true;\n      }\n      if (extensionsRemoved.includes('KHR_texture_basisu')) {\n        this.contentFormats.ktx2 = true;\n      }\n    }\n  }\n\n  _onStartTileLoading() {\n    this._pendingCount++;\n    this.stats.get(TILES_LOADING).incrementCount();\n  }\n\n  _onEndTileLoading() {\n    this._pendingCount--;\n    this.stats.get(TILES_LOADING).decrementCount();\n  }\n\n  _addTileToCache(tile: Tile3D) {\n    this._cache.add(this, tile, (tileset) => tileset._updateCacheStats(tile));\n  }\n\n  _updateCacheStats(tile) {\n    this.stats.get(TILES_LOADED).incrementCount();\n    this.stats.get(TILES_IN_MEMORY).incrementCount();\n\n    // TODO: Calculate GPU memory usage statistics for a tile.\n    this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;\n\n    this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;\n\n    // Adjust SSE based on cache limits\n    if (this.options.memoryAdjustedScreenSpaceError) {\n      this.adjustScreenSpaceError();\n    }\n  }\n\n  _unloadTile(tile) {\n    this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;\n\n    this.stats.get(TILES_IN_MEMORY).decrementCount();\n    this.stats.get(TILES_UNLOADED).incrementCount();\n    this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;\n\n    this.options.onTileUnload(tile);\n    tile.unloadContent();\n  }\n\n  // Traverse the tree and destroy all tiles\n  _destroy() {\n    const stack: Tile3D[] = [];\n\n    if (this.root) {\n      stack.push(this.root);\n    }\n\n    while (stack.length > 0) {\n      const tile: Tile3D = stack.pop() as Tile3D;\n\n      for (const child of tile.children) {\n        stack.push(child);\n      }\n\n      this._destroyTile(tile);\n    }\n    this.root = null;\n  }\n\n  // Traverse the tree and destroy all sub tiles\n  _destroySubtree(tile) {\n    const root = tile;\n    const stack: Tile3D[] = [];\n    stack.push(root);\n    while (stack.length > 0) {\n      tile = stack.pop();\n      for (const child of tile.children) {\n        stack.push(child);\n      }\n      if (tile !== root) {\n        this._destroyTile(tile);\n      }\n    }\n    root.children = [];\n  }\n\n  _destroyTile(tile) {\n    this._cache.unloadTile(this, tile);\n    this._unloadTile(tile);\n    tile.destroy();\n  }\n\n  _initializeTiles3DTileset(tilesetJson) {\n    if (tilesetJson.queryString) {\n      const searchParams = new URLSearchParams(tilesetJson.queryString);\n      const queryParams = Object.fromEntries(searchParams.entries());\n      this._queryParams = {...this._queryParams, ...queryParams};\n    }\n\n    this.asset = tilesetJson.asset;\n    if (!this.asset) {\n      throw new Error('Tileset must have an asset property.');\n    }\n    if (\n      this.asset.version !== '0.0' &&\n      this.asset.version !== '1.0' &&\n      this.asset.version !== '1.1'\n    ) {\n      throw new Error('The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.');\n    }\n\n    // Note: `asset.tilesetVersion` is version of the tileset itself (not the version of the 3D TILES standard)\n    // We add this version as a `v=1.0` query param to fetch the right version and not get an older cached version\n    if ('tilesetVersion' in this.asset) {\n      this._queryParams.v = this.asset.tilesetVersion;\n    }\n\n    // TODO - ion resources have a credits property we can use for additional attribution.\n    this.credits = {\n      attributions: this.options.attributions || []\n    };\n    this.description = this.options.description || '';\n\n    // Gets the tileset's properties dictionary object, which contains metadata about per-feature properties.\n    this.properties = tilesetJson.properties;\n    this.geometricError = tilesetJson.geometricError;\n    this._extensionsUsed = tilesetJson.extensionsUsed || [];\n    // Returns the extras property at the top of the tileset JSON (application specific metadata).\n    this.extras = tilesetJson.extras;\n  }\n\n  _initializeI3STileset() {\n    const i3sOptions = this.loadOptions.i3s;\n    if (i3sOptions && typeof i3sOptions === 'object' && 'token' in i3sOptions) {\n      this._queryParams.token = (i3sOptions as Record<string, unknown>).token as string;\n    }\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/**\n * Doubly linked list node\n * @private\n */\nexport class DoublyLinkedListNode {\n  item;\n  previous;\n  next;\n\n  constructor(item, previous, next) {\n    this.item = item;\n    this.previous = previous;\n    this.next = next;\n  }\n}\n", "// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {DoublyLinkedListNode} from './doubly-linked-list-node';\n\n/**\n * Doubly linked list\n * @private\n */\nexport class DoublyLinkedList {\n  head: DoublyLinkedListNode | null = null;\n  tail: DoublyLinkedListNode | null = null;\n  _length = 0;\n\n  get length() {\n    return this._length;\n  }\n\n  /**\n   * Adds the item to the end of the list\n   * @param {*} [item]\n   * @return {DoublyLinkedListNode}\n   */\n  add(item) {\n    const node = new DoublyLinkedListNode(item, this.tail, null);\n\n    if (this.tail) {\n      this.tail.next = node;\n      this.tail = node;\n    } else {\n      this.head = node;\n      this.tail = node;\n    }\n\n    ++this._length;\n\n    return node;\n  }\n\n  /**\n   * Removes the given node from the list\n   * @param {DoublyLinkedListNode} node\n   */\n  remove(node) {\n    if (!node) {\n      return;\n    }\n\n    if (node.previous && node.next) {\n      node.previous.next = node.next;\n      node.next.previous = node.previous;\n    } else if (node.previous) {\n      // Remove last node\n      node.previous.next = null;\n      this.tail = node.previous;\n    } else if (node.next) {\n      // Remove first node\n      node.next.previous = null;\n      this.head = node.next;\n    } else {\n      // Remove last node in the linked list\n      this.head = null;\n      this.tail = null;\n    }\n\n    node.next = null;\n    node.previous = null;\n\n    --this._length;\n  }\n\n  /**\n   * Moves nextNode after node\n   * @param {DoublyLinkedListNode} node\n   * @param {DoublyLinkedListNode} nextNode\n   */\n  splice(node, nextNode) {\n    if (node === nextNode) {\n      return;\n    }\n\n    // Remove nextNode, then insert after node\n    this.remove(nextNode);\n    this._insert(node, nextNode);\n  }\n\n  _insert(node, nextNode) {\n    const oldNodeNext = node.next;\n    node.next = nextNode;\n\n    // nextNode is the new tail\n    if (this.tail === node) {\n      this.tail = nextNode;\n    } else {\n      oldNodeNext.previous = nextNode;\n    }\n\n    nextNode.next = oldNodeNext;\n    nextNode.previous = node;\n\n    ++this._length;\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport type {Tileset3D} from './tileset-3d';\nimport type {Tile3D} from './tile-3d';\nimport {DoublyLinkedList} from '../utils/doubly-linked-list';\n\n/**\n * Stores tiles with content loaded.\n * @private\n */\nexport class TilesetCache {\n  private _list: DoublyLinkedList;\n  private _sentinel: any;\n  private _trimTiles: boolean;\n\n  constructor() {\n    // [head, sentinel) -> tiles that weren't selected this frame and may be removed from the cache\n    // (sentinel, tail] -> tiles that were selected this frame\n    this._list = new DoublyLinkedList();\n    this._sentinel = this._list.add('sentinel');\n    this._trimTiles = false;\n  }\n\n  reset(): void {\n    // Move sentinel node to the tail so, at the start of the frame, all tiles\n    // may be potentially replaced.  Tiles are moved to the right of the sentinel\n    // when they are selected so they will not be replaced.\n    this._list.splice(this._list.tail, this._sentinel);\n  }\n\n  touch(tile: Tile3D): void {\n    const node = tile._cacheNode;\n    if (node) {\n      this._list.splice(this._sentinel, node);\n    }\n  }\n\n  add(\n    tileset: Tileset3D,\n    tile: Tile3D,\n    addCallback?: (tileset: Tileset3D, tile: Tile3D) => void\n  ): void {\n    if (!tile._cacheNode) {\n      tile._cacheNode = this._list.add(tile);\n\n      if (addCallback) {\n        addCallback(tileset, tile);\n      }\n    }\n  }\n\n  unloadTile(\n    tileset: Tileset3D,\n    tile: Tile3D,\n    unloadCallback?: (tileset: Tileset3D, tile: Tile3D) => void\n  ): void {\n    const node = tile._cacheNode;\n    if (!node) {\n      return;\n    }\n\n    this._list.remove(node);\n    tile._cacheNode = null;\n    if (unloadCallback) {\n      unloadCallback(tileset, tile);\n    }\n  }\n\n  unloadTiles(tileset, unloadCallback): void {\n    const trimTiles = this._trimTiles;\n    this._trimTiles = false;\n\n    const list = this._list;\n\n    const maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;\n\n    // Traverse the list only to the sentinel since tiles/nodes to the\n    // right of the sentinel were used this frame.\n    // The sub-list to the left of the sentinel is ordered from LRU to MRU.\n    const sentinel = this._sentinel;\n    let node = list.head;\n\n    while (\n      node !== sentinel &&\n      (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)\n    ) {\n      // @ts-expect-error\n      const tile = node.item;\n      // @ts-expect-error\n      node = node.next;\n      this.unloadTile(tileset, tile, unloadCallback);\n    }\n  }\n\n  trim(): void {\n    this._trimTiles = true;\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {assert} from '@loaders.gl/loader-utils';\n\nimport {Tile3D} from '../tile-3d';\n\nexport function calculateTransformProps(tileHeader: Tile3D, tile: Tile3D['content']) {\n  assert(tileHeader);\n  assert(tile);\n\n  const {rtcCenter, gltfUpAxis} = tile;\n  const {\n    computedTransform,\n    boundingVolume: {center}\n  } = tileHeader;\n\n  let modelMatrix = new Matrix4(computedTransform);\n\n  // Translate if appropriate\n  if (rtcCenter) {\n    modelMatrix.translate(rtcCenter);\n  }\n\n  // glTF models need to be rotated from Y to Z up\n  // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n  switch (gltfUpAxis) {\n    case 'Z':\n      break;\n    case 'Y':\n      const rotationY = new Matrix4().rotateX(Math.PI / 2);\n      modelMatrix = modelMatrix.multiplyRight(rotationY);\n      break;\n    case 'X':\n      const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n      modelMatrix = modelMatrix.multiplyRight(rotationX);\n      break;\n    default:\n      break;\n  }\n\n  // Scale/offset positions if normalized integers\n  if (tile.isQuantized) {\n    modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n  }\n\n  // Option 1: Cartesian matrix and origin\n  const cartesianOrigin = new Vector3(center);\n\n  tile.cartesianModelMatrix = modelMatrix;\n  tile.cartesianOrigin = cartesianOrigin;\n\n  // Option 2: Cartographic matrix and origin\n  const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n    cartesianOrigin,\n    new Vector3()\n  );\n  const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n  const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n\n  tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n  tile.cartographicOrigin = cartographicOrigin;\n\n  // Absorb glTF root node matrix into model matrices for Float32 precision.\n  // The glTF root node matrix (applied as sceneModelMatrix in the shader) may contain\n  // ECEF-scale translations (~millions of meters). When both cartographicModelMatrix\n  // and sceneModelMatrix are applied in the Float32 GPU shader, catastrophic cancellation\n  // occurs causing visible seams between adjacent tiles. By combining them here in Float64,\n  // the result has small ENU-scale values that preserve precision.\n  const rootNode = _getRootNode(tile);\n  if (rootNode) {\n    tile.cartesianModelMatrix = new Matrix4(modelMatrix).multiplyRight(rootNode.matrix);\n    tile.cartographicModelMatrix.multiplyRight(rootNode.matrix);\n    rootNode.matrix = Matrix4.IDENTITY;\n  }\n\n  // Deprecated, drop\n  if (!tile.coordinateSystem) {\n    tile.modelMatrix = tile.cartographicModelMatrix;\n  }\n}\n\nconst TRANSLATION_LIMIT_SQUARED = 10e5 ** 2; // 100km\n\n/**\n * Returns the glTF root node if it has a matrix with earth-scale translations (> 100km).\n * These large translations cause Float32 precision issues when applied in the GPU shader.\n */\nfunction _getRootNode(tile: Tile3D['content']): {matrix: number[]} | null {\n  const gltf = tile.gltf;\n  if (!gltf) {\n    return null;\n  }\n\n  const sceneIndex = typeof gltf.scene === 'number' ? gltf.scene : 0;\n  const scene = gltf.scenes?.[sceneIndex];\n  const rootNode = scene?.nodes?.[0];\n  if (!rootNode?.matrix) return null;\n\n  // Extract translation and compare magnitude (meters) to limit\n  const m = rootNode.matrix;\n  const translationMagnitude = m[12] * m[12] + m[13] * m[13] + m[14] * m[14];\n  if (translationMagnitude <= TRANSLATION_LIMIT_SQUARED) return null;\n\n  return rootNode;\n}\n", "import {Tile3D} from '@loaders.gl/tiles';\nimport {Vector3} from '@math.gl/core';\nimport {CullingVolume, Plane} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {GeospatialViewport, Viewport} from '../../types';\n\nexport type FrameState = {\n  camera: {\n    position: number[];\n    direction: number[];\n    up: number[];\n  };\n  viewport: GeospatialViewport;\n  topDownViewport: GeospatialViewport; // Use it to calculate projected radius for a tile\n  height: number;\n  cullingVolume: CullingVolume;\n  frameNumber: number; // TODO: This can be the same between updates, what number is unique for between updates?\n  sseDenominator: number; // Assumes fovy = 60 degrees\n};\n\nconst scratchVector = new Vector3();\nconst scratchPosition = new Vector3();\nconst cullingVolume = new CullingVolume([\n  new Plane(),\n  new Plane(),\n  new Plane(),\n  new Plane(),\n  new Plane(),\n  new Plane()\n]);\n\n// Extracts a frame state appropriate for tile culling from a deck.gl viewport\n// TODO - this could likely be generalized and merged back into deck.gl for other culling scenarios\nexport function getFrameState(viewport: GeospatialViewport, frameNumber: number): FrameState {\n  // Traverse and and request. Update _selectedTiles so that we know what to render.\n  // Traverse and and request. Update _selectedTiles so that we know what to render.\n  const {cameraDirection, cameraUp, height} = viewport;\n  const {metersPerUnit} = viewport.distanceScales;\n\n  // TODO - Ellipsoid.eastNorthUpToFixedFrame() breaks on raw array, create a Vector.\n  // TODO - Ellipsoid.eastNorthUpToFixedFrame() takes a cartesian, is that intuitive?\n  const viewportCenterCartesian = worldToCartesian(viewport, viewport.center);\n  const enuToFixedTransform = Ellipsoid.WGS84.eastNorthUpToFixedFrame(viewportCenterCartesian);\n\n  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n  const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(\n    cameraPositionCartographic,\n    new Vector3()\n  );\n\n  // These should still be normalized as the transform has scale 1 (goes from meters to meters)\n  const cameraDirectionCartesian = new Vector3(\n    // @ts-ignore\n    enuToFixedTransform.transformAsVector(new Vector3(cameraDirection).scale(metersPerUnit))\n  ).normalize();\n  const cameraUpCartesian = new Vector3(\n    // @ts-ignore\n    enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))\n  ).normalize();\n\n  commonSpacePlanesToWGS84(viewport);\n\n  const ViewportClass = viewport.constructor;\n  const {longitude, latitude, width, bearing, zoom} = viewport;\n  // @ts-ignore\n  const topDownViewport = new ViewportClass({\n    longitude,\n    latitude,\n    height,\n    width,\n    bearing,\n    zoom,\n    pitch: 0\n  });\n\n  // TODO: make a file/class for frameState and document what needs to be attached to this so that traversal can function\n  return {\n    camera: {\n      position: cameraPositionCartesian,\n      direction: cameraDirectionCartesian,\n      up: cameraUpCartesian\n    },\n    viewport,\n    topDownViewport,\n    height,\n    cullingVolume,\n    frameNumber, // TODO: This can be the same between updates, what number is unique for between updates?\n    sseDenominator: 1.15 // Assumes fovy = 60 degrees\n  };\n}\n\n/**\n * Limit `tiles` array length with `maximumTilesSelected` number.\n * The criteria for this filtering is distance of a tile center\n * to the `frameState.viewport`'s longitude and latitude\n * @param tiles - tiles array to filter\n * @param frameState - frameState to calculate distances\n * @param maximumTilesSelected - maximal amount of tiles in the output array\n * @returns new tiles array\n */\nexport function limitSelectedTiles(\n  tiles: Tile3D[],\n  frameState: FrameState,\n  maximumTilesSelected: number\n): [Tile3D[], Tile3D[]] {\n  if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n    return [tiles, []];\n  }\n  // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n  const tuples: [number, number][] = [];\n  const {longitude: viewportLongitude, latitude: viewportLatitude} = frameState.viewport;\n  for (const [index, tile] of tiles.entries()) {\n    const [longitude, latitude] = tile.header.mbs;\n    const deltaLon = Math.abs(viewportLongitude - longitude);\n    const deltaLat = Math.abs(viewportLatitude - latitude);\n    const distance = Math.sqrt(deltaLat * deltaLat + deltaLon * deltaLon);\n    tuples.push([index, distance]);\n  }\n  const tuplesSorted = tuples.sort((a, b) => a[1] - b[1]);\n  const selectedTiles: Tile3D[] = [];\n  for (let i = 0; i < maximumTilesSelected; i++) {\n    selectedTiles.push(tiles[tuplesSorted[i][0]]);\n  }\n  const unselectedTiles: Tile3D[] = [];\n  for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n    unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n  }\n\n  return [selectedTiles, unselectedTiles];\n}\n\nfunction commonSpacePlanesToWGS84(viewport) {\n  // Extract frustum planes based on current view.\n  const frustumPlanes = viewport.getFrustumPlanes();\n\n  // Get the near/far plane centers\n  const nearCenterCommon = closestPointOnPlane(frustumPlanes.near, viewport.cameraPosition);\n  const nearCenterCartesian = worldToCartesian(viewport, nearCenterCommon);\n  const cameraCartesian = worldToCartesian(viewport, viewport.cameraPosition, scratchPosition);\n\n  let i = 0;\n  cullingVolume.planes[i++].fromPointNormal(\n    nearCenterCartesian,\n    scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian)\n  );\n\n  for (const dir in frustumPlanes) {\n    if (dir === 'near') {\n      continue; // eslint-disable-line no-continue\n    }\n    const plane = frustumPlanes[dir];\n    const posCommon = closestPointOnPlane(plane, nearCenterCommon, scratchPosition);\n    const cartesianPos = worldToCartesian(viewport, posCommon, scratchPosition);\n\n    cullingVolume.planes[i++].fromPointNormal(\n      cartesianPos,\n      // Want the normal to point into the frustum since that's what culling expects\n      scratchVector.copy(nearCenterCartesian).subtract(cartesianPos)\n    );\n  }\n}\n\nfunction closestPointOnPlane(\n  plane: {distance: number; normal: Vector3},\n  refPoint: [number, number, number] | Vector3,\n  out: Vector3 = new Vector3()\n): Vector3 {\n  const distanceToRef = plane.normal.dot(refPoint);\n  out\n    .copy(plane.normal)\n    .scale(plane.distance - distanceToRef)\n    .add(refPoint);\n  return out;\n}\n\nfunction worldToCartesian(\n  viewport: Viewport,\n  point: number[] | Vector3,\n  out: Vector3 = new Vector3()\n): Vector3 {\n  const cartographicPos = viewport.unprojectPosition(point);\n  return Ellipsoid.WGS84.cartographicToCartesian(cartographicPos, out);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {BoundingRectangle} from '../../types';\n\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\n\nconst scratchVector = new Vector3();\n\n/**\n * Calculate appropriate zoom value for a particular boundingVolume\n * @param boundingVolume - the instance of bounding volume\n * @param cartorgraphicCenter - cartographic center of the bounding volume\n * @returns {number} - zoom value\n */\nexport function getZoomFromBoundingVolume(\n  boundingVolume: BoundingSphere | OrientedBoundingBox | BoundingRectangle,\n  cartorgraphicCenter: Vector3\n) {\n  if (boundingVolume instanceof OrientedBoundingBox) {\n    // OrientedBoundingBox\n    const {halfAxes} = boundingVolume;\n    const obbSize = getObbSize(halfAxes);\n    // Use WGS84_RADIUS_Z to allign with BoundingSphere algorithm\n    // Add the tile elevation value for correct zooming to elevated tiles\n    return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));\n  } else if (boundingVolume instanceof BoundingSphere) {\n    // BoundingSphere\n    const {radius} = boundingVolume;\n    // Add the tile elevation value for correct zooming to elevated tiles\n    return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));\n  } else if (boundingVolume.width && boundingVolume.height) {\n    // BoundingRectangle\n    const {width, height} = boundingVolume;\n    const zoomX = Math.log2(WGS84_RADIUS_X / width);\n    const zoomY = Math.log2(WGS84_RADIUS_Y / height);\n\n    return (zoomX + zoomY) / 2;\n  }\n\n  return 1;\n}\n\n/**\n * Calculate initial zoom for the tileset from 3D `fullExtent` defined in\n * the tileset metadata\n * @param fullExtent - 3D extent of the tileset\n * @param fullExtent.xmin - minimal longitude in decimal degrees\n * @param fullExtent.xmax - maximal longitude in decimal degrees\n * @param fullExtent.ymin - minimal latitude in decimal degrees\n * @param fullExtent.ymax - maximal latitude in decimal degrees\n * @param fullExtent.zmin - minimal elevation in meters\n * @param fullExtent.zmax - maximal elevation in meters\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromFullExtent(\n  fullExtent: {\n    xmin: number;\n    xmax: number;\n    ymin: number;\n    ymax: number;\n    zmin: number;\n    zmax: number;\n  },\n  cartorgraphicCenter: Vector3,\n  cartesianCenter: Vector3\n) {\n  Ellipsoid.WGS84.cartographicToCartesian(\n    [fullExtent.xmax, fullExtent.ymax, fullExtent.zmax],\n    scratchVector\n  );\n  const extentSize = Math.sqrt(\n    Math.pow(scratchVector[0] - cartesianCenter[0], 2) +\n      Math.pow(scratchVector[1] - cartesianCenter[1], 2) +\n      Math.pow(scratchVector[2] - cartesianCenter[2], 2)\n  );\n  return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\n}\n\n/**\n * Calculate initial zoom for the tileset from 2D `extent` defined in\n * the tileset metadata\n * @param extent - 2D extent of the tileset. It is array of 4 elements [xmin, ymin, xmax, ymax]\n * @param extent[0] - minimal longitude in decimal degrees\n * @param extent[1] - minimal latitude in decimal degrees\n * @param extent[2] - maximal longitude in decimal degrees\n * @param extent[3] - maximal latitude in decimal degrees\n * @param cartorgraphicCenter - tileset center in cartographic coordinate system\n * @param cartesianCenter - tileset center in cartesian coordinate system\n * @returns - initial zoom for the tileset\n */\nexport function getZoomFromExtent(\n  extent: [number, number, number, number],\n  cartorgraphicCenter: Vector3,\n  cartesianCenter: Vector3\n) {\n  const [xmin, ymin, xmax, ymax] = extent;\n  return getZoomFromFullExtent(\n    {xmin, xmax, ymin, ymax, zmin: 0, zmax: 0},\n    cartorgraphicCenter,\n    cartesianCenter\n  );\n}\n\nfunction getObbSize(halfAxes) {\n  halfAxes.getColumn(0, scratchVector);\n  const axeY = halfAxes.getColumn(1);\n  const axeZ = halfAxes.getColumn(2);\n  const farthestVertex = scratchVector.add(axeY).add(axeZ);\n  const size = farthestVertex.len();\n  return size;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {Vector3, Matrix4} from '@math.gl/core';\nimport {CullingVolume} from '@math.gl/culling';\n\nimport {load} from '@loaders.gl/core';\n\n// Note: circular dependency\nimport type {Tileset3D} from './tileset-3d';\nimport type {DoublyLinkedListNode} from '../utils/doubly-linked-list-node';\nimport {TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE} from '../constants';\n\nimport {FrameState} from './helpers/frame-state';\nimport {\n  createBoundingVolume,\n  getCartographicBounds,\n  CartographicBounds\n} from './helpers/bounding-volume';\nimport {getTiles3DScreenSpaceError} from './helpers/tiles-3d-lod';\nimport {getProjectedRadius} from './helpers/i3s-lod';\nimport {get3dTilesOptions} from './helpers/3d-tiles-options';\nimport {TilesetTraverser} from './tileset-traverser';\n\nconst scratchVector = new Vector3();\n\nfunction defined(x) {\n  return x !== undefined && x !== null;\n}\n\n/**\n * @param tileset - Tileset3D instance\n * @param header - tile header - JSON loaded from a dataset\n * @param parentHeader - parent Tile3D instance\n * @param extendedId - optional ID to separate copies of a tile for different viewports.\n *                              const extendedId = `${tile.id}-${frameState.viewport.id}`;\n */\nexport type Tile3DProps = {\n  tileset: Tileset3D;\n  header: Object;\n  parentHeader: Tile3D;\n  extendedId: string;\n};\n\n/**\n * A Tile3DHeader represents a tile as Tileset3D. When a tile is first created, its content is not loaded;\n * the content is loaded on-demand when needed based on the view.\n * Do not construct this directly, instead access tiles through {@link Tileset3D#tileVisible}.\n */\nexport class Tile3D {\n  tileset: Tileset3D;\n  header: any;\n  id: string;\n  url: string;\n  parent: Tile3D;\n  /* Specifies the type of refine that is used when traversing this tile for rendering. */\n  refine: TILE_REFINEMENT;\n  type: string;\n  contentUrl: string;\n  /** Different refinement algorithms used by I3S and 3D tiles */\n  lodMetricType: 'geometricError' | 'maxScreenThreshold' = 'geometricError';\n  /** The error, in meters, introduced if this tile is rendered and its children are not. */\n  lodMetricValue: number = 0;\n\n  /** @todo math.gl is not exporting BoundingVolume base type? */\n  boundingVolume: any = null;\n\n  /**\n   * The tile's content.  This represents the actual tile's payload,\n   * not the content's metadata in the tileset JSON file.\n   */\n  content: any = null;\n  contentState: number = TILE_CONTENT_STATE.UNLOADED;\n  gpuMemoryUsageInBytes: number = 0;\n\n  /** The tile's children - an array of Tile3D objects. */\n  children: Tile3D[] = [];\n  depth: number = 0;\n  viewportIds: any[] = [];\n  transform = new Matrix4();\n  extensions: any = null;\n  /** TODO Cesium 3d tiles specific */\n  implicitTiling?: any = null;\n\n  /** Container to store application specific data */\n  userData: Record<string, any> = {};\n\n  computedTransform: any;\n  hasEmptyContent: boolean = false;\n  hasTilesetContent: boolean = false;\n\n  traverser = new TilesetTraverser({});\n\n  /** Used by TilesetCache */\n  _cacheNode: DoublyLinkedListNode | null = null;\n\n  private _frameNumber: any = null;\n\n  // TODO Cesium 3d tiles specific\n  private _expireDate: any = null;\n  private _expiredContent: any = null;\n\n  private _boundingBox?: CartographicBounds = undefined;\n\n  /** updated every frame for tree traversal and rendering optimizations: */\n  public _distanceToCamera: number = 0;\n  _screenSpaceError: number = 0;\n  private _visibilityPlaneMask: any;\n  private _visible: boolean | undefined = undefined;\n\n  private _contentBoundingVolume: any;\n  private _viewerRequestVolume: any;\n\n  _initialTransform: Matrix4 = new Matrix4();\n\n  // Used by traverser, cannot be marked private\n  _priority: number = 0;\n  _selectedFrame: number = 0;\n  _requestedFrame: number = 0;\n  _selectionDepth: number = 0;\n  _touchedFrame: number = 0;\n  _centerZDepth: number = 0;\n  _shouldRefine: boolean = false;\n  _stackLength: number = 0;\n  _visitedFrame: number = 0;\n  _inRequestVolume: boolean = false;\n  _lodJudge: any = null; // TODO i3s specific, needs to remove\n\n  /**\n   * Indicates whether the tile has been drawn by the renderer.\n   * Defaults to true for backwards compatibility \u2014 renderers that support\n   * transition hold (e.g. deck.gl 9.3+) should set this to false on tile load,\n   * then back to true after first draw to avoid flashes (see deck.gl #7914).\n   */\n  tileDrawn: boolean = true;\n\n  /**\n   * @constructs\n   * Create a Tile3D instance\n   * @param tileset - Tileset3D instance\n   * @param header - tile header - JSON loaded from a dataset\n   * @param parentHeader - parent Tile3D instance\n   * @param extendedId - optional ID to separate copies of a tile for different viewports.\n   *    const extendedId = `${tile.id}-${frameState.viewport.id}`;\n   */\n  // eslint-disable-next-line max-statements\n  constructor(\n    tileset: Tileset3D,\n    header: {[key: string]: any},\n    parentHeader?: Tile3D,\n    extendedId = ''\n  ) {\n    // PUBLIC MEMBERS\n    // original tile data\n    this.header = header;\n\n    // The tileset containing this tile.\n    this.tileset = tileset;\n    this.id = extendedId || header.id;\n    this.url = header.url;\n\n    // This tile's parent or `undefined` if this tile is the root.\n    // @ts-ignore\n    this.parent = parentHeader;\n    this.refine = this._getRefine(header.refine);\n    this.type = header.type;\n    this.contentUrl = header.contentUrl;\n\n    this._initializeLodMetric(header);\n    this._initializeTransforms(header);\n    this._initializeBoundingVolumes(header);\n    this._initializeContent(header);\n    this._initializeRenderingState(header);\n\n    Object.seal(this);\n  }\n\n  destroy() {\n    this.header = null;\n  }\n\n  isDestroyed() {\n    return this.header === null;\n  }\n\n  get selected() {\n    return this._selectedFrame === this.tileset._frameNumber;\n  }\n\n  get isVisible() {\n    return this._visible;\n  }\n\n  get isVisibleAndInRequestVolume() {\n    return this._visible && this._inRequestVolume;\n  }\n\n  /** Returns true if tile is not an empty tile and not an external tileset */\n  get hasRenderContent() {\n    return !this.hasEmptyContent && !this.hasTilesetContent;\n  }\n\n  /** Returns true if tile has children */\n  get hasChildren() {\n    return this.children.length > 0 || (this.header.children && this.header.children.length > 0);\n  }\n\n  /**\n   * Determines if the tile's content is ready. This is automatically `true` for\n   * tiles with empty content.\n   */\n  get contentReady() {\n    return this.contentState === TILE_CONTENT_STATE.READY || this.hasEmptyContent;\n  }\n\n  /**\n   * Determines if the tile has available content to render.  `true` if the tile's\n   * content is ready or if it has expired content this renders while new content loads; otherwise,\n   */\n  get contentAvailable() {\n    return Boolean(\n      (this.contentReady && this.hasRenderContent) || (this._expiredContent && !this.contentFailed)\n    );\n  }\n\n  /** Returns true if tile has renderable content but it's unloaded */\n  get hasUnloadedContent() {\n    return this.hasRenderContent && this.contentUnloaded;\n  }\n\n  /**\n   * Determines if the tile's content has not be requested. `true` if tile's\n   * content has not be requested; otherwise, `false`.\n   */\n  get contentUnloaded() {\n    return this.contentState === TILE_CONTENT_STATE.UNLOADED;\n  }\n\n  /**\n   * Determines if the tile's content is expired. `true` if tile's\n   * content is expired; otherwise, `false`.\n   */\n  get contentExpired() {\n    return this.contentState === TILE_CONTENT_STATE.EXPIRED;\n  }\n\n  // Determines if the tile's content failed to load.  `true` if the tile's\n  // content failed to load; otherwise, `false`.\n  get contentFailed() {\n    return this.contentState === TILE_CONTENT_STATE.FAILED;\n  }\n\n  /**\n   * Distance from the tile's bounding volume center to the camera\n   */\n  get distanceToCamera(): number {\n    return this._distanceToCamera;\n  }\n\n  /**\n   * Screen space error for LOD selection\n   */\n  get screenSpaceError(): number {\n    return this._screenSpaceError;\n  }\n\n  /**\n   * Get bounding box in cartographic coordinates\n   * @returns [min, max] each in [longitude, latitude, altitude]\n   */\n  get boundingBox(): CartographicBounds {\n    if (!this._boundingBox) {\n      this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);\n    }\n    return this._boundingBox;\n  }\n\n  /** Get the tile's screen space error. */\n  getScreenSpaceError(frameState, useParentLodMetric) {\n    switch (this.tileset.type) {\n      case TILESET_TYPE.I3S:\n        return getProjectedRadius(this, frameState);\n      case TILESET_TYPE.TILES3D:\n        return getTiles3DScreenSpaceError(this, frameState, useParentLodMetric);\n      default:\n        // eslint-disable-next-line\n        throw new Error('Unsupported tileset type');\n    }\n  }\n\n  /**\n   * Make tile unselected than means it won't be shown\n   * but it can be still loaded in memory\n   */\n  unselect(): void {\n    this._selectedFrame = 0;\n  }\n\n  /**\n   * Memory usage of tile on GPU\n   */\n  _getGpuMemoryUsageInBytes(): number {\n    return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;\n  }\n\n  /*\n   * If skipLevelOfDetail is off try to load child tiles as soon as possible so that their parent can refine sooner.\n   * Tiles are prioritized by screen space error.\n   */\n  // eslint-disable-next-line complexity\n  _getPriority() {\n    const traverser = this.tileset._traverser;\n    const {skipLevelOfDetail} = traverser.options;\n\n    /*\n     * Tiles that are outside of the camera's frustum could be skipped if we are in 'ADD' mode\n     * or if we are using 'Skip Traversal' in 'REPLACE' mode.\n     * Otherewise, all 'touched' child tiles have to be loaded and displayed,\n     * this may include tiles that are outide of the camera frustum (so that we can hide the parent tile).\n     */\n    const maySkipTile = this.refine === TILE_REFINEMENT.ADD || skipLevelOfDetail;\n\n    // Check if any reason to abort\n    if (maySkipTile && !this.isVisible && this._visible !== undefined) {\n      return -1;\n    }\n    // Condition used in `cancelOutOfViewRequests` function in CesiumJS/Cesium3DTileset.js\n    if (this.tileset._frameNumber - this._touchedFrame >= 1) {\n      return -1;\n    }\n    if (this.contentState === TILE_CONTENT_STATE.UNLOADED) {\n      return -1;\n    }\n\n    // Based on the priority function `getPriorityReverseScreenSpaceError` in CesiumJS. Scheduling priority is based on the parent's screen space error when possible.\n    const parent = this.parent;\n    const useParentScreenSpaceError =\n      parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);\n    const screenSpaceError = useParentScreenSpaceError\n      ? parent._screenSpaceError\n      : this._screenSpaceError;\n\n    const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;\n\n    // Map higher SSE to lower values (e.g. root tile is highest priority)\n    return Math.max(rootScreenSpaceError - screenSpaceError, 0);\n  }\n\n  /**\n   *  Requests the tile's content.\n   * The request may not be made if the Request Scheduler can't prioritize it.\n   */\n  // eslint-disable-next-line max-statements, complexity\n  async loadContent(): Promise<boolean> {\n    if (this.hasEmptyContent) {\n      return false;\n    }\n\n    if (this.content) {\n      return true;\n    }\n\n    const expired = this.contentExpired;\n\n    if (expired) {\n      this._expireDate = null;\n    }\n\n    this.contentState = TILE_CONTENT_STATE.LOADING;\n\n    const requestToken = await this.tileset._requestScheduler.scheduleRequest(\n      this.id,\n      this._getPriority.bind(this)\n    );\n\n    if (!requestToken) {\n      // cancelled\n      this.contentState = TILE_CONTENT_STATE.UNLOADED;\n      return false;\n    }\n\n    try {\n      const contentUrl = this.tileset.getTileUrl(this.contentUrl);\n      // The content can be a binary tile ot a JSON tileset\n      const loader = this.tileset.loader;\n      const tilesetLoaderOptions =\n        (this.tileset.loadOptions[loader.id] as Record<string, unknown>) || {};\n      const options = {\n        ...this.tileset.loadOptions,\n        [loader.id]: {\n          ...tilesetLoaderOptions,\n          isTileset: this.type === 'json',\n          ...this._getLoaderSpecificOptions(loader.id)\n        } // TODO add typecheck - as const satisfies ...\n      };\n\n      this.content = await load(contentUrl, loader, options);\n\n      if (this.tileset.options.contentLoader) {\n        await this.tileset.options.contentLoader(this);\n      }\n\n      if (this._isTileset()) {\n        // Add tile headers for the nested tilset's subtree\n        // Async update of the tree should be fine since there would never be edits to the same node\n        // TODO - we need to capture the child tileset's URL\n        this.tileset._initializeTileHeaders(this.content, this);\n      }\n\n      this.contentState = TILE_CONTENT_STATE.READY;\n      this._onContentLoaded();\n      return true;\n    } catch (error) {\n      // Tile is unloaded before the content finishes loading\n      this.contentState = TILE_CONTENT_STATE.FAILED;\n      throw error;\n    } finally {\n      requestToken.done();\n    }\n  }\n\n  // Unloads the tile's content.\n  unloadContent() {\n    if (this.content && this.content.destroy) {\n      this.content.destroy();\n    }\n    this.content = null;\n    if (this.header.content && this.header.content.destroy) {\n      this.header.content.destroy();\n    }\n    this.header.content = null;\n    this.contentState = TILE_CONTENT_STATE.UNLOADED;\n    this.tileDrawn = true;\n    return true;\n  }\n\n  /**\n   * Update the tile's visibility\n   * @param {Object} frameState - frame state for tile culling\n   * @param {string[]} viewportIds - a list of viewport ids that show this tile\n   * @return {void}\n   */\n  updateVisibility(frameState, viewportIds) {\n    if (this._frameNumber === frameState.frameNumber) {\n      // Return early if visibility has already been checked during the traversal.\n      // The visibility may have already been checked if the cullWithChildrenBounds optimization is used.\n      return;\n    }\n\n    const parent = this.parent;\n    const parentVisibilityPlaneMask = parent\n      ? parent._visibilityPlaneMask\n      : CullingVolume.MASK_INDETERMINATE;\n\n    if (this.tileset._traverser.options.updateTransforms) {\n      const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;\n      this._updateTransform(parentTransform);\n    }\n\n    this._distanceToCamera = this.distanceToTile(frameState);\n    this._screenSpaceError = this.getScreenSpaceError(frameState, false);\n    this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask); // Use parent's plane mask to speed up visibility test\n    this._visible = this._visibilityPlaneMask !== CullingVolume.MASK_OUTSIDE;\n    this._inRequestVolume = this.insideViewerRequestVolume(frameState);\n\n    this._frameNumber = frameState.frameNumber;\n    this.viewportIds = viewportIds;\n  }\n\n  // Determines whether the tile's bounding volume intersects the culling volume.\n  // @param {FrameState} frameState The frame state.\n  // @param {Number} parentVisibilityPlaneMask The parent's plane mask to speed up the visibility check.\n  // @returns {Number} A plane mask as described above in {@link CullingVolume#computeVisibilityWithPlaneMask}.\n  visibility(frameState, parentVisibilityPlaneMask) {\n    const {cullingVolume} = frameState;\n    const {boundingVolume} = this;\n\n    // TODO Cesium specific - restore clippingPlanes\n    // const {clippingPlanes, clippingPlanesOriginMatrix} = tileset;\n    // if (clippingPlanes && clippingPlanes.enabled) {\n    //   const intersection = clippingPlanes.computeIntersectionWithBoundingVolume(\n    //     boundingVolume,\n    //     clippingPlanesOriginMatrix\n    //   );\n    //   this._isClipped = intersection !== Intersect.INSIDE;\n    //   if (intersection === Intersect.OUTSIDE) {\n    //     return CullingVolume.MASK_OUTSIDE;\n    //   }\n    // }\n\n    // return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);\n    return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);\n  }\n\n  // Assuming the tile's bounding volume intersects the culling volume, determines\n  // whether the tile's content's bounding volume intersects the culling volume.\n  // @param {FrameState} frameState The frame state.\n  // @returns {Intersect} The result of the intersection: the tile's content is completely outside, completely inside, or intersecting the culling volume.\n  contentVisibility() {\n    return true;\n\n    // TODO restore\n    /*\n    // Assumes the tile's bounding volume intersects the culling volume already, so\n    // just return Intersect.INSIDE if there is no content bounding volume.\n    if (!defined(this.contentBoundingVolume)) {\n      return Intersect.INSIDE;\n    }\n\n    if (this._visibilityPlaneMask === CullingVolume.MASK_INSIDE) {\n      // The tile's bounding volume is completely inside the culling volume so\n      // the content bounding volume must also be inside.\n      return Intersect.INSIDE;\n    }\n\n    // PERFORMANCE_IDEA: is it possible to burn less CPU on this test since we know the\n    // tile's (not the content's) bounding volume intersects the culling volume?\n    const cullingVolume = frameState.cullingVolume;\n    const boundingVolume = tile.contentBoundingVolume;\n\n    const tileset = this.tileset;\n    const clippingPlanes = tileset.clippingPlanes;\n    if (defined(clippingPlanes) && clippingPlanes.enabled) {\n      const intersection = clippingPlanes.computeIntersectionWithBoundingVolume(\n        boundingVolume,\n        tileset.clippingPlanesOriginMatrix\n      );\n      this._isClipped = intersection !== Intersect.INSIDE;\n      if (intersection === Intersect.OUTSIDE) {\n        return Intersect.OUTSIDE;\n      }\n    }\n\n    return cullingVolume.computeVisibility(boundingVolume);\n    */\n  }\n\n  /**\n   * Computes the (potentially approximate) distance from the closest point of the tile's bounding volume to the camera.\n   * @param frameState The frame state.\n   * @returns {Number} The distance, in meters, or zero if the camera is inside the bounding volume.\n   */\n  distanceToTile(frameState: FrameState): number {\n    const boundingVolume = this.boundingVolume;\n    return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));\n  }\n\n  /**\n   * Computes the tile's camera-space z-depth.\n   * @param frameState The frame state.\n   * @returns The distance, in meters.\n   */\n  cameraSpaceZDepth({camera}): number {\n    const boundingVolume = this.boundingVolume; // Gets the underlying OrientedBoundingBox or BoundingSphere\n    scratchVector.subVectors(boundingVolume.center, camera.position);\n    return camera.direction.dot(scratchVector);\n  }\n\n  /**\n   * Checks if the camera is inside the viewer request volume.\n   * @param {FrameState} frameState The frame state.\n   * @returns {Boolean} Whether the camera is inside the volume.\n   */\n  insideViewerRequestVolume(frameState: FrameState) {\n    const viewerRequestVolume = this._viewerRequestVolume;\n    return (\n      !viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0\n    );\n  }\n\n  // TODO Cesium specific\n\n  // Update whether the tile has expired.\n  updateExpiration() {\n    if (defined(this._expireDate) && this.contentReady && !this.hasEmptyContent) {\n      const now = Date.now();\n      // @ts-ignore Date.lessThan - replace with ms compare?\n      if (Date.lessThan(this._expireDate, now)) {\n        this.contentState = TILE_CONTENT_STATE.EXPIRED;\n        this._expiredContent = this.content;\n      }\n    }\n  }\n\n  get extras() {\n    return this.header.extras;\n  }\n\n  // INTERNAL METHODS\n\n  _initializeLodMetric(header) {\n    if ('lodMetricType' in header) {\n      this.lodMetricType = header.lodMetricType;\n    } else {\n      this.lodMetricType = (this.parent && this.parent.lodMetricType) || this.tileset.lodMetricType;\n      // eslint-disable-next-line\n      console.warn(`3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType`);\n    }\n\n    // This is used to compute screen space error, i.e., the error measured in pixels.\n    if ('lodMetricValue' in header) {\n      this.lodMetricValue = header.lodMetricValue;\n    } else {\n      this.lodMetricValue =\n        (this.parent && this.parent.lodMetricValue) || this.tileset.lodMetricValue;\n      // eslint-disable-next-line\n      console.warn(\n        '3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue'\n      );\n    }\n  }\n\n  _initializeTransforms(tileHeader) {\n    // The local transform of this tile.\n    this.transform = tileHeader.transform ? new Matrix4(tileHeader.transform) : new Matrix4();\n\n    const parent = this.parent;\n    const tileset = this.tileset;\n\n    const parentTransform =\n      parent && parent.computedTransform\n        ? parent.computedTransform.clone()\n        : tileset.modelMatrix.clone();\n    this.computedTransform = new Matrix4(parentTransform).multiplyRight(this.transform);\n\n    const parentInitialTransform =\n      parent && parent._initialTransform ? parent._initialTransform.clone() : new Matrix4();\n    this._initialTransform = new Matrix4(parentInitialTransform).multiplyRight(this.transform);\n  }\n\n  _initializeBoundingVolumes(tileHeader) {\n    this._contentBoundingVolume = null;\n    this._viewerRequestVolume = null;\n\n    this._updateBoundingVolume(tileHeader);\n  }\n\n  _initializeContent(tileHeader) {\n    // Empty tile by default\n    this.content = {_tileset: this.tileset, _tile: this};\n    this.hasEmptyContent = true;\n    this.contentState = TILE_CONTENT_STATE.UNLOADED;\n\n    // When `true`, the tile's content points to an external tileset.\n    // This is `false` until the tile's content is loaded.\n    this.hasTilesetContent = false;\n\n    if (tileHeader.contentUrl) {\n      this.content = null;\n      this.hasEmptyContent = false;\n    }\n  }\n\n  // TODO - remove anything not related to basic visibility detection\n  _initializeRenderingState(header) {\n    this.depth = header.level || (this.parent ? this.parent.depth + 1 : 0);\n    this._shouldRefine = false;\n\n    // Members this are updated every frame for tree traversal and rendering optimizations:\n    this._distanceToCamera = 0;\n    this._centerZDepth = 0;\n    this._screenSpaceError = 0;\n    this._visibilityPlaneMask = CullingVolume.MASK_INDETERMINATE;\n    this._visible = undefined;\n    this._inRequestVolume = false;\n\n    this._stackLength = 0;\n    this._selectionDepth = 0;\n\n    this._frameNumber = 0;\n    this._touchedFrame = 0;\n    this._visitedFrame = 0;\n    this._selectedFrame = 0;\n    this._requestedFrame = 0;\n\n    this._priority = 0.0;\n  }\n\n  _getRefine(refine) {\n    // Inherit from parent tile if omitted.\n    return refine || (this.parent && this.parent.refine) || TILE_REFINEMENT.REPLACE;\n  }\n\n  _isTileset() {\n    return this.contentUrl.indexOf('.json') !== -1;\n  }\n\n  _onContentLoaded() {\n    // Vector and Geometry tile rendering do not support the skip LOD optimization.\n    switch (this.content && this.content.type) {\n      case 'vctr':\n      case 'geom':\n        // @ts-ignore\n        this.tileset._traverser.disableSkipLevelOfDetail = true;\n        break;\n      default:\n    }\n\n    // The content may be tileset json\n    if (this._isTileset()) {\n      this.hasTilesetContent = true;\n    } else {\n      this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();\n    }\n  }\n\n  _updateBoundingVolume(header) {\n    // Update the bounding volumes\n    this.boundingVolume = createBoundingVolume(\n      header.boundingVolume,\n      this.computedTransform,\n      this.boundingVolume\n    );\n\n    const content = header.content;\n    if (!content) {\n      return;\n    }\n\n    // TODO Cesium specific\n    // Non-leaf tiles may have a content bounding-volume, which is a tight-fit bounding volume\n    // around only the features in the tile. This box is useful for culling for rendering,\n    // but not for culling for traversing the tree since it does not guarantee spatial coherence, i.e.,\n    // since it only bounds features in the tile, not the entire tile, children may be\n    // outside of this box.\n    if (content.boundingVolume) {\n      this._contentBoundingVolume = createBoundingVolume(\n        content.boundingVolume,\n        this.computedTransform,\n        this._contentBoundingVolume\n      );\n    }\n    if (header.viewerRequestVolume) {\n      this._viewerRequestVolume = createBoundingVolume(\n        header.viewerRequestVolume,\n        this.computedTransform,\n        this._viewerRequestVolume\n      );\n    }\n  }\n\n  // Update the tile's transform. The transform is applied to the tile's bounding volumes.\n  _updateTransform(parentTransform = new Matrix4()) {\n    const computedTransform = parentTransform.clone().multiplyRight(this.transform);\n    const didTransformChange = !computedTransform.equals(this.computedTransform);\n\n    if (!didTransformChange) {\n      return;\n    }\n\n    this.computedTransform = computedTransform;\n\n    this._updateBoundingVolume(this.header);\n  }\n\n  // Get options which are applicable only for the particular loader\n  _getLoaderSpecificOptions(loaderId) {\n    switch (loaderId) {\n      case 'i3s':\n        return {\n          ...this.tileset.options.i3s,\n          _tileOptions: {\n            attributeUrls: this.header.attributeUrls,\n            textureUrl: this.header.textureUrl,\n            textureFormat: this.header.textureFormat,\n            textureLoaderOptions: this.header.textureLoaderOptions,\n            materialDefinition: this.header.materialDefinition,\n            isDracoGeometry: this.header.isDracoGeometry,\n            mbs: this.header.mbs\n          },\n          _tilesetOptions: {\n            store: this.tileset.tileset.store,\n            attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,\n            fields: this.tileset.tileset.fields\n          },\n          isTileHeader: false\n        };\n      case '3d-tiles':\n      case 'cesium-ion':\n      default:\n        return get3dTilesOptions(this.tileset.tileset);\n    }\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport type TileContentState =\n  | 'unloaded' // Has never been requested\n  | 'loading' // Is waiting on a pending request\n  | 'processing' // Request received.  Contents are being processed for rendering.  Depending on the content, it might make its own requests for external data.\n  | 'ready' // Ready to render.\n  | 'expired' // Is expired and will be unloaded once new content is loaded.\n  | 'failed'; // Request failed.\n\nexport const TILE_CONTENT_STATE = {\n  UNLOADED: 0, // Has never been requested\n  LOADING: 1, // Is waiting on a pending request\n  PROCESSING: 2, // Request received.  Contents are being processed for rendering.  Depending on the content, it might make its own requests for external data.\n  READY: 3, // Ready to render.\n  EXPIRED: 4, // Is expired and will be unloaded once new content is loaded.\n  FAILED: 5 // Request failed.\n};\n\nexport type TileRefinement = 'add' | 'replace';\n\nexport enum TILE_REFINEMENT {\n  ADD = 1, // Render tile and, if screen space error exceeded, also refine to its children.\n  REPLACE = 2 // Render tile or, if screen space error exceeded, refine to its descendants instead.\n}\n\nexport type TileType = 'empty' | 'scenegraph' | 'pointcloud' | 'mesh';\n\nexport enum TILE_TYPE {\n  EMPTY = 'empty',\n  SCENEGRAPH = 'scenegraph',\n  POINTCLOUD = 'pointcloud',\n  MESH = 'mesh'\n}\n\nexport type TilesetType = 'I3S' | 'TILES3D';\n\nexport enum TILESET_TYPE {\n  I3S = 'I3S',\n  TILES3D = 'TILES3D'\n}\n\nexport type LODMetricType = 'geometricError' | 'maxScreenThreshold';\n\nexport enum LOD_METRIC_TYPE {\n  GEOMETRIC_ERROR = 'geometricError',\n  MAX_SCREEN_THRESHOLD = 'maxScreenThreshold'\n}\n\n// Cesium 3D Tiles Specific\nexport type Tile3DOptimizationHint = 'NOT_COMPUTED' | 'USE_OPTIMIZATION' | 'SKIP_OPTIMIZATION';\n\nexport const TILE3D_OPTIMIZATION_HINT = {\n  NOT_COMPUTED: -1,\n  USE_OPTIMIZATION: 1,\n  SKIP_OPTIMIZATION: 0\n};\n", "// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n/* eslint-disable */\nimport {Quaternion, Vector3, Matrix3, Matrix4, degrees} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {assert} from '@loaders.gl/loader-utils';\n\n// const scratchProjectedBoundingSphere = new BoundingSphere();\n\nfunction defined(x) {\n  return x !== undefined && x !== null;\n}\n\n// const scratchMatrix = new Matrix3();\nconst scratchPoint = new Vector3();\nconst scratchScale = new Vector3();\nconst scratchNorthWest = new Vector3();\nconst scratchSouthEast = new Vector3();\nconst scratchCenter = new Vector3();\nconst scratchXAxis = new Vector3();\nconst scratchYAxis = new Vector3();\nconst scratchZAxis = new Vector3();\n// const scratchRectangle = new Rectangle();\n// const scratchOrientedBoundingBox = new OrientedBoundingBox();\n// const scratchTransform = new Matrix4();\n\n/**\n * Create a bounding volume from the tile's bounding volume header.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {Matrix4} transform The transform to apply to the bounding volume.\n * @param [result] The object onto which to store the result.\n * @returns The modified result parameter or a new TileBoundingVolume instance if none was provided.\n */\nexport function createBoundingVolume(boundingVolumeHeader, transform, result?) {\n  assert(boundingVolumeHeader, '3D Tile: boundingVolume must be defined');\n\n  // boundingVolume schema:\n  // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n  if (boundingVolumeHeader.box) {\n    return createBox(boundingVolumeHeader.box, transform, result);\n  }\n  if (boundingVolumeHeader.region) {\n    return createObbFromRegion(boundingVolumeHeader.region);\n  }\n\n  if (boundingVolumeHeader.sphere) {\n    return createSphere(boundingVolumeHeader.sphere, transform, result);\n  }\n\n  throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\n}\n\n/** [min, max] each in [longitude, latitude, altitude] */\nexport type CartographicBounds = [min: number[], max: number[]];\n\n/**\n * Calculate the cartographic bounding box the tile's bounding volume.\n * @param {Object} boundingVolumeHeader The tile's bounding volume header.\n * @param {BoundingVolume} boundingVolume The bounding volume.\n * @returns {CartographicBounds}\n */\nexport function getCartographicBounds(\n  boundingVolumeHeader,\n  boundingVolume: OrientedBoundingBox | BoundingSphere\n): CartographicBounds {\n  // boundingVolume schema:\n  // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/schema/boundingVolume.schema.json\n  if (boundingVolumeHeader.box) {\n    return orientedBoundingBoxToCartographicBounds(boundingVolume as OrientedBoundingBox);\n  }\n  if (boundingVolumeHeader.region) {\n    // [west, south, east, north, minimum height, maximum height]\n    // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n    // Heights are in meters above (or below) the WGS 84 ellipsoid.\n    const [west, south, east, north, minHeight, maxHeight] = boundingVolumeHeader.region;\n\n    return [\n      [degrees(west), degrees(south), minHeight],\n      [degrees(east), degrees(north), maxHeight]\n    ];\n  }\n\n  if (boundingVolumeHeader.sphere) {\n    return boundingSphereToCartographicBounds(boundingVolume as BoundingSphere);\n  }\n\n  throw new Error('Unkown boundingVolume type');\n}\n\nfunction createBox(box, transform, result?) {\n  // https://math.gl/modules/culling/docs/api-reference/oriented-bounding-box\n  // 1. A half-axes based representation.\n  // box: An array of 12 numbers that define an oriented bounding box.\n  // The first three elements define the x, y, and z values for the center of the box.\n  // The next three elements (with indices 3, 4, and 5) define the x axis direction and half-length.\n  // The next three elements (indices 6, 7, and 8) define the y axis direction and half-length.\n  // The last three elements (indices 9, 10, and 11) define the z axis direction and half-length.\n  // 2. A half-size-quaternion based representation.\n  // box: An array of 10 numbers that define an oriented bounding box.\n  // The first three elements define the x, y, and z values for the center of the box in a right-handed 3-axis (x, y, z) Cartesian coordinate system where the z-axis is up.\n  // The next three elements (with indices 3, 4, and 5) define the halfSize.\n  // The last four elements (indices 6, 7, 8 and 10) define the quaternion.\n  const center = new Vector3(box[0], box[1], box[2]);\n  transform.transform(center, center);\n  let origin: number[] = [];\n  if (box.length === 10) {\n    const halfSize = box.slice(3, 6);\n    const quaternion = new Quaternion();\n    quaternion.fromArray(box, 6);\n    const x = new Vector3([1, 0, 0]);\n    const y = new Vector3([0, 1, 0]);\n    const z = new Vector3([0, 0, 1]);\n    x.transformByQuaternion(quaternion);\n    x.scale(halfSize[0]);\n    y.transformByQuaternion(quaternion);\n    y.scale(halfSize[1]);\n    z.transformByQuaternion(quaternion);\n    z.scale(halfSize[2]);\n    origin = [...x.toArray(), ...y.toArray(), ...z.toArray()];\n  } else {\n    origin = [...box.slice(3, 6), ...box.slice(6, 9), ...box.slice(9, 12)];\n  }\n  const xAxis = transform.transformAsVector(origin.slice(0, 3));\n  const yAxis = transform.transformAsVector(origin.slice(3, 6));\n  const zAxis = transform.transformAsVector(origin.slice(6, 9));\n  const halfAxes = new Matrix3([\n    xAxis[0],\n    xAxis[1],\n    xAxis[2],\n    yAxis[0],\n    yAxis[1],\n    yAxis[2],\n    zAxis[0],\n    zAxis[1],\n    zAxis[2]\n  ]);\n\n  if (defined(result)) {\n    result.center = center;\n    result.halfAxes = halfAxes;\n    return result;\n  }\n\n  return new OrientedBoundingBox(center, halfAxes);\n}\n\n/*\nfunction createBoxFromTransformedRegion(region, transform, initialTransform, result) {\n  const rectangle = Rectangle.unpack(region, 0, scratchRectangle);\n  const minimumHeight = region[4];\n  const maximumHeight = region[5];\n\n  const orientedBoundingBox = OrientedBoundingBox.fromRectangle(\n    rectangle,\n    minimumHeight,\n    maximumHeight,\n    Ellipsoid.WGS84,\n    scratchOrientedBoundingBox\n  );\n  const center = orientedBoundingBox.center;\n  const halfAxes = orientedBoundingBox.halfAxes;\n\n  // A region bounding volume is not transformed by the transform in the tileset JSON,\n  // but may be transformed by additional transforms applied in Cesium.\n  // This is why the transform is calculated as the difference between the initial transform and the current transform.\n  transform = Matrix4.multiplyTransformation(\n    transform,\n    Matrix4.inverseTransformation(initialTransform, scratchTransform),\n    scratchTransform\n  );\n  center = Matrix4.multiplyByPoint(transform, center, center);\n  const rotationScale = Matrix4.getRotation(transform, scratchMatrix);\n  halfAxes = Matrix3.multiply(rotationScale, halfAxes, halfAxes);\n\n  if (defined(result) && result instanceof TileOrientedBoundingBox) {\n    result.update(center, halfAxes);\n    return result;\n  }\n\n  return new TileOrientedBoundingBox(center, halfAxes);\n}\n\nfunction createRegion(region, transform, initialTransform, result) {\n  if (!Matrix4.equalsEpsilon(transform, initialTransform, CesiumMath.EPSILON8)) {\n    return createBoxFromTransformedRegion(region, transform, initialTransform, result);\n  }\n\n  if (defined(result)) {\n    return result;\n  }\n\n  const rectangleRegion = Rectangle.unpack(region, 0, scratchRectangle);\n\n  return new TileBoundingRegion({\n    rectangle: rectangleRegion,\n    minimumHeight: region[4],\n    maximumHeight: region[5]\n  });\n}\n*/\n\nfunction createSphere(sphere, transform, result?) {\n  // Find the transformed center\n  const center = new Vector3(sphere[0], sphere[1], sphere[2]);\n  transform.transform(center, center);\n  const scale = transform.getScale(scratchScale);\n\n  const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n  const radius = sphere[3] * uniformScale;\n\n  if (defined(result)) {\n    result.center = center;\n    result.radius = radius;\n    return result;\n  }\n\n  return new BoundingSphere(center, radius);\n}\n\n/**\n * Create OrientedBoundingBox instance from region 3D tiles bounding volume\n * @param region - region 3D tiles bounding volume\n * @returns OrientedBoundingBox instance\n */\nfunction createObbFromRegion(region: number[]): OrientedBoundingBox {\n  // [west, south, east, north, minimum height, maximum height]\n  // Latitudes and longitudes are in the WGS 84 datum as defined in EPSG 4979 and are in radians.\n  // Heights are in meters above (or below) the WGS 84 ellipsoid.\n  const [west, south, east, north, minHeight, maxHeight] = region;\n\n  const northWest = Ellipsoid.WGS84.cartographicToCartesian(\n    [degrees(west), degrees(north), minHeight],\n    scratchNorthWest\n  );\n  const southEast = Ellipsoid.WGS84.cartographicToCartesian(\n    [degrees(east), degrees(south), maxHeight],\n    scratchSouthEast\n  );\n  const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);\n  Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);\n\n  Ellipsoid.WGS84.cartographicToCartesian(\n    [degrees(east), scratchCenter[1], scratchCenter[2]],\n    scratchXAxis\n  );\n  Ellipsoid.WGS84.cartographicToCartesian(\n    [scratchCenter[0], degrees(north), scratchCenter[2]],\n    scratchYAxis\n  );\n  Ellipsoid.WGS84.cartographicToCartesian(\n    [scratchCenter[0], scratchCenter[1], maxHeight],\n    scratchZAxis\n  );\n\n  return createBox(\n    [\n      ...centerInCartesian,\n      ...scratchXAxis.subtract(centerInCartesian),\n      ...scratchYAxis.subtract(centerInCartesian),\n      ...scratchZAxis.subtract(centerInCartesian)\n    ],\n    new Matrix4()\n  );\n}\n\n/**\n * Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction orientedBoundingBoxToCartographicBounds(\n  boundingVolume: OrientedBoundingBox\n): CartographicBounds {\n  const result = emptyCartographicBounds();\n\n  const {halfAxes} = boundingVolume as OrientedBoundingBox;\n  const xAxis = new Vector3(halfAxes.getColumn(0));\n  const yAxis = new Vector3(halfAxes.getColumn(1));\n  const zAxis = new Vector3(halfAxes.getColumn(2));\n\n  // Test all 8 corners of the box\n  for (let x = 0; x < 2; x++) {\n    for (let y = 0; y < 2; y++) {\n      for (let z = 0; z < 2; z++) {\n        scratchPoint.copy(boundingVolume.center);\n        scratchPoint.add(xAxis);\n        scratchPoint.add(yAxis);\n        scratchPoint.add(zAxis);\n\n        addToCartographicBounds(result, scratchPoint);\n        zAxis.negate();\n      }\n      yAxis.negate();\n    }\n    xAxis.negate();\n  }\n  return result;\n}\n\n/**\n * Convert a bounding volume defined by BoundingSphere to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction boundingSphereToCartographicBounds(boundingVolume: BoundingSphere): CartographicBounds {\n  const result = emptyCartographicBounds();\n\n  const {center, radius} = boundingVolume as BoundingSphere;\n  const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);\n\n  let zAxis: Vector3;\n  if (point) {\n    zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point) as Vector3;\n  } else {\n    zAxis = new Vector3(0, 0, 1);\n  }\n  let xAxis = new Vector3(zAxis[2], -zAxis[1], 0);\n  if (xAxis.len() > 0) {\n    xAxis.normalize();\n  } else {\n    xAxis = new Vector3(0, 1, 0);\n  }\n  const yAxis = xAxis.clone().cross(zAxis);\n\n  // Test 6 end points of the 3 axes\n  for (const axis of [xAxis, yAxis, zAxis]) {\n    scratchScale.copy(axis).scale(radius);\n    for (let dir = 0; dir < 2; dir++) {\n      scratchPoint.copy(center);\n      scratchPoint.add(scratchScale);\n      addToCartographicBounds(result, scratchPoint);\n      // Flip the axis\n      scratchScale.negate();\n    }\n  }\n  return result;\n}\n\n/**\n * Create a new cartographic bounds that contains no points\n * @returns {CartographicBounds}\n */\nfunction emptyCartographicBounds(): CartographicBounds {\n  return [\n    [Infinity, Infinity, Infinity],\n    [-Infinity, -Infinity, -Infinity]\n  ];\n}\n\n/**\n * Add a point to the target cartographic bounds\n * @param {CartographicBounds} target\n * @param {Vector3} cartesian coordinates of the point to add\n */\nfunction addToCartographicBounds(target: CartographicBounds, cartesian: Readonly<Vector3>) {\n  Ellipsoid.WGS84.cartesianToCartographic(cartesian, scratchPoint);\n  target[0][0] = Math.min(target[0][0], scratchPoint[0]);\n  target[0][1] = Math.min(target[0][1], scratchPoint[1]);\n  target[0][2] = Math.min(target[0][2], scratchPoint[2]);\n\n  target[1][0] = Math.max(target[1][0], scratchPoint[0]);\n  target[1][1] = Math.max(target[1][1], scratchPoint[1]);\n  target[1][2] = Math.max(target[1][2], scratchPoint[2]);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n\n/* eslint-disable */\n// @ts-nocheck\nimport {Matrix4, Vector3, clamp} from '@math.gl/core';\n\nconst scratchPositionNormal = new Vector3();\nconst scratchCartographic = new Vector3();\nconst scratchMatrix = new Matrix4();\nconst scratchCenter = new Vector3();\nconst scratchPosition = new Vector3();\nconst scratchDirection = new Vector3();\n\n// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, {camera, mapProjection}, options = {}) {\n  const {dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278} =\n    options;\n\n  let up;\n  let direction;\n  let height;\n  let minimumHeight;\n  let maximumHeight;\n\n  const tileBoundingVolume = root.contentBoundingVolume;\n\n  if (tileBoundingVolume instanceof TileBoundingRegion) {\n    up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n    direction = camera.directionWC;\n    height = camera.positionCartographic.height;\n    minimumHeight = tileBoundingVolume.minimumHeight;\n    maximumHeight = tileBoundingVolume.maximumHeight;\n  } else {\n    // Transform camera position and direction into the local coordinate system of the tileset\n    const transformLocal = Matrix4.inverseTransformation(root.computedTransform, scratchMatrix);\n    const ellipsoid = mapProjection.ellipsoid;\n    const boundingVolume = tileBoundingVolume.boundingVolume;\n    const centerLocal = Matrix4.multiplyByPoint(\n      transformLocal,\n      boundingVolume.center,\n      scratchCenter\n    );\n    if (Cartesian3.magnitude(centerLocal) > ellipsoid.minimumRadius) {\n      // The tileset is defined in WGS84. Approximate the minimum and maximum height.\n      const centerCartographic = Cartographic.fromCartesian(\n        centerLocal,\n        ellipsoid,\n        scratchCartographic\n      );\n      up = Cartesian3.normalize(camera.positionWC, scratchPositionNormal);\n      direction = camera.directionWC;\n      height = camera.positionCartographic.height;\n      minimumHeight = 0.0;\n      maximumHeight = centerCartographic.height * 2.0;\n    } else {\n      // The tileset is defined in local coordinates (z-up)\n      const positionLocal = Matrix4.multiplyByPoint(\n        transformLocal,\n        camera.positionWC,\n        scratchPosition\n      );\n      up = Cartesian3.UNIT_Z;\n      direction = Matrix4.multiplyByPointAsVector(\n        transformLocal,\n        camera.directionWC,\n        scratchDirection\n      );\n      direction = Cartesian3.normalize(direction, direction);\n      height = positionLocal.z;\n      if (tileBoundingVolume instanceof TileOrientedBoundingBox) {\n        // Assuming z-up, the last component stores the half-height of the box\n        const boxHeight = root._header.boundingVolume.box[11];\n        minimumHeight = centerLocal.z - boxHeight;\n        maximumHeight = centerLocal.z + boxHeight;\n      } else if (tileBoundingVolume instanceof TileBoundingSphere) {\n        const radius = boundingVolume.radius;\n        minimumHeight = centerLocal.z - radius;\n        maximumHeight = centerLocal.z + radius;\n      }\n    }\n  }\n\n  // The range where the density starts to lessen. Start at the quarter height of the tileset.\n  const heightFalloff = dynamicScreenSpaceErrorHeightFalloff;\n  const heightClose = minimumHeight + (maximumHeight - minimumHeight) * heightFalloff;\n  const heightFar = maximumHeight;\n\n  const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n\n  // Increase density as the camera tilts towards the horizon\n  const dot = Math.abs(Cartesian3.dot(direction, up));\n\n  let horizonFactor = 1.0 - dot;\n\n  // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.\n  // The goal is to increase density for the \"street view\", not when viewing the tileset from a distance.\n  horizonFactor = horizonFactor * (1.0 - t);\n\n  return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\n\nexport function fog(distanceToCamera, density) {\n  const scalar = distanceToCamera * density;\n  return 1.0 - Math.exp(-(scalar * scalar));\n}\n\nexport function getDynamicScreenSpaceError(tileset, distanceToCamera) {\n  if (tileset.dynamicScreenSpaceError && tileset.dynamicScreenSpaceErrorComputedDensity) {\n    const density = tileset.dynamicScreenSpaceErrorComputedDensity;\n    const factor = tileset.dynamicScreenSpaceErrorFactor;\n    // TODO: Refined screen space error that minimizes tiles in non-first-person\n    const dynamicError = fog(distanceToCamera, density) * factor;\n    return dynamicError;\n  }\n\n  return 0;\n}\n\nexport function getTiles3DScreenSpaceError(tile, frameState, useParentLodMetric) {\n  const tileset = tile.tileset;\n  const parentLodMetricValue = (tile.parent && tile.parent.lodMetricValue) || tile.lodMetricValue;\n  const lodMetricValue = useParentLodMetric ? parentLodMetricValue : tile.lodMetricValue;\n\n  // Leaf tiles do not have any error so save the computation\n  if (lodMetricValue === 0.0) {\n    return 0.0;\n  }\n\n  // TODO: Orthographic Frustum needs special treatment?\n  // this._getOrthograhicScreenSpaceError();\n\n  // Avoid divide by zero when viewer is inside the tile\n  const distance = Math.max(tile._distanceToCamera, 1e-7);\n  const {height, sseDenominator} = frameState;\n  const {viewDistanceScale} = tileset.options;\n  let error = (lodMetricValue * height * (viewDistanceScale || 1.0)) / (distance * sseDenominator);\n\n  error -= getDynamicScreenSpaceError(tileset, distance);\n\n  return error;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {Tile3D} from '../tile-3d';\nimport {FrameState} from './frame-state';\n\nconst cameraPositionCartesian = new Vector3();\nconst toEye = new Vector3();\nconst cameraPositionEnu = new Vector3();\nconst extraVertexEnu = new Vector3();\nconst projectedOriginVector = new Vector3();\nconst enuToCartesianMatrix = new Matrix4();\nconst cartesianToEnuMatrix = new Matrix4();\n\n/**\n * For the maxScreenThreshold error metric, maxError means that you should replace the node with it's children\n   as soon as the nodes bounding sphere has a screen radius larger than maxError pixels.\n   In this sense a value of 0 means you should always load it's children,\n   or if it's a leaf node, you should always display it.\n * @param tile \n * @param frameState \n * @returns \n */\nexport function getLodStatus(tile: Tile3D, frameState: FrameState): 'DIG' | 'OUT' | 'DRAW' {\n  if (tile.lodMetricValue === 0 || isNaN(tile.lodMetricValue)) {\n    return 'DIG';\n  }\n  const screenSize = 2 * getProjectedRadius(tile, frameState);\n  if (screenSize < 2) {\n    return 'OUT';\n  }\n  if (!tile.header.children || screenSize <= tile.lodMetricValue) {\n    return 'DRAW';\n  } else if (tile.header.children) {\n    return 'DIG';\n  }\n  return 'OUT';\n}\n\n/**\n * Calculate size of MBS radius projected on the screen plane\n * @param tile\n * @param frameState\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport function getProjectedRadius(tile: Tile3D, frameState: FrameState): number {\n  const {topDownViewport: viewport} = frameState;\n  const mbsLat = tile.header.mbs[1];\n  const mbsLon = tile.header.mbs[0];\n  const mbsZ = tile.header.mbs[2];\n  const mbsR = tile.header.mbs[3];\n  const mbsCenterCartesian = [...tile.boundingVolume.center];\n  const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n  Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, cameraPositionCartesian);\n\n  // ---------------------------\n  // Calculate mbs border vertex\n  // ---------------------------\n  toEye.copy(cameraPositionCartesian).subtract(mbsCenterCartesian).normalize();\n  // Add extra vector to form plane\n  Ellipsoid.WGS84.eastNorthUpToFixedFrame(mbsCenterCartesian, enuToCartesianMatrix);\n  cartesianToEnuMatrix.copy(enuToCartesianMatrix).invert();\n  cameraPositionEnu.copy(cameraPositionCartesian).transform(cartesianToEnuMatrix);\n  // Mean Proportionals in Right Triangles - Altitude rule\n  // https://mathbitsnotebook.com/Geometry/RightTriangles/RTmeanRight.html\n  const projection = Math.sqrt(\n    cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]\n  );\n  const extraZ = (projection * projection) / cameraPositionEnu[2];\n  extraVertexEnu.copy([cameraPositionEnu[0], cameraPositionEnu[1], extraZ]);\n  const extraVertexCartesian = extraVertexEnu.transform(enuToCartesianMatrix);\n  const extraVectorCartesian = extraVertexCartesian.subtract(mbsCenterCartesian).normalize();\n  // We need radius vector orthogonal to toEye vector\n  const radiusVector = toEye.cross(extraVectorCartesian).normalize().scale(mbsR);\n  const sphereMbsBorderVertexCartesian = radiusVector.add(mbsCenterCartesian);\n  const sphereMbsBorderVertexCartographic = Ellipsoid.WGS84.cartesianToCartographic(\n    sphereMbsBorderVertexCartesian\n  );\n  // ---------------------------\n\n  // Project center vertex and border vertex and calculate projected radius of MBS\n  const projectedOrigin = viewport.project([mbsLon, mbsLat, mbsZ]);\n  const projectedMbsBorderVertex = viewport.project(\n    sphereMbsBorderVertexCartographic as [number, number, number]\n  );\n  const projectedRadius = projectedOriginVector\n    .copy(projectedOrigin)\n    .subtract(projectedMbsBorderVertex)\n    .magnitude();\n  return projectedRadius;\n}\n", "import type {Tileset3D} from '../tileset-3d';\n\nexport function get3dTilesOptions(tileset: Tileset3D): {assetGltfUpAxis: 'X' | 'Y' | 'Z'} {\n  return {\n    assetGltfUpAxis: (tileset.asset && tileset.asset.gltfUpAxis) || 'Y'\n  };\n}\n", "// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {assert} from '@loaders.gl/loader-utils';\n\n/**\n * A wrapper around arrays so that the internal length of the array can be manually managed.\n *\n * @alias ManagedArray\n * @constructor\n * @private\n *\n * @param {Number} [length=0] The initial length of the array.\n */\nexport class ManagedArray {\n  _map = new Map();\n  _array: any[];\n  _length: number;\n\n  constructor(length = 0) {\n    this._array = new Array(length);\n    this._length = length;\n  }\n\n  /**\n   * Gets or sets the length of the array.\n   * If the set length is greater than the length of the internal array, the internal array is resized.\n   *\n   * @memberof ManagedArray.prototype\n   * @type Number\n   */\n  get length() {\n    return this._length;\n  }\n\n  set length(length) {\n    this._length = length;\n    if (length > this._array.length) {\n      this._array.length = length;\n    }\n  }\n\n  /**\n   * Gets the internal array.\n   *\n   * @memberof ManagedArray.prototype\n   * @type Array\n   * @readonly\n   */\n  get values() {\n    return this._array;\n  }\n\n  /**\n   * Gets the element at an index.\n   *\n   * @param {Number} index The index to get.\n   */\n  get(index) {\n    assert(index < this._array.length);\n    return this._array[index];\n  }\n\n  /**\n   * Sets the element at an index. Resizes the array if index is greater than the length of the array.\n   *\n   * @param {Number} index The index to set.\n   * @param {*} element The element to set at index.\n   */\n  set(index, element) {\n    assert(index >= 0);\n\n    if (index >= this.length) {\n      this.length = index + 1;\n    }\n\n    if (this._map.has(this._array[index])) {\n      this._map.delete(this._array[index]);\n    }\n\n    this._array[index] = element;\n    this._map.set(element, index);\n  }\n\n  delete(element) {\n    const index = this._map.get(element);\n    if (index >= 0) {\n      this._array.splice(index, 1);\n      this._map.delete(element);\n      this.length--;\n    }\n  }\n\n  /**\n   * Returns the last element in the array without modifying the array.\n   *\n   * @returns {*} The last element in the array.\n   */\n  peek() {\n    return this._array[this._length - 1];\n  }\n\n  /**\n   * Push an element into the array.\n   *\n   * @param {*} element The element to push.\n   */\n  push(element) {\n    if (!this._map.has(element)) {\n      const index = this.length++;\n      this._array[index] = element;\n      this._map.set(element, index);\n    }\n  }\n\n  /**\n   * Pop an element from the array.\n   *\n   * @returns {*} The last element in the array.\n   */\n  pop() {\n    const element = this._array[--this.length];\n    this._map.delete(element);\n    return element;\n  }\n\n  /**\n   * Resize the internal array if length > _array.length.\n   *\n   * @param {Number} length The length.\n   */\n  reserve(length) {\n    assert(length >= 0);\n\n    if (length > this._array.length) {\n      this._array.length = length;\n    }\n  }\n\n  /**\n   * Resize the array.\n   *\n   * @param {Number} length The length.\n   */\n  resize(length) {\n    assert(length >= 0);\n\n    this.length = length;\n  }\n\n  /**\n   * Trim the internal array to the specified length. Defaults to the current length.\n   *\n   * @param {Number} [length] The length.\n   */\n  trim(length) {\n    if (length === null || length === undefined) {\n      length = this.length;\n    }\n    this._array.length = length;\n  }\n\n  reset() {\n    this._array = [];\n    this._map = new Map();\n    this._length = 0;\n  }\n\n  find(target) {\n    return this._map.has(target);\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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  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  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(tile: Tile3D, frameState: FrameState): 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    return this.shouldRefine(tile, frameState);\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 > tile.tileset.memoryAdjustedScreenSpaceError;\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    stack.push(root);\n\n    while (stack.length > 0) {\n      const tile = stack.pop();\n\n      const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState);\n      const emptyLeaf = !tile.hasRenderContent && tile.children.length === 0;\n\n      // Traversal stops but the tile does not have content yet\n      // There will be holes if the parent tries to refine to its children, so don't refine\n      // One exception: a parent may refine even if one of its descendants is an empty leaf\n      if (!traverse && !tile.contentAvailable && !emptyLeaf) {\n        allDescendantsLoaded = false;\n      }\n\n      this.updateTile(tile, frameState);\n\n      if (!tile.isVisibleAndInRequestVolume) {\n        this.loadTile(tile, frameState);\n        this.touchTile(tile, frameState);\n      }\n\n      if (traverse) {\n        const children = tile.children;\n        for (const child of children) {\n          stack.push(child);\n        }\n      }\n    }\n    return root.hasEmptyContent || allDescendantsLoaded;\n  }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\n// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT} from '../../constants';\nimport {TilesetTraverser} from '../tileset-traverser';\n\nexport class Tileset3DTraverser extends TilesetTraverser {\n  compareDistanceToCamera(a, b) {\n    // Sort by farthest child first since this is going on a stack\n    return b._distanceToCamera === 0 && a._distanceToCamera === 0\n      ? b._centerZDepth - a._centerZDepth\n      : b._distanceToCamera - a._distanceToCamera;\n  }\n\n  updateTileVisibility(tile, frameState) {\n    super.updateTileVisibility(tile, frameState);\n\n    //  Optimization - if none of the tile's children are visible then this tile isn't visible\n    if (!tile.isVisibleAndInRequestVolume) {\n      return;\n    }\n\n    const hasChildren = tile.children.length > 0;\n    if (tile.hasTilesetContent && hasChildren) {\n      // Use the root tile's visibility instead of this tile's visibility.\n      // The root tile may be culled by the children bounds optimization in which\n      // case this tile should also be culled.\n      const firstChild = tile.children[0];\n      this.updateTileVisibility(firstChild, frameState);\n      tile._visible = firstChild._visible;\n      return;\n    }\n\n    if (this.meetsScreenSpaceErrorEarly(tile, frameState)) {\n      tile._visible = false;\n      return;\n    }\n\n    const replace = tile.refine === TILE_REFINEMENT.REPLACE;\n    const useOptimization =\n      tile._optimChildrenWithinParent === TILE3D_OPTIMIZATION_HINT.USE_OPTIMIZATION;\n    if (replace && useOptimization && hasChildren) {\n      if (!this.anyChildrenVisible(tile, frameState)) {\n        tile._visible = false;\n        return;\n      }\n    }\n  }\n\n  meetsScreenSpaceErrorEarly(tile, frameState) {\n    const {parent} = tile;\n    if (!parent || parent.hasTilesetContent || parent.refine !== TILE_REFINEMENT.ADD) {\n      return false;\n    }\n\n    // Use parent's geometric error with child's box to see if the tile already meet the SSE\n    return !this.shouldRefine(tile, frameState, true);\n  }\n}\n", "import {load} from '@loaders.gl/core';\nimport {TilesetTraverser} from '../tileset-traverser';\n\nimport {getLodStatus} from '../helpers/i3s-lod';\nimport {Tile3D} from '../tile-3d';\nimport {I3STileManager} from './i3s-tile-manager';\nimport {FrameState} from '../helpers/frame-state';\n\nexport class I3STilesetTraverser extends TilesetTraverser {\n  private _tileManager: I3STileManager;\n\n  constructor(options) {\n    super(options);\n    this._tileManager = new I3STileManager();\n  }\n\n  /**\n   * Check if there are no penging tile header requests,\n   * that means the traversal is finished and we can call\n   * following-up callbacks.\n   */\n  traversalFinished(frameState: FrameState): boolean {\n    return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);\n  }\n\n  shouldRefine(tile, frameState: FrameState) {\n    tile._lodJudge = getLodStatus(tile, frameState);\n    return tile._lodJudge === 'DIG';\n  }\n\n  updateChildTiles(tile, frameState: FrameState): boolean {\n    const children = tile.header.children || [];\n    // children which are already fetched and constructed as Tile3D instances\n    const childTiles = tile.children;\n    const tileset = tile.tileset;\n\n    for (const child of children) {\n      const extendedId = `${child.id}-${frameState.viewport.id}`;\n      // if child tile is not fetched\n      const childTile = childTiles && childTiles.find((t) => t.id === extendedId);\n      if (!childTile) {\n        let request = () => this._loadTile(child.id, tileset);\n        const cachedRequest = this._tileManager.find(extendedId);\n        if (!cachedRequest) {\n          // eslint-disable-next-line max-depth\n          if (tileset.tileset.nodePages) {\n            request = () => tileset.tileset.nodePagesTile.formTileFromNodePages(child.id);\n          }\n          this._tileManager.add(\n            request,\n            extendedId,\n            (header) => this._onTileLoad(header, tile, extendedId),\n            frameState\n          );\n        } else {\n          // update frameNumber since it is still needed in current frame\n          this._tileManager.update(extendedId, frameState);\n        }\n      } else if (childTile) {\n        // if child tile is fetched and available\n        this.updateTile(childTile, frameState);\n      }\n    }\n    return false;\n  }\n\n  async _loadTile(nodeId, tileset) {\n    const {loader} = tileset;\n    const nodeUrl = tileset.getTileUrl(`${tileset.url}/nodes/${nodeId}`);\n    // load metadata\n    const options = {\n      ...tileset.loadOptions,\n      i3s: {\n        ...tileset.loadOptions.i3s,\n        isTileHeader: true\n      }\n    };\n\n    return await load(nodeUrl, loader, options);\n  }\n\n  /**\n   * The callback to init Tile3D instance after loading the tile JSON\n   * @param {Object} header - the tile JSON from a dataset\n   * @param {Tile3D} tile - the parent Tile3D instance\n   * @param {string} extendedId - optional ID to separate copies of a tile for different viewports.\n   *                              const extendedId = `${tile.id}-${frameState.viewport.id}`;\n   * @return {void}\n   */\n  _onTileLoad(header, tile, extendedId) {\n    // after child tile is fetched\n    const childTile = new Tile3D(tile.tileset, header, tile, extendedId);\n    tile.children.push(childTile);\n    const frameState = this._tileManager.find(childTile.id).frameState;\n    this.updateTile(childTile, frameState);\n\n    // after tile fetched, resume traversal if still in current update/traversal frame\n    if (\n      this._frameNumber === frameState.frameNumber &&\n      (this.traversalFinished(frameState) ||\n        new Date().getTime() - this.lastUpdate > this.updateDebounceTime)\n    ) {\n      this.executeTraversal(childTile, frameState);\n    }\n  }\n}\n", "/**\n * Counter to register pending tile headers for the particular frameNumber\n * Until all tiles are loaded we won't call `onTraversalEnd` callback\n */\nexport class I3SPendingTilesRegister {\n  private frameNumberMap: Map<string, Map<number, number>> = new Map();\n\n  /**\n   * Register a new pending tile header for the particular frameNumber\n   * @param viewportId\n   * @param frameNumber\n   */\n  register(viewportId: string, frameNumber: number) {\n    const viewportMap = this.frameNumberMap.get(viewportId) || new Map();\n    const oldCount = viewportMap.get(frameNumber) || 0;\n    viewportMap.set(frameNumber, oldCount + 1);\n    this.frameNumberMap.set(viewportId, viewportMap);\n  }\n\n  /**\n   * Deregister a pending tile header for the particular frameNumber\n   * @param viewportId\n   * @param frameNumber\n   */\n  deregister(viewportId: string, frameNumber: number) {\n    const viewportMap = this.frameNumberMap.get(viewportId);\n    if (!viewportMap) {\n      return;\n    }\n    const oldCount = viewportMap.get(frameNumber) || 1;\n    viewportMap.set(frameNumber, oldCount - 1);\n  }\n\n  /**\n   * Check is there are no pending tile headers registered for the particular frameNumber\n   * @param viewportId\n   * @param frameNumber\n   * @returns\n   */\n  isZero(viewportId: string, frameNumber: number) {\n    const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;\n    return count === 0;\n  }\n}\n", "import {FrameState} from '../helpers/frame-state';\nimport {I3SPendingTilesRegister} from './i3s-pending-tiles-register';\n\nconst STATUS = {\n  REQUESTED: 'REQUESTED',\n  COMPLETED: 'COMPLETED',\n  ERROR: 'ERROR'\n};\n\n// A helper class to manage tile metadata fetching\nexport class I3STileManager {\n  private _statusMap: object;\n  private pendingTilesRegister = new I3SPendingTilesRegister();\n\n  constructor() {\n    this._statusMap = {};\n  }\n\n  /**\n   * Add request to map\n   * @param request - node metadata request\n   * @param key - unique key\n   * @param callback - callback after request completed\n   * @param frameState - frameState data\n   */\n  add(request, key, callback, frameState: FrameState) {\n    if (!this._statusMap[key]) {\n      const {\n        frameNumber,\n        viewport: {id}\n      } = frameState;\n      this._statusMap[key] = {request, callback, key, frameState, status: STATUS.REQUESTED};\n      // Register pending request for the frameNumber\n      this.pendingTilesRegister.register(id, frameNumber);\n      request()\n        .then((data) => {\n          this._statusMap[key].status = STATUS.COMPLETED;\n          const {\n            frameNumber: actualFrameNumber,\n            viewport: {id}\n          } = this._statusMap[key].frameState;\n          // Deregister pending request for the frameNumber\n          this.pendingTilesRegister.deregister(id, actualFrameNumber);\n          this._statusMap[key].callback(data, frameState);\n        })\n        .catch((error) => {\n          this._statusMap[key].status = STATUS.ERROR;\n          const {\n            frameNumber: actualFrameNumber,\n            viewport: {id}\n          } = this._statusMap[key].frameState;\n          // Deregister pending request for the frameNumber\n          this.pendingTilesRegister.deregister(id, actualFrameNumber);\n          callback(error);\n        });\n    }\n  }\n\n  /**\n   * Update request if it is still actual for the new frameState\n   * @param key - unique key\n   * @param frameState - frameState data\n   */\n  update(key, frameState: FrameState) {\n    if (this._statusMap[key]) {\n      // Deregister pending request for the old frameNumber\n      const {\n        frameNumber,\n        viewport: {id}\n      } = this._statusMap[key].frameState;\n      this.pendingTilesRegister.deregister(id, frameNumber);\n\n      // Register pending request for the new frameNumber\n      const {\n        frameNumber: newFrameNumber,\n        viewport: {id: newViewportId}\n      } = frameState;\n      this.pendingTilesRegister.register(newViewportId, newFrameNumber);\n      this._statusMap[key].frameState = frameState;\n    }\n  }\n\n  /**\n   * Find request in the map\n   * @param key - unique key\n   * @returns\n   */\n  find(key) {\n    return this._statusMap[key];\n  }\n\n  /**\n   * Check it there are pending tile headers for the particular frameNumber\n   * @param viewportId\n   * @param frameNumber\n   * @returns\n   */\n  hasPendingTiles(viewportId: string, frameNumber: number): boolean {\n    return !this.pendingTilesRegister.isZero(viewportId, frameNumber);\n  }\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;ACMA,IAAAA,gBAA+B;AAC/B,IAAAC,qBAAwB;AACxB,mBAAoB;AACpB,IAAAC,uBA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AK,aAAa,IAAI;MACxB;IACF;AACA,SAAK,WAAW,CAAA;EAClB;EAEA,aAAa,MAAI;AACf,SAAK,OAAO,WAAW,MAAM,IAAI;AACjC,SAAK,YAAY,IAAI;AACrB,SAAK,QAAO;EACd;EAEA,0BAA0B,aAAW;AACnC,QAAI,YAAY,aAAa;AAC3B,YAAM,eAAe,IAAI,gBAAgB,YAAY,WAAW;AAChE,YAAM,cAAc,OAAO,YAAY,aAAa,QAAO,CAAE;AAC7D,WAAK,eAAe,EAAC,GAAG,KAAK,cAAc,GAAG,YAAW;IAC3D;AAEA,SAAK,QAAQ,YAAY;AACzB,QAAI,CAAC,KAAK,OAAO;AACf,YAAM,IAAI,MAAM,sCAAsC;IACxD;AACA,QACE,KAAK,MAAM,YAAY,SACvB,KAAK,MAAM,YAAY,SACvB,KAAK,MAAM,YAAY,OACvB;AACA,YAAM,IAAI,MAAM,gEAAgE;IAClF;AAIA,QAAI,oBAAoB,KAAK,OAAO;AAClC,WAAK,aAAa,IAAI,KAAK,MAAM;IACnC;AAGA,SAAK,UAAU;MACb,cAAc,KAAK,QAAQ,gBAAgB,CAAA;;AAE7C,SAAK,cAAc,KAAK,QAAQ,eAAe;AAG/C,SAAK,aAAa,YAAY;AAC9B,SAAK,iBAAiB,YAAY;AAClC,SAAK,kBAAkB,YAAY,kBAAkB,CAAA;AAErD,SAAK,SAAS,YAAY;EAC5B;EAEA,wBAAqB;AACnB,UAAM,aAAa,KAAK,YAAY;AACpC,QAAI,cAAc,OAAO,eAAe,YAAY,WAAW,YAAY;AACzE,WAAK,aAAa,QAAS,WAAuC;IACpE;EACF;;",
  "names": ["import_core", "import_geospatial", "import_loader_utils", "import_core", "import_geospatial", "cameraPositionCartesian", "import_core", "import_culling", "import_geospatial", "scratchVector", "import_core", "import_culling", "TILE_REFINEMENT", "TILE_TYPE", "TILESET_TYPE", "LOD_METRIC_TYPE", "import_core", "import_culling", "import_geospatial", "import_loader_utils", "import_core", "scratchCenter", "scratchPosition", "import_core", "import_geospatial", "import_loader_utils", "scratchVector", "defined", "cullingVolume", "import_core", "id", "DEFAULT_PROPS"]
}
