{ "version": 3, "sources": ["index.js", "tileset/tileset-3d.js", "utils/doubly-linked-list-node.js", "utils/doubly-linked-list.js", "tileset/tileset-cache.js", "tileset/helpers/transform-utils.js", "tileset/helpers/frame-state.js", "tileset/helpers/zoom.js", "tileset/tile-3d.js", "constants.js", "tileset/helpers/bounding-volume.js", "tileset/helpers/tiles-3d-lod.js", "tileset/helpers/i3s-lod.js", "tileset/helpers/3d-tiles-options.js", "utils/managed-array.js", "tileset/tileset-traverser.js", "tileset/format-3d-tiles/tileset-3d-traverser.js", "tileset/format-i3s/i3s-tileset-traverser.js", "tileset/format-i3s/i3s-pending-tiles-register.js", "tileset/format-i3s/i3s-tile-manager.js"], "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { Tileset3D } from \"./tileset/tileset-3d.js\";\nexport { Tile3D } from \"./tileset/tile-3d.js\";\nexport { TilesetTraverser } from \"./tileset/tileset-traverser.js\";\nexport { TilesetCache } from \"./tileset/tileset-cache.js\";\nexport { createBoundingVolume } from \"./tileset/helpers/bounding-volume.js\";\nexport { calculateTransformProps } from \"./tileset/helpers/transform-utils.js\";\nexport { getFrameState } from \"./tileset/helpers/frame-state.js\";\nexport { getLodStatus } from \"./tileset/helpers/i3s-lod.js\";\nexport { TILE_CONTENT_STATE, TILE_REFINEMENT, TILE_TYPE, TILESET_TYPE, LOD_METRIC_TYPE } from \"./constants.js\";\n", "// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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\nimport { Matrix4, Vector3 } from '@math.gl/core';\nimport { Ellipsoid } from '@math.gl/geospatial';\nimport { Stats } from '@probe.gl/stats';\nimport { RequestScheduler, path } from '@loaders.gl/loader-utils';\nimport { TilesetCache } from \"./tileset-cache.js\";\nimport { calculateTransformProps } from \"./helpers/transform-utils.js\";\nimport { getFrameState, limitSelectedTiles } from \"./helpers/frame-state.js\";\nimport { getZoomFromBoundingVolume, getZoomFromExtent, getZoomFromFullExtent } from \"./helpers/zoom.js\";\nimport { Tile3D } from \"./tile-3d.js\";\nimport { TILESET_TYPE } from \"../constants.js\";\nimport { TilesetTraverser } from \"./tileset-traverser.js\";\n// TODO - these should be moved into their respective modules\nimport { Tileset3DTraverser } from \"./format-3d-tiles/tileset-3d-traverser.js\";\nimport { I3STilesetTraverser } from \"./format-i3s/i3s-tileset-traverser.js\";\nconst DEFAULT_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) => selectedTiles,\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// 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 * 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;\n loadOptions;\n type;\n tileset;\n loader;\n url;\n basePath;\n modelMatrix;\n ellipsoid;\n lodMetricType;\n lodMetricValue;\n refine;\n root = null;\n roots = {};\n /** @todo any->unknown */\n asset = {};\n // Metadata for the entire tileset\n description = '';\n properties;\n extras = null;\n attributions = {};\n credits = {};\n stats;\n /** flags that contain information about data types in nested tiles */\n contentFormats = { draco: false, meshopt: false, dds: false, ktx2: false };\n // view props\n cartographicCenter = null;\n cartesianCenter = null;\n zoom = 1;\n boundingVolume = null;\n /** Updated based on the camera position and direction */\n dynamicScreenSpaceErrorComputedDensity = 0.0;\n // METRICS\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 = 32;\n /** The total amount of GPU memory in bytes used by the tileset. */\n gpuMemoryUsageInBytes = 0;\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 = 0.0;\n _cacheBytes = 0;\n _cacheOverflowBytes = 0;\n /** Update tracker. increase in each update cycle. */\n _frameNumber = 0;\n _queryParams = {};\n _extensionsUsed = [];\n _tiles = {};\n /** counter for tracking tiles requests */\n _pendingCount = 0;\n /** Hold traversal results */\n selectedTiles = [];\n // TRAVERSAL\n traverseCounter = 0;\n geometricError = 0;\n lastUpdatedVieports = null;\n _requestedTiles = [];\n _emptyTiles = [];\n frameStateData = {};\n _traverser;\n _cache = new TilesetCache();\n _requestScheduler;\n // Promise tracking\n updatePromise = null;\n tilesetInitializationPromise;\n /**\n * Create a new Tileset3D\n * @param json\n * @param props\n */\n // eslint-disable-next-line max-statements\n constructor(tileset, options) {\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 // 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 this.loadOptions = this.options.loadOptions || {};\n // TRAVERSAL\n this._traverser = this._initializeTraverser();\n this._requestScheduler = new RequestScheduler({\n throttleRequests: this.options.throttleRequests,\n maxRequests: this.options.maxRequests\n });\n this.memoryAdjustedScreenSpaceError = this.options.maximumScreenSpaceError;\n this._cacheBytes = this.options.maximumMemoryUsage * 1024 * 1024;\n this._cacheOverflowBytes = this.options.memoryCacheOverflow * 1024 * 1024;\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 this.tilesetInitializationPromise = this._initializeTileSet(tileset);\n }\n /** Release resources */\n destroy() {\n this._destroy();\n }\n /** Is the tileset loaded (update needs to have been called at least once) */\n isLoaded() {\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 get tiles() {\n return Object.values(this._tiles);\n }\n get frameNumber() {\n return this._frameNumber;\n }\n get queryParams() {\n return new URLSearchParams(this._queryParams).toString();\n }\n setProps(props) {\n this.options = { ...this.options, ...props };\n }\n /** @deprecated */\n // setOptions(options: Tileset3DProps): void {\n // this.options = {...this.options, ...options};\n // }\n /**\n * Return a loadable tile url for a specific tile subpath\n * @param tilePath a tile subpath\n */\n getTileUrl(tilePath) {\n const isDataUrl = tilePath.startsWith('data:');\n if (isDataUrl) {\n return tilePath;\n }\n let tileUrl = tilePath;\n if (this.queryParams.length) {\n tileUrl = `${tilePath}${tilePath.includes('?') ? '&' : '?'}${this.queryParams}`;\n }\n return tileUrl;\n }\n // TODO CESIUM specific\n hasExtension(extensionName) {\n return Boolean(this._extensionsUsed.indexOf(extensionName) > -1);\n }\n /**\n * Update visible tiles relying on a list of viewports\n * @param viewports - list of viewports\n * @deprecated\n */\n update(viewports = 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 }\n else {\n this.lastUpdatedVieports = viewports;\n }\n if (viewports) {\n this.doUpdate(viewports);\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 = null) {\n await this.tilesetInitializationPromise;\n if (viewports) {\n this.lastUpdatedVieports = viewports;\n }\n if (!this.updatePromise) {\n this.updatePromise = new Promise((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 adjustScreenSpaceError() {\n if (this.gpuMemoryUsageInBytes < this._cacheBytes) {\n this.memoryAdjustedScreenSpaceError = Math.max(this.memoryAdjustedScreenSpaceError / 1.02, 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 doUpdate(viewports) {\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 this._cache.reset();\n this._frameNumber++;\n this.traverseCounter = preparedViewports.length;\n const viewportsToTraverse = [];\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 }\n else {\n this.traverseCounter--;\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 if (!viewportsToTraverse.includes(id)) {\n continue; // eslint-disable-line no-continue\n }\n const frameState = getFrameState(viewport, this._frameNumber);\n this._traverser.traverse(this.roots[id], frameState, this.options);\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) {\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 return true;\n }\n /**\n * The callback to post-process tiles after traversal procedure\n * @param frameState - frame state for tile culling\n */\n _onTraversalEnd(frameState) {\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(selectedTiles, frameState, this.options.maximumTilesSelected);\n currentFrameStateData.selectedTiles = filteredSelectedTiles;\n for (const tile of unselectedTiles) {\n tile.unselect();\n }\n currentFrameStateData._requestedTiles = Object.values(this._traverser.requestedTiles);\n currentFrameStateData._emptyTiles = Object.values(this._traverser.emptyTiles);\n this.traverseCounter--;\n if (this.traverseCounter > 0) {\n return;\n }\n this._updateTiles();\n }\n /**\n * Update tiles relying on data from all traversers\n */\n _updateTiles() {\n this.selectedTiles = [];\n this._requestedTiles = [];\n this._emptyTiles = [];\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 this.selectedTiles = this.options.onTraversalComplete(this.selectedTiles);\n for (const tile of this.selectedTiles) {\n this._tiles[tile.id] = tile;\n }\n this._loadTiles();\n this._unloadTiles();\n this._updateStats();\n }\n _tilesChanged(oldSelectedTiles, selectedTiles) {\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 _loadTiles() {\n // Sort requests by priority before making any requests.\n // This makes it less likely this requests will be cancelled after being issued.\n // 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 _unloadTiles() {\n // unload tiles from cache when hit maximumMemoryUsage\n this._cache.unloadTiles(this, (tileset, tile) => tileset._unloadTile(tile));\n }\n _updateStats() {\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 }\n else {\n // Calculate vertices for non point cloud tiles.\n pointsRenderable += tile.content.vertexCount;\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 async _initializeTileSet(tilesetJson) {\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 if (this.type === TILESET_TYPE.TILES3D) {\n this._initializeTiles3DTileset(tilesetJson);\n this.calculateViewPropsTiles3D();\n }\n if (this.type === TILESET_TYPE.I3S) {\n this._initializeI3STileset();\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 calculateViewPropsI3S() {\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(xmin + (xmax - xmin) / 2, ymin + (ymax - ymin) / 2, zmin + (zmax - zmin) / 2);\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 * 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 calculateViewPropsTiles3D() {\n const root = this.root;\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 // 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 }\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 _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 // 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, parentTileHeader) {\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 // 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 // 3DTiles knows the hierarchy beforehand\n if (this.type === TILESET_TYPE.TILES3D) {\n const stack = [];\n stack.push(rootTile);\n while (stack.length > 0) {\n const tile = stack.pop();\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 // 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 tile.children.push(childTile);\n childTile.depth = tile.depth + 1;\n stack.push(childTile);\n }\n }\n }\n return rootTile;\n }\n _initializeTraverser() {\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 return new TraverserClass({\n basePath: this.basePath,\n onTraversalEnd: this._onTraversalEnd.bind(this)\n });\n }\n _destroyTileHeaders(parentTile) {\n this._destroySubtree(parentTile);\n }\n async _loadTile(tile) {\n let loaded;\n try {\n this._onStartTileLoading();\n loaded = await tile.loadContent();\n }\n catch (error) {\n this._onTileLoadError(tile, error instanceof Error ? error : new Error('load failed'));\n }\n finally {\n this._onEndTileLoading();\n this._onTileLoad(tile, loaded);\n }\n }\n _onTileLoadError(tile, error) {\n this.stats.get(TILES_LOAD_FAILED).incrementCount();\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 _onTileLoad(tile, loaded) {\n if (!loaded) {\n return;\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 // add coordinateOrigin and modelMatrix to tile\n if (tile && tile.content) {\n calculateTransformProps(tile, tile.content);\n }\n this.updateContentTypes(tile);\n this._addTileToCache(tile);\n this.options.onTileLoad(tile);\n }\n /**\n * Update information about data types in nested tiles\n * @param tile instance of a nested Tile3D\n */\n updateContentTypes(tile) {\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 }\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 _onStartTileLoading() {\n this._pendingCount++;\n this.stats.get(TILES_LOADING).incrementCount();\n }\n _onEndTileLoading() {\n this._pendingCount--;\n this.stats.get(TILES_LOADING).decrementCount();\n }\n _addTileToCache(tile) {\n this._cache.add(this, tile, (tileset) => tileset._updateCacheStats(tile));\n }\n _updateCacheStats(tile) {\n this.stats.get(TILES_LOADED).incrementCount();\n this.stats.get(TILES_IN_MEMORY).incrementCount();\n // TODO: Calculate GPU memory usage statistics for a tile.\n this.gpuMemoryUsageInBytes += tile.gpuMemoryUsageInBytes || 0;\n this.stats.get(TILES_GPU_MEMORY).count = this.gpuMemoryUsageInBytes;\n // Adjust SSE based on cache limits\n if (this.options.memoryAdjustedScreenSpaceError) {\n this.adjustScreenSpaceError();\n }\n }\n _unloadTile(tile) {\n this.gpuMemoryUsageInBytes -= tile.gpuMemoryUsageInBytes || 0;\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 this.options.onTileUnload(tile);\n tile.unloadContent();\n }\n // Traverse the tree and destroy all tiles\n _destroy() {\n const stack = [];\n if (this.root) {\n stack.push(this.root);\n }\n while (stack.length > 0) {\n const tile = stack.pop();\n for (const child of tile.children) {\n stack.push(child);\n }\n this._destroyTile(tile);\n }\n this.root = null;\n }\n // Traverse the tree and destroy all sub tiles\n _destroySubtree(tile) {\n const root = tile;\n const stack = [];\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 _destroyTile(tile) {\n this._cache.unloadTile(this, tile);\n this._unloadTile(tile);\n tile.destroy();\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 this.asset = tilesetJson.asset;\n if (!this.asset) {\n throw new Error('Tileset must have an asset property.');\n }\n if (this.asset.version !== '0.0' &&\n this.asset.version !== '1.0' &&\n this.asset.version !== '1.1') {\n throw new Error('The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.');\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 // 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 // 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 _initializeI3STileset() {\n // @ts-expect-error\n if (this.loadOptions.i3s && 'token' in this.loadOptions.i3s) {\n // @ts-ignore\n this._queryParams.token = this.loadOptions.i3s.token;\n }\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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 * Doubly linked list node\n * @private\n */\nexport class DoublyLinkedListNode {\n item;\n previous;\n next;\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\nimport { DoublyLinkedListNode } from \"./doubly-linked-list-node.js\";\n/**\n * Doubly linked list\n * @private\n */\nexport class DoublyLinkedList {\n head = null;\n tail = null;\n _length = 0;\n get length() {\n return this._length;\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 if (this.tail) {\n this.tail.next = node;\n this.tail = node;\n }\n else {\n this.head = node;\n this.tail = node;\n }\n ++this._length;\n return node;\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 if (node.previous && node.next) {\n node.previous.next = node.next;\n node.next.previous = node.previous;\n }\n else if (node.previous) {\n // Remove last node\n node.previous.next = null;\n this.tail = node.previous;\n }\n else if (node.next) {\n // Remove first node\n node.next.previous = null;\n this.head = node.next;\n }\n else {\n // Remove last node in the linked list\n this.head = null;\n this.tail = null;\n }\n node.next = null;\n node.previous = null;\n --this._length;\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 // Remove nextNode, then insert after node\n this.remove(nextNode);\n this._insert(node, nextNode);\n }\n _insert(node, nextNode) {\n const oldNodeNext = node.next;\n node.next = nextNode;\n // nextNode is the new tail\n if (this.tail === node) {\n this.tail = nextNode;\n }\n else {\n oldNodeNext.previous = nextNode;\n }\n nextNode.next = oldNodeNext;\n nextNode.previous = node;\n ++this._length;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { DoublyLinkedList } from \"../utils/doubly-linked-list.js\";\n/**\n * Stores tiles with content loaded.\n * @private\n */\nexport class TilesetCache {\n _list;\n _sentinel;\n _trimTiles;\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 reset() {\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 touch(tile) {\n const node = tile._cacheNode;\n if (node) {\n this._list.splice(this._sentinel, node);\n }\n }\n add(tileset, tile, addCallback) {\n if (!tile._cacheNode) {\n tile._cacheNode = this._list.add(tile);\n if (addCallback) {\n addCallback(tileset, tile);\n }\n }\n }\n unloadTile(tileset, tile, unloadCallback) {\n const node = tile._cacheNode;\n if (!node) {\n return;\n }\n this._list.remove(node);\n tile._cacheNode = null;\n if (unloadCallback) {\n unloadCallback(tileset, tile);\n }\n }\n unloadTiles(tileset, unloadCallback) {\n const trimTiles = this._trimTiles;\n this._trimTiles = false;\n const list = this._list;\n const maximumMemoryUsageInBytes = tileset.maximumMemoryUsage * 1024 * 1024;\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 while (node !== sentinel &&\n (tileset.gpuMemoryUsageInBytes > maximumMemoryUsageInBytes || trimTiles)) {\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 trim() {\n this._trimTiles = true;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Ellipsoid } from '@math.gl/geospatial';\nimport { Matrix4, Vector3 } from '@math.gl/core';\nimport { assert } from '@loaders.gl/loader-utils';\nexport function calculateTransformProps(tileHeader, tile) {\n assert(tileHeader);\n assert(tile);\n const { rtcCenter, gltfUpAxis } = tile;\n const { computedTransform, boundingVolume: { center } } = tileHeader;\n let modelMatrix = new Matrix4(computedTransform);\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\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 // Scale/offset positions if normalized integers\n if (tile.isQuantized) {\n modelMatrix.translate(tile.quantizedVolumeOffset).scale(tile.quantizedVolumeScale);\n }\n // Option 1: Cartesian matrix and origin\n const cartesianOrigin = new Vector3(center);\n tile.cartesianModelMatrix = modelMatrix;\n tile.cartesianOrigin = cartesianOrigin;\n // Option 2: Cartographic matrix and origin\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(cartesianOrigin, new Vector3());\n const fromFixedFrameMatrix = Ellipsoid.WGS84.eastNorthUpToFixedFrame(cartesianOrigin);\n const toFixedFrameMatrix = fromFixedFrameMatrix.invert();\n tile.cartographicModelMatrix = toFixedFrameMatrix.multiplyRight(modelMatrix);\n tile.cartographicOrigin = cartographicOrigin;\n // Deprecated, drop\n if (!tile.coordinateSystem) {\n tile.modelMatrix = tile.cartographicModelMatrix;\n }\n}\n", "import { Vector3 } from '@math.gl/core';\nimport { CullingVolume, Plane } from '@math.gl/culling';\nimport { Ellipsoid } from '@math.gl/geospatial';\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// 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, frameNumber) {\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 // 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 const cameraPositionCartographic = viewport.unprojectPosition(viewport.cameraPosition);\n const cameraPositionCartesian = Ellipsoid.WGS84.cartographicToCartesian(cameraPositionCartographic, new Vector3());\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))).normalize();\n const cameraUpCartesian = new Vector3(\n // @ts-ignore\n enuToFixedTransform.transformAsVector(new Vector3(cameraUp).scale(metersPerUnit))).normalize();\n commonSpacePlanesToWGS84(viewport);\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 // 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 * 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(tiles, frameState, maximumTilesSelected) {\n if (maximumTilesSelected === 0 || tiles.length <= maximumTilesSelected) {\n return [tiles, []];\n }\n // Accumulate distances in couples array: [tileIndex: number, distanceToViewport: number]\n const tuples = [];\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 = [];\n for (let i = 0; i < maximumTilesSelected; i++) {\n selectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n const unselectedTiles = [];\n for (let i = maximumTilesSelected; i < tuplesSorted.length; i++) {\n unselectedTiles.push(tiles[tuplesSorted[i][0]]);\n }\n return [selectedTiles, unselectedTiles];\n}\nfunction commonSpacePlanesToWGS84(viewport) {\n // Extract frustum planes based on current view.\n const frustumPlanes = viewport.getFrustumPlanes();\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 let i = 0;\n cullingVolume.planes[i++].fromPointNormal(nearCenterCartesian, scratchVector.copy(nearCenterCartesian).subtract(cameraCartesian));\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 cullingVolume.planes[i++].fromPointNormal(cartesianPos, \n // Want the normal to point into the frustum since that's what culling expects\n scratchVector.copy(nearCenterCartesian).subtract(cartesianPos));\n }\n}\nfunction closestPointOnPlane(plane, refPoint, out = new 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}\nfunction worldToCartesian(viewport, point, out = new 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\nimport { Vector3 } from '@math.gl/core';\nimport { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';\nimport { Ellipsoid } from '@math.gl/geospatial';\nconst WGS84_RADIUS_X = 6378137.0;\nconst WGS84_RADIUS_Y = 6378137.0;\nconst WGS84_RADIUS_Z = 6356752.3142451793;\nconst scratchVector = new Vector3();\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(boundingVolume, cartorgraphicCenter) {\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 }\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 }\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 return (zoomX + zoomY) / 2;\n }\n return 1;\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(fullExtent, cartorgraphicCenter, cartesianCenter) {\n Ellipsoid.WGS84.cartographicToCartesian([fullExtent.xmax, fullExtent.ymax, fullExtent.zmax], scratchVector);\n const extentSize = Math.sqrt(Math.pow(scratchVector[0] - cartesianCenter[0], 2) +\n Math.pow(scratchVector[1] - cartesianCenter[1], 2) +\n Math.pow(scratchVector[2] - cartesianCenter[2], 2));\n return Math.log2(WGS84_RADIUS_Z / (extentSize + cartorgraphicCenter[2]));\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(extent, cartorgraphicCenter, cartesianCenter) {\n const [xmin, ymin, xmax, ymax] = extent;\n return getZoomFromFullExtent({ xmin, xmax, ymin, ymax, zmin: 0, zmax: 0 }, cartorgraphicCenter, cartesianCenter);\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// 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\nimport { Vector3, Matrix4 } from '@math.gl/core';\nimport { CullingVolume } from '@math.gl/culling';\nimport { load } from '@loaders.gl/core';\nimport { TILE_REFINEMENT, TILE_CONTENT_STATE, TILESET_TYPE } from \"../constants.js\";\nimport { createBoundingVolume, getCartographicBounds } from \"./helpers/bounding-volume.js\";\nimport { getTiles3DScreenSpaceError } from \"./helpers/tiles-3d-lod.js\";\nimport { getProjectedRadius } from \"./helpers/i3s-lod.js\";\nimport { get3dTilesOptions } from \"./helpers/3d-tiles-options.js\";\nimport { TilesetTraverser } from \"./tileset-traverser.js\";\nconst scratchVector = new Vector3();\nfunction defined(x) {\n return x !== undefined && x !== null;\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;\n header;\n id;\n url;\n parent;\n /* Specifies the type of refine that is used when traversing this tile for rendering. */\n refine;\n type;\n contentUrl;\n /** Different refinement algorithms used by I3S and 3D tiles */\n lodMetricType = 'geometricError';\n /** The error, in meters, introduced if this tile is rendered and its children are not. */\n lodMetricValue = 0;\n /** @todo math.gl is not exporting BoundingVolume base type? */\n boundingVolume = null;\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 = null;\n contentState = TILE_CONTENT_STATE.UNLOADED;\n gpuMemoryUsageInBytes = 0;\n /** The tile's children - an array of Tile3D objects. */\n children = [];\n depth = 0;\n viewportIds = [];\n transform = new Matrix4();\n extensions = null;\n /** TODO Cesium 3d tiles specific */\n implicitTiling = null;\n /** Container to store application specific data */\n userData = {};\n computedTransform;\n hasEmptyContent = false;\n hasTilesetContent = false;\n traverser = new TilesetTraverser({});\n /** Used by TilesetCache */\n _cacheNode = null;\n _frameNumber = null;\n // TODO Cesium 3d tiles specific\n _expireDate = null;\n _expiredContent = null;\n _boundingBox = undefined;\n /** updated every frame for tree traversal and rendering optimizations: */\n _distanceToCamera = 0;\n _screenSpaceError = 0;\n _visibilityPlaneMask;\n _visible = undefined;\n _contentBoundingVolume;\n _viewerRequestVolume;\n _initialTransform = new Matrix4();\n // Used by traverser, cannot be marked private\n _priority = 0;\n _selectedFrame = 0;\n _requestedFrame = 0;\n _selectionDepth = 0;\n _touchedFrame = 0;\n _centerZDepth = 0;\n _shouldRefine = false;\n _stackLength = 0;\n _visitedFrame = 0;\n _inRequestVolume = false;\n _lodJudge = null; // TODO i3s specific, needs to remove\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(tileset, header, parentHeader, extendedId = '') {\n // PUBLIC MEMBERS\n // original tile data\n this.header = header;\n // The tileset containing this tile.\n this.tileset = tileset;\n this.id = extendedId || header.id;\n this.url = header.url;\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 this._initializeLodMetric(header);\n this._initializeTransforms(header);\n this._initializeBoundingVolumes(header);\n this._initializeContent(header);\n this._initializeRenderingState(header);\n Object.seal(this);\n }\n destroy() {\n this.header = null;\n }\n isDestroyed() {\n return this.header === null;\n }\n get selected() {\n return this._selectedFrame === this.tileset._frameNumber;\n }\n get isVisible() {\n return this._visible;\n }\n get isVisibleAndInRequestVolume() {\n return this._visible && this._inRequestVolume;\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 /** 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 * 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 * 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((this.contentReady && this.hasRenderContent) || (this._expiredContent && !this.contentFailed));\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 * 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 * 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 // 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 * Distance from the tile's bounding volume center to the camera\n */\n get distanceToCamera() {\n return this._distanceToCamera;\n }\n /**\n * Screen space error for LOD selection\n */\n get screenSpaceError() {\n return this._screenSpaceError;\n }\n /**\n * Get bounding box in cartographic coordinates\n * @returns [min, max] each in [longitude, latitude, altitude]\n */\n get boundingBox() {\n if (!this._boundingBox) {\n this._boundingBox = getCartographicBounds(this.header.boundingVolume, this.boundingVolume);\n }\n return this._boundingBox;\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 * Make tile unselected than means it won't be shown\n * but it can be still loaded in memory\n */\n unselect() {\n this._selectedFrame = 0;\n }\n /**\n * Memory usage of tile on GPU\n */\n _getGpuMemoryUsageInBytes() {\n return this.content.gpuMemoryUsageInBytes || this.content.byteLength || 0;\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 * 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 // 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 // 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 = parent && (!maySkipTile || this._screenSpaceError === 0.0 || parent.hasTilesetContent);\n const screenSpaceError = useParentScreenSpaceError\n ? parent._screenSpaceError\n : this._screenSpaceError;\n const rootScreenSpaceError = traverser.root ? traverser.root._screenSpaceError : 0.0;\n // Map higher SSE to lower values (e.g. root tile is highest priority)\n return Math.max(rootScreenSpaceError - screenSpaceError, 0);\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() {\n if (this.hasEmptyContent) {\n return false;\n }\n if (this.content) {\n return true;\n }\n const expired = this.contentExpired;\n if (expired) {\n this._expireDate = null;\n }\n this.contentState = TILE_CONTENT_STATE.LOADING;\n const requestToken = await this.tileset._requestScheduler.scheduleRequest(this.id, this._getPriority.bind(this));\n if (!requestToken) {\n // cancelled\n this.contentState = TILE_CONTENT_STATE.UNLOADED;\n return false;\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 options = {\n ...this.tileset.loadOptions,\n [loader.id]: {\n // @ts-expect-error\n ...this.tileset.loadOptions[loader.id],\n isTileset: this.type === 'json',\n ...this._getLoaderSpecificOptions(loader.id)\n }\n };\n this.content = await load(contentUrl, loader, options);\n if (this.tileset.options.contentLoader) {\n await this.tileset.options.contentLoader(this);\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 this.contentState = TILE_CONTENT_STATE.READY;\n this._onContentLoaded();\n return true;\n }\n catch (error) {\n // Tile is unloaded before the content finishes loading\n this.contentState = TILE_CONTENT_STATE.FAILED;\n throw error;\n }\n finally {\n requestToken.done();\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 return true;\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 const parent = this.parent;\n const parentVisibilityPlaneMask = parent\n ? parent._visibilityPlaneMask\n : CullingVolume.MASK_INDETERMINATE;\n if (this.tileset._traverser.options.updateTransforms) {\n const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;\n this._updateTransform(parentTransform);\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 this._frameNumber = frameState.frameNumber;\n this.viewportIds = viewportIds;\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 // 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 // return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);\n return cullingVolume.computeVisibilityWithPlaneMask(boundingVolume, parentVisibilityPlaneMask);\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 // 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 * 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) {\n const boundingVolume = this.boundingVolume;\n return Math.sqrt(Math.max(boundingVolume.distanceSquaredTo(frameState.camera.position), 0));\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 }) {\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 * 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) {\n const viewerRequestVolume = this._viewerRequestVolume;\n return (!viewerRequestVolume || viewerRequestVolume.distanceSquaredTo(frameState.camera.position) <= 0);\n }\n // TODO Cesium specific\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 get extras() {\n return this.header.extras;\n }\n // INTERNAL METHODS\n _initializeLodMetric(header) {\n if ('lodMetricType' in header) {\n this.lodMetricType = header.lodMetricType;\n }\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 // 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 }\n else {\n this.lodMetricValue =\n (this.parent && this.parent.lodMetricValue) || this.tileset.lodMetricValue;\n // eslint-disable-next-line\n console.warn('3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue');\n }\n }\n _initializeTransforms(tileHeader) {\n // The local transform of this tile.\n this.transform = tileHeader.transform ? new Matrix4(tileHeader.transform) : new Matrix4();\n const parent = this.parent;\n const tileset = this.tileset;\n const parentTransform = parent && parent.computedTransform\n ? parent.computedTransform.clone()\n : tileset.modelMatrix.clone();\n this.computedTransform = new Matrix4(parentTransform).multiplyRight(this.transform);\n const parentInitialTransform = parent && parent._initialTransform ? parent._initialTransform.clone() : new Matrix4();\n this._initialTransform = new Matrix4(parentInitialTransform).multiplyRight(this.transform);\n }\n _initializeBoundingVolumes(tileHeader) {\n this._contentBoundingVolume = null;\n this._viewerRequestVolume = null;\n this._updateBoundingVolume(tileHeader);\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 // 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 if (tileHeader.contentUrl) {\n this.content = null;\n this.hasEmptyContent = false;\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 // 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 this._stackLength = 0;\n this._selectionDepth = 0;\n this._frameNumber = 0;\n this._touchedFrame = 0;\n this._visitedFrame = 0;\n this._selectedFrame = 0;\n this._requestedFrame = 0;\n this._priority = 0.0;\n }\n _getRefine(refine) {\n // Inherit from parent tile if omitted.\n return refine || (this.parent && this.parent.refine) || TILE_REFINEMENT.REPLACE;\n }\n _isTileset() {\n return this.contentUrl.indexOf('.json') !== -1;\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 // The content may be tileset json\n if (this._isTileset()) {\n this.hasTilesetContent = true;\n }\n else {\n this.gpuMemoryUsageInBytes = this._getGpuMemoryUsageInBytes();\n }\n }\n _updateBoundingVolume(header) {\n // Update the bounding volumes\n this.boundingVolume = createBoundingVolume(header.boundingVolume, this.computedTransform, this.boundingVolume);\n const content = header.content;\n if (!content) {\n return;\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(content.boundingVolume, this.computedTransform, this._contentBoundingVolume);\n }\n if (header.viewerRequestVolume) {\n this._viewerRequestVolume = createBoundingVolume(header.viewerRequestVolume, this.computedTransform, this._viewerRequestVolume);\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 if (!didTransformChange) {\n return;\n }\n this.computedTransform = computedTransform;\n this._updateBoundingVolume(this.header);\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\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};\nexport var TILE_REFINEMENT;\n(function (TILE_REFINEMENT) {\n TILE_REFINEMENT[TILE_REFINEMENT[\"ADD\"] = 1] = \"ADD\";\n TILE_REFINEMENT[TILE_REFINEMENT[\"REPLACE\"] = 2] = \"REPLACE\"; // Render tile or, if screen space error exceeded, refine to its descendants instead.\n})(TILE_REFINEMENT || (TILE_REFINEMENT = {}));\nexport var TILE_TYPE;\n(function (TILE_TYPE) {\n TILE_TYPE[\"EMPTY\"] = \"empty\";\n TILE_TYPE[\"SCENEGRAPH\"] = \"scenegraph\";\n TILE_TYPE[\"POINTCLOUD\"] = \"pointcloud\";\n TILE_TYPE[\"MESH\"] = \"mesh\";\n})(TILE_TYPE || (TILE_TYPE = {}));\nexport var TILESET_TYPE;\n(function (TILESET_TYPE) {\n TILESET_TYPE[\"I3S\"] = \"I3S\";\n TILESET_TYPE[\"TILES3D\"] = \"TILES3D\";\n})(TILESET_TYPE || (TILESET_TYPE = {}));\nexport var LOD_METRIC_TYPE;\n(function (LOD_METRIC_TYPE) {\n LOD_METRIC_TYPE[\"GEOMETRIC_ERROR\"] = \"geometricError\";\n LOD_METRIC_TYPE[\"MAX_SCREEN_THRESHOLD\"] = \"maxScreenThreshold\";\n})(LOD_METRIC_TYPE || (LOD_METRIC_TYPE = {}));\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/* 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// const scratchProjectedBoundingSphere = new BoundingSphere();\nfunction defined(x) {\n return x !== undefined && x !== null;\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 * 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 // 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 if (boundingVolumeHeader.sphere) {\n return createSphere(boundingVolumeHeader.sphere, transform, result);\n }\n throw new Error('3D Tile: boundingVolume must contain a sphere, region, or box');\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(boundingVolumeHeader, boundingVolume) {\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);\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 return [\n [degrees(west), degrees(south), minHeight],\n [degrees(east), degrees(north), maxHeight]\n ];\n }\n if (boundingVolumeHeader.sphere) {\n return boundingSphereToCartographicBounds(boundingVolume);\n }\n throw new Error('Unkown boundingVolume type');\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 = [];\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 }\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 if (defined(result)) {\n result.center = center;\n result.halfAxes = halfAxes;\n return result;\n }\n return new OrientedBoundingBox(center, halfAxes);\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*/\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 const uniformScale = Math.max(Math.max(scale[0], scale[1]), scale[2]);\n const radius = sphere[3] * uniformScale;\n if (defined(result)) {\n result.center = center;\n result.radius = radius;\n return result;\n }\n return new BoundingSphere(center, radius);\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) {\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 const northWest = Ellipsoid.WGS84.cartographicToCartesian([degrees(west), degrees(north), minHeight], scratchNorthWest);\n const southEast = Ellipsoid.WGS84.cartographicToCartesian([degrees(east), degrees(south), maxHeight], scratchSouthEast);\n const centerInCartesian = new Vector3().addVectors(northWest, southEast).multiplyByScalar(0.5);\n Ellipsoid.WGS84.cartesianToCartographic(centerInCartesian, scratchCenter);\n Ellipsoid.WGS84.cartographicToCartesian([degrees(east), scratchCenter[1], scratchCenter[2]], scratchXAxis);\n Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], degrees(north), scratchCenter[2]], scratchYAxis);\n Ellipsoid.WGS84.cartographicToCartesian([scratchCenter[0], scratchCenter[1], maxHeight], scratchZAxis);\n return createBox([\n ...centerInCartesian,\n ...scratchXAxis.subtract(centerInCartesian),\n ...scratchYAxis.subtract(centerInCartesian),\n ...scratchZAxis.subtract(centerInCartesian)\n ], new Matrix4());\n}\n/**\n * Convert a bounding volume defined by OrientedBoundingBox to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction orientedBoundingBoxToCartographicBounds(boundingVolume) {\n const result = emptyCartographicBounds();\n const { halfAxes } = boundingVolume;\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 // 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 addToCartographicBounds(result, scratchPoint);\n zAxis.negate();\n }\n yAxis.negate();\n }\n xAxis.negate();\n }\n return result;\n}\n/**\n * Convert a bounding volume defined by BoundingSphere to cartographic bounds\n * @returns {CartographicBounds}\n */\nfunction boundingSphereToCartographicBounds(boundingVolume) {\n const result = emptyCartographicBounds();\n const { center, radius } = boundingVolume;\n const point = Ellipsoid.WGS84.scaleToGeodeticSurface(center, scratchPoint);\n let zAxis;\n if (point) {\n zAxis = Ellipsoid.WGS84.geodeticSurfaceNormal(point);\n }\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 }\n else {\n xAxis = new Vector3(0, 1, 0);\n }\n const yAxis = xAxis.clone().cross(zAxis);\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 * Create a new cartographic bounds that contains no points\n * @returns {CartographicBounds}\n */\nfunction emptyCartographicBounds() {\n return [\n [Infinity, Infinity, Infinity],\n [-Infinity, -Infinity, -Infinity]\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, cartesian) {\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 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// 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// TODO - Dynamic screen space error provides an optimization when looking at\n// tilesets from above\n/* eslint-disable */\n// @ts-nocheck\nimport { Matrix4, Vector3, clamp } from '@math.gl/core';\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// eslint-disable-next-line max-statements, complexity\nexport function calculateDynamicScreenSpaceError(root, { camera, mapProjection }, options = {}) {\n const { dynamicScreenSpaceErrorHeightFalloff = 0.25, dynamicScreenSpaceErrorDensity = 0.00278 } = options;\n let up;\n let direction;\n let height;\n let minimumHeight;\n let maximumHeight;\n const tileBoundingVolume = root.contentBoundingVolume;\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 }\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(transformLocal, boundingVolume.center, scratchCenter);\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(centerLocal, ellipsoid, scratchCartographic);\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 }\n else {\n // The tileset is defined in local coordinates (z-up)\n const positionLocal = Matrix4.multiplyByPoint(transformLocal, camera.positionWC, scratchPosition);\n up = Cartesian3.UNIT_Z;\n direction = Matrix4.multiplyByPointAsVector(transformLocal, camera.directionWC, scratchDirection);\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 }\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 // 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 const t = clamp((height - heightClose) / (heightFar - heightClose), 0.0, 1.0);\n // Increase density as the camera tilts towards the horizon\n const dot = Math.abs(Cartesian3.dot(direction, up));\n let horizonFactor = 1.0 - dot;\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 return dynamicScreenSpaceErrorDensity * horizonFactor;\n}\nexport function fog(distanceToCamera, density) {\n const scalar = distanceToCamera * density;\n return 1.0 - Math.exp(-(scalar * scalar));\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 return 0;\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 // Leaf tiles do not have any error so save the computation\n if (lodMetricValue === 0.0) {\n return 0.0;\n }\n // TODO: Orthographic Frustum needs special treatment?\n // this._getOrthograhicScreenSpaceError();\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 error -= getDynamicScreenSpaceError(tileset, distance);\n return error;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { Matrix4, Vector3 } from '@math.gl/core';\nimport { Ellipsoid } from '@math.gl/geospatial';\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 * 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, frameState) {\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 }\n else if (tile.header.children) {\n return 'DIG';\n }\n return 'OUT';\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, frameState) {\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 // 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(cameraPositionEnu[0] * cameraPositionEnu[0] + cameraPositionEnu[1] * cameraPositionEnu[1]);\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(sphereMbsBorderVertexCartesian);\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(sphereMbsBorderVertexCartographic);\n const projectedRadius = projectedOriginVector\n .copy(projectedOrigin)\n .subtract(projectedMbsBorderVertex)\n .magnitude();\n return projectedRadius;\n}\n", "export function get3dTilesOptions(tileset) {\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\nimport { assert } from '@loaders.gl/loader-utils';\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;\n _length;\n constructor(length = 0) {\n this._array = new Array(length);\n this._length = length;\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 set length(length) {\n this._length = length;\n if (length > this._array.length) {\n this._array.length = length;\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 * 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 * 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 if (index >= this.length) {\n this.length = index + 1;\n }\n if (this._map.has(this._array[index])) {\n this._map.delete(this._array[index]);\n }\n this._array[index] = element;\n this._map.set(element, index);\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 * 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 * 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 * 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 * Resize the internal array if length > _array.length.\n *\n * @param {Number} length The length.\n */\n reserve(length) {\n assert(length >= 0);\n if (length > this._array.length) {\n this._array.length = length;\n }\n }\n /**\n * Resize the array.\n *\n * @param {Number} length The length.\n */\n resize(length) {\n assert(length >= 0);\n this.length = length;\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 reset() {\n this._array = [];\n this._map = new Map();\n this._length = 0;\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\nimport { ManagedArray } from \"../utils/managed-array.js\";\nimport { TILE_REFINEMENT } from \"../constants.js\";\nexport const DEFAULT_PROPS = {\n loadSiblings: false,\n skipLevelOfDetail: false,\n updateTransforms: true,\n onTraversalEnd: () => { },\n viewportTraversersMap: {},\n basePath: ''\n};\nexport class TilesetTraverser {\n options;\n // fulfill in traverse call\n root = null;\n // tiles should be rendered\n selectedTiles = {};\n // tiles should be loaded from server\n requestedTiles = {};\n // tiles does not have render content\n emptyTiles = {};\n lastUpdate = new Date().getTime();\n updateDebounceTime = 1000;\n /** temporary storage to hold the traversed tiles during a traversal */\n _traversalStack = new ManagedArray();\n _emptyTraversalStack = new ManagedArray();\n /** set in every traverse cycle */\n _frameNumber = null;\n // RESULT\n traversalFinished(frameState) {\n return true;\n }\n // TODO nested props\n constructor(options) {\n this.options = { ...DEFAULT_PROPS, ...options };\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 // reset result\n this.reset();\n // update tile (visibility and expiration)\n this.updateTile(root, frameState);\n this._frameNumber = frameState.frameNumber;\n this.executeTraversal(root, frameState);\n }\n reset() {\n this.requestedTiles = {};\n this.selectedTiles = {};\n this.emptyTiles = {};\n this._traversalStack.reset();\n this._emptyTraversalStack.reset();\n }\n /**\n * Execute traverse\n * Depth-first traversal that traverses all visible tiles and marks tiles for selection.\n * If skipLevelOfDetail is off then a tile does not refine until all children are loaded.\n * This is the traditional replacement refinement approach and is called the base traversal.\n * Tiles that have a greater screen space error than the base screen space error are part of the base traversal,\n * all other tiles are part of the skip traversal. The skip traversal allows for skipping levels of the tree\n * and rendering children and parent tiles simultaneously.\n */\n /* eslint-disable-next-line complexity, max-statements */\n executeTraversal(root, frameState) {\n // stack to store traversed tiles, only visible tiles should be added to stack\n // visible: visible in the current view frustum\n const stack = this._traversalStack;\n root._selectionDepth = 1;\n stack.push(root);\n while (stack.length > 0) {\n // 1. pop tile\n const tile = stack.pop();\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(tile, frameState, stack, tile.hasRenderContent ? tile._selectionDepth + 1 : tile._selectionDepth);\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 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 }\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 // replace tiles\n }\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 // 3. update cache, most recent touched tiles have higher priority to be fetched from server\n this.touchTile(tile, frameState);\n // 4. update tile refine prop and parent refinement status to trickle down to the descendants\n tile._shouldRefine = shouldRefine && parentRefines;\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 updateChildTiles(tile, frameState) {\n const children = tile.children;\n for (const child of children) {\n this.updateTile(child, frameState);\n }\n }\n /* eslint-disable complexity, max-statements */\n updateAndPushChildren(tile, frameState, stack, depth) {\n const { loadSiblings, skipLevelOfDetail } = this.options;\n const children = tile.children;\n // sort children tiles\n children.sort(this.compareDistanceToCamera.bind(this));\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 = tile.refine === TILE_REFINEMENT.REPLACE && tile.hasRenderContent && !skipLevelOfDetail;\n let hasVisibleChild = false;\n let refines = true;\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 }\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 if (checkRefines) {\n let childRefines;\n if (!child._inRequestVolume) {\n childRefines = false;\n }\n else if (!child.hasRenderContent) {\n childRefines = this.executeEmptyTraversal(child, frameState);\n }\n else {\n childRefines = child.contentAvailable;\n }\n refines = refines && childRefines;\n if (!refines) {\n return false;\n }\n }\n }\n if (!hasVisibleChild) {\n refines = false;\n }\n return refines;\n }\n /* eslint-enable complexity, max-statements */\n updateTile(tile, frameState) {\n this.updateTileVisibility(tile, frameState);\n }\n // tile to render in the browser\n selectTile(tile, frameState) {\n if (this.shouldSelectTile(tile)) {\n // The tile can be selected right away and does not require traverseAndSelect\n tile._selectedFrame = frameState.frameNumber;\n this.selectedTiles[tile.id] = tile;\n }\n }\n // tile to load from server\n loadTile(tile, frameState) {\n if (this.shouldLoadTile(tile)) {\n tile._requestedFrame = frameState.frameNumber;\n tile._priority = tile._getPriority();\n this.requestedTiles[tile.id] = tile;\n }\n }\n // cache tile\n touchTile(tile, frameState) {\n tile.tileset._cache.touch(tile);\n tile._touchedFrame = frameState.frameNumber;\n }\n // tile should be visible\n // tile should have children\n // tile LoD (level of detail) is not sufficient under current viewport\n canTraverse(tile, frameState) {\n if (!tile.hasChildren) {\n return false;\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 return this.shouldRefine(tile, frameState);\n }\n shouldLoadTile(tile) {\n // if request tile is in current frame\n // and has unexpired render content\n return tile.hasUnloadedContent || tile.contentExpired;\n }\n shouldSelectTile(tile) {\n // if select tile is in current frame\n // and content available\n return tile.contentAvailable && !this.options.skipLevelOfDetail;\n }\n /** Decide if tile LoD (level of detail) is not sufficient under current viewport */\n shouldRefine(tile, frameState, useParentMetric = false) {\n let screenSpaceError = tile._screenSpaceError;\n if (useParentMetric) {\n screenSpaceError = tile.getScreenSpaceError(frameState, true);\n }\n return screenSpaceError > tile.tileset.memoryAdjustedScreenSpaceError;\n }\n updateTileVisibility(tile, frameState) {\n const viewportIds = [];\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 }\n else {\n viewportIds.push(frameState.viewport.id);\n }\n tile.updateVisibility(frameState, viewportIds);\n }\n // UTILITIES\n compareDistanceToCamera(b, a) {\n return b._distanceToCamera - a._distanceToCamera;\n }\n anyChildrenVisible(tile, frameState) {\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 // Depth-first traversal that checks if all nearest descendants with content are loaded.\n // Ignores visibility.\n executeEmptyTraversal(root, frameState) {\n let allDescendantsLoaded = true;\n const stack = this._emptyTraversalStack;\n stack.push(root);\n while (stack.length > 0) {\n const tile = stack.pop();\n const traverse = !tile.hasRenderContent && this.canTraverse(tile, frameState);\n const emptyLeaf = !tile.hasRenderContent && tile.children.length === 0;\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 this.updateTile(tile, frameState);\n if (!tile.isVisibleAndInRequestVolume) {\n this.loadTile(tile, frameState);\n this.touchTile(tile, frameState);\n }\n if (traverse) {\n const children = tile.children;\n for (const child of children) {\n stack.push(child);\n }\n }\n }\n return allDescendantsLoaded;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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\nimport { TILE3D_OPTIMIZATION_HINT, TILE_REFINEMENT } from \"../../constants.js\";\nimport { TilesetTraverser } from \"../tileset-traverser.js\";\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 updateTileVisibility(tile, frameState) {\n super.updateTileVisibility(tile, frameState);\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 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 if (this.meetsScreenSpaceErrorEarly(tile, frameState)) {\n tile._visible = false;\n return;\n }\n const replace = tile.refine === TILE_REFINEMENT.REPLACE;\n const useOptimization = 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 meetsScreenSpaceErrorEarly(tile, frameState) {\n const { parent } = tile;\n if (!parent || parent.hasTilesetContent || parent.refine !== TILE_REFINEMENT.ADD) {\n return false;\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.js\";\nimport { getLodStatus } from \"../helpers/i3s-lod.js\";\nimport { Tile3D } from \"../tile-3d.js\";\nimport { I3STileManager } from \"./i3s-tile-manager.js\";\nexport class I3STilesetTraverser extends TilesetTraverser {\n _tileManager;\n constructor(options) {\n super(options);\n this._tileManager = new I3STileManager();\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) {\n return !this._tileManager.hasPendingTiles(frameState.viewport.id, this._frameNumber || 0);\n }\n shouldRefine(tile, frameState) {\n tile._lodJudge = getLodStatus(tile, frameState);\n return tile._lodJudge === 'DIG';\n }\n updateChildTiles(tile, frameState) {\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 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(request, extendedId, (header) => this._onTileLoad(header, tile, extendedId), frameState);\n }\n else {\n // update frameNumber since it is still needed in current frame\n this._tileManager.update(extendedId, frameState);\n }\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 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 return await load(nodeUrl, loader, options);\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 // after tile fetched, resume traversal if still in current update/traversal frame\n if (this._frameNumber === frameState.frameNumber &&\n (this.traversalFinished(frameState) ||\n new Date().getTime() - this.lastUpdate > this.updateDebounceTime)) {\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 frameNumberMap = new Map();\n /**\n * Register a new pending tile header for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n */\n register(viewportId, frameNumber) {\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 * Deregister a pending tile header for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n */\n deregister(viewportId, frameNumber) {\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 * 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, frameNumber) {\n const count = this.frameNumberMap.get(viewportId)?.get(frameNumber) || 0;\n return count === 0;\n }\n}\n", "import { I3SPendingTilesRegister } from \"./i3s-pending-tiles-register.js\";\nconst STATUS = {\n REQUESTED: 'REQUESTED',\n COMPLETED: 'COMPLETED',\n ERROR: 'ERROR'\n};\n// A helper class to manage tile metadata fetching\nexport class I3STileManager {\n _statusMap;\n pendingTilesRegister = new I3SPendingTilesRegister();\n constructor() {\n this._statusMap = {};\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) {\n if (!this._statusMap[key]) {\n const { frameNumber, viewport: { id } } = 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 { frameNumber: actualFrameNumber, viewport: { id } } = 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 { frameNumber: actualFrameNumber, viewport: { id } } = 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 * 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) {\n if (this._statusMap[key]) {\n // Deregister pending request for the old frameNumber\n const { frameNumber, viewport: { id } } = this._statusMap[key].frameState;\n this.pendingTilesRegister.deregister(id, frameNumber);\n // Register pending request for the new frameNumber\n const { frameNumber: newFrameNumber, viewport: { id: newViewportId } } = frameState;\n this.pendingTilesRegister.register(newViewportId, newFrameNumber);\n this._statusMap[key].frameState = frameState;\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 * Check it there are pending tile headers for the particular frameNumber\n * @param viewportId\n * @param frameNumber\n * @returns\n */\n hasPendingTiles(viewportId, frameNumber) {\n return !this.pendingTilesRegister.isZero(viewportId, frameNumber);\n }\n}\n"], "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,IAAAA,gBAAiC;AACjC,IAAAC,qBAA0B;AAC1B,mBA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AAS,MAAM;AACf,aAAK,aAAa,IAAI;AAAA,MAC1B;AAAA,IACJ;AACA,SAAK,WAAW,CAAC;AAAA,EACrB;AAAA,EACA,aAAa,MAAM;AACf,SAAK,OAAO,WAAW,MAAM,IAAI;AACjC,SAAK,YAAY,IAAI;AACrB,SAAK,QAAQ;AAAA,EACjB;AAAA,EACA,0BAA0B,aAAa;AACnC,QAAI,YAAY,aAAa;AACzB,YAAM,eAAe,IAAI,gBAAgB,YAAY,WAAW;AAChE,YAAM,cAAc,OAAO,YAAY,aAAa,QAAQ,CAAC;AAC7D,WAAK,eAAe,EAAE,GAAG,KAAK,cAAc,GAAG,YAAY;AAAA,IAC/D;AACA,SAAK,QAAQ,YAAY;AACzB,QAAI,CAAC,KAAK,OAAO;AACb,YAAM,IAAI,MAAM,sCAAsC;AAAA,IAC1D;AACA,QAAI,KAAK,MAAM,YAAY,SACvB,KAAK,MAAM,YAAY,SACvB,KAAK,MAAM,YAAY,OAAO;AAC9B,YAAM,IAAI,MAAM,gEAAgE;AAAA,IACpF;AAGA,QAAI,oBAAoB,KAAK,OAAO;AAChC,WAAK,aAAa,IAAI,KAAK,MAAM;AAAA,IACrC;AAEA,SAAK,UAAU;AAAA,MACX,cAAc,KAAK,QAAQ,gBAAgB,CAAC;AAAA,IAChD;AACA,SAAK,cAAc,KAAK,QAAQ,eAAe;AAE/C,SAAK,aAAa,YAAY;AAC9B,SAAK,iBAAiB,YAAY;AAClC,SAAK,kBAAkB,YAAY,kBAAkB,CAAC;AAEtD,SAAK,SAAS,YAAY;AAAA,EAC9B;AAAA,EACA,wBAAwB;AAEpB,QAAI,KAAK,YAAY,OAAO,WAAW,KAAK,YAAY,KAAK;AAEzD,WAAK,aAAa,QAAQ,KAAK,YAAY,IAAI;AAAA,IACnD;AAAA,EACJ;AACJ;", "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"] }