@loaders.gl/3d-tiles 4.0.0-alpha.20 → 4.0.0-alpha.22

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 (74) hide show
  1. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +29 -0
  2. package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
  3. package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +72 -0
  4. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
  5. package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
  6. package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +33 -0
  7. package/dist/3d-tiles-archive-loader.d.ts +13 -0
  8. package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
  9. package/dist/3d-tiles-archive-loader.js +31 -0
  10. package/dist/dist.min.js +5429 -215
  11. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
  12. package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  13. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js +69 -0
  14. package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  15. package/dist/es5/3d-tiles-archive-loader.js +50 -0
  16. package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
  17. package/dist/es5/index.js +14 -0
  18. package/dist/es5/index.js.map +1 -1
  19. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
  20. package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  21. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
  22. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  23. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +12 -12
  24. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  25. package/dist/es5/lib/parsers/parse-3d-tile-header.js +2 -1
  26. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  27. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
  28. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  29. package/dist/es5/lib/utils/version.js +1 -1
  30. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js +46 -0
  31. package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
  32. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js +23 -0
  33. package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
  34. package/dist/esm/3d-tiles-archive-loader.js +20 -0
  35. package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
  36. package/dist/esm/index.js +2 -0
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
  39. package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
  40. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
  41. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  42. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +5 -7
  43. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  44. package/dist/esm/lib/parsers/parse-3d-tile-header.js +2 -1
  45. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  46. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
  47. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  48. package/dist/esm/lib/utils/version.js +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +5 -1
  52. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +31 -0
  53. package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
  54. package/dist/lib/filesystems/tiles-3d-archive-file-system.js +75 -0
  55. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  56. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +2 -2
  57. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
  58. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  59. package/dist/lib/parsers/parse-3d-tile-gltf.js +6 -6
  60. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  61. package/dist/lib/parsers/parse-3d-tile-header.js +2 -1
  62. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
  63. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  64. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +10 -2
  65. package/package.json +8 -7
  66. package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +84 -0
  67. package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +52 -0
  68. package/src/3d-tiles-archive-loader.ts +47 -0
  69. package/src/index.ts +3 -0
  70. package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
  71. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
  72. package/src/lib/parsers/parse-3d-tile-gltf.ts +8 -8
  73. package/src/lib/parsers/parse-3d-tile-header.ts +2 -1
  74. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiles-3d-archive-file-system.js","names":["ZipFileSystem","cdSignature","cdHeaderSignature","searchFromTheEnd","parseZipCDFileHeader","parseHashFile","parseZipLocalFileHeader","Tiles3DArchive","Tiles3DArchiveFileSystem","constructor","file","_defineProperty","fetch","filename","fileProvider","Error","hashData","archive","fileData","getFile","response","Response","Object","defineProperty","value","concat","fileName","undefined","hashCDOffset","cdFileHeader","localFileHeader","localHeaderOffset","fileDataOffset","hashFile","slice","compressedSize"],"sources":["../../../../src/lib/filesystems/tiles-3d-archive-file-system.ts"],"sourcesContent":["import {\n FileProvider,\n ZipFileSystem,\n cdSignature as cdHeaderSignature,\n searchFromTheEnd,\n parseZipCDFileHeader,\n HashElement,\n parseHashFile,\n parseZipLocalFileHeader\n} from '@loaders.gl/zip';\nimport {Tiles3DArchive} from '../../3d-tiles-archive/3d-tiles-archive-archive';\n\n/**\n * FileSystem adapter for a 3tz (3D tiles archive format) file\n * Holds FileProvider object that provides random access to archived files.\n * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases\n * access speed to archived files\n * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md\n */\nexport class Tiles3DArchiveFileSystem extends ZipFileSystem {\n hashData?: HashElement[] | null;\n\n /**\n * Constructor\n * @param file - instance of FileProvider or file path string\n */\n constructor(file: FileProvider | string) {\n super(file);\n }\n\n /**\n * Implementation of fetch against this file system.\n * It tries to take `@3dtilesIndex1@` file from the archive and use it\n * for faster access to archived files\n * @param filename - name of a file\n * @returns - Response with file data\n */\n async fetch(filename: string): Promise<Response> {\n const fileProvider = await this.fileProvider;\n if (!fileProvider) {\n throw new Error('No data detected in the zip archive');\n }\n await this.parseHashFile();\n if (this.hashData) {\n const archive = new Tiles3DArchive(fileProvider, this.hashData);\n\n const fileData = await archive.getFile(filename);\n const response = new Response(fileData);\n Object.defineProperty(response, 'url', {value: `${this.fileName || ''}/${filename}`});\n return response;\n }\n return super.fetch(filename);\n }\n\n /**\n * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access\n * to files inside the archive\n * @returns void\n */\n private async parseHashFile(): Promise<void> {\n if (this.hashData !== undefined) {\n return;\n }\n\n const fileProvider = await this.fileProvider;\n if (!fileProvider) {\n throw new Error('No data detected in the zip archive');\n }\n\n const hashCDOffset = await searchFromTheEnd(fileProvider, cdHeaderSignature);\n\n const cdFileHeader = await parseZipCDFileHeader(hashCDOffset, fileProvider);\n\n // '@3dtilesIndex1@' is index file that must be the last in the archive. It allows\n // to improve load and read performance when the archive contains a very large number\n // of files.\n if (cdFileHeader?.fileName === '@3dtilesIndex1@') {\n const localFileHeader = await parseZipLocalFileHeader(\n cdFileHeader.localHeaderOffset,\n fileProvider\n );\n if (!localFileHeader) {\n throw new Error('corrupted 3tz');\n }\n\n const fileDataOffset = localFileHeader.fileDataOffset;\n const hashFile = await fileProvider.slice(\n fileDataOffset,\n fileDataOffset + localFileHeader.compressedSize\n );\n\n this.hashData = parseHashFile(hashFile);\n } else {\n this.hashData = null;\n }\n }\n}\n"],"mappings":";AAAA,SAEEA,aAAa,EACbC,WAAW,IAAIC,iBAAiB,EAChCC,gBAAgB,EAChBC,oBAAoB,EAEpBC,aAAa,EACbC,uBAAuB,QAClB,iBAAiB;AACxB,SAAQC,cAAc,QAAO,iDAAiD;AAS9E,OAAO,MAAMC,wBAAwB,SAASR,aAAa,CAAC;EAO1DS,WAAWA,CAACC,IAA2B,EAAE;IACvC,KAAK,CAACA,IAAI,CAAC;IAACC,eAAA;EACd;EASA,MAAMC,KAAKA,CAACC,QAAgB,EAAqB;IAC/C,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACA,YAAY;IAC5C,IAAI,CAACA,YAAY,EAAE;MACjB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;IACxD;IACA,MAAM,IAAI,CAACV,aAAa,CAAC,CAAC;IAC1B,IAAI,IAAI,CAACW,QAAQ,EAAE;MACjB,MAAMC,OAAO,GAAG,IAAIV,cAAc,CAACO,YAAY,EAAE,IAAI,CAACE,QAAQ,CAAC;MAE/D,MAAME,QAAQ,GAAG,MAAMD,OAAO,CAACE,OAAO,CAACN,QAAQ,CAAC;MAChD,MAAMO,QAAQ,GAAG,IAAIC,QAAQ,CAACH,QAAQ,CAAC;MACvCI,MAAM,CAACC,cAAc,CAACH,QAAQ,EAAE,KAAK,EAAE;QAACI,KAAK,KAAAC,MAAA,CAAK,IAAI,CAACC,QAAQ,IAAI,EAAE,OAAAD,MAAA,CAAIZ,QAAQ;MAAE,CAAC,CAAC;MACrF,OAAOO,QAAQ;IACjB;IACA,OAAO,KAAK,CAACR,KAAK,CAACC,QAAQ,CAAC;EAC9B;EAOA,MAAcR,aAAaA,CAAA,EAAkB;IAC3C,IAAI,IAAI,CAACW,QAAQ,KAAKW,SAAS,EAAE;MAC/B;IACF;IAEA,MAAMb,YAAY,GAAG,MAAM,IAAI,CAACA,YAAY;IAC5C,IAAI,CAACA,YAAY,EAAE;MACjB,MAAM,IAAIC,KAAK,CAAC,qCAAqC,CAAC;IACxD;IAEA,MAAMa,YAAY,GAAG,MAAMzB,gBAAgB,CAACW,YAAY,EAAEZ,iBAAiB,CAAC;IAE5E,MAAM2B,YAAY,GAAG,MAAMzB,oBAAoB,CAACwB,YAAY,EAAEd,YAAY,CAAC;IAK3E,IAAI,CAAAe,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEH,QAAQ,MAAK,iBAAiB,EAAE;MAChD,MAAMI,eAAe,GAAG,MAAMxB,uBAAuB,CACnDuB,YAAY,CAACE,iBAAiB,EAC9BjB,YACF,CAAC;MACD,IAAI,CAACgB,eAAe,EAAE;QACpB,MAAM,IAAIf,KAAK,CAAC,eAAe,CAAC;MAClC;MAEA,MAAMiB,cAAc,GAAGF,eAAe,CAACE,cAAc;MACrD,MAAMC,QAAQ,GAAG,MAAMnB,YAAY,CAACoB,KAAK,CACvCF,cAAc,EACdA,cAAc,GAAGF,eAAe,CAACK,cACnC,CAAC;MAED,IAAI,CAACnB,QAAQ,GAAGX,aAAa,CAAC4B,QAAQ,CAAC;IACzC,CAAC,MAAM;MACL,IAAI,CAACjB,QAAQ,GAAG,IAAI;IACtB;EACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { GLTFLoader, postProcessGLTF, _getMemoryUsageGLTF } from '@loaders.gl/gltf';
2
- import { sliceArrayBuffer } from '@loaders.gl/loader-utils';
2
+ import { sliceArrayBuffer, parseFromContext } from '@loaders.gl/loader-utils';
3
3
  export const GLTF_FORMAT = {
4
4
  URI: 0,
5
5
  EMBEDDED: 1
@@ -26,17 +26,16 @@ export async function extractGLTF(tile, gltfFormat, options, context) {
26
26
  if (!context) {
27
27
  return;
28
28
  }
29
- const {
30
- parse,
31
- fetch
32
- } = context;
33
29
  if (tile.gltfUrl) {
30
+ const {
31
+ fetch
32
+ } = context;
34
33
  const response = await fetch(tile.gltfUrl, options);
35
34
  tile.gltfArrayBuffer = await response.arrayBuffer();
36
35
  tile.gltfByteOffset = 0;
37
36
  }
38
37
  if (tile.gltfArrayBuffer) {
39
- const gltfWithBuffers = await parse(tile.gltfArrayBuffer, GLTFLoader, options, context);
38
+ const gltfWithBuffers = await parseFromContext(tile.gltfArrayBuffer, GLTFLoader, options, context);
40
39
  tile.gltf = postProcessGLTF(gltfWithBuffers);
41
40
  tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);
42
41
  delete tile.gltfArrayBuffer;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf-view.js","names":["GLTFLoader","postProcessGLTF","_getMemoryUsageGLTF","sliceArrayBuffer","GLTF_FORMAT","URI","EMBEDDED","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","gltfByteOffset","console","warn","concat","type","extractGLTF","gltfFormat","context","tile3DOptions","extractGLTFBufferOrURL","loadGLTF","parse","fetch","gltfUrl","response","gltfWithBuffers","gltf","gpuMemoryUsageInBytes","gltfUrlBytes","Uint8Array","textDecoder","TextDecoder","decode","replace"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - should we automatically parse the embedded glTF or leave it to the app?\n// - I.e. some apps might work directly on a GLB, in that case no need for us to decode...\n// - And if we decode, do we still keep the GLB in case it is needed?\n// - Do we add an option to control this?\n// - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?\n\nimport {GLTFLoader, postProcessGLTF, _getMemoryUsageGLTF} from '@loaders.gl/gltf';\nimport {LoaderContext, sliceArrayBuffer} from '@loaders.gl/loader-utils';\nimport {Tiles3DTileContent} from '../../../types';\nimport {Tiles3DLoaderOptions} from '../../../tiles-3d-loader';\n\nexport const GLTF_FORMAT = {\n URI: 0,\n EMBEDDED: 1\n};\n\nexport function parse3DTileGLTFViewSync(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: Tiles3DLoaderOptions | undefined\n) {\n // Set flags\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 tile.rotateYtoZ = true;\n\n // Assume glTF consumes rest of tile\n const gltfByteLength = (tile.byteOffset || 0) + (tile.byteLength || 0) - byteOffset;\n if (gltfByteLength === 0) {\n throw new Error('glTF byte length must be greater than 0.');\n }\n\n // Save gltf up axis\n tile.gltfUpAxis =\n options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n // TODO - We can avoid copy if already 4-byte aligned...\n // However the rest of the code may not be able to accept byteOffsets, so copy anyway\n tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);\n tile.gltfByteOffset = 0;\n tile.gltfByteLength = gltfByteLength;\n\n if (byteOffset % 4 === 0) {\n // tile.gltfArrayBuffer = arrayBuffer;\n // tile.gltfByteOffset = byteOffset;\n // tile.gltfByteLength = gltfByteLength;\n } else {\n // Create a copy of the glb so that it is 4-byte aligned\n // eslint-disable-next-line\n console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);\n }\n\n // Entire tile is consumed\n return (tile.byteOffset || 0) + (tile.byteLength || 0);\n}\n\nexport async function extractGLTF(\n tile: Tiles3DTileContent,\n gltfFormat: number,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n const tile3DOptions = options?.['3d-tiles'] || {};\n\n extractGLTFBufferOrURL(tile, gltfFormat, options);\n\n if (tile3DOptions.loadGLTF) {\n if (!context) {\n return;\n }\n const {parse, fetch} = context;\n if (tile.gltfUrl) {\n const response = await fetch(tile.gltfUrl, options);\n tile.gltfArrayBuffer = await response.arrayBuffer();\n tile.gltfByteOffset = 0;\n }\n if (tile.gltfArrayBuffer) {\n // TODO - Should handle byteOffset... However, not used now...\n const gltfWithBuffers = await parse(tile.gltfArrayBuffer, GLTFLoader, options, context);\n tile.gltf = postProcessGLTF(gltfWithBuffers);\n tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n }\n }\n}\n\nfunction extractGLTFBufferOrURL(\n tile: Tiles3DTileContent,\n gltfFormat: number,\n options: Tiles3DLoaderOptions | undefined\n) {\n switch (gltfFormat) {\n case GLTF_FORMAT.URI:\n // We need to remove padding from the end of the model URL in case this tile was part of a composite tile.\n // This removes all white space and null characters from the end of the string.\n if (tile.gltfArrayBuffer) {\n const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);\n const textDecoder = new TextDecoder();\n const gltfUrl = textDecoder.decode(gltfUrlBytes);\n tile.gltfUrl = gltfUrl.replace(/[\\s\\0]+$/, '');\n }\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n break;\n case GLTF_FORMAT.EMBEDDED:\n break;\n default:\n throw new Error('b3dm: Illegal glTF format field');\n }\n}\n"],"mappings":"AASA,SAAQA,UAAU,EAAEC,eAAe,EAAEC,mBAAmB,QAAO,kBAAkB;AACjF,SAAuBC,gBAAgB,QAAO,0BAA0B;AAIxE,OAAO,MAAMC,WAAW,GAAG;EACzBC,GAAG,EAAE,CAAC;EACNC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,SAASC,uBAAuB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V,IAAI,CAACW,cAAc;MAC1B,OAAOX,IAAI,CAACK,cAAc;MAC1B;IACF,KAAKT,WAAW,CAACE,QAAQ;MACvB;IACF;MACE,MAAM,IAAIS,KAAK,CAAC,iCAAiC,CAAC;EACtD;AACF"}
1
+ {"version":3,"file":"parse-3d-tile-gltf-view.js","names":["GLTFLoader","postProcessGLTF","_getMemoryUsageGLTF","sliceArrayBuffer","parseFromContext","GLTF_FORMAT","URI","EMBEDDED","parse3DTileGLTFViewSync","tile","arrayBuffer","byteOffset","options","rotateYtoZ","gltfByteLength","byteLength","Error","gltfUpAxis","assetGltfUpAxis","gltfArrayBuffer","gltfByteOffset","console","warn","concat","type","extractGLTF","gltfFormat","context","tile3DOptions","extractGLTFBufferOrURL","loadGLTF","gltfUrl","fetch","response","gltfWithBuffers","gltf","gpuMemoryUsageInBytes","gltfUrlBytes","Uint8Array","textDecoder","TextDecoder","decode","replace"],"sources":["../../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\n// TODO - should we automatically parse the embedded glTF or leave it to the app?\n// - I.e. some apps might work directly on a GLB, in that case no need for us to decode...\n// - And if we decode, do we still keep the GLB in case it is needed?\n// - Do we add an option to control this?\n// - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?\n\nimport {GLTFLoader, postProcessGLTF, _getMemoryUsageGLTF} from '@loaders.gl/gltf';\nimport {LoaderContext, sliceArrayBuffer, parseFromContext} from '@loaders.gl/loader-utils';\nimport {Tiles3DTileContent} from '../../../types';\nimport {Tiles3DLoaderOptions} from '../../../tiles-3d-loader';\n\nexport const GLTF_FORMAT = {\n URI: 0,\n EMBEDDED: 1\n};\n\nexport function parse3DTileGLTFViewSync(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options: Tiles3DLoaderOptions | undefined\n) {\n // Set flags\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 tile.rotateYtoZ = true;\n\n // Assume glTF consumes rest of tile\n const gltfByteLength = (tile.byteOffset || 0) + (tile.byteLength || 0) - byteOffset;\n if (gltfByteLength === 0) {\n throw new Error('glTF byte length must be greater than 0.');\n }\n\n // Save gltf up axis\n tile.gltfUpAxis =\n options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n // TODO - We can avoid copy if already 4-byte aligned...\n // However the rest of the code may not be able to accept byteOffsets, so copy anyway\n tile.gltfArrayBuffer = sliceArrayBuffer(arrayBuffer, byteOffset, gltfByteLength);\n tile.gltfByteOffset = 0;\n tile.gltfByteLength = gltfByteLength;\n\n if (byteOffset % 4 === 0) {\n // tile.gltfArrayBuffer = arrayBuffer;\n // tile.gltfByteOffset = byteOffset;\n // tile.gltfByteLength = gltfByteLength;\n } else {\n // Create a copy of the glb so that it is 4-byte aligned\n // eslint-disable-next-line\n console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);\n }\n\n // Entire tile is consumed\n return (tile.byteOffset || 0) + (tile.byteLength || 0);\n}\n\nexport async function extractGLTF(\n tile: Tiles3DTileContent,\n gltfFormat: number,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n const tile3DOptions = options?.['3d-tiles'] || {};\n\n extractGLTFBufferOrURL(tile, gltfFormat, options);\n\n if (tile3DOptions.loadGLTF) {\n if (!context) {\n return;\n }\n if (tile.gltfUrl) {\n const {fetch} = context;\n const response = await fetch(tile.gltfUrl, options);\n tile.gltfArrayBuffer = await response.arrayBuffer();\n tile.gltfByteOffset = 0;\n }\n if (tile.gltfArrayBuffer) {\n // TODO - Should handle byteOffset... However, not used now...\n const gltfWithBuffers = await parseFromContext(\n tile.gltfArrayBuffer,\n GLTFLoader,\n options,\n context\n );\n tile.gltf = postProcessGLTF(gltfWithBuffers);\n tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n }\n }\n}\n\nfunction extractGLTFBufferOrURL(\n tile: Tiles3DTileContent,\n gltfFormat: number,\n options: Tiles3DLoaderOptions | undefined\n) {\n switch (gltfFormat) {\n case GLTF_FORMAT.URI:\n // We need to remove padding from the end of the model URL in case this tile was part of a composite tile.\n // This removes all white space and null characters from the end of the string.\n if (tile.gltfArrayBuffer) {\n const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);\n const textDecoder = new TextDecoder();\n const gltfUrl = textDecoder.decode(gltfUrlBytes);\n tile.gltfUrl = gltfUrl.replace(/[\\s\\0]+$/, '');\n }\n delete tile.gltfArrayBuffer;\n delete tile.gltfByteOffset;\n delete tile.gltfByteLength;\n break;\n case GLTF_FORMAT.EMBEDDED:\n break;\n default:\n throw new Error('b3dm: Illegal glTF format field');\n }\n}\n"],"mappings":"AASA,SAAQA,UAAU,EAAEC,eAAe,EAAEC,mBAAmB,QAAO,kBAAkB;AACjF,SAAuBC,gBAAgB,EAAEC,gBAAgB,QAAO,0BAA0B;AAI1F,OAAO,MAAMC,WAAW,GAAG;EACzBC,GAAG,EAAE,CAAC;EACNC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,SAASC,uBAAuBA,CACrCC,IAAwB,EACxBC,WAAwB,EACxBC,UAAkB,EAClBC,OAAyC,EACzC;EAIAH,IAAI,CAACI,UAAU,GAAG,IAAI;EAGtB,MAAMC,cAAc,GAAG,CAACL,IAAI,CAACE,UAAU,IAAI,CAAC,KAAKF,IAAI,CAACM,UAAU,IAAI,CAAC,CAAC,GAAGJ,UAAU;EACnF,IAAIG,cAAc,KAAK,CAAC,EAAE;IACxB,MAAM,IAAIE,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAGAP,IAAI,CAACQ,UAAU,GACb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MAAMe,eAAe,GAAG,MAAM9B,gBAAgB,CAC5CK,IAAI,CAACU,eAAe,EACpBnB,UAAU,EACVY,OAAO,EACPe,OACF,CAAC;MACDlB,IAAI,CAAC0B,IAAI,GAAGlC,eAAe,CAACiC,eAAe,CAAC;MAC5CzB,IAAI,CAAC2B,qBAAqB,GAAGlC,mBAAmB,CAACO,IAAI,CAAC0B,IAAI,CAAC;MAC3D,OAAO1B,IAAI,CAACU,eAAe;MAC3B,OAAOV,IAAI,CAACW,cAAc;MAC1B,OAAOX,IAAI,CAACK,cAAc;IAC5B;EACF;AACF;AAEA,SAASe,sBAAsBA,CAC7BpB,IAAwB,EACxBiB,UAAkB,EAClBd,OAAyC,EACzC;EACA,QAAQc,UAAU;IAChB,KAAKrB,WAAW,CAACC,GAAG;MAGlB,IAAIG,IAAI,CAACU,eAAe,EAAE;QACxB,MAAMkB,YAAY,GAAG,IAAIC,UAAU,CAAC7B,IAAI,CAACU,eAAe,EAAEV,IAAI,CAACW,cAAc,CAAC;QAC9E,MAAMmB,WAAW,GAAG,IAAIC,WAAW,CAAC,CAAC;QACrC,MAAMT,OAAO,GAAGQ,WAAW,CAACE,MAAM,CAACJ,YAAY,CAAC;QAChD5B,IAAI,CAACsB,OAAO,GAAGA,OAAO,CAACW,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;MAChD;MACA,OAAOjC,IAAI,CAACU,eAAe;MAC3B,OAAOV,IAAI,CAACW,cAAc;MAC1B,OAAOX,IAAI,CAACK,cAAc;MAC1B;IACF,KAAKT,WAAW,CAACE,QAAQ;MACvB;IACF;MACE,MAAM,IAAIS,KAAK,CAAC,iCAAiC,CAAC;EACtD;AACF"}
@@ -1,16 +1,14 @@
1
+ import { parseFromContext } from '@loaders.gl/loader-utils';
1
2
  import { _getMemoryUsageGLTF, GLTFLoader, postProcessGLTF } from '@loaders.gl/gltf';
2
3
  export async function parseGltf3DTile(tile, arrayBuffer, options, context) {
3
- var _options$3dTiles;
4
+ var _options$3dTiles, _options$3dTiles2;
4
5
  tile.rotateYtoZ = true;
5
- tile.gltfUpAxis = options !== null && options !== void 0 && options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis ? options['3d-tiles'].assetGltfUpAxis : 'Y';
6
- if (options !== null && options !== void 0 && (_options$3dTiles = options['3d-tiles']) !== null && _options$3dTiles !== void 0 && _options$3dTiles.loadGLTF) {
6
+ tile.gltfUpAxis = options !== null && options !== void 0 && (_options$3dTiles = options['3d-tiles']) !== null && _options$3dTiles !== void 0 && _options$3dTiles.assetGltfUpAxis ? options['3d-tiles'].assetGltfUpAxis : 'Y';
7
+ if (options !== null && options !== void 0 && (_options$3dTiles2 = options['3d-tiles']) !== null && _options$3dTiles2 !== void 0 && _options$3dTiles2.loadGLTF) {
7
8
  if (!context) {
8
9
  return;
9
10
  }
10
- const {
11
- parse
12
- } = context;
13
- const gltfWithBuffers = await parse(arrayBuffer, GLTFLoader, options, context);
11
+ const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
14
12
  tile.gltf = postProcessGLTF(gltfWithBuffers);
15
13
  tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);
16
14
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf.js","names":["_getMemoryUsageGLTF","GLTFLoader","postProcessGLTF","parseGltf3DTile","tile","arrayBuffer","options","context","_options$3dTiles","rotateYtoZ","gltfUpAxis","assetGltfUpAxis","loadGLTF","parse","gltfWithBuffers","gltf","gpuMemoryUsageInBytes","gltfArrayBuffer"],"sources":["../../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"sourcesContent":["import type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport {_getMemoryUsageGLTF, GLTFLoader, postProcessGLTF} from '@loaders.gl/gltf';\nimport {Tiles3DTileContent} from '../../types';\n\nexport async function parseGltf3DTile(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n // Set flags\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 tile.rotateYtoZ = true;\n // Save gltf up axis\n tile.gltfUpAxis =\n options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n if (options?.['3d-tiles']?.loadGLTF) {\n if (!context) {\n return;\n }\n const {parse} = context;\n const gltfWithBuffers = await parse(arrayBuffer, GLTFLoader, options, context);\n tile.gltf = postProcessGLTF(gltfWithBuffers);\n tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);\n } else {\n tile.gltfArrayBuffer = arrayBuffer;\n }\n}\n"],"mappings":"AAEA,SAAQA,mBAAmB,EAAEC,UAAU,EAAEC,eAAe,QAAO,kBAAkB;AAGjF,OAAO,eAAeC,eAAeA,CACnCC,IAAwB,EACxBC,WAAwB,EACxBC,OAA8B,EAC9BC,OAAuB,EACR;EAAA,IAAAC,gBAAA;EAIfJ,IAAI,CAACK,UAAU,GAAG,IAAI;EAEtBL,IAAI,CAACM,UAAU,GACbJ,OAAO,aAAPA,OAAO,eAAPA,OAAO,CAAG,UAAU,CAAC,IAAIA,OAAO,CAAC,UAAU,CAAC,CAACK,eAAe,GACxDL,OAAO,CAAC,UAAU,CAAC,CAACK,eAAe,GACnC,GAAG;EAET,IAAIL,OAAO,aAAPA,OAAO,gBAAAE,gBAAA,GAAPF,OAAO,CAAG,UAAU,CAAC,cAAAE,gBAAA,eAArBA,gBAAA,CAAuBI,QAAQ,EAAE;IACnC,IAAI,CAACL,OAAO,EAAE;MACZ;IACF;IACA,MAAM;MAACM;IAAK,CAAC,GAAGN,OAAO;IACvB,MAAMO,eAAe,GAAG,MAAMD,KAAK,CAACR,WAAW,EAAEJ,UAAU,EAAEK,OAAO,EAAEC,OAAO,CAAC;IAC9EH,IAAI,CAACW,IAAI,GAAGb,eAAe,CAACY,eAAe,CAAC;IAC5CV,IAAI,CAACY,qBAAqB,GAAGhB,mBAAmB,CAACI,IAAI,CAACW,IAAI,CAAC;EAC7D,CAAC,MAAM;IACLX,IAAI,CAACa,eAAe,GAAGZ,WAAW;EACpC;AACF"}
1
+ {"version":3,"file":"parse-3d-tile-gltf.js","names":["parseFromContext","_getMemoryUsageGLTF","GLTFLoader","postProcessGLTF","parseGltf3DTile","tile","arrayBuffer","options","context","_options$3dTiles","_options$3dTiles2","rotateYtoZ","gltfUpAxis","assetGltfUpAxis","loadGLTF","gltfWithBuffers","gltf","gpuMemoryUsageInBytes","gltfArrayBuffer"],"sources":["../../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport {parseFromContext, LoaderContext} from '@loaders.gl/loader-utils';\nimport {_getMemoryUsageGLTF, GLTFLoader, postProcessGLTF} from '@loaders.gl/gltf';\nimport type {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport {Tiles3DTileContent} from '../../types';\n\nexport async function parseGltf3DTile(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n // Set flags\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 tile.rotateYtoZ = true;\n // Save gltf up axis\n tile.gltfUpAxis = options?.['3d-tiles']?.assetGltfUpAxis\n ? options['3d-tiles'].assetGltfUpAxis\n : 'Y';\n\n if (options?.['3d-tiles']?.loadGLTF) {\n if (!context) {\n return;\n }\n const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);\n tile.gltf = postProcessGLTF(gltfWithBuffers);\n tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);\n } else {\n tile.gltfArrayBuffer = arrayBuffer;\n }\n}\n"],"mappings":"AAEA,SAAQA,gBAAgB,QAAsB,0BAA0B;AACxE,SAAQC,mBAAmB,EAAEC,UAAU,EAAEC,eAAe,QAAO,kBAAkB;AAIjF,OAAO,eAAeC,eAAeA,CACnCC,IAAwB,EACxBC,WAAwB,EACxBC,OAA8B,EAC9BC,OAAuB,EACR;EAAA,IAAAC,gBAAA,EAAAC,iBAAA;EAIfL,IAAI,CAACM,UAAU,GAAG,IAAI;EAEtBN,IAAI,CAACO,UAAU,GAAGL,OAAO,aAAPA,OAAO,gBAAAE,gBAAA,GAAPF,OAAO,CAAG,UAAU,CAAC,cAAAE,gBAAA,eAArBA,gBAAA,CAAuBI,eAAe,GACpDN,OAAO,CAAC,UAAU,CAAC,CAACM,eAAe,GACnC,GAAG;EAEP,IAAIN,OAAO,aAAPA,OAAO,gBAAAG,iBAAA,GAAPH,OAAO,CAAG,UAAU,CAAC,cAAAG,iBAAA,eAArBA,iBAAA,CAAuBI,QAAQ,EAAE;IACnC,IAAI,CAACN,OAAO,EAAE;MACZ;IACF;IACA,MAAMO,eAAe,GAAG,MAAMf,gBAAgB,CAACM,WAAW,EAAEJ,UAAU,EAAEK,OAAO,EAAEC,OAAO,CAAC;IACzFH,IAAI,CAACW,IAAI,GAAGb,eAAe,CAACY,eAAe,CAAC;IAC5CV,IAAI,CAACY,qBAAqB,GAAGhB,mBAAmB,CAACI,IAAI,CAACW,IAAI,CAAC;EAC7D,CAAC,MAAM;IACLX,IAAI,CAACa,eAAe,GAAGZ,WAAW;EACpC;AACF"}
@@ -1,3 +1,4 @@
1
+ import { path } from '@loaders.gl/loader-utils';
1
2
  import { Tile3DSubtreeLoader } from '../../tile-3d-subtree-loader';
2
3
  import { load } from '@loaders.gl/core';
3
4
  import { LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE } from '@loaders.gl/tiles';
@@ -44,7 +45,7 @@ function resolveUri() {
44
45
  } else if (uri.startsWith('/')) {
45
46
  return uri;
46
47
  }
47
- return "".concat(basePath, "/").concat(uri);
48
+ return path.resolve(basePath, uri);
48
49
  }
49
50
  export function normalizeTileData(tile, basePath) {
50
51
  if (!tile) {
@@ -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","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;EAAA,IAA5CC,GAAW,GAAAf,SAAA,CAAAC,MAAA,QAAAD,SAAA,Q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BK,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
+ {"version":3,"file":"parse-3d-tile-header.js","names":["path","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","resolve","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 {path} 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 path.resolve(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,IAAI,QAAO,0BAA0B;AAC7C,SAAQC,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;E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,MAAIpF,IAAI,aAAJA,IAAI,uBAAJA,IAAI,CAAEqF,cAAc;AAC9E"}
@@ -1,4 +1,5 @@
1
1
  import { DracoLoader } from '@loaders.gl/draco';
2
+ import { parseFromContext } from '@loaders.gl/loader-utils';
2
3
  import { GL } from '@loaders.gl/math';
3
4
  import { Vector3 } from '@math.gl/core';
4
5
  import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
@@ -183,9 +184,6 @@ export async function loadDraco(tile, dracoData, options, context) {
183
184
  if (!context) {
184
185
  return;
185
186
  }
186
- const {
187
- parse
188
- } = context;
189
187
  const dracoOptions = {
190
188
  ...options,
191
189
  draco: {
@@ -194,7 +192,7 @@ export async function loadDraco(tile, dracoData, options, context) {
194
192
  }
195
193
  };
196
194
  delete dracoOptions['3d-tiles'];
197
- const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);
195
+ const data = await parseFromContext(dracoData.buffer, DracoLoader, dracoOptions, context);
198
196
  const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
199
197
  const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
200
198
  const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-point-cloud.js","names":["DracoLoader","GL","Vector3","Tile3DFeatureTable","Tile3DBatchTable","parse3DTileHeaderSync","parse3DTileTablesHeaderSync","parse3DTileTablesSync","normalize3DTileColorAttribute","normalize3DTileNormalAttribute","normalize3DTilePositionAttribute","parsePointCloud3DTile","tile","arrayBuffer","byteOffset","options","context","initializeTile","featureTable","batchTable","parsePointCloudTables","parseDraco","parsePositions","parseColors","parseNormals","attributes","positions","colors","normals","batchIds","isQuantized","isTranslucent","isRGB565","isOctEncoded16P","featureTableJson","featureTableBinary","pointsLength","getGlobalProperty","Number","isFinite","Error","featuresLength","pointCount","rtcCenter","FLOAT","parseBatchIds","hasProperty","getPropertyArray","UNSIGNED_SHORT","quantizedRange","quantizedVolumeScale","quantizedVolumeOffset","UNSIGNED_BYTE","constantRGBA","batchFeatureLength","batchTableJson","batchTableBinary","dracoBuffer","dracoFeatureTableProperties","dracoBatchTableProperties","batchTableDraco","extensions","properties","featureTableDraco","getExtension","dracoByteOffset","dracoByteLength","byteLength","slice","hasPositions","POSITION","hasColors","RGB","RGBA","hasNormals","NORMAL","hasBatchIds","BATCH_ID","dracoData","buffer","featureTableProperties","batchTableProperties","dequantizeInShader","loadDraco","parse","dracoOptions","draco","extraAttributes","data","decodedPositions","value","decodedColors","COLOR_0","decodedNormals","decodedBatchIds","isQuantizedDraco","quantization","isOctEncodedDraco","range","minValues","quantizationBits","octEncodedRange","batchTableAttributes","attributeName","Object","keys","toLowerCase","undefined"],"sources":["../../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {GL} from '@loaders.gl/math';\nimport {Vector3} from '@math.gl/core';\n\nimport Tile3DFeatureTable from '../classes/tile-3d-feature-table';\nimport Tile3DBatchTable from '../classes/tile-3d-batch-table';\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\nimport {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';\nimport {normalize3DTileColorAttribute} from './helpers/normalize-3d-tile-colors';\nimport {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normals';\nimport {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';\nimport {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport {LoaderContext} from '@loaders.gl/loader-utils';\nimport {Tiles3DTileContent} from '../../types';\n\nexport async function parsePointCloud3DTile(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<number> {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);\n initializeTile(tile);\n\n const {featureTable, batchTable} = parsePointCloudTables(tile);\n\n await parseDraco(tile, featureTable, batchTable, options, context);\n\n parsePositions(tile, featureTable, options);\n // @ts-expect-error TODO - do we need to assert on the batch table?\n parseColors(tile, featureTable, batchTable);\n parseNormals(tile, featureTable);\n\n return byteOffset;\n}\n\nfunction initializeTile(tile: Tiles3DTileContent): void {\n // Initialize point cloud tile defaults\n tile.attributes = {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n tile.isQuantized = false;\n tile.isTranslucent = false;\n tile.isRGB565 = false;\n tile.isOctEncoded16P = false;\n}\n\nfunction parsePointCloudTables(tile: Tiles3DTileContent): {\n featureTable: Tile3DFeatureTable;\n batchTable: Tile3DBatchTable | null;\n} {\n const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);\n\n const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');\n if (!Number.isFinite(pointsLength)) {\n throw new Error('POINTS_LENGTH must be defined');\n }\n featureTable.featuresLength = pointsLength;\n\n tile.featuresLength = pointsLength;\n tile.pointsLength = pointsLength;\n tile.pointCount = pointsLength;\n\n tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);\n\n const batchTable = parseBatchIds(tile, featureTable);\n\n return {featureTable, batchTable};\n}\n\nfunction parsePositions(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n options: Tiles3DLoaderOptions | undefined\n): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n tile.isQuantized = true;\n tile.quantizedRange = (1 << 16) - 1;\n\n tile.quantizedVolumeScale = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_SCALE',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeScale) {\n throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');\n }\n\n tile.quantizedVolumeOffset = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_OFFSET',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeOffset) {\n throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');\n }\n\n tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n\nfunction parseColors(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n batchTable: Tile3DBatchTable\n): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.colors) {\n let colors = null;\n if (featureTable.hasProperty('RGBA')) {\n colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasProperty('RGB565')) {\n colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n\n tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);\n }\n\n if (featureTable.hasProperty('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n}\n\nfunction parseNormals(tile: Tiles3DTileContent, featureTable: Tile3DFeatureTable): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.normals) {\n let normals = null;\n if (featureTable.hasProperty('NORMAL')) {\n normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('NORMAL_OCT16P')) {\n normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n\n tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);\n }\n}\n\nfunction parseBatchIds(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable\n): Tile3DBatchTable | null {\n let batchTable: Tile3DBatchTable | null = null;\n if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n\n if (tile.batchIds) {\n const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!batchFeatureLength) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n const {batchTableJson, batchTableBinary} = tile;\n batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);\n }\n }\n return batchTable;\n}\n\n// eslint-disable-next-line complexity\nasync function parseDraco(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n batchTable,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n const batchTableDraco =\n tile.batchTableJson &&\n tile.batchTableJson.extensions &&\n tile.batchTableJson.extensions['3DTILES_draco_point_compression'];\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = (tile.featureTableBinary || []).slice(\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n\n tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);\n tile.hasColors =\n Number.isFinite(dracoFeatureTableProperties.RGB) ||\n Number.isFinite(dracoFeatureTableProperties.RGBA);\n tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);\n tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);\n tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);\n }\n\n if (!dracoBuffer) {\n return true;\n }\n\n const dracoData = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n return await loadDraco(tile, dracoData, options, context);\n}\n\n// eslint-disable-next-line complexity, max-statements\nexport async function loadDraco(\n tile: Tiles3DTileContent,\n dracoData,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n if (!context) {\n return;\n }\n const {parse} = context;\n const dracoOptions = {\n ...options,\n draco: {\n ...options?.draco,\n extraAttributes: dracoData.batchTableProperties || {}\n }\n };\n\n // The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n\n const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);\n\n const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;\n const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;\n const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;\n const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;\n const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;\n const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n const quantization = data.POSITION.data.quantization;\n const range = quantization.range;\n tile.quantizedVolumeScale = new Vector3(range, range, range);\n tile.quantizedVolumeOffset = new Vector3(quantization.minValues);\n tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile.isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile.isOctEncodedDraco = true;\n }\n\n // Extra batch table attributes\n const batchTableAttributes = {};\n if (dracoData.batchTableProperties) {\n for (const attributeName of Object.keys(dracoData.batchTableProperties)) {\n if (data.attributes[attributeName] && data.attributes[attributeName].value) {\n batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;\n }\n }\n }\n\n tile.attributes = {\n positions: decodedPositions,\n colors: normalize3DTileColorAttribute(tile, decodedColors, undefined),\n normals: decodedNormals,\n batchIds: decodedBatchIds,\n ...batchTableAttributes\n };\n}\n\n// TODO - this is the remaining code from Cesium's parser\n/*\n const batchTable = new Tile3DBatchTable(tile);\n\n // parseDracoBuffer(tile, featureTable, batchTable);\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n/*\n\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n\n if (!tile.colors) {\n if (featureTable.hasProperty('RGBA')) {\n tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasPropertry('RGB565')) {\n tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n }\n\n if (!tile.attributes.normals) {\n if (featureTable.getPropertry('NORMAL')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.getProperty('NORMAL_OCT16P')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n }\n\n if (!tile.batchIds) {\n if (featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n\n if (featureTable.getPropertry('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n\n if (tile.batchIds) {\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!defined(batchLength)) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n\n if (defined(batchTableBinary)) {\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n batchTableBinary = new Uint8Array(batchTableBinary);\n }\n\n if (defined(pointCloud._batchTableLoaded)) {\n pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);\n }\n }\n\n // If points are not batched and there are per-point properties, use these properties for styling purposes\n var styleableProperties;\n if (!hasBatchIds && defined(batchTableBinary)) {\n tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(\n pointsLength,\n batchTableJson,\n batchTableBinary\n );\n }\n\n tile.draco = draco;\n}\n\n// Separate parsing and decoding of Draco\nexport function parseDracoBuffer(tile, featureTable, batchTable) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n\n const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = arraySlice(\n featureTableBinary,\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n tile.hasPositions = dracoFeatureTableProperties.POSITION;\n tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;\n tile.hasNormals = dracoFeatureTableProperties.NORMAL;\n tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;\n tile.isTranslucent = dracoFeatureTableProperties.RGBA;\n }\n\n if (dracoBuffer) {\n tile.draco = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n tile.decodingState = DECODING_STATE.NEEDS_DECODE;\n }\n}\n\n/*\nfunction decodeDraco(tile, context) {\n if (tile.decodingState === DECODING_STATE.READY) {\n return false;\n }\n if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {\n var parsedContent = tile._parsedContent;\n var draco = parsedContent.draco;\n var decodePromise = DracoLoader.decodePointCloud(draco, context);\n if (defined(decodePromise)) {\n tile.decodingState = DECODING_STATE.DECODING;\n decodePromise.then(function(result) {\n tile.decodingState = DECODING_STATE.READY;\n var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;\n var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;\n var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;\n var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;\n var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;\n var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);\n var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n var quantization = result.POSITION.data.quantization;\n var range = quantization.range;\n tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);\n tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);\n tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile._isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile._isOctEncodedDraco = true;\n }\n var styleableProperties = parsedContent.styleableProperties;\n var batchTableProperties = draco.batchTableProperties;\n for (var name in batchTableProperties) {\n if (batchTableProperties.hasOwnProperty(name)) {\n var property = result[name];\n if (!defined(styleableProperties)) {\n styleableProperties = {};\n }\n styleableProperties[name] = {\n typedArray : property.array,\n componentCount : property.data.componentsPerAttribute\n };\n }\n }\n parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);\n parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);\n parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);\n parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);\n parsedContent.styleableProperties = styleableProperties;\n }).otherwise(function(error) {\n tile.decodingState = DECODING_STATE.FAILED;\n tile._readyPromise.reject(error);\n });\n }\n }\n return true;\n}\n*/\n"],"mappings":"AAGA,SAAQA,WAAW,QAAO,mBAAmB;AAC7C,SAAQC,EAAE,QAAO,kBAAkB;AACnC,SAAQC,OAAO,QAAO,eAAe;AAErC,OAAOC,kBAAkB,MAAM,kCAAkC;AAC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KAAK,MAAMsB,aAAa,IAAIC,MAAM,CAACC,IAAI,CAAC3B,SAAS,CAACG,oBAAoB,CAAC,EAAE;MACvE,IAAIO,IAAI,CAAC/D,UAAU,CAAC8E,aAAa,CAAC,IAAIf,IAAI,CAAC/D,UAAU,CAAC8E,aAAa,CAAC,CAACb,KAAK,EAAE;QAC1EY,oBAAoB,CAACC,aAAa,CAACG,WAAW,CAAC,CAAC,CAAC,GAAGlB,IAAI,CAAC/D,UAAU,CAAC8E,aAAa,CAAC,CAACb,KAAK;MAC1F;IACF;EACF;EAEA9E,IAAI,CAACa,UAAU,GAAG;IAChBC,SAAS,EAAE+D,gBAAgB;IAC3B9D,MAAM,EAAEnB,6BAA6B,CAACI,IAAI,EAAE+E,aAAa,EAAEgB,SAAS,CAAC;IACrE/E,OAAO,EAAEiE,cAAc;IACvBhE,QAAQ,EAAEiE,eAAe;IACzB,GAAGQ;EACL,CAAC;AACH"}
1
+ {"version":3,"file":"parse-3d-tile-point-cloud.js","names":["DracoLoader","parseFromContext","GL","Vector3","Tile3DFeatureTable","Tile3DBatchTable","parse3DTileHeaderSync","parse3DTileTablesHeaderSync","parse3DTileTablesSync","normalize3DTileColorAttribute","normalize3DTileNormalAttribute","normalize3DTilePositionAttribute","parsePointCloud3DTile","tile","arrayBuffer","byteOffset","options","context","initializeTile","featureTable","batchTable","parsePointCloudTables","parseDraco","parsePositions","parseColors","parseNormals","attributes","positions","colors","normals","batchIds","isQuantized","isTranslucent","isRGB565","isOctEncoded16P","featureTableJson","featureTableBinary","pointsLength","getGlobalProperty","Number","isFinite","Error","featuresLength","pointCount","rtcCenter","FLOAT","parseBatchIds","hasProperty","getPropertyArray","UNSIGNED_SHORT","quantizedRange","quantizedVolumeScale","quantizedVolumeOffset","UNSIGNED_BYTE","constantRGBA","batchFeatureLength","batchTableJson","batchTableBinary","dracoBuffer","dracoFeatureTableProperties","dracoBatchTableProperties","batchTableDraco","extensions","properties","featureTableDraco","getExtension","dracoByteOffset","dracoByteLength","byteLength","slice","hasPositions","POSITION","hasColors","RGB","RGBA","hasNormals","NORMAL","hasBatchIds","BATCH_ID","dracoData","buffer","featureTableProperties","batchTableProperties","dequantizeInShader","loadDraco","dracoOptions","draco","extraAttributes","data","decodedPositions","value","decodedColors","COLOR_0","decodedNormals","decodedBatchIds","isQuantizedDraco","quantization","isOctEncodedDraco","range","minValues","quantizationBits","octEncodedRange","batchTableAttributes","attributeName","Object","keys","toLowerCase","undefined"],"sources":["../../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"sourcesContent":["// This file is derived from the Cesium code base under Apache 2 license\n// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md\n\nimport {DracoLoader} from '@loaders.gl/draco';\nimport {LoaderContext, parseFromContext} from '@loaders.gl/loader-utils';\nimport {GL} from '@loaders.gl/math';\nimport {Vector3} from '@math.gl/core';\n\nimport Tile3DFeatureTable from '../classes/tile-3d-feature-table';\nimport Tile3DBatchTable from '../classes/tile-3d-batch-table';\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\nimport {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';\nimport {normalize3DTileColorAttribute} from './helpers/normalize-3d-tile-colors';\nimport {normalize3DTileNormalAttribute} from './helpers/normalize-3d-tile-normals';\nimport {normalize3DTilePositionAttribute} from './helpers/normalize-3d-tile-positions';\nimport {Tiles3DLoaderOptions} from '../../tiles-3d-loader';\nimport {Tiles3DTileContent} from '../../types';\n\nexport async function parsePointCloud3DTile(\n tile: Tiles3DTileContent,\n arrayBuffer: ArrayBuffer,\n byteOffset: number,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<number> {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);\n initializeTile(tile);\n\n const {featureTable, batchTable} = parsePointCloudTables(tile);\n\n await parseDraco(tile, featureTable, batchTable, options, context);\n\n parsePositions(tile, featureTable, options);\n // @ts-expect-error TODO - do we need to assert on the batch table?\n parseColors(tile, featureTable, batchTable);\n parseNormals(tile, featureTable);\n\n return byteOffset;\n}\n\nfunction initializeTile(tile: Tiles3DTileContent): void {\n // Initialize point cloud tile defaults\n tile.attributes = {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n tile.isQuantized = false;\n tile.isTranslucent = false;\n tile.isRGB565 = false;\n tile.isOctEncoded16P = false;\n}\n\nfunction parsePointCloudTables(tile: Tiles3DTileContent): {\n featureTable: Tile3DFeatureTable;\n batchTable: Tile3DBatchTable | null;\n} {\n const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);\n\n const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');\n if (!Number.isFinite(pointsLength)) {\n throw new Error('POINTS_LENGTH must be defined');\n }\n featureTable.featuresLength = pointsLength;\n\n tile.featuresLength = pointsLength;\n tile.pointsLength = pointsLength;\n tile.pointCount = pointsLength;\n\n tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);\n\n const batchTable = parseBatchIds(tile, featureTable);\n\n return {featureTable, batchTable};\n}\n\nfunction parsePositions(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n options: Tiles3DLoaderOptions | undefined\n): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n tile.isQuantized = true;\n tile.quantizedRange = (1 << 16) - 1;\n\n tile.quantizedVolumeScale = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_SCALE',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeScale) {\n throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');\n }\n\n tile.quantizedVolumeOffset = featureTable.getGlobalProperty(\n 'QUANTIZED_VOLUME_OFFSET',\n GL.FLOAT,\n 3\n );\n if (!tile.quantizedVolumeOffset) {\n throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');\n }\n\n tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n\nfunction parseColors(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n batchTable: Tile3DBatchTable\n): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.colors) {\n let colors = null;\n if (featureTable.hasProperty('RGBA')) {\n colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasProperty('RGB565')) {\n colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n\n tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);\n }\n\n if (featureTable.hasProperty('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n}\n\nfunction parseNormals(tile: Tiles3DTileContent, featureTable: Tile3DFeatureTable): void {\n tile.attributes = tile.attributes || {\n positions: null,\n colors: null,\n normals: null,\n batchIds: null\n };\n if (!tile.attributes.normals) {\n let normals = null;\n if (featureTable.hasProperty('NORMAL')) {\n normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('NORMAL_OCT16P')) {\n normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n\n tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);\n }\n}\n\nfunction parseBatchIds(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable\n): Tile3DBatchTable | null {\n let batchTable: Tile3DBatchTable | null = null;\n if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n\n if (tile.batchIds) {\n const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!batchFeatureLength) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n const {batchTableJson, batchTableBinary} = tile;\n batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);\n }\n }\n return batchTable;\n}\n\n// eslint-disable-next-line complexity\nasync function parseDraco(\n tile: Tiles3DTileContent,\n featureTable: Tile3DFeatureTable,\n batchTable,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n const batchTableDraco =\n tile.batchTableJson &&\n tile.batchTableJson.extensions &&\n tile.batchTableJson.extensions['3DTILES_draco_point_compression'];\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = (tile.featureTableBinary || []).slice(\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n\n tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);\n tile.hasColors =\n Number.isFinite(dracoFeatureTableProperties.RGB) ||\n Number.isFinite(dracoFeatureTableProperties.RGBA);\n tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);\n tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);\n tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);\n }\n\n if (!dracoBuffer) {\n return true;\n }\n\n const dracoData = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n return await loadDraco(tile, dracoData, options, context);\n}\n\n// eslint-disable-next-line complexity, max-statements\nexport async function loadDraco(\n tile: Tiles3DTileContent,\n dracoData,\n options?: Tiles3DLoaderOptions,\n context?: LoaderContext\n): Promise<void> {\n if (!context) {\n return;\n }\n const dracoOptions = {\n ...options,\n draco: {\n ...options?.draco,\n extraAttributes: dracoData.batchTableProperties || {}\n }\n };\n\n // The entire tileset might be included, too expensive to serialize\n delete dracoOptions['3d-tiles'];\n\n const data = await parseFromContext(dracoData.buffer, DracoLoader, dracoOptions, context);\n\n const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;\n const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;\n const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;\n const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;\n // @ts-expect-error\n const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;\n // @ts-expect-error\n const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n // @ts-expect-error This doesn't look right\n const quantization = data.POSITION.data.quantization;\n const range = quantization.range;\n tile.quantizedVolumeScale = new Vector3(range, range, range);\n tile.quantizedVolumeOffset = new Vector3(quantization.minValues);\n tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile.isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n // @ts-expect-error This doesn't look right\n tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile.isOctEncodedDraco = true;\n }\n\n // Extra batch table attributes\n const batchTableAttributes = {};\n if (dracoData.batchTableProperties) {\n for (const attributeName of Object.keys(dracoData.batchTableProperties)) {\n if (data.attributes[attributeName] && data.attributes[attributeName].value) {\n batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;\n }\n }\n }\n\n tile.attributes = {\n // @ts-expect-error\n positions: decodedPositions,\n // @ts-expect-error\n colors: normalize3DTileColorAttribute(tile, decodedColors, undefined),\n // @ts-expect-error\n normals: decodedNormals,\n // @ts-expect-error\n batchIds: decodedBatchIds,\n ...batchTableAttributes\n };\n}\n\n// TODO - this is the remaining code from Cesium's parser\n/*\n const batchTable = new Tile3DBatchTable(tile);\n\n // parseDracoBuffer(tile, featureTable, batchTable);\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n}\n/*\n\n if (!tile.attributes.positions) {\n if (featureTable.hasProperty('POSITION')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);\n } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {\n tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);\n\n\n if (!tile.colors) {\n if (featureTable.hasProperty('RGBA')) {\n tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);\n tile.isTranslucent = true;\n } else if (featureTable.hasProperty('RGB')) {\n tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);\n } else if (featureTable.hasPropertry('RGB565')) {\n tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);\n tile.isRGB565 = true;\n }\n }\n\n if (!tile.attributes.normals) {\n if (featureTable.getPropertry('NORMAL')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);\n } else if (featureTable.getProperty('NORMAL_OCT16P')) {\n tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);\n tile.isOctEncoded16P = true;\n }\n }\n\n if (!tile.batchIds) {\n if (featureTable.hasProperty('BATCH_ID')) {\n tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);\n }\n }\n\n if (!tile.attributes.positions) {\n throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');\n }\n\n if (featureTable.getPropertry('CONSTANT_RGBA')) {\n tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);\n }\n\n if (tile.batchIds) {\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n if (!defined(batchLength)) {\n throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');\n }\n\n if (defined(batchTableBinary)) {\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n batchTableBinary = new Uint8Array(batchTableBinary);\n }\n\n if (defined(pointCloud._batchTableLoaded)) {\n pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);\n }\n }\n\n // If points are not batched and there are per-point properties, use these properties for styling purposes\n var styleableProperties;\n if (!hasBatchIds && defined(batchTableBinary)) {\n tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(\n pointsLength,\n batchTableJson,\n batchTableBinary\n );\n }\n\n tile.draco = draco;\n}\n\n// Separate parsing and decoding of Draco\nexport function parseDracoBuffer(tile, featureTable, batchTable) {\n let dracoBuffer;\n let dracoFeatureTableProperties;\n let dracoBatchTableProperties;\n\n const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');\n if (batchTableDraco) {\n dracoBatchTableProperties = batchTableDraco.properties;\n }\n\n const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');\n if (featureTableDraco) {\n dracoFeatureTableProperties = featureTableDraco.properties;\n const dracoByteOffset = featureTableDraco.byteOffset;\n const dracoByteLength = featureTableDraco.byteLength;\n if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {\n throw new Error('Draco properties, byteOffset, and byteLength must be defined');\n }\n\n dracoBuffer = arraySlice(\n featureTableBinary,\n dracoByteOffset,\n dracoByteOffset + dracoByteLength\n );\n tile.hasPositions = dracoFeatureTableProperties.POSITION;\n tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;\n tile.hasNormals = dracoFeatureTableProperties.NORMAL;\n tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;\n tile.isTranslucent = dracoFeatureTableProperties.RGBA;\n }\n\n if (dracoBuffer) {\n tile.draco = {\n buffer: dracoBuffer,\n properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},\n featureTableProperties: dracoFeatureTableProperties,\n batchTableProperties: dracoBatchTableProperties,\n dequantizeInShader: false\n };\n\n tile.decodingState = DECODING_STATE.NEEDS_DECODE;\n }\n}\n\n/*\nfunction decodeDraco(tile, context) {\n if (tile.decodingState === DECODING_STATE.READY) {\n return false;\n }\n if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {\n var parsedContent = tile._parsedContent;\n var draco = parsedContent.draco;\n var decodePromise = DracoLoader.decodePointCloud(draco, context);\n if (defined(decodePromise)) {\n tile.decodingState = DECODING_STATE.DECODING;\n decodePromise.then(function(result) {\n tile.decodingState = DECODING_STATE.READY;\n var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;\n var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;\n var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;\n var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;\n var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;\n var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);\n var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);\n if (isQuantizedDraco) {\n // Draco quantization range == quantized volume scale - size in meters of the quantized volume\n // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc\n var quantization = result.POSITION.data.quantization;\n var range = quantization.range;\n tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);\n tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);\n tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;\n tile._isQuantizedDraco = true;\n }\n if (isOctEncodedDraco) {\n tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;\n tile._isOctEncodedDraco = true;\n }\n var styleableProperties = parsedContent.styleableProperties;\n var batchTableProperties = draco.batchTableProperties;\n for (var name in batchTableProperties) {\n if (batchTableProperties.hasOwnProperty(name)) {\n var property = result[name];\n if (!defined(styleableProperties)) {\n styleableProperties = {};\n }\n styleableProperties[name] = {\n typedArray : property.array,\n componentCount : property.data.componentsPerAttribute\n };\n }\n }\n parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);\n parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);\n parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);\n parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);\n parsedContent.styleableProperties = styleableProperties;\n }).otherwise(function(error) {\n tile.decodingState = DECODING_STATE.FAILED;\n tile._readyPromise.reject(error);\n });\n }\n }\n return true;\n}\n*/\n"],"mappings":"AAGA,SAAQA,WAAW,QAAO,mBAAmB;AAC7C,SAAuBC,gBAAgB,QAAO,0BAA0B;AACxE,SAAQC,EAAE,QAAO,kBAAkB;AACnC,SAAQC,OAAO,QAAO,eAAe;AAErC,OAAOC,kBAAkB,MAAM,kCAA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AAa,IAAIC,MAAM,CAACC,IAAI,CAAC1B,SAAS,CAACG,oBAAoB,CAAC,EAAE;MACvE,IAAIM,IAAI,CAAC9D,UAAU,CAAC6E,aAAa,CAAC,IAAIf,IAAI,CAAC9D,UAAU,CAAC6E,aAAa,CAAC,CAACb,KAAK,EAAE;QAC1EY,oBAAoB,CAACC,aAAa,CAACG,WAAW,CAAC,CAAC,CAAC,GAAGlB,IAAI,CAAC9D,UAAU,CAAC6E,aAAa,CAAC,CAACb,KAAK;MAC1F;IACF;EACF;EAEA7E,IAAI,CAACa,UAAU,GAAG;IAEhBC,SAAS,EAAE8D,gBAAgB;IAE3B7D,MAAM,EAAEnB,6BAA6B,CAACI,IAAI,EAAE8E,aAAa,EAAEgB,SAAS,CAAC;IAErE9E,OAAO,EAAEgE,cAAc;IAEvB/D,QAAQ,EAAEgE,eAAe;IACzB,GAAGQ;EACL,CAAC;AACH"}
@@ -1,2 +1,2 @@
1
- export const VERSION = typeof "4.0.0-alpha.20" !== 'undefined' ? "4.0.0-alpha.20" : 'latest';
1
+ export const VERSION = typeof "4.0.0-alpha.22" !== 'undefined' ? "4.0.0-alpha.22" : 'latest';
2
2
  //# sourceMappingURL=version.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  export { Tiles3DLoader } from './tiles-3d-loader';
2
2
  export { CesiumIonLoader } from './cesium-ion-loader';
3
3
  export { Tile3DSubtreeLoader } from './tile-3d-subtree-loader';
4
+ export type { Tiles3DArchiveFileLoaderOptions } from './3d-tiles-archive-loader';
5
+ export { Tiles3DArchiveFileLoader } from './3d-tiles-archive-loader';
6
+ export { Tiles3DArchiveFileSystem } from './lib/filesystems/tiles-3d-archive-file-system';
4
7
  export { Tile3DWriter } from './tile-3d-writer';
5
8
  export { default as Tile3DFeatureTable } from './lib/classes/tile-3d-feature-table';
6
9
  export { default as Tile3DBatchTable } from './lib/classes/tile-3d-batch-table';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRo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gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AAG9E,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,qBAAqB,IAAI,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAC9E,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EAClB,+BAA+B,EAC/B,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AACjB,YAAY,EAAC,oBAAoB,EAAC,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports._getIonTilesetMetadata = exports.TILE3D_TYPE = exports.Tile3DBatchTable = exports.Tile3DFeatureTable = exports.Tile3DWriter = exports.Tile3DSubtreeLoader = exports.CesiumIonLoader = exports.Tiles3DLoader = void 0;
6
+ exports._getIonTilesetMetadata = exports.TILE3D_TYPE = exports.Tile3DBatchTable = exports.Tile3DFeatureTable = exports.Tile3DWriter = exports.Tiles3DArchiveFileSystem = exports.Tiles3DArchiveFileLoader = exports.Tile3DSubtreeLoader = exports.CesiumIonLoader = exports.Tiles3DLoader = void 0;
7
7
  // LOADERS
8
8
  var tiles_3d_loader_1 = require("./tiles-3d-loader");
9
9
  Object.defineProperty(exports, "Tiles3DLoader", { enumerable: true, get: function () { return tiles_3d_loader_1.Tiles3DLoader; } });
@@ -11,6 +11,10 @@ var cesium_ion_loader_1 = require("./cesium-ion-loader");
11
11
  Object.defineProperty(exports, "CesiumIonLoader", { enumerable: true, get: function () { return cesium_ion_loader_1.CesiumIonLoader; } });
12
12
  var tile_3d_subtree_loader_1 = require("./tile-3d-subtree-loader");
13
13
  Object.defineProperty(exports, "Tile3DSubtreeLoader", { enumerable: true, get: function () { return tile_3d_subtree_loader_1.Tile3DSubtreeLoader; } });
14
+ var _3d_tiles_archive_loader_1 = require("./3d-tiles-archive-loader");
15
+ Object.defineProperty(exports, "Tiles3DArchiveFileLoader", { enumerable: true, get: function () { return _3d_tiles_archive_loader_1.Tiles3DArchiveFileLoader; } });
16
+ var tiles_3d_archive_file_system_1 = require("./lib/filesystems/tiles-3d-archive-file-system");
17
+ Object.defineProperty(exports, "Tiles3DArchiveFileSystem", { enumerable: true, get: function () { return tiles_3d_archive_file_system_1.Tiles3DArchiveFileSystem; } });
14
18
  // WRITERS
15
19
  var tile_3d_writer_1 = require("./tile-3d-writer");
16
20
  Object.defineProperty(exports, "Tile3DWriter", { enumerable: true, get: function () { return tile_3d_writer_1.Tile3DWriter; } });
@@ -0,0 +1,31 @@
1
+ import { FileProvider, ZipFileSystem, HashElement } from '@loaders.gl/zip';
2
+ /**
3
+ * FileSystem adapter for a 3tz (3D tiles archive format) file
4
+ * Holds FileProvider object that provides random access to archived files.
5
+ * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
6
+ * access speed to archived files
7
+ * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
8
+ */
9
+ export declare class Tiles3DArchiveFileSystem extends ZipFileSystem {
10
+ hashData?: HashElement[] | null;
11
+ /**
12
+ * Constructor
13
+ * @param file - instance of FileProvider or file path string
14
+ */
15
+ constructor(file: FileProvider | string);
16
+ /**
17
+ * Implementation of fetch against this file system.
18
+ * It tries to take `@3dtilesIndex1@` file from the archive and use it
19
+ * for faster access to archived files
20
+ * @param filename - name of a file
21
+ * @returns - Response with file data
22
+ */
23
+ fetch(filename: string): Promise<Response>;
24
+ /**
25
+ * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
26
+ * to files inside the archive
27
+ * @returns void
28
+ */
29
+ private parseHashFile;
30
+ }
31
+ //# sourceMappingURL=tiles-3d-archive-file-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiles-3d-archive-file-system.d.ts","sourceRoot":"","sources":["../../../src/lib/filesystems/tiles-3d-archive-file-system.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,aAAa,EAIb,WAAW,EAGZ,MAAM,iBAAiB,CAAC;AAGzB;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,aAAa;IACzD,QAAQ,CAAC,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAEhC;;;OAGG;gBACS,IAAI,EAAE,YAAY,GAAG,MAAM;IAIvC;;;;;;OAMG;IACG,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAiBhD;;;;OAIG;YACW,aAAa;CAqC5B"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tiles3DArchiveFileSystem = void 0;
4
+ const zip_1 = require("@loaders.gl/zip");
5
+ const _3d_tiles_archive_archive_1 = require("../../3d-tiles-archive/3d-tiles-archive-archive");
6
+ /**
7
+ * FileSystem adapter for a 3tz (3D tiles archive format) file
8
+ * Holds FileProvider object that provides random access to archived files.
9
+ * The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
10
+ * access speed to archived files
11
+ * @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
12
+ */
13
+ class Tiles3DArchiveFileSystem extends zip_1.ZipFileSystem {
14
+ /**
15
+ * Constructor
16
+ * @param file - instance of FileProvider or file path string
17
+ */
18
+ constructor(file) {
19
+ super(file);
20
+ }
21
+ /**
22
+ * Implementation of fetch against this file system.
23
+ * It tries to take `@3dtilesIndex1@` file from the archive and use it
24
+ * for faster access to archived files
25
+ * @param filename - name of a file
26
+ * @returns - Response with file data
27
+ */
28
+ async fetch(filename) {
29
+ const fileProvider = await this.fileProvider;
30
+ if (!fileProvider) {
31
+ throw new Error('No data detected in the zip archive');
32
+ }
33
+ await this.parseHashFile();
34
+ if (this.hashData) {
35
+ const archive = new _3d_tiles_archive_archive_1.Tiles3DArchive(fileProvider, this.hashData);
36
+ const fileData = await archive.getFile(filename);
37
+ const response = new Response(fileData);
38
+ Object.defineProperty(response, 'url', { value: `${this.fileName || ''}/${filename}` });
39
+ return response;
40
+ }
41
+ return super.fetch(filename);
42
+ }
43
+ /**
44
+ * Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
45
+ * to files inside the archive
46
+ * @returns void
47
+ */
48
+ async parseHashFile() {
49
+ if (this.hashData !== undefined) {
50
+ return;
51
+ }
52
+ const fileProvider = await this.fileProvider;
53
+ if (!fileProvider) {
54
+ throw new Error('No data detected in the zip archive');
55
+ }
56
+ const hashCDOffset = await (0, zip_1.searchFromTheEnd)(fileProvider, zip_1.cdSignature);
57
+ const cdFileHeader = await (0, zip_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
58
+ // '@3dtilesIndex1@' is index file that must be the last in the archive. It allows
59
+ // to improve load and read performance when the archive contains a very large number
60
+ // of files.
61
+ if (cdFileHeader?.fileName === '@3dtilesIndex1@') {
62
+ const localFileHeader = await (0, zip_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
63
+ if (!localFileHeader) {
64
+ throw new Error('corrupted 3tz');
65
+ }
66
+ const fileDataOffset = localFileHeader.fileDataOffset;
67
+ const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
68
+ this.hashData = (0, zip_1.parseHashFile)(hashFile);
69
+ }
70
+ else {
71
+ this.hashData = null;
72
+ }
73
+ }
74
+ }
75
+ exports.Tiles3DArchiveFileSystem = Tiles3DArchiveFileSystem;
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf-view.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,aAAa,EAAmB,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,UAqC1C;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
1
+ {"version":3,"file":"parse-3d-tile-gltf-view.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,aAAa,EAAqC,MAAM,0BAA0B,CAAC;AAC3F,OAAO,EAAC,kBAAkB,EAAC,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAE9D,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,UAqC1C;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CA8Bf"}
@@ -55,15 +55,15 @@ async function extractGLTF(tile, gltfFormat, options, context) {
55
55
  if (!context) {
56
56
  return;
57
57
  }
58
- const { parse, fetch } = context;
59
58
  if (tile.gltfUrl) {
59
+ const { fetch } = context;
60
60
  const response = await fetch(tile.gltfUrl, options);
61
61
  tile.gltfArrayBuffer = await response.arrayBuffer();
62
62
  tile.gltfByteOffset = 0;
63
63
  }
64
64
  if (tile.gltfArrayBuffer) {
65
65
  // TODO - Should handle byteOffset... However, not used now...
66
- const gltfWithBuffers = await parse(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
66
+ const gltfWithBuffers = await (0, loader_utils_1.parseFromContext)(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
67
67
  tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
68
68
  tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
69
69
  delete tile.gltfArrayBuffer;
@@ -1,4 +1,4 @@
1
- import type { LoaderContext } from '@loaders.gl/loader-utils';
1
+ import { LoaderContext } from '@loaders.gl/loader-utils';
2
2
  import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
3
  import { Tiles3DTileContent } from '../../types';
4
4
  export declare function parseGltf3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;