@loaders.gl/3d-tiles 4.0.0-alpha.12 → 4.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/dist.min.js +690 -62
  2. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +63 -38
  3. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  4. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +69 -44
  5. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  6. package/dist/es5/lib/parsers/parse-3d-tile-header.js +12 -11
  7. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  8. package/dist/es5/lib/utils/version.js +1 -1
  9. package/dist/es5/types.js.map +1 -1
  10. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +45 -23
  11. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  12. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +18 -14
  13. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  14. package/dist/esm/lib/parsers/parse-3d-tile-header.js +6 -4
  15. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  16. package/dist/esm/lib/utils/version.js +1 -1
  17. package/dist/esm/types.js.map +1 -1
  18. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +4 -1
  19. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  20. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +65 -28
  21. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
  22. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +24 -18
  23. package/dist/lib/parsers/parse-3d-tile-header.d.ts +30 -2
  24. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  25. package/dist/lib/parsers/parse-3d-tile-header.js +6 -5
  26. package/dist/types.d.ts +45 -3
  27. package/dist/types.d.ts.map +1 -1
  28. package/package.json +8 -7
  29. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +76 -32
  30. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +43 -35
  31. package/src/lib/parsers/parse-3d-tile-header.ts +37 -5
  32. package/src/types.ts +46 -4
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-subtree.js","names":["SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","data","options","context","magic","Uint32Array","slice","Error","version","jsonByteLength","parseUint64Value","stringAttribute","Uint8Array","textDecoder","TextDecoder","string","decode","subtree","JSON","parse","binaryByteLength","internalBinaryBuffer","ArrayBuffer","tileAvailability","explicitBitstream","getExplicitBitstream","contentAvailability","childSubtreeAvailability","name","bufferViewIndex","bufferView","bufferViews","buffer","buffers","url","fetch","uri","bufferUri","concat","baseUrl","response","arrayBuffer","byteOffset","byteLength","dataView","DataView","left","getUint32","right"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"sourcesContent":["import type {Subtree, ExplicitBitstream} from '../../../types';\nimport type {LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';\n\nconst SUBTREE_FILE_MAGIC = 0x74627573;\nconst SUBTREE_FILE_VERSION = 1;\n\n/**\n * Parse subtree file\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n * @param data\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport default async function parse3DTilesSubtree(\n data: ArrayBuffer,\n options: LoaderOptions | undefined,\n context: LoaderContext | undefined\n): Promise<Subtree> {\n const magic = new Uint32Array(data.slice(0, 4));\n\n if (magic[0] !== SUBTREE_FILE_MAGIC) {\n throw new Error('Wrong subtree file magic number');\n }\n\n const version = new Uint32Array(data.slice(4, 8));\n\n if (version[0] !== SUBTREE_FILE_VERSION) {\n throw new Error('Wrong subtree file verson, must be 1');\n }\n\n const jsonByteLength = parseUint64Value(data.slice(8, 16));\n const stringAttribute = new Uint8Array(data, 24, jsonByteLength);\n\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(stringAttribute);\n const subtree = JSON.parse(string);\n\n const binaryByteLength = parseUint64Value(data.slice(16, 24));\n let internalBinaryBuffer = new ArrayBuffer(0);\n\n if (binaryByteLength) {\n internalBinaryBuffer = data.slice(24 + jsonByteLength);\n }\n\n if ('bufferView' in subtree.tileAvailability) {\n subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'tileAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.contentAvailability) {\n subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'contentAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n if ('bufferView' in subtree.childSubtreeAvailability) {\n subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'childSubtreeAvailability',\n internalBinaryBuffer,\n context\n );\n }\n\n return subtree;\n}\n\n/**\n * Get explicit bitstream for subtree availability data.\n * @param subtree\n * @param name\n * @param internalBinaryBuffer\n */\nasync function getExplicitBitstream(\n subtree: Subtree,\n name: string,\n internalBinaryBuffer: ArrayBuffer,\n context: LoaderContext | undefined\n): Promise<ExplicitBitstream> {\n const bufferViewIndex = subtree[name].bufferView;\n const bufferView = subtree.bufferViews[bufferViewIndex];\n const buffer = subtree.buffers[bufferView.buffer];\n\n if (!context?.url || !context.fetch) {\n throw new Error('Url is not provided');\n }\n\n if (!context.fetch) {\n throw new Error('fetch is not provided');\n }\n\n // External bitstream loading\n if (buffer.uri) {\n const bufferUri = `${context?.baseUrl || ''}/${buffer.uri}`;\n const response = await context.fetch(bufferUri);\n const data = await response.arrayBuffer();\n // Return view of bitstream.\n return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);\n }\n // Return view of bitstream.\n return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);\n}\n\n/**\n * Parse buffer to return uint64 value\n * @param buffer\n * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Value(buffer: ArrayBuffer): number {\n const dataView = new DataView(buffer);\n const left = dataView.getUint32(0, true);\n const right = dataView.getUint32(4, true);\n // combine the two 32-bit values\n return left + 2 ** 32 * right;\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,GAAG,UAAU;AACrC,MAAMC,oBAAoB,GAAG,CAAC;AAS9B,eAAe,eAAeC,mBAAmBA,CAC/CC,IAAiB,EACjBC,OAAkC,EAClCC,OAAkC,EAChB;EAClB,MAAMC,KAAK,GAAG,IAAIC,WAAW,CAACJ,IAAI,CAACK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAE/C,IAAIF,KAAK,CAAC,CAAC,CAAC,KAAKN,kBAAkB,EAAE;IACnC,MAAM,IAAIS,KAAK,CAAC,iCAAiC,CAAC;EACpD;EAEA,MAAMC,OAAO,GAAG,IAAIH,WAAW,CAACJ,IAAI,CAACK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAEjD,IAAIE,OAAO,CAAC,CAAC,CAAC,KAAKT,oBAAoB,EAAE;IACvC,MAAM,IAAIQ,KAAK,CAAC,sCAAsC,CAAC;EACzD;EAEA,MAAME,cAAc,GAAGC,gBAAgB,CAACT,IAAI,CAACK,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;EAC1D,MAAMK,eAAe,GAAG,IAAIC,UAAU,CAACX,IAAI,EAAE,EAAE,EAAEQ,cAAc,CAAC;EAEhE,MAAMI,WAAW,GAAG,IAAIC,WAAW,CAAC,MAAM,CAAC;EAC3C,MAAMC,MAAM,GAAGF,WAAW,CAACG,MAAM,CAACL,eAAe,CAAC;EAClD,MAAMM,OAAO,GAAGC,IAAI,CAACC,KAAK,CAACJ,MAAM,CAAC;EAElC,MAAMK,gBAAgB,GAAGV,gBA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CAAC,qBAAqB,CAAC;EACxC;EAEA,IAAI,CAACJ,OAAO,CAACgC,KAAK,EAAE;IAClB,MAAM,IAAI5B,KAAK,CAAC,uBAAuB,CAAC;EAC1C;EAGA,IAAIyB,MAAM,CAACI,GAAG,EAAE;IACd,MAAMC,SAAS,MAAAC,MAAA,CAAM,CAAAnC,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEoC,OAAO,KAAI,EAAE,OAAAD,MAAA,CAAIN,MAAM,CAACI,GAAG,CAAE;IAC3D,MAAMI,QAAQ,GAAG,MAAMrC,OAAO,CAACgC,KAAK,CAACE,SAAS,CAAC;IAC/C,MAAMpC,IAAI,GAAG,MAAMuC,QAAQ,CAACC,WAAW,CAAC,CAAC;IAEzC,OAAO,IAAI7B,UAAU,CAACX,IAAI,EAAE6B,UAAU,CAACY,UAAU,EAAEZ,UAAU,CAACa,UAAU,CAAC;EAC3E;EAEA,OAAO,IAAI/B,UAAU,CAACS,oBAAoB,EAAES,UAAU,CAACY,UAAU,EAAEZ,UAAU,CAACa,UAAU,CAAC;AAC3F;AAOA,SAASjC,gBAAgBA,CAACsB,MAAmB,EAAU;EACrD,MAAMY,QAAQ,GAAG,IAAIC,QAAQ,CAACb,MAAM,CAAC;EACrC,MAAMc,IAAI,GAAGF,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EACxC,MAAMC,KAAK,GAAGJ,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EAEzC,OAAOD,IAAI,GAAG,CAAC,IAAI,EAAE,GAAGE,KAAK;AAC/B"}
1
+ {"version":3,"file":"parse-3d-tile-subtree.js","names":["SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","data","options","context","magic","Uint32Array","slice","Error","version","jsonByteLength","parseUint64Value","stringAttribute","Uint8Array","textDecoder","TextDecoder","string","decode","subtree","JSON","parse","binaryByteLength","internalBinaryBuffer","ArrayBuffer","loadExplicitBitstream","tileAvailability","Array","isArray","contentAvailability","childSubtreeAvailability","availabilityObject","bufferViewIndex","Number","isFinite","bitstream","bufferView","bufferViews","buffer","buffers","baseUrl","fetch","uri","bufferUri","concat","response","arrayBuffer","explicitBitstream","byteOffset","byteLength","dataView","DataView","left","getUint32","right"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"sourcesContent":["import type {Subtree, Availability} from '../../../types';\nimport type {LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';\n\nconst SUBTREE_FILE_MAGIC = 0x74627573;\nconst SUBTREE_FILE_VERSION = 1;\n\n/**\n * Parse subtree file\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n * @param data\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport default async function parse3DTilesSubtree(\n data: ArrayBuffer,\n options: LoaderOptions | undefined,\n context: LoaderContext | undefined\n): Promise<Subtree> {\n const magic = new Uint32Array(data.slice(0, 4));\n\n if (magic[0] !== SUBTREE_FILE_MAGIC) {\n throw new Error('Wrong subtree file magic number');\n }\n\n const version = new Uint32Array(data.slice(4, 8));\n\n if (version[0] !== SUBTREE_FILE_VERSION) {\n throw new Error('Wrong subtree file verson, must be 1');\n }\n\n const jsonByteLength = parseUint64Value(data.slice(8, 16));\n const stringAttribute = new Uint8Array(data, 24, jsonByteLength);\n\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(stringAttribute);\n const subtree = JSON.parse(string);\n\n const binaryByteLength = parseUint64Value(data.slice(16, 24));\n let internalBinaryBuffer = new ArrayBuffer(0);\n\n if (binaryByteLength) {\n internalBinaryBuffer = data.slice(24 + jsonByteLength);\n }\n\n await loadExplicitBitstream(subtree, subtree.tileAvailability, internalBinaryBuffer, context);\n if (Array.isArray(subtree.contentAvailability)) {\n for (const contentAvailability of subtree.contentAvailability) {\n await loadExplicitBitstream(subtree, contentAvailability, internalBinaryBuffer, context);\n }\n } else {\n await loadExplicitBitstream(\n subtree,\n subtree.contentAvailability,\n internalBinaryBuffer,\n context\n );\n }\n await loadExplicitBitstream(\n subtree,\n subtree.childSubtreeAvailability,\n internalBinaryBuffer,\n context\n );\n\n return subtree;\n}\n\n/**\n * Load explicit bitstream for subtree availability data.\n * @param subtree - subtree data\n * @param availabilityObject - tileAvailability / contentAvailability / childSubtreeAvailability object\n * @param internalBinaryBuffer - subtree binary buffer\n * @param context - loaders.gl context\n */\nasync function loadExplicitBitstream(\n subtree: Subtree,\n availabilityObject: Availability,\n internalBinaryBuffer: ArrayBuffer,\n context: LoaderContext | undefined\n): Promise<void> {\n const bufferViewIndex = Number.isFinite(availabilityObject.bitstream)\n ? availabilityObject.bitstream\n : availabilityObject.bufferView;\n\n if (typeof bufferViewIndex !== 'number') {\n return;\n }\n\n const bufferView = subtree.bufferViews[bufferViewIndex];\n const buffer = subtree.buffers[bufferView.buffer];\n\n if (!context?.baseUrl) {\n throw new Error('Url is not provided');\n }\n\n if (!context.fetch) {\n throw new Error('fetch is not provided');\n }\n\n // External bitstream loading\n if (buffer.uri) {\n const bufferUri = `${context?.baseUrl || ''}/${buffer.uri}`;\n const response = await context.fetch(bufferUri);\n const data = await response.arrayBuffer();\n availabilityObject.explicitBitstream = new Uint8Array(\n data,\n bufferView.byteOffset,\n bufferView.byteLength\n );\n return;\n }\n availabilityObject.explicitBitstream = new Uint8Array(\n internalBinaryBuffer,\n bufferView.byteOffset,\n bufferView.byteLength\n );\n}\n\n/**\n * Parse buffer to return uint64 value\n * @param buffer\n * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Value(buffer: ArrayBuffer): number {\n const dataView = new DataView(buffer);\n const left = dataView.getUint32(0, true);\n const right = dataView.getUint32(4, true);\n // combine the two 32-bit values\n return left + 2 ** 32 * right;\n}\n"],"mappings":"AAGA,MAAMA,kBAAkB,GAAG,UAAU;AACrC,MAAMC,oBAAoB,GAAG,CAAC;AAS9B,eAAe,eAAeC,mBAAmBA,CAC/CC,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AA,CAAIN,MAAM,CAACI,GAAG,CAAE;IAC3D,MAAMG,QAAQ,GAAG,MAAMxC,OAAO,CAACoC,KAAK,CAACE,SAAS,CAAC;IAC/C,MAAMxC,IAAI,GAAG,MAAM0C,QAAQ,CAACC,WAAW,CAAC,CAAC;IACzCf,kBAAkB,CAACgB,iBAAiB,GAAG,IAAIjC,UAAU,CACnDX,IAAI,EACJiC,UAAU,CAACY,UAAU,EACrBZ,UAAU,CAACa,UACb,CAAC;IACD;EACF;EACAlB,kBAAkB,CAACgB,iBAAiB,GAAG,IAAIjC,UAAU,CACnDS,oBAAoB,EACpBa,UAAU,CAACY,UAAU,EACrBZ,UAAU,CAACa,UACb,CAAC;AACH;AAOA,SAASrC,gBAAgBA,CAAC0B,MAAmB,EAAU;EACrD,MAAMY,QAAQ,GAAG,IAAIC,QAAQ,CAACb,MAAM,CAAC;EACrC,MAAMc,IAAI,GAAGF,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EACxC,MAAMC,KAAK,GAAGJ,QAAQ,CAACG,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;EAEzC,OAAOD,IAAI,GAAG,CAAC,IAAI,EAAE,GAAGE,KAAK;AAC/B"}
@@ -104,6 +104,7 @@ export async function normalizeImplicitTileHeaders(tile, tileset, basePath, impl
104
104
  const {
105
105
  subdivisionScheme,
106
106
  maximumLevel,
107
+ availableLevels,
107
108
  subtreeLevels,
108
109
  subtrees: {
109
110
  uri: subtreesUriTemplate
@@ -130,7 +131,7 @@ export async function normalizeImplicitTileHeaders(tile, tileset, basePath, impl
130
131
  subtreesUriTemplate,
131
132
  subdivisionScheme,
132
133
  subtreeLevels,
133
- maximumLevel,
134
+ maximumLevel: Number.isFinite(availableLevels) ? availableLevels - 1 : maximumLevel,
134
135
  refine,
135
136
  basePath,
136
137
  lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
@@ -139,9 +140,9 @@ export async function normalizeImplicitTileHeaders(tile, tileset, basePath, impl
139
140
  getTileType,
140
141
  getRefine
141
142
  };
142
- return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions);
143
+ return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions, options);
143
144
  }
144
- export async function normalizeImplicitTileData(tile, basePath, rootSubtree, options) {
145
+ export async function normalizeImplicitTileData(tile, basePath, rootSubtree, implicitOptions, loaderOptions) {
145
146
  if (!tile) {
146
147
  return null;
147
148
  }
@@ -150,7 +151,8 @@ export async function normalizeImplicitTileData(tile, basePath, rootSubtree, opt
150
151
  contentUrl
151
152
  } = await parseImplicitTiles({
152
153
  subtree: rootSubtree,
153
- options
154
+ implicitOptions,
155
+ loaderOptions
154
156
  });
155
157
  let tileContentUrl;
156
158
  let tileContent = null;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-header.js","names":["Tile3DSubtreeLoader","load","LOD_METRIC_TYPE","TILE_REFINEMENT","TILE_TYPE","parseImplicitTiles","replaceContentUrlTemplate","convertS2BoundingVolumetoOBB","getTileType","tile","tileContentUrl","arguments","length","undefined","EMPTY","contentUrl","split","fileExtension","pop","POINTCLOUD","SCENEGRAPH","getRefine","refine","REPLACE","ADD","resolveUri","uri","basePath","urlSchemeRegex","test","url","URL","concat","decodeURI","toString","startsWith","normalizeTileData","content","_tile$content","contentUri","tilePostprocessed","id","lodMetricType","GEOMETRIC_ERROR","lodMetricValue","geometricError","transformMatrix","transform","type","normalizeTileHeaders","tileset","options","root","rootImplicitTilingExtension","getImplicitTilingExtensionData","normalizeImplicitTileHeaders","stack","push","children","childrenPostprocessed","childHeader","childImplicitTilingExtension","childHeaderPostprocessed","implicitTilingExtension","_tile$content2","_tileset$root","_tile$boundingVolume$","subdivisionScheme","maximumLevel","subtreeLevels","subtrees","subtreesUriTemplate","replacedUrlTemplate","subtreeUrl","subtree","contentUrlTemplate","rootLodMetricValue","s2VolumeInfo","boundingVolume","extensions","box","s2VolumeBox","rootBoundingVolume","implicitOptions","normalizeImplicitTileData","rootSubtree","tileContent","replace","_tile$extensions","implicitTiling"],"sources":["../../../../src/lib/parsers/parse-3d-tile-header.ts"],"sourcesContent":["import type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Tile3DSubtreeLoader} from '../../tile-3d-subtree-loader';\nimport {load} from '@loaders.gl/core';\nimport {LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE} from '@loaders.gl/tiles';\nimport {\n ImplicitTilingExensionData,\n Subtree,\n Tiles3DTileContentJSON,\n Tiles3DTileJSON,\n Tiles3DTileJSONPostprocessed,\n Tiles3DTilesetJSON\n} from '../../types';\nimport type {S2VolumeBox} from './helpers/parse-3d-implicit-tiles';\nimport {parseImplicitTiles, replaceContentUrlTemplate} from './helpers/parse-3d-implicit-tiles';\nimport type {S2VolumeInfo} from '../utils/obb/s2-corners-to-obb';\nimport {convertS2BoundingVolumetoOBB} from '../utils/obb/s2-corners-to-obb';\n\nfunction getTileType(tile: Tiles3DTileJSON, tileContentUrl: string = ''): TILE_TYPE | string {\n if (!tileContentUrl) {\n return TILE_TYPE.EMPTY;\n }\n\n const contentUrl = tileContentUrl.split('?')[0]; // Discard query string\n const fileExtension = contentUrl.split('.').pop();\n switch (fileExtension) {\n case 'pnts':\n return TILE_TYPE.POINTCLOUD;\n case 'i3dm':\n case 'b3dm':\n case 'glb':\n case 'gltf':\n return TILE_TYPE.SCENEGRAPH;\n default:\n return fileExtension || TILE_TYPE.EMPTY;\n }\n}\n\nfunction getRefine(refine?: string): TILE_REFINEMENT | string | undefined {\n switch (refine) {\n case 'REPLACE':\n case 'replace':\n return TILE_REFINEMENT.REPLACE;\n case 'ADD':\n case 'add':\n return TILE_REFINEMENT.ADD;\n default:\n return refine;\n }\n}\n\nfunction resolveUri(uri: string = '', basePath: string): string {\n // url scheme per RFC3986\n const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;\n\n if (urlSchemeRegex.test(basePath)) {\n const url = new URL(uri, `${basePath}/`);\n return decodeURI(url.toString());\n } else if (uri.startsWith('/')) {\n return uri;\n }\n\n return `${basePath}/${uri}`;\n}\n\nexport function normalizeTileData(\n tile: Tiles3DTileJSON | null,\n basePath: string\n): Tiles3DTileJSONPostprocessed | null {\n if (!tile) {\n return null;\n }\n let tileContentUrl: string | undefined;\n if (tile.content) {\n const contentUri = tile.content.uri || tile.content?.url;\n tileContentUrl = resolveUri(contentUri, basePath);\n }\n const tilePostprocessed: Tiles3DTileJSONPostprocessed = {\n ...tile,\n id: tileContentUrl,\n contentUrl: tileContentUrl,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n lodMetricValue: tile.geometricError,\n transformMatrix: tile.transform,\n type: getTileType(tile, tileContentUrl),\n refine: getRefine(tile.refine)\n };\n\n return tilePostprocessed;\n}\n\n// normalize tile headers\nexport async function normalizeTileHeaders(\n tileset: Tiles3DTilesetJSON,\n basePath: string,\n options: LoaderOptions\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n let root: Tiles3DTileJSONPostprocessed | null = null;\n\n const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);\n if (rootImplicitTilingExtension && tileset.root) {\n root = await normalizeImplicitTileHeaders(\n tileset.root,\n tileset,\n basePath,\n rootImplicitTilingExtension,\n options\n );\n } else {\n root = normalizeTileData(tileset.root, basePath);\n }\n\n const stack: any[] = [];\n stack.push(root);\n\n while (stack.length > 0) {\n const tile = stack.pop() || {};\n const children = tile.children || [];\n const childrenPostprocessed: Tiles3DTileJSONPostprocessed[] = [];\n for (const childHeader of children) {\n const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);\n let childHeaderPostprocessed: Tiles3DTileJSONPostprocessed | null;\n if (childImplicitTilingExtension) {\n childHeaderPostprocessed = await normalizeImplicitTileHeaders(\n childHeader,\n tileset,\n basePath,\n childImplicitTilingExtension,\n options\n );\n } else {\n childHeaderPostprocessed = normalizeTileData(childHeader, basePath);\n }\n\n if (childHeaderPostprocessed) {\n childrenPostprocessed.push(childHeaderPostprocessed);\n stack.push(childHeaderPostprocessed);\n }\n }\n tile.children = childrenPostprocessed;\n }\n\n return root;\n}\n\n/**\n * Do normalisation of implicit tile headers\n * TODO Check if Tile3D class can be a return type here.\n * @param tileset\n */\nexport async function normalizeImplicitTileHeaders(\n tile: Tiles3DTileJSON,\n tileset: Tiles3DTilesetJSON,\n basePath: string,\n implicitTilingExtension: ImplicitTilingExensionData,\n options: Tiles3DLoaderOptions\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n const {\n subdivisionScheme,\n maximumLevel,\n subtreeLevels,\n subtrees: {uri: subtreesUriTemplate}\n } = implicitTilingExtension;\n const replacedUrlTemplate = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);\n const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);\n const subtree = await load(subtreeUrl, Tile3DSubtreeLoader, options);\n const contentUrlTemplate = resolveUri(tile.content?.uri, basePath);\n const refine = tileset?.root?.refine;\n // @ts-ignore\n const rootLodMetricValue = tile.geometricError;\n\n // Replace tile.boundingVolume with the the bounding volume specified by the extensions['3DTILES_bounding_volume_S2']\n const s2VolumeInfo: S2VolumeInfo = tile.boundingVolume.extensions?.['3DTILES_bounding_volume_S2'];\n if (s2VolumeInfo) {\n const box = convertS2BoundingVolumetoOBB(s2VolumeInfo);\n const s2VolumeBox: S2VolumeBox = {box, s2VolumeInfo};\n tile.boundingVolume = s2VolumeBox;\n }\n\n const rootBoundingVolume = tile.boundingVolume;\n\n const implicitOptions = {\n contentUrlTemplate,\n subtreesUriTemplate,\n subdivisionScheme,\n subtreeLevels,\n maximumLevel,\n refine,\n basePath,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n rootLodMetricValue,\n rootBoundingVolume,\n getTileType,\n getRefine\n };\n\n return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions);\n}\n\n/**\n * Do implicit data normalisation to create hierarchical tile structure\n * @param tile\n * @param rootSubtree\n * @param options\n * @returns\n */\nexport async function normalizeImplicitTileData(\n tile: Tiles3DTileJSON,\n basePath: string,\n rootSubtree: Subtree,\n options: any\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n if (!tile) {\n return null;\n }\n\n const {children, contentUrl} = await parseImplicitTiles({\n subtree: rootSubtree,\n options\n });\n\n let tileContentUrl: string | undefined;\n let tileContent: Tiles3DTileContentJSON | null = null;\n if (contentUrl) {\n tileContentUrl = contentUrl;\n tileContent = {uri: contentUrl.replace(`${basePath}/`, '')};\n }\n const tilePostprocessed: Tiles3DTileJSONPostprocessed = {\n ...tile,\n id: tileContentUrl,\n contentUrl: tileContentUrl,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n lodMetricValue: tile.geometricError,\n transformMatrix: tile.transform,\n type: getTileType(tile, tileContentUrl),\n refine: getRefine(tile.refine),\n content: tileContent || tile.content,\n children\n };\n\n return tilePostprocessed;\n}\n\n/**\n * Implicit Tiling data can be in 3DTILES_implicit_tiling for 3DTiles v.Next or directly in implicitTiling object for 3DTiles v1.1.\n * Spec 3DTiles v.Next - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n * Spec 3DTiles v.1.1 - https://github.com/CesiumGS/3d-tiles/tree/draft-1.1/specification/ImplicitTiling\n * @param tile\n * @returns\n */\nfunction getImplicitTilingExtensionData(tile: Tiles3DTileJSON | null): ImplicitTilingExensionData {\n return tile?.extensions?.['3DTILES_implicit_tiling'] || tile?.implicitTiling;\n}\n"],"mappings":"AAEA,SAAQA,mBAAmB,QAAO,8BAA8B;AAChE,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,eAAe,EAAEC,eAAe,EAAEC,SAAS,QAAO,mBAAmB;AAU7E,SAAQC,kBAAkB,EAAEC,yBAAyB,QAAO,mCAAmC;AAE/F,SAAQC,4BAA4B,QAAO,gCAAgC;AAE3E,SAASC,WAAWA,CAACC,IAAqB,EAAmD;EAAA,IAAjDC,cAAsB,GAAAC,S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UAAU,cAAAS,gBAAA,uBAAhBA,gBAAA,CAAmB,yBAAyB,CAAC,MAAI/E,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEgF,cAAc;AAC9E"}
1
+ {"version":3,"file":"parse-3d-tile-header.js","names":["Tile3DSubtreeLoader","load","LOD_METRIC_TYPE","TILE_REFINEMENT","TILE_TYPE","parseImplicitTiles","replaceContentUrlTemplate","convertS2BoundingVolumetoOBB","getTileType","tile","tileContentUrl","arguments","length","undefined","EMPTY","contentUrl","split","fileExtension","pop","POINTCLOUD","SCENEGRAPH","getRefine","refine","REPLACE","ADD","resolveUri","uri","basePath","urlSchemeRegex","test","url","URL","concat","decodeURI","toString","startsWith","normalizeTileData","content","_tile$content","contentUri","tilePostprocessed","id","lodMetricType","GEOMETRIC_ERROR","lodMetricValue","geometricError","transformMatrix","transform","type","normalizeTileHeaders","tileset","options","root","rootImplicitTilingExtension","getImplicitTilingExtensionData","normalizeImplicitTileHeaders","stack","push","children","childrenPostprocessed","childHeader","childImplicitTilingExtension","childHeaderPostprocessed","implicitTilingExtension","_tile$content2","_tileset$root","_tile$boundingVolume$","subdivisionScheme","maximumLevel","availableLevels","subtreeLevels","subtrees","subtreesUriTemplate","replacedUrlTemplate","subtreeUrl","subtree","contentUrlTemplate","rootLodMetricValue","s2VolumeInfo","boundingVolume","extensions","box","s2VolumeBox","rootBoundingVolume","implicitOptions","Number","isFinite","normalizeImplicitTileData","rootSubtree","loaderOptions","tileContent","replace","_tile$extensions","implicitTiling"],"sources":["../../../../src/lib/parsers/parse-3d-tile-header.ts"],"sourcesContent":["import type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport type {LoaderOptions} from '@loaders.gl/loader-utils';\nimport {Tile3DSubtreeLoader} from '../../tile-3d-subtree-loader';\nimport {load} from '@loaders.gl/core';\nimport {LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE} from '@loaders.gl/tiles';\nimport {\n ImplicitTilingExensionData,\n Subtree,\n Tile3DBoundingVolume,\n Tiles3DTileContentJSON,\n Tiles3DTileJSON,\n Tiles3DTileJSONPostprocessed,\n Tiles3DTilesetJSON\n} from '../../types';\nimport type {S2VolumeBox} from './helpers/parse-3d-implicit-tiles';\nimport {parseImplicitTiles, replaceContentUrlTemplate} from './helpers/parse-3d-implicit-tiles';\nimport type {S2VolumeInfo} from '../utils/obb/s2-corners-to-obb';\nimport {convertS2BoundingVolumetoOBB} from '../utils/obb/s2-corners-to-obb';\n\n/** Options for recursive loading implicit subtrees */\nexport type ImplicitOptions = {\n /** Template of the full url of the content template */\n contentUrlTemplate: string;\n /** Template of the full url of the subtree */\n subtreesUriTemplate: string;\n /** Implicit subdivision scheme */\n subdivisionScheme: 'QUADTREE' | 'OCTREE' | string;\n /** Levels per subtree */\n subtreeLevels: number;\n /** Maximum implicit level through all subtrees */\n maximumLevel?: number;\n /** 3DTiles refine method (add/replace) */\n refine?: string;\n /** Tileset base path */\n basePath: string;\n /** 3DTiles LOD metric type */\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR;\n /** Root metric value of the root tile of the implicit subtrees */\n rootLodMetricValue: number;\n /** Bounding volume of the root tile of the implicit subtrees */\n rootBoundingVolume: Tile3DBoundingVolume;\n /** Function that detects TILE_TYPE by tile metadata and content URL */\n getTileType: (tile: Tiles3DTileJSON, tileContentUrl?: string) => TILE_TYPE | string;\n /** Function that converts string refine method to enum value */\n getRefine: (refine?: string) => TILE_REFINEMENT | string | undefined;\n};\n\nfunction getTileType(tile: Tiles3DTileJSON, tileContentUrl: string = ''): TILE_TYPE | string {\n if (!tileContentUrl) {\n return TILE_TYPE.EMPTY;\n }\n\n const contentUrl = tileContentUrl.split('?')[0]; // Discard query string\n const fileExtension = contentUrl.split('.').pop();\n switch (fileExtension) {\n case 'pnts':\n return TILE_TYPE.POINTCLOUD;\n case 'i3dm':\n case 'b3dm':\n case 'glb':\n case 'gltf':\n return TILE_TYPE.SCENEGRAPH;\n default:\n return fileExtension || TILE_TYPE.EMPTY;\n }\n}\n\nfunction getRefine(refine?: string): TILE_REFINEMENT | string | undefined {\n switch (refine) {\n case 'REPLACE':\n case 'replace':\n return TILE_REFINEMENT.REPLACE;\n case 'ADD':\n case 'add':\n return TILE_REFINEMENT.ADD;\n default:\n return refine;\n }\n}\n\nfunction resolveUri(uri: string = '', basePath: string): string {\n // url scheme per RFC3986\n const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;\n\n if (urlSchemeRegex.test(basePath)) {\n const url = new URL(uri, `${basePath}/`);\n return decodeURI(url.toString());\n } else if (uri.startsWith('/')) {\n return uri;\n }\n\n return `${basePath}/${uri}`;\n}\n\nexport function normalizeTileData(\n tile: Tiles3DTileJSON | null,\n basePath: string\n): Tiles3DTileJSONPostprocessed | null {\n if (!tile) {\n return null;\n }\n let tileContentUrl: string | undefined;\n if (tile.content) {\n const contentUri = tile.content.uri || tile.content?.url;\n tileContentUrl = resolveUri(contentUri, basePath);\n }\n const tilePostprocessed: Tiles3DTileJSONPostprocessed = {\n ...tile,\n id: tileContentUrl,\n contentUrl: tileContentUrl,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n lodMetricValue: tile.geometricError,\n transformMatrix: tile.transform,\n type: getTileType(tile, tileContentUrl),\n refine: getRefine(tile.refine)\n };\n\n return tilePostprocessed;\n}\n\n// normalize tile headers\nexport async function normalizeTileHeaders(\n tileset: Tiles3DTilesetJSON,\n basePath: string,\n options: LoaderOptions\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n let root: Tiles3DTileJSONPostprocessed | null = null;\n\n const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);\n if (rootImplicitTilingExtension && tileset.root) {\n root = await normalizeImplicitTileHeaders(\n tileset.root,\n tileset,\n basePath,\n rootImplicitTilingExtension,\n options\n );\n } else {\n root = normalizeTileData(tileset.root, basePath);\n }\n\n const stack: any[] = [];\n stack.push(root);\n\n while (stack.length > 0) {\n const tile = stack.pop() || {};\n const children = tile.children || [];\n const childrenPostprocessed: Tiles3DTileJSONPostprocessed[] = [];\n for (const childHeader of children) {\n const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);\n let childHeaderPostprocessed: Tiles3DTileJSONPostprocessed | null;\n if (childImplicitTilingExtension) {\n childHeaderPostprocessed = await normalizeImplicitTileHeaders(\n childHeader,\n tileset,\n basePath,\n childImplicitTilingExtension,\n options\n );\n } else {\n childHeaderPostprocessed = normalizeTileData(childHeader, basePath);\n }\n\n if (childHeaderPostprocessed) {\n childrenPostprocessed.push(childHeaderPostprocessed);\n stack.push(childHeaderPostprocessed);\n }\n }\n tile.children = childrenPostprocessed;\n }\n\n return root;\n}\n\n/**\n * Do normalisation of implicit tile headers\n * TODO Check if Tile3D class can be a return type here.\n * @param tileset\n */\nexport async function normalizeImplicitTileHeaders(\n tile: Tiles3DTileJSON,\n tileset: Tiles3DTilesetJSON,\n basePath: string,\n implicitTilingExtension: ImplicitTilingExensionData,\n options: Tiles3DLoaderOptions\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n const {\n subdivisionScheme,\n maximumLevel,\n availableLevels,\n subtreeLevels,\n subtrees: {uri: subtreesUriTemplate}\n } = implicitTilingExtension;\n const replacedUrlTemplate = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);\n const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);\n const subtree = await load(subtreeUrl, Tile3DSubtreeLoader, options);\n const contentUrlTemplate = resolveUri(tile.content?.uri, basePath);\n const refine = tileset?.root?.refine;\n // @ts-ignore\n const rootLodMetricValue = tile.geometricError;\n\n // Replace tile.boundingVolume with the the bounding volume specified by the extensions['3DTILES_bounding_volume_S2']\n const s2VolumeInfo: S2VolumeInfo = tile.boundingVolume.extensions?.['3DTILES_bounding_volume_S2'];\n if (s2VolumeInfo) {\n const box = convertS2BoundingVolumetoOBB(s2VolumeInfo);\n const s2VolumeBox: S2VolumeBox = {box, s2VolumeInfo};\n tile.boundingVolume = s2VolumeBox;\n }\n\n const rootBoundingVolume = tile.boundingVolume;\n\n const implicitOptions: ImplicitOptions = {\n contentUrlTemplate,\n subtreesUriTemplate,\n subdivisionScheme,\n subtreeLevels,\n maximumLevel: Number.isFinite(availableLevels) ? availableLevels - 1 : maximumLevel,\n refine,\n basePath,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n rootLodMetricValue,\n rootBoundingVolume,\n getTileType,\n getRefine\n };\n\n return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions, options);\n}\n\n/**\n * Do implicit data normalisation to create hierarchical tile structure\n * @param tile\n * @param rootSubtree\n * @param options\n * @returns\n */\nexport async function normalizeImplicitTileData(\n tile: Tiles3DTileJSON,\n basePath: string,\n rootSubtree: Subtree,\n implicitOptions: ImplicitOptions,\n loaderOptions: Tiles3DLoaderOptions\n): Promise<Tiles3DTileJSONPostprocessed | null> {\n if (!tile) {\n return null;\n }\n\n const {children, contentUrl} = await parseImplicitTiles({\n subtree: rootSubtree,\n implicitOptions,\n loaderOptions\n });\n\n let tileContentUrl: string | undefined;\n let tileContent: Tiles3DTileContentJSON | null = null;\n if (contentUrl) {\n tileContentUrl = contentUrl;\n tileContent = {uri: contentUrl.replace(`${basePath}/`, '')};\n }\n const tilePostprocessed: Tiles3DTileJSONPostprocessed = {\n ...tile,\n id: tileContentUrl,\n contentUrl: tileContentUrl,\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,\n lodMetricValue: tile.geometricError,\n transformMatrix: tile.transform,\n type: getTileType(tile, tileContentUrl),\n refine: getRefine(tile.refine),\n content: tileContent || tile.content,\n children\n };\n\n return tilePostprocessed;\n}\n\n/**\n * Implicit Tiling data can be in 3DTILES_implicit_tiling for 3DTiles v.Next or directly in implicitTiling object for 3DTiles v1.1.\n * Spec 3DTiles v.Next - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n * Spec 3DTiles v.1.1 - https://github.com/CesiumGS/3d-tiles/tree/draft-1.1/specification/ImplicitTiling\n * @param tile\n * @returns\n */\nfunction getImplicitTilingExtensionData(tile: Tiles3DTileJSON | null): ImplicitTilingExensionData {\n return tile?.extensions?.['3DTILES_implicit_tiling'] || tile?.implicitTiling;\n}\n"],"mappings":"AAEA,SAAQA,mBAAmB,QAAO,8BAA8B;AAChE,SAAQC,IAAI,QAAO,kBAAkB;AACrC,SAAQC,eAAe,EAAEC,eAAe,EAAEC,SAAS,QAAO,mBAAmB;AAW7E,SAAQC,kBAAkB,EAAEC,yBAAyB,QAAO,mCAAmC;AAE/F,SAAQC,4BAA4B,QAAO,gCAAgC;AA8B3E,SAASC,WAAWA,CAACC,IAAqB,EAAmD;EAAA,IAAjDC,cAAsB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACrE,IAAI,CAACD,cAAc,EAAE;IACnB,OAAON,SAAS,CAACU,KAAK;EACxB;EAEA,MAAMC,UAAU,GAAGL,cAAc,CAACM,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC/C,MAAMC,aAAa,GAAGF,UAAU,CAACC,KAAK,CAAC,GAAG,CAAC,CAACE,GAAG,CAAC,CAAC;EACjD,QAAQD,aAAa;IACnB,KAAK,MAAM;MACT,OAAOb,SAAS,CAACe,UAAU;IAC7B,KAAK,MAAM;IACX,KAAK,MAAM;IACX,KAAK,KAAK;IACV,KAAK,MAAM;MACT,OAAOf,SAAS,CAACgB,UAAU;IAC7B;MACE,OAAOH,aAAa,IAAIb,SAAS,CAACU,KAAK;EAC3C;AACF;AAEA,SAASO,SAASA,CAACC,MAAe,EAAwC;EACxE,QAAQA,MAAM;IACZ,KAAK,SAAS;IACd,KAAK,SAAS;MACZ,OAAOnB,eAAe,CAACoB,OAAO;IAChC,KAAK,KAAK;IACV,KAAK,KAAK;MACR,OAAOpB,eAAe,CAACqB,GAAG;IAC5B;MACE,OAAOF,MAAM;EACjB;AACF;AAEA,SAASG,UAAUA,CAAA,EAA6C;EA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,GAAG;IACtD,GAAG/B,IAAI;IACPgC,EAAE,EAAE/B,cAAc;IAClBK,UAAU,EAAEL,cAAc;IAC1BgC,aAAa,EAAExC,eAAe,CAACyC,eAAe;IAC9CC,cAAc,EAAEnC,IAAI,CAACoC,cAAc;IACnCC,eAAe,EAAErC,IAAI,CAACsC,SAAS;IAC/BC,IAAI,EAAExC,WAAW,CAACC,IAAI,EAAEC,cAAc,CAAC;IACvCY,MAAM,EAAED,SAAS,CAACZ,IAAI,CAACa,MAAM,CAAC;IAC9Be,OAAO,EAAEqD,WAAW,IAAIjF,IAAI,CAAC4B,OAAO;IACpCqB;EACF,CAAC;EAED,OAAOlB,iBAAiB;AAC1B;AASA,SAASc,8BAA8BA,CAAC7C,IAA4B,EAA8B;EAAA,IAAAmF,gBAAA;EAChG,OAAO,CAAAnF,IAAI,aAAJA,IAAI,wBAAAmF,gBAAA,GAAJnF,IAAI,CAAEuE,UAAU,cAAAY,gBAAA,uBAAhBA,gBAAA,CAAmB,yBAAyB,CAAC,MAAInF,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEoF,cAAc;AAC9E"}
@@ -1,2 +1,2 @@
1
- export const VERSION = typeof "4.0.0-alpha.12" !== 'undefined' ? "4.0.0-alpha.12" : 'latest';
1
+ export const VERSION = typeof "4.0.0-alpha.14" !== 'undefined' ? "4.0.0-alpha.14" : 'latest';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {GLTFPostprocessed} from '@loaders.gl/gltf';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {TILESET_TYPE, LOD_METRIC_TYPE, TILE_TYPE, TILE_REFINEMENT} from '@loaders.gl/tiles';\n\nexport type FeatureTableJson = {\n [key: string]: any[];\n};\n\nexport type B3DMContent = {\n batchTableJson?: FeatureTableJson;\n byteLength: number;\n byteOffset: number;\n cartesianModelMatrix: Matrix4;\n cartesianOrigin: Vector3;\n cartographicModelMatrix: Matrix4;\n cartographicOrigin: Vector3;\n featureIds?: number[] | null;\n featureTableBinary?: Uint8Array;\n featureTableJson?: FeatureTableJson;\n gltf?: GLTFPostprocessed;\n gltfUpAxis: string;\n header: GLTFHeader;\n magic: number;\n modelMatrix: Matrix4;\n rotateYtoZ: boolean;\n rtcCenter: [number, number, number];\n type: string;\n version: number;\n};\n\nexport type GLTFHeader = {\n batchLength?: number;\n batchTableBinaryByteLength: number;\n batchTableJsonByteLength: number;\n featureTableBinaryByteLength: number;\n featureTableJsonByteLength: number;\n};\n\n/**\n * A 3D Tiles tileset JSON\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#property-reference\n */\nexport type Tiles3DTilesetJSON = {\n /** Metadata about the entire tileset.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#asset\n */\n asset: {\n /** The 3D Tiles version. The version defines the JSON schema for the tileset JSON and the base set of tile formats. */\n version: string;\n /** Application-specific version of this tileset, e.g., for when an existing tileset is updated. */\n tilesetVersion?: string;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n /** Not mentioned in 1.0 spec but some tilesets contain this option */\n gltfUpAxis?: string;\n };\n /** A dictionary object of metadata about per-feature properties. */\n properties?: Record<string, TilesetProperty>;\n /** The error, in meters, introduced if this tileset is not rendered. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */\n geometricError: number;\n /** A tile in a 3D Tiles tileset. */\n root: Tiles3DTileJSON;\n /** Names of 3D Tiles extensions used somewhere in this tileset. */\n extensionsUsed?: string[];\n /** Names of 3D Tiles extensions required to properly load this tileset. */\n extensionsRequired?: string[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/** TilesetJSON postprocessed by Tiles3DLoader */\nexport type Tiles3DTilesetJSONPostprocessed = Omit<Tiles3DTilesetJSON, 'root'> & {\n /**\n * Loader used\n * @deprecated\n */\n loader: LoaderWithParser;\n /** URL used to load a tileset resource */\n url: string;\n /** HTTP request query string */\n queryString: string;\n /** base path that non-absolute paths in tileset are relative to. */\n basePath: string;\n /** tileset type */\n type: TILESET_TYPE.TILES3D;\n /** LOD metric type */\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR;\n /** LOD metric value */\n lodMetricValue: number;\n /** Postprocessed root */\n root: Tiles3DTileJSONPostprocessed;\n};\n\n/**\n * A tile in a 3D Tiles tileset.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#tile\n */\nexport type Tiles3DTileJSON = {\n /** A bounding volume that encloses a tile or its content. */\n boundingVolume: Tile3DBoundingVolume;\n /** A bounding volume that encloses a tile or its content. */\n viewerRequestVolume?: object;\n /** The error, in meters, introduced if this tile is rendered and its children are not. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */\n geometricError: number;\n /**\n * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.\n * The default is to inherit from the parent tile.\n */\n refine?: string;\n /** A floating-point 4x4 affine transformation matrix, stored in column-major order, that transforms the tile's content */\n transform?: number[];\n /** Metadata about the tile's content and a link to the content. */\n content?: Tiles3DTileContentJSON;\n /** An array of objects that define child tiles. */\n children: Tiles3DTileJSON[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n\n /** 3DTiles v1.1 properties\n * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.schema.json\n */\n /** This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally. */\n implicitTiling?: ImplicitTilingData;\n};\n\nexport type Tiles3DTileJSONPostprocessed = Omit<Tiles3DTileJSON, 'refine' | 'children'> & {\n /** Unique ID */\n id?: string;\n /** Content full URL */\n contentUrl?: string;\n /** LOD metric type */\n lodMetricType?: LOD_METRIC_TYPE.GEOMETRIC_ERROR;\n /** LOD metric value */\n lodMetricValue?: number;\n /** Duplicate of transform */\n transformMatrix?: number[];\n /** Type of tile */\n type?: TILE_TYPE | string;\n /**\n * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.\n * The default is to inherit from the parent tile.\n */\n refine?: TILE_REFINEMENT | string;\n /** An array of objects that define child tiles. */\n children: Tiles3DTileJSONPostprocessed[];\n};\n\n/** Metadata about the tile's content and a link to the content. */\nexport type Tiles3DTileContentJSON = {\n /** A uri that points to the tile's content. When the uri is relative, it is relative to the referring tileset JSON file. */\n uri: string;\n /** url doesn't allign the spec but we support it same way as uri */\n url?: string;\n /** A bounding volume that encloses a tile or its content. At least one bounding volume property is required. Bounding volumes include box, region, or sphere. */\n boundingVolume?: Tile3DBoundingVolume;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/** A bounding volume that encloses a tile or its content.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#bounding-volume\n */\nexport type Tile3DBoundingVolume = {\n /** An array of 12 numbers that define an oriented bounding box. 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. The next three elements (indices 6, 7, and 8) define\n * the y axis direction and half-length. The last three elements (indices 9, 10, and 11) define the z axis direction and half-length. */\n box?: number[];\n /** An array of four numbers that define a bounding sphere. The first three elements define the x, y, and z values for the center of the sphere.\n * The last element (with index 3) defines the radius in meters. */\n sphere?: number[];\n /** An array of six numbers that define a bounding geographic region in EPSG:4979 coordinates with the order [west, south, east, north, minimum height, maximum height].\n * Longitudes and latitudes are in radians, and heights are in meters above (or below) the WGS84 ellipsoid. */\n region?: number[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/**\n * A dictionary object of metadata about per-feature properties.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#properties\n */\nexport type TilesetProperty = {\n /** The maximum value of this property of all the features in the tileset. */\n maximum: number;\n /** The minimum value of this property of all the features in the tileset. */\n minimum: number;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\nexport type Tiles3DTileContent = {\n /** Common properties */\n byteOffset?: number;\n type?: string;\n featureIds?: null;\n\n /** 3DTile header */\n magic?: number;\n version?: number;\n byteLength?: number;\n\n /** 3DTile tables header */\n header?: {\n featureTableJsonByteLength?: number;\n featureTableBinaryByteLength?: number;\n batchTableJsonByteLength?: number;\n batchTableBinaryByteLength?: number;\n batchLength?: number;\n };\n\n /** 3DTile tables */\n featureTableJson?:\n | {\n BATCH_LENGTH?: number;\n }\n | Record<string, any>;\n featureTableBinary?: Uint8Array;\n batchTableJson?: Record<string, (string | number)[]>;\n batchTableBinary?: Uint8Array;\n rtcCenter?: number[];\n\n /** 3DTile glTF */\n gltfArrayBuffer?: ArrayBuffer;\n gltfByteOffset?: number;\n gltfByteLength?: number;\n rotateYtoZ?: boolean;\n gltfUpAxis?: 'x' | 'X' | 'y' | 'Y' | 'z' | 'Z';\n gltfUrl?: string;\n gpuMemoryUsageInBytes?: number;\n gltf?: GLTFPostprocessed;\n\n /** For Composite tiles */\n tilesLength?: number;\n tiles?: Tiles3DTileContent[];\n\n /** For Instances model and Pointcloud tiles */\n featuresLength?: number;\n\n /** For Instanced model tiles */\n gltfFormat?: number;\n eastNorthUp?: boolean;\n normalUp?: number[];\n normalRight?: number[];\n hasCustomOrientation?: boolean;\n octNormalUp?: number[];\n octNormalRight?: number[];\n instances?: {\n modelMatrix: Matrix4;\n batchId: number;\n }[];\n\n /** For Pointcloud tiles */\n attributes?: {\n positions: null | number[];\n colors:\n | null\n | number[]\n | {type: number; value: Uint8ClampedArray; size: number; normalized: boolean};\n normals: null | number[] | {type: number; size: number; value: Float32Array};\n batchIds: null | number[];\n };\n constantRGBA?: number[];\n isQuantized?: boolean;\n isTranslucent?: boolean;\n isRGB565?: boolean;\n isOctEncoded16P?: boolean;\n pointsLength?: number;\n pointCount?: number;\n batchIds?: number[];\n hasPositions?: boolean;\n hasColors?: boolean;\n hasNormals?: boolean;\n hasBatchIds?: boolean;\n quantizedVolumeScale?: Vector3;\n quantizedVolumeOffset?: Vector3;\n quantizedRange?: number;\n isQuantizedDraco?: boolean;\n octEncodedRange?: number;\n isOctEncodedDraco?: boolean;\n};\n\n/**\n * 3DTILES_implicit_tiling types\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n */\nexport type Subtree = {\n buffers: Buffer[];\n bufferViews: BufferView[];\n tileAvailability: Availability;\n contentAvailability: Availability;\n childSubtreeAvailability: Availability;\n};\n\nexport type Availability = {\n constant?: 0 | 1;\n bufferView?: number;\n // Internal bitstream type\n explicitBitstream?: ExplicitBitstream;\n};\n\nexport type ExplicitBitstream = Uint8Array;\n\n/**\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-scheme\n */\nexport type SubdivisionScheme = 'QUADTREE' | 'OCTREE';\n\ntype Buffer = {\n name: string;\n uri?: string;\n byteLength: number;\n};\n\ntype BufferView = {\n buffer: number;\n byteOffset: number;\n byteLength: number;\n};\n\n/**\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n */\nexport type ImplicitTilingExensionData = ImplicitTilingData & {\n maximumLevel?: number;\n};\n\n/** 3DTiles v1.1 types */\n\n/**\n * This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally.\n * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.implicitTiling.schema.json\n * */\ntype ImplicitTilingData = {\n /** A string describing the subdivision scheme used within the tileset. */\n subdivisionScheme: 'QUADTREE' | 'OCTREE' | string;\n /** The number of distinct levels in each subtree. For example, a quadtree with `subtreeLevels = 2` will have subtrees with 5 nodes (one root and 4 children). */\n subtreeLevels: number;\n /** The numbers of the levels in the tree with available tiles. */\n availableLevels: number;\n /** An object describing the location of subtree files. */\n subtrees: {\n /** A template URI pointing to subtree files. A subtree is a fixed-depth (defined by `subtreeLevels`) portion of the tree to keep memory use bounded.\n * The URI of each file is substituted with the subtree root's global level, x, and y. For subdivision scheme `OCTREE`, z shall also be given. Relative paths are relative to the tileset JSON. */\n uri: string;\n };\n};\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/types.ts"],"sourcesContent":["import type {GLTFPostprocessed} from '@loaders.gl/gltf';\nimport {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {TILESET_TYPE, LOD_METRIC_TYPE, TILE_TYPE, TILE_REFINEMENT} from '@loaders.gl/tiles';\n\nexport type FeatureTableJson = {\n [key: string]: any[];\n};\n\nexport type B3DMContent = {\n batchTableJson?: FeatureTableJson;\n byteLength: number;\n byteOffset: number;\n cartesianModelMatrix: Matrix4;\n cartesianOrigin: Vector3;\n cartographicModelMatrix: Matrix4;\n cartographicOrigin: Vector3;\n featureIds?: number[] | null;\n featureTableBinary?: Uint8Array;\n featureTableJson?: FeatureTableJson;\n gltf?: GLTFPostprocessed;\n gltfUpAxis: string;\n header: GLTFHeader;\n magic: number;\n modelMatrix: Matrix4;\n rotateYtoZ: boolean;\n rtcCenter: [number, number, number];\n type: string;\n version: number;\n};\n\nexport type GLTFHeader = {\n batchLength?: number;\n batchTableBinaryByteLength: number;\n batchTableJsonByteLength: number;\n featureTableBinaryByteLength: number;\n featureTableJsonByteLength: number;\n};\n\n/**\n * A 3D Tiles tileset JSON\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#property-reference\n */\nexport type Tiles3DTilesetJSON = {\n /** Metadata about the entire tileset.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#asset\n */\n asset: {\n /** The 3D Tiles version. The version defines the JSON schema for the tileset JSON and the base set of tile formats. */\n version: string;\n /** Application-specific version of this tileset, e.g., for when an existing tileset is updated. */\n tilesetVersion?: string;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n /** Not mentioned in 1.0 spec but some tilesets contain this option */\n gltfUpAxis?: string;\n };\n /** A dictionary object of metadata about per-feature properties. */\n properties?: Record<string, TilesetProperty>;\n /** The error, in meters, introduced if this tileset is not rendered. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */\n geometricError: number;\n /** A tile in a 3D Tiles tileset. */\n root: Tiles3DTileJSON;\n /** Names of 3D Tiles extensions used somewhere in this tileset. */\n extensionsUsed?: string[];\n /** Names of 3D Tiles extensions required to properly load this tileset. */\n extensionsRequired?: string[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/** TilesetJSON postprocessed by Tiles3DLoader */\nexport type Tiles3DTilesetJSONPostprocessed = Omit<Tiles3DTilesetJSON, 'root'> & {\n /**\n * Loader used\n * @deprecated\n */\n loader: LoaderWithParser;\n /** URL used to load a tileset resource */\n url: string;\n /** HTTP request query string */\n queryString: string;\n /** base path that non-absolute paths in tileset are relative to. */\n basePath: string;\n /** tileset type */\n type: TILESET_TYPE.TILES3D;\n /** LOD metric type */\n lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR;\n /** LOD metric value */\n lodMetricValue: number;\n /** Postprocessed root */\n root: Tiles3DTileJSONPostprocessed;\n};\n\n/**\n * A tile in a 3D Tiles tileset.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#tile\n */\nexport type Tiles3DTileJSON = {\n /** A bounding volume that encloses a tile or its content. */\n boundingVolume: Tile3DBoundingVolume;\n /** A bounding volume that encloses a tile or its content. */\n viewerRequestVolume?: object;\n /** The error, in meters, introduced if this tile is rendered and its children are not. At runtime, the geometric error is used to compute screen space error (SSE), i.e., the error measured in pixels. */\n geometricError: number;\n /**\n * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.\n * The default is to inherit from the parent tile.\n */\n refine?: string;\n /** A floating-point 4x4 affine transformation matrix, stored in column-major order, that transforms the tile's content */\n transform?: number[];\n /** Metadata about the tile's content and a link to the content. */\n content?: Tiles3DTileContentJSON;\n /** An array of objects that define child tiles. */\n children: Tiles3DTileJSON[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n\n /** 3DTiles v1.1 properties\n * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.schema.json\n */\n /** This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally. */\n implicitTiling?: ImplicitTilingData;\n};\n\nexport type Tiles3DTileJSONPostprocessed = Omit<Tiles3DTileJSON, 'refine' | 'children'> & {\n /** Unique ID */\n id?: string;\n /** Content full URL */\n contentUrl?: string;\n /** LOD metric type */\n lodMetricType?: LOD_METRIC_TYPE.GEOMETRIC_ERROR;\n /** LOD metric value */\n lodMetricValue?: number;\n /** Duplicate of transform */\n transformMatrix?: number[];\n /** Type of tile */\n type?: TILE_TYPE | string;\n /**\n * Specifies if additive or replacement refinement is used when traversing the tileset for rendering. This property is required for the root tile of a tileset; it is optional for all other tiles.\n * The default is to inherit from the parent tile.\n */\n refine?: TILE_REFINEMENT | string;\n /** An array of objects that define child tiles. */\n children: Tiles3DTileJSONPostprocessed[];\n};\n\n/** Metadata about the tile's content and a link to the content. */\nexport type Tiles3DTileContentJSON = {\n /** A uri that points to the tile's content. When the uri is relative, it is relative to the referring tileset JSON file. */\n uri: string;\n /** url doesn't allign the spec but we support it same way as uri */\n url?: string;\n /** A bounding volume that encloses a tile or its content. At least one bounding volume property is required. Bounding volumes include box, region, or sphere. */\n boundingVolume?: Tile3DBoundingVolume;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/** A bounding volume that encloses a tile or its content.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#bounding-volume\n */\nexport type Tile3DBoundingVolume = {\n /** An array of 12 numbers that define an oriented bounding box. 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. The next three elements (indices 6, 7, and 8) define\n * the y axis direction and half-length. The last three elements (indices 9, 10, and 11) define the z axis direction and half-length. */\n box?: number[];\n /** An array of four numbers that define a bounding sphere. The first three elements define the x, y, and z values for the center of the sphere.\n * The last element (with index 3) defines the radius in meters. */\n sphere?: number[];\n /** An array of six numbers that define a bounding geographic region in EPSG:4979 coordinates with the order [west, south, east, north, minimum height, maximum height].\n * Longitudes and latitudes are in radians, and heights are in meters above (or below) the WGS84 ellipsoid. */\n region?: number[];\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\n/**\n * A dictionary object of metadata about per-feature properties.\n * https://github.com/CesiumGS/3d-tiles/tree/main/specification#properties\n */\nexport type TilesetProperty = {\n /** The maximum value of this property of all the features in the tileset. */\n maximum: number;\n /** The minimum value of this property of all the features in the tileset. */\n minimum: number;\n /** Dictionary object with extension-specific objects. */\n extensions?: object;\n /** Application-specific data. */\n extras?: any;\n};\n\nexport type Tiles3DTileContent = {\n /** Common properties */\n byteOffset?: number;\n type?: string;\n featureIds?: null;\n\n /** 3DTile header */\n magic?: number;\n version?: number;\n byteLength?: number;\n\n /** 3DTile tables header */\n header?: {\n featureTableJsonByteLength?: number;\n featureTableBinaryByteLength?: number;\n batchTableJsonByteLength?: number;\n batchTableBinaryByteLength?: number;\n batchLength?: number;\n };\n\n /** 3DTile tables */\n featureTableJson?:\n | {\n BATCH_LENGTH?: number;\n }\n | Record<string, any>;\n featureTableBinary?: Uint8Array;\n batchTableJson?: Record<string, (string | number)[]>;\n batchTableBinary?: Uint8Array;\n rtcCenter?: number[];\n\n /** 3DTile glTF */\n gltfArrayBuffer?: ArrayBuffer;\n gltfByteOffset?: number;\n gltfByteLength?: number;\n rotateYtoZ?: boolean;\n gltfUpAxis?: 'x' | 'X' | 'y' | 'Y' | 'z' | 'Z';\n gltfUrl?: string;\n gpuMemoryUsageInBytes?: number;\n gltf?: GLTFPostprocessed;\n\n /** For Composite tiles */\n tilesLength?: number;\n tiles?: Tiles3DTileContent[];\n\n /** For Instances model and Pointcloud tiles */\n featuresLength?: number;\n\n /** For Instanced model tiles */\n gltfFormat?: number;\n eastNorthUp?: boolean;\n normalUp?: number[];\n normalRight?: number[];\n hasCustomOrientation?: boolean;\n octNormalUp?: number[];\n octNormalRight?: number[];\n instances?: {\n modelMatrix: Matrix4;\n batchId: number;\n }[];\n\n /** For Pointcloud tiles */\n attributes?: {\n positions: null | number[];\n colors:\n | null\n | number[]\n | {type: number; value: Uint8ClampedArray; size: number; normalized: boolean};\n normals: null | number[] | {type: number; size: number; value: Float32Array};\n batchIds: null | number[];\n };\n constantRGBA?: number[];\n isQuantized?: boolean;\n isTranslucent?: boolean;\n isRGB565?: boolean;\n isOctEncoded16P?: boolean;\n pointsLength?: number;\n pointCount?: number;\n batchIds?: number[];\n hasPositions?: boolean;\n hasColors?: boolean;\n hasNormals?: boolean;\n hasBatchIds?: boolean;\n quantizedVolumeScale?: Vector3;\n quantizedVolumeOffset?: Vector3;\n quantizedRange?: number;\n isQuantizedDraco?: boolean;\n octEncodedRange?: number;\n isOctEncodedDraco?: boolean;\n};\n\n/**\n * 3DTILES_implicit_tiling types\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n * JSON Schema v1.1 https://github.com/CesiumGS/3d-tiles/blob/8e5e67e078850cc8ce15bd1873fe54f11bbee02f/specification/schema/Subtree/subtree.schema.json\n * JSON Schema vNext https://github.com/CesiumGS/3d-tiles/blob/8e5e67e078850cc8ce15bd1873fe54f11bbee02f/extensions/3DTILES_implicit_tiling/schema/subtree/subtree.schema.json\n */\nexport type Subtree = {\n /** An array of buffers. */\n buffers: Buffer[];\n /** An array of buffer views. */\n bufferViews: BufferView[];\n /** The availability of tiles in the subtree. The availability bitstream is a 1D boolean array where tiles are ordered by their level in the subtree and Morton index\n * within that level. A tile's availability is determined by a single bit, 1 meaning a tile exists at that spatial index, and 0 meaning it does not.\n * The number of elements in the array is `(N^subtreeLevels - 1)/(N - 1)` where N is 4 for subdivision scheme `QUADTREE` and 8 for `OCTREE`.\n * Availability may be stored in a buffer view or as a constant value that applies to all tiles. If a non-root tile's availability is 1 its parent\n * tile's availability shall also be 1. `tileAvailability.constant: 0` is disallowed, as subtrees shall have at least one tile.\n */\n tileAvailability: Availability;\n /** It is array by spec but there are tiles that has a single object\n * An array of content availability objects. If the tile has a single content this array will have one element; if the tile has multiple contents -\n * as supported by 3DTILES_multiple_contents and 3D Tiles 1.1 - this array will have multiple elements.\n */\n contentAvailability: Availability | Availability[];\n /** The availability of children subtrees. The availability bitstream is a 1D boolean array where subtrees are ordered by their Morton index in the level of the tree\n * immediately below the bottom row of the subtree. A child subtree's availability is determined by a single bit, 1 meaning a subtree exists at that spatial index,\n * and 0 meaning it does not. The number of elements in the array is `N^subtreeLevels` where N is 4 for subdivision scheme `QUADTREE` and 8 for `OCTREE`.\n * Availability may be stored in a buffer view or as a constant value that applies to all child subtrees. If availability is 0 for all child subtrees,\n * then the tileset does not subdivide further.\n */\n childSubtreeAvailability: Availability;\n // TODO: These are unused properties. Improve types when they are required\n propertyTables: unknown;\n tileMetadata: unknown;\n contentMetadata: unknown;\n subtreeMetadata: unknown;\n};\n\nexport type Availability = {\n /** Integer indicating whether all of the elements are available (1) or all are unavailable (0). */\n constant?: 0 | 1;\n /** Index of a buffer view that indicates whether each element is available. The bitstream conforms to the boolean array encoding described\n * in the 3D Metadata specification. If an element is available, its bit is 1, and if it is unavailable, its bit is 0. */\n bitstream?: number;\n /**\n * v1.1 https://github.com/CesiumGS/3d-tiles/blob/8e5e67e078850cc8ce15bd1873fe54f11bbee02f/specification/schema/Subtree/availability.schema.json\n * vNext https://github.com/CesiumGS/3d-tiles/blob/8e5e67e078850cc8ce15bd1873fe54f11bbee02f/extensions/3DTILES_implicit_tiling/schema/subtree/availability.schema.json\n * The schemas of vNext and 1.1 are same but there are tiles with `bufferView` property instead of `bitstream`\n */\n bufferView?: number;\n /**\n * Postprocessing property\n * contain availability bits loaded from the bufferView\n */\n explicitBitstream?: ExplicitBitstream;\n};\n\nexport type ExplicitBitstream = Uint8Array;\n\n/**\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-scheme\n */\nexport type SubdivisionScheme = 'QUADTREE' | 'OCTREE';\n\ntype Buffer = {\n name: string;\n uri?: string;\n byteLength: number;\n};\n\n/** Subtree buffer view */\nexport type BufferView = {\n buffer: number;\n byteOffset: number;\n byteLength: number;\n};\n\n/**\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling\n */\nexport type ImplicitTilingExensionData = ImplicitTilingData & {\n /** This property is not part of the schema\n * https://github.com/CesiumGS/3d-tiles/blob/main/extensions/3DTILES_implicit_tiling/schema/tile.3DTILES_implicit_tiling.schema.json\n * But it can be seen in some test datasets. It is handled as substitute of `availableLevels`\n */\n maximumLevel?: number;\n};\n\n/** 3DTiles v1.1 types */\n\n/**\n * This object allows a tile to be implicitly subdivided. Tile and content availability and metadata is stored in subtrees which are referenced externally.\n * https://github.com/CesiumGS/3d-tiles/blob/draft-1.1/specification/schema/tile.implicitTiling.schema.json\n * */\ntype ImplicitTilingData = {\n /** A string describing the subdivision scheme used within the tileset. */\n subdivisionScheme: 'QUADTREE' | 'OCTREE' | string;\n /** The number of distinct levels in each subtree. For example, a quadtree with `subtreeLevels = 2` will have subtrees with 5 nodes (one root and 4 children). */\n subtreeLevels: number;\n /** The numbers of the levels in the tree with available tiles. */\n availableLevels: number;\n /** An object describing the location of subtree files. */\n subtrees: {\n /** A template URI pointing to subtree files. A subtree is a fixed-depth (defined by `subtreeLevels`) portion of the tree to keep memory use bounded.\n * The URI of each file is substituted with the subtree root's global level, x, and y. For subdivision scheme `OCTREE`, z shall also be given. Relative paths are relative to the tileset JSON. */\n uri: string;\n };\n};\n"],"mappings":""}
@@ -1,5 +1,7 @@
1
1
  import type { Subtree } from '../../../types';
2
2
  import type { S2VolumeInfo } from '../../utils/obb/s2-corners-to-obb';
3
+ import { Tiles3DLoaderOptions } from '../../../tiles-3d-loader';
4
+ import { ImplicitOptions } from '../parse-3d-tile-header';
3
5
  /**
4
6
  * S2VolumeBox is an extention of BoundingVolume of type "box"
5
7
  */
@@ -23,7 +25,7 @@ export type S2VolumeBox = {
23
25
  */
24
26
  export declare function parseImplicitTiles(params: {
25
27
  subtree: Subtree;
26
- options: any;
28
+ implicitOptions: ImplicitOptions;
27
29
  parentData?: {
28
30
  mortonIndex: number;
29
31
  x: number;
@@ -40,6 +42,7 @@ export declare function parseImplicitTiles(params: {
40
42
  z: number;
41
43
  };
42
44
  s2VolumeBox?: S2VolumeBox;
45
+ loaderOptions: Tiles3DLoaderOptions;
43
46
  }): Promise<{
44
47
  children: never[];
45
48
  lodMetricValue: number;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-implicit-tiles.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-implicit-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqC,OAAO,EAAC,MAAM,gBAAgB,CAAC;AAKhF,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAYpE;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,yFAAyF;IACzF,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,uGAAuG;IACvG,YAAY,EAAE,YAAY,CAAC;CAC5B,CAAC;AA6CF;;;;;;;;;;;GAWG;AAEH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,C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AAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IACnF,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,aAAa,EAAE,oBAAoB,CAAC;CACrC;;;;GAoJA;AAmJD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,MAAM,CAGR"}
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.replaceContentUrlTemplate = exports.parseImplicitTiles = void 0;
4
7
  const tile_3d_subtree_loader_1 = require("../../../tile-3d-subtree-loader");
5
8
  const core_1 = require("@loaders.gl/core");
9
+ const log_1 = __importDefault(require("@probe.gl/log"));
6
10
  const index_1 = require("../../utils/s2/index");
7
11
  const s2_corners_to_obb_1 = require("../../utils/obb/s2-corners-to-obb");
8
12
  const QUADTREE_DEVISION_COUNT = 4;
@@ -61,7 +65,7 @@ function getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme) {
61
65
  */
62
66
  // eslint-disable-next-line max-statements
63
67
  async function parseImplicitTiles(params) {
64
- const { options, parentData = {
68
+ const { implicitOptions, parentData = {
65
69
  mortonIndex: 0,
66
70
  x: 0,
67
71
  y: 0,
@@ -72,33 +76,43 @@ async function parseImplicitTiles(params) {
72
76
  x: 0,
73
77
  y: 0,
74
78
  z: 0
75
- }, s2VolumeBox } = params;
79
+ }, s2VolumeBox, loaderOptions } = params;
76
80
  let { subtree, level = 0 } = params;
77
- const { subdivisionScheme, subtreeLevels, maximumLevel, contentUrlTemplate, subtreesUriTemplate, basePath } = options;
81
+ const { subdivisionScheme, subtreeLevels, maximumLevel, contentUrlTemplate, subtreesUriTemplate, basePath } = implicitOptions;
78
82
  const tile = { children: [], lodMetricValue: 0, contentUrl: '' };
83
+ if (!maximumLevel) {
84
+ // eslint-disable-next-line no-console
85
+ log_1.default.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${contentUrlTemplate} won't be loaded...`);
86
+ return tile;
87
+ }
88
+ const lev = level + globalData.level;
89
+ if (lev > maximumLevel) {
90
+ return tile;
91
+ }
79
92
  const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
80
- const childX = childIndex & 0b01;
81
- const childY = (childIndex >> 1) & 0b01;
82
- const childZ = (childIndex >> 2) & 0b01;
93
+ const bitsPerTile = Math.log2(childrenPerTile);
94
+ // childIndex is in range [0,4] for quadtrees and [0, 7] for octrees
95
+ const childX = childIndex & 0b01; // Get first bit for X
96
+ const childY = (childIndex >> 1) & 0b01; // Get second bit for Y
97
+ const childZ = (childIndex >> 2) & 0b01; // Get third bit for Z
83
98
  const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
84
- let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
99
+ let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex, bitsPerTile);
85
100
  let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
86
101
  // Local tile coordinates
87
- let childTileX = concatBits(parentData.x, childX);
88
- let childTileY = concatBits(parentData.y, childY);
89
- let childTileZ = concatBits(parentData.z, childZ);
102
+ let childTileX = concatBits(parentData.x, childX, 1);
103
+ let childTileY = concatBits(parentData.y, childY, 1);
104
+ let childTileZ = concatBits(parentData.z, childZ, 1);
90
105
  let isChildSubtreeAvailable = false;
91
- if (level + 1 > subtreeLevels) {
106
+ if (level >= subtreeLevels) {
92
107
  isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
93
108
  }
94
- const x = concatBits(globalData.x, childTileX);
95
- const y = concatBits(globalData.y, childTileY);
96
- const z = concatBits(globalData.z, childTileZ);
97
- const lev = level + globalData.level;
109
+ const x = concatBits(globalData.x, childTileX, level * bitsPerTile);
110
+ const y = concatBits(globalData.y, childTileY, level * bitsPerTile);
111
+ const z = concatBits(globalData.z, childTileZ, level * bitsPerTile);
98
112
  if (isChildSubtreeAvailable) {
99
113
  const subtreePath = `${basePath}/${subtreesUriTemplate}`;
100
114
  const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
101
- const childSubtree = await (0, core_1.load)(childSubtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader);
115
+ const childSubtree = await (0, core_1.load)(childSubtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader, loaderOptions);
102
116
  subtree = childSubtree;
103
117
  globalData.mortonIndex = childTileMortonIndex;
104
118
  globalData.x = childTileX;
@@ -113,7 +127,7 @@ async function parseImplicitTiles(params) {
113
127
  level = 0;
114
128
  }
115
129
  const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
116
- if (!isTileAvailable || level > maximumLevel) {
130
+ if (!isTileAvailable) {
117
131
  return tile;
118
132
  }
119
133
  const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
@@ -127,17 +141,18 @@ async function parseImplicitTiles(params) {
127
141
  // Recursive calling...
128
142
  const childTileParsed = await parseImplicitTiles({
129
143
  subtree,
130
- options,
144
+ implicitOptions,
145
+ loaderOptions,
131
146
  parentData: pData,
132
147
  childIndex: index,
133
148
  level: childTileLevel,
134
- globalData,
149
+ globalData: { ...globalData },
135
150
  s2VolumeBox: childS2VolumeBox
136
151
  });
137
152
  if (childTileParsed.contentUrl || childTileParsed.children.length) {
138
153
  const globalLevel = lev + 1;
139
154
  const childCoordinates = { childTileX, childTileY, childTileZ };
140
- const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, options, s2VolumeBox);
155
+ const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, implicitOptions, s2VolumeBox);
141
156
  // @ts-ignore
142
157
  tile.children.push(formattedTile);
143
158
  }
@@ -145,12 +160,33 @@ async function parseImplicitTiles(params) {
145
160
  return tile;
146
161
  }
147
162
  exports.parseImplicitTiles = parseImplicitTiles;
163
+ /**
164
+ * Check tile availability in the bitstream array
165
+ * @param availabilityData - tileAvailability / contentAvailability / childSubtreeAvailability object
166
+ * @param index - index in the bitstream array
167
+ * @returns
168
+ */
148
169
  function getAvailabilityResult(availabilityData, index) {
149
- if ('constant' in availabilityData) {
150
- return Boolean(availabilityData.constant);
170
+ let availabilityObject;
171
+ if (Array.isArray(availabilityData)) {
172
+ /** TODO: we don't support `3DTILES_multiple_contents` extension at the moment.
173
+ * https://github.com/CesiumGS/3d-tiles/blob/main/extensions/3DTILES_implicit_tiling/README.md#multiple-contents
174
+ * Take first item in the array
175
+ */
176
+ availabilityObject = availabilityData[0];
177
+ if (availabilityData.length > 1) {
178
+ // eslint-disable-next-line no-console
179
+ log_1.default.once('Not supported extension "3DTILES_multiple_contents" has been detected');
180
+ }
181
+ }
182
+ else {
183
+ availabilityObject = availabilityData;
184
+ }
185
+ if ('constant' in availabilityObject) {
186
+ return Boolean(availabilityObject.constant);
151
187
  }
152
- if (availabilityData.explicitBitstream) {
153
- return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);
188
+ if (availabilityObject.explicitBitstream) {
189
+ return getBooleanValueFromBitstream(index, availabilityObject.explicitBitstream);
154
190
  }
155
191
  return false;
156
192
  }
@@ -220,11 +256,12 @@ function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoo
220
256
  }
221
257
  /**
222
258
  * Do binary concatenation
223
- * @param first
224
- * @param second
259
+ * @param higher - number to put to higher part of result
260
+ * @param lower - number to put to lower part of result
261
+ * @param shift - number of bits to shift lower number
225
262
  */
226
- function concatBits(first, second) {
227
- return parseInt(first.toString(2) + second.toString(2), 2);
263
+ function concatBits(higher, lower, shift) {
264
+ return (higher << shift) + lower;
228
265
  }
229
266
  /**
230
267
  * Replace implicit tile content url with real coordinates.
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-subtree.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAoB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E;;;;;GAKG;AAEH,wBAA8B,mBAAmB,CAC/C,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,OAAO,CAAC,OAAO,CAAC,CAuDlB"}
1
+ {"version":3,"file":"parse-3d-tile-subtree.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAe,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAK3E;;;;;GAKG;AAEH,wBAA8B,mBAAmB,CAC/C,IAAI,EAAE,WAAW,EACjB,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,OAAO,EAAE,aAAa,GAAG,SAAS,GACjC,OAAO,CAAC,OAAO,CAAC,CAgDlB"}
@@ -28,29 +28,36 @@ async function parse3DTilesSubtree(data, options, context) {
28
28
  if (binaryByteLength) {
29
29
  internalBinaryBuffer = data.slice(24 + jsonByteLength);
30
30
  }
31
- if ('bufferView' in subtree.tileAvailability) {
32
- subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer, context);
31
+ await loadExplicitBitstream(subtree, subtree.tileAvailability, internalBinaryBuffer, context);
32
+ if (Array.isArray(subtree.contentAvailability)) {
33
+ for (const contentAvailability of subtree.contentAvailability) {
34
+ await loadExplicitBitstream(subtree, contentAvailability, internalBinaryBuffer, context);
35
+ }
33
36
  }
34
- if ('bufferView' in subtree.contentAvailability) {
35
- subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer, context);
36
- }
37
- if ('bufferView' in subtree.childSubtreeAvailability) {
38
- subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer, context);
37
+ else {
38
+ await loadExplicitBitstream(subtree, subtree.contentAvailability, internalBinaryBuffer, context);
39
39
  }
40
+ await loadExplicitBitstream(subtree, subtree.childSubtreeAvailability, internalBinaryBuffer, context);
40
41
  return subtree;
41
42
  }
42
43
  exports.default = parse3DTilesSubtree;
43
44
  /**
44
- * Get explicit bitstream for subtree availability data.
45
- * @param subtree
46
- * @param name
47
- * @param internalBinaryBuffer
45
+ * Load explicit bitstream for subtree availability data.
46
+ * @param subtree - subtree data
47
+ * @param availabilityObject - tileAvailability / contentAvailability / childSubtreeAvailability object
48
+ * @param internalBinaryBuffer - subtree binary buffer
49
+ * @param context - loaders.gl context
48
50
  */
49
- async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context) {
50
- const bufferViewIndex = subtree[name].bufferView;
51
+ async function loadExplicitBitstream(subtree, availabilityObject, internalBinaryBuffer, context) {
52
+ const bufferViewIndex = Number.isFinite(availabilityObject.bitstream)
53
+ ? availabilityObject.bitstream
54
+ : availabilityObject.bufferView;
55
+ if (typeof bufferViewIndex !== 'number') {
56
+ return;
57
+ }
51
58
  const bufferView = subtree.bufferViews[bufferViewIndex];
52
59
  const buffer = subtree.buffers[bufferView.buffer];
53
- if (!context?.url || !context.fetch) {
60
+ if (!context?.baseUrl) {
54
61
  throw new Error('Url is not provided');
55
62
  }
56
63
  if (!context.fetch) {
@@ -61,11 +68,10 @@ async function getExplicitBitstream(subtree, name, internalBinaryBuffer, context
61
68
  const bufferUri = `${context?.baseUrl || ''}/${buffer.uri}`;
62
69
  const response = await context.fetch(bufferUri);
63
70
  const data = await response.arrayBuffer();
64
- // Return view of bitstream.
65
- return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
71
+ availabilityObject.explicitBitstream = new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
72
+ return;
66
73
  }
67
- // Return view of bitstream.
68
- return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
74
+ availabilityObject.explicitBitstream = new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
69
75
  }
70
76
  /**
71
77
  * Parse buffer to return uint64 value
@@ -1,6 +1,34 @@
1
1
  import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
2
2
  import type { LoaderOptions } from '@loaders.gl/loader-utils';
3
- import { ImplicitTilingExensionData, Subtree, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from '../../types';
3
+ import { LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE } from '@loaders.gl/tiles';
4
+ import { ImplicitTilingExensionData, Subtree, Tile3DBoundingVolume, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from '../../types';
5
+ /** Options for recursive loading implicit subtrees */
6
+ export type ImplicitOptions = {
7
+ /** Template of the full url of the content template */
8
+ contentUrlTemplate: string;
9
+ /** Template of the full url of the subtree */
10
+ subtreesUriTemplate: string;
11
+ /** Implicit subdivision scheme */
12
+ subdivisionScheme: 'QUADTREE' | 'OCTREE' | string;
13
+ /** Levels per subtree */
14
+ subtreeLevels: number;
15
+ /** Maximum implicit level through all subtrees */
16
+ maximumLevel?: number;
17
+ /** 3DTiles refine method (add/replace) */
18
+ refine?: string;
19
+ /** Tileset base path */
20
+ basePath: string;
21
+ /** 3DTiles LOD metric type */
22
+ lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR;
23
+ /** Root metric value of the root tile of the implicit subtrees */
24
+ rootLodMetricValue: number;
25
+ /** Bounding volume of the root tile of the implicit subtrees */
26
+ rootBoundingVolume: Tile3DBoundingVolume;
27
+ /** Function that detects TILE_TYPE by tile metadata and content URL */
28
+ getTileType: (tile: Tiles3DTileJSON, tileContentUrl?: string) => TILE_TYPE | string;
29
+ /** Function that converts string refine method to enum value */
30
+ getRefine: (refine?: string) => TILE_REFINEMENT | string | undefined;
31
+ };
4
32
  export declare function normalizeTileData(tile: Tiles3DTileJSON | null, basePath: string): Tiles3DTileJSONPostprocessed | null;
5
33
  export declare function normalizeTileHeaders(tileset: Tiles3DTilesetJSON, basePath: string, options: LoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
6
34
  /**
@@ -16,5 +44,5 @@ export declare function normalizeImplicitTileHeaders(tile: Tiles3DTileJSON, tile
16
44
  * @param options
17
45
  * @returns
18
46
  */
19
- export declare function normalizeImplicitTileData(tile: Tiles3DTileJSON, basePath: string, rootSubtree: Subtree, options: any): Promise<Tiles3DTileJSONPostprocessed | null>;
47
+ export declare function normalizeImplicitTileData(tile: Tiles3DTileJSON, basePath: string, rootSubtree: Subtree, implicitOptions: ImplicitOptions, loaderOptions: Tiles3DLoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
20
48
  //# sourceMappingURL=parse-3d-tile-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAI5D,OAAO,EACL,0BAA0B,EAC1B,OAAO,EAEP,eAAe,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