@loaders.gl/3d-tiles 4.0.0-alpha.6 → 4.0.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/dist.min.js +1778 -1499
  2. package/dist/es5/index.js.map +1 -1
  3. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +4 -3
  4. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  5. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  6. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  7. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  8. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +33 -19
  9. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  10. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  11. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  12. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +12 -12
  13. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  14. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +5 -5
  16. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  17. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +23 -6
  18. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  19. package/dist/es5/lib/parsers/parse-3d-tile-header.js +98 -80
  20. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  21. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
  22. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  23. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +29 -5
  24. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  25. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  26. package/dist/es5/lib/utils/version.js +1 -1
  27. package/dist/es5/tiles-3d-loader.js +61 -62
  28. package/dist/es5/tiles-3d-loader.js.map +1 -1
  29. package/dist/es5/types.js.map +1 -1
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
  32. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  33. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  34. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  35. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
  36. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +19 -11
  37. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  38. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  39. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
  40. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
  41. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  42. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  43. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +1 -1
  44. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  45. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +16 -6
  46. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
  47. package/dist/esm/lib/parsers/parse-3d-tile-header.js +62 -45
  48. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  49. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
  50. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  51. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +23 -2
  52. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  53. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  54. package/dist/esm/lib/utils/version.js +1 -1
  55. package/dist/esm/tiles-3d-loader.js +32 -28
  56. package/dist/esm/tiles-3d-loader.js.map +1 -1
  57. package/dist/esm/types.js.map +1 -1
  58. package/dist/index.d.ts +2 -1
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +4 -2
  61. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
  62. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
  63. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +3 -2
  64. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
  65. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
  66. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  67. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +5 -2
  68. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  69. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +18 -10
  70. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
  71. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -1
  72. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -1
  73. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +4 -2
  74. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -1
  75. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
  76. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +4 -1
  77. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
  78. package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
  79. package/dist/lib/parsers/parse-3d-tile-composite.d.ts +7 -1
  80. package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
  81. package/dist/lib/parsers/parse-3d-tile-composite.js +1 -3
  82. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +4 -1
  83. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  84. package/dist/lib/parsers/parse-3d-tile-gltf.js +13 -3
  85. package/dist/lib/parsers/parse-3d-tile-header.d.ts +6 -6
  86. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  87. package/dist/lib/parsers/parse-3d-tile-header.js +57 -42
  88. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +4 -1
  89. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
  90. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +11 -25
  91. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +5 -2
  92. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  93. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +24 -2
  94. package/dist/lib/parsers/parse-3d-tile.d.ts +4 -1
  95. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
  96. package/dist/lib/parsers/parse-3d-tile.js +0 -4
  97. package/dist/tiles-3d-loader.d.ts +15 -1
  98. package/dist/tiles-3d-loader.d.ts.map +1 -1
  99. package/dist/tiles-3d-loader.js +35 -32
  100. package/dist/types.d.ts +257 -15
  101. package/dist/types.d.ts.map +1 -1
  102. package/package.json +8 -8
  103. package/src/index.ts +12 -1
  104. package/src/lib/parsers/helpers/normalize-3d-tile-colors.ts +10 -4
  105. package/src/lib/parsers/helpers/normalize-3d-tile-normals.ts +7 -3
  106. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +4 -4
  107. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +39 -15
  108. package/src/lib/parsers/helpers/parse-3d-tile-header.ts +7 -1
  109. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +1 -1
  110. package/src/lib/parsers/helpers/parse-3d-tile-tables.ts +32 -11
  111. package/src/lib/parsers/parse-3d-tile-batched-model.ts +18 -3
  112. package/src/lib/parsers/parse-3d-tile-composite.ts +20 -8
  113. package/src/lib/parsers/parse-3d-tile-gltf.ts +22 -5
  114. package/src/lib/parsers/parse-3d-tile-header.ts +86 -53
  115. package/src/lib/parsers/parse-3d-tile-instanced-model.ts +35 -30
  116. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +71 -12
  117. package/src/lib/parsers/parse-3d-tile.ts +10 -5
  118. package/src/tiles-3d-loader.ts +68 -38
  119. package/src/types.ts +269 -15
@@ -56,17 +56,17 @@ function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {
56
56
  }
57
57
  exports.parse3DTileTablesSync = parse3DTileTablesSync;
58
58
  function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
59
- const { featureTableJsonByteLength, featureTableBinaryByteLength, batchLength } = tile.header;
59
+ const { featureTableJsonByteLength, featureTableBinaryByteLength, batchLength } = tile.header || {};
60
60
  tile.featureTableJson = {
61
61
  BATCH_LENGTH: batchLength || 0
62
62
  };
63
- if (featureTableJsonByteLength > 0) {
63
+ if (featureTableJsonByteLength && featureTableJsonByteLength > 0) {
64
64
  const featureTableString = (0, parse_utils_1.getStringFromArrayBuffer)(arrayBuffer, byteOffset, featureTableJsonByteLength);
65
65
  tile.featureTableJson = JSON.parse(featureTableString);
66
66
  }
67
- byteOffset += featureTableJsonByteLength;
67
+ byteOffset += featureTableJsonByteLength || 0;
68
68
  tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
69
- byteOffset += featureTableBinaryByteLength;
69
+ byteOffset += featureTableBinaryByteLength || 0;
70
70
  /*
71
71
  const featureTable = parseFeatureTable(featureTableJson, featureTableBinary);
72
72
 
@@ -76,12 +76,12 @@ function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
76
76
  return byteOffset;
77
77
  }
78
78
  function parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {
79
- const { batchTableJsonByteLength, batchTableBinaryByteLength } = tile.header;
80
- if (batchTableJsonByteLength > 0) {
79
+ const { batchTableJsonByteLength, batchTableBinaryByteLength } = tile.header || {};
80
+ if (batchTableJsonByteLength && batchTableJsonByteLength > 0) {
81
81
  const batchTableString = (0, parse_utils_1.getStringFromArrayBuffer)(arrayBuffer, byteOffset, batchTableJsonByteLength);
82
82
  tile.batchTableJson = JSON.parse(batchTableString);
83
83
  byteOffset += batchTableJsonByteLength;
84
- if (batchTableBinaryByteLength > 0) {
84
+ if (batchTableBinaryByteLength && batchTableBinaryByteLength > 0) {
85
85
  // Has a batch table binary
86
86
  tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);
87
87
  // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
@@ -1,2 +1,5 @@
1
- export declare function parseBatchedModel3DTile(tile: any, arrayBuffer: any, byteOffset: any, options: any, context: any): Promise<any>;
1
+ import { Tiles3DTileContent } from '../../types';
2
+ import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
+ import { LoaderContext } from '@loaders.gl/loader-utils';
4
+ export declare function parseBatchedModel3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
2
5
  //# sourceMappingURL=parse-3d-tile-batched-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-batched-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-batched-model.ts"],"names":[],"mappings":"AAWA,wBAAsB,uBAAuB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,gBAU5F"}
1
+ {"version":3,"file":"parse-3d-tile-batched-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-batched-model.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,mBAWxB"}
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.parseBatchedModel3DTile = void 0;
9
9
  const math_1 = require("@loaders.gl/math"); // math.gl/geometry;
10
10
  const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
11
- // import Tile3DBatchTable from '../classes/tile-3d-batch-table.js';
11
+ // import Tile3DBatchTable from '../classes/tile-3d-batch-table';
12
12
  const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
13
13
  const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
14
14
  const parse_3d_tile_gltf_view_1 = require("./helpers/parse-3d-tile-gltf-view");
@@ -1,2 +1,8 @@
1
- export declare function parseComposite3DTile(tile: any, arrayBuffer: any, byteOffset: any, options: any, context: any, parse3DTile: any): Promise<any>;
1
+ import type { LoaderContext } from '@loaders.gl/loader-utils';
2
+ import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
+ import { Tiles3DTileContent } from '../../types';
4
+ /** Resolve circulate dependency by passing in parsing function as argument */
5
+ type Parse3DTile = (arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, subtile: any) => Promise<number>;
6
+ export declare function parseComposite3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, parse3DTile: Parse3DTile): Promise<number>;
7
+ export {};
2
8
  //# sourceMappingURL=parse-3d-tile-composite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AASA,wBAAsB,oBAAoB,CACxC,IAAI,KAAA,EACJ,WAAW,KAAA,EACX,UAAU,KAAA,EACV,OAAO,KAAA,EACP,OAAO,KAAA,EACP,WAAW,KAAA,gBAoBZ"}
1
+ {"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,8EAA8E;AAC9E,KAAK,WAAW,GAAG,CACjB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,OAAO,KAAA,KACJ,OAAO,CAAC,MAAM,CAAC,CAAC;AAGrB,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
@@ -3,8 +3,6 @@
3
3
  // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.parseComposite3DTile = void 0;
6
- // Reference code:
7
- // https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Composite3DTileContent.js#L182
8
6
  const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
9
7
  // eslint-disable-next-line max-params
10
8
  async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile) {
@@ -15,7 +13,7 @@ async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, cont
15
13
  byteOffset += 4;
16
14
  // extract each tile from the byte stream
17
15
  tile.tiles = [];
18
- while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {
16
+ while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
19
17
  const subtile = {};
20
18
  tile.tiles.push(subtile);
21
19
  byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);
@@ -1,2 +1,5 @@
1
- export declare function parseGltf3DTile(tile: any, arrayBuffer: any, options: any, context: any): Promise<void>;
1
+ import type { LoaderContext } from '@loaders.gl/loader-utils';
2
+ import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
+ import { Tiles3DTileContent } from '../../types';
4
+ export declare function parseGltf3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
2
5
  //# sourceMappingURL=parse-3d-tile-gltf.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAEA,wBAAsB,eAAe,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,iBAaxE"}
1
+ {"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAsBf"}
@@ -9,10 +9,20 @@ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
9
9
  tile.rotateYtoZ = true;
10
10
  // Save gltf up axis
11
11
  tile.gltfUpAxis =
12
- options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
12
+ options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
13
13
  ? options['3d-tiles'].assetGltfUpAxis
14
14
  : 'Y';
15
- const { parse } = context;
16
- tile.gltf = await parse(arrayBuffer, gltf_1.GLTFLoader, options, context);
15
+ if (options?.['3d-tiles']?.loadGLTF) {
16
+ if (!context) {
17
+ return;
18
+ }
19
+ const { parse } = context;
20
+ const gltfWithBuffers = await parse(arrayBuffer, gltf_1.GLTFLoader, options, context);
21
+ tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
22
+ tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
23
+ }
24
+ else {
25
+ tile.gltfArrayBuffer = arrayBuffer;
26
+ }
17
27
  }
18
28
  exports.parseGltf3DTile = parseGltf3DTile;
@@ -1,14 +1,14 @@
1
+ import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
1
2
  import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
- import { Tileset3D, Tile3D } from '@loaders.gl/tiles';
3
- import { ImplicitTilingExtension, Subtree } from '../../types';
4
- export declare function normalizeTileData(tile: any, options: any): any;
5
- export declare function normalizeTileHeaders(tileset: Tileset3D, options: LoaderOptions): Promise<Tileset3D>;
3
+ import { ImplicitTilingExensionData, Subtree, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from '../../types';
4
+ export declare function normalizeTileData(tile: Tiles3DTileJSON | null, basePath: string): Tiles3DTileJSONPostprocessed | null;
5
+ export declare function normalizeTileHeaders(tileset: Tiles3DTilesetJSON, basePath: string, options: LoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
6
6
  /**
7
7
  * Do normalisation of implicit tile headers
8
8
  * TODO Check if Tile3D class can be a return type here.
9
9
  * @param tileset
10
10
  */
11
- export declare function normalizeImplicitTileHeaders(tile: Tile3D, tileset: Tileset3D, implicitTilingExtension: ImplicitTilingExtension, options: LoaderOptions): Promise<any>;
11
+ export declare function normalizeImplicitTileHeaders(tile: Tiles3DTileJSON, tileset: Tiles3DTilesetJSON, basePath: string, implicitTilingExtension: ImplicitTilingExensionData, options: Tiles3DLoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
12
12
  /**
13
13
  * Do implicit data normalisation to create hierarchical tile structure
14
14
  * @param tile
@@ -16,5 +16,5 @@ export declare function normalizeImplicitTileHeaders(tile: Tile3D, tileset: Tile
16
16
  * @param options
17
17
  * @returns
18
18
  */
19
- export declare function normalizeImplicitTileData(tile: any, rootSubtree: Subtree, options: any): Promise<any>;
19
+ export declare function normalizeImplicitTileData(tile: Tiles3DTileJSON, basePath: string, rootSubtree: Subtree, options: any): Promise<Tiles3DTileJSONPostprocessed | null>;
20
20
  //# sourceMappingURL=parse-3d-tile-header.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAC,SAAS,EAA+C,MAAM,EAAC,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAAC,uBAAuB,EAAE,OAAO,EAAC,MAAM,aAAa,CAAC;AAqD7D,wBAAgB,iBAAiB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,OAgB9C;AAGD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,SAAS,CAAC,CAwCpB;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,EAClB,uBAAuB,EAAE,uBAAuB,EAChD,OAAO,EAAE,aAAa,gBA2CvB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,KAAA,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,gBA0BvF"}
1
+ {"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAI5D,OAAO,EACL,0BAA0B,EAC1B,OAAO,EAEP,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAqDrB,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,QAAQ,EAAE,MAAM,GACf,4BAA4B,GAAG,IAAI,CAqBrC;AAGD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA+C9C;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,0BAA0B,EACnD,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAyC9C;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA8B9C"}
@@ -6,11 +6,11 @@ const core_1 = require("@loaders.gl/core");
6
6
  const tiles_1 = require("@loaders.gl/tiles");
7
7
  const parse_3d_implicit_tiles_1 = require("./helpers/parse-3d-implicit-tiles");
8
8
  const s2_corners_to_obb_1 = require("../utils/obb/s2-corners-to-obb");
9
- function getTileType(tile) {
10
- if (!tile.contentUrl) {
9
+ function getTileType(tile, tileContentUrl = '') {
10
+ if (!tileContentUrl) {
11
11
  return tiles_1.TILE_TYPE.EMPTY;
12
12
  }
13
- const contentUrl = tile.contentUrl;
13
+ const contentUrl = tileContentUrl.split('?')[0]; // Discard query string
14
14
  const fileExtension = contentUrl.split('.').pop();
15
15
  switch (fileExtension) {
16
16
  case 'pnts':
@@ -21,7 +21,7 @@ function getTileType(tile) {
21
21
  case 'gltf':
22
22
  return tiles_1.TILE_TYPE.SCENEGRAPH;
23
23
  default:
24
- return fileExtension;
24
+ return fileExtension || tiles_1.TILE_TYPE.EMPTY;
25
25
  }
26
26
  }
27
27
  function getRefine(refine) {
@@ -36,7 +36,7 @@ function getRefine(refine) {
36
36
  return refine;
37
37
  }
38
38
  }
39
- function resolveUri(uri, basePath) {
39
+ function resolveUri(uri = '', basePath) {
40
40
  // url scheme per RFC3986
41
41
  const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;
42
42
  if (urlSchemeRegex.test(basePath)) {
@@ -48,49 +48,59 @@ function resolveUri(uri, basePath) {
48
48
  }
49
49
  return `${basePath}/${uri}`;
50
50
  }
51
- function normalizeTileData(tile, options) {
51
+ function normalizeTileData(tile, basePath) {
52
52
  if (!tile) {
53
53
  return null;
54
54
  }
55
+ let tileContentUrl;
55
56
  if (tile.content) {
56
- const contentUri = tile.content.uri || tile.content.url;
57
- tile.contentUrl = resolveUri(contentUri, options.basePath);
57
+ const contentUri = tile.content.uri || tile.content?.url;
58
+ tileContentUrl = resolveUri(contentUri, basePath);
58
59
  }
59
- tile.id = tile.contentUrl;
60
- tile.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
61
- tile.lodMetricValue = tile.geometricError;
62
- tile.transformMatrix = tile.transform;
63
- tile.type = getTileType(tile);
64
- tile.refine = getRefine(tile.refine);
65
- return tile;
60
+ const tilePostprocessed = {
61
+ ...tile,
62
+ id: tileContentUrl,
63
+ contentUrl: tileContentUrl,
64
+ lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
65
+ lodMetricValue: tile.geometricError,
66
+ transformMatrix: tile.transform,
67
+ type: getTileType(tile, tileContentUrl),
68
+ refine: getRefine(tile.refine)
69
+ };
70
+ return tilePostprocessed;
66
71
  }
67
72
  exports.normalizeTileData = normalizeTileData;
68
73
  // normalize tile headers
69
- async function normalizeTileHeaders(tileset, options) {
70
- const basePath = tileset.basePath;
71
- let root;
72
- const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset?.root);
74
+ async function normalizeTileHeaders(tileset, basePath, options) {
75
+ let root = null;
76
+ const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);
73
77
  if (rootImplicitTilingExtension && tileset.root) {
74
- root = await normalizeImplicitTileHeaders(tileset.root, tileset, rootImplicitTilingExtension, options);
78
+ root = await normalizeImplicitTileHeaders(tileset.root, tileset, basePath, rootImplicitTilingExtension, options);
75
79
  }
76
80
  else {
77
- root = normalizeTileData(tileset.root, tileset);
81
+ root = normalizeTileData(tileset.root, basePath);
78
82
  }
79
83
  const stack = [];
80
84
  stack.push(root);
81
85
  while (stack.length > 0) {
82
86
  const tile = stack.pop() || {};
83
87
  const children = tile.children || [];
84
- for (let childHeader of children) {
88
+ const childrenPostprocessed = [];
89
+ for (const childHeader of children) {
85
90
  const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);
91
+ let childHeaderPostprocessed;
86
92
  if (childImplicitTilingExtension) {
87
- childHeader = await normalizeImplicitTileHeaders(childHeader, tileset, childImplicitTilingExtension, options);
93
+ childHeaderPostprocessed = await normalizeImplicitTileHeaders(childHeader, tileset, basePath, childImplicitTilingExtension, options);
88
94
  }
89
95
  else {
90
- normalizeTileData(childHeader, { basePath });
96
+ childHeaderPostprocessed = normalizeTileData(childHeader, basePath);
97
+ }
98
+ if (childHeaderPostprocessed) {
99
+ childrenPostprocessed.push(childHeaderPostprocessed);
100
+ stack.push(childHeaderPostprocessed);
91
101
  }
92
- stack.push(childHeader);
93
102
  }
103
+ tile.children = childrenPostprocessed;
94
104
  }
95
105
  return root;
96
106
  }
@@ -100,13 +110,12 @@ exports.normalizeTileHeaders = normalizeTileHeaders;
100
110
  * TODO Check if Tile3D class can be a return type here.
101
111
  * @param tileset
102
112
  */
103
- async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtension, options) {
104
- const basePath = tileset.basePath;
113
+ async function normalizeImplicitTileHeaders(tile, tileset, basePath, implicitTilingExtension, options) {
105
114
  const { subdivisionScheme, maximumLevel, subtreeLevels, subtrees: { uri: subtreesUriTemplate } } = implicitTilingExtension;
106
115
  const replacedUrlTemplate = (0, parse_3d_implicit_tiles_1.replaceContentUrlTemplate)(subtreesUriTemplate, 0, 0, 0, 0);
107
116
  const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);
108
117
  const subtree = await (0, core_1.load)(subtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader, options);
109
- const contentUrlTemplate = resolveUri(tile.content.uri, basePath);
118
+ const contentUrlTemplate = resolveUri(tile.content?.uri, basePath);
110
119
  const refine = tileset?.root?.refine;
111
120
  // @ts-ignore
112
121
  const rootLodMetricValue = tile.geometricError;
@@ -132,7 +141,7 @@ async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtensi
132
141
  getTileType,
133
142
  getRefine
134
143
  };
135
- return await normalizeImplicitTileData(tile, subtree, implicitOptions);
144
+ return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions);
136
145
  }
137
146
  exports.normalizeImplicitTileHeaders = normalizeImplicitTileHeaders;
138
147
  /**
@@ -142,27 +151,33 @@ exports.normalizeImplicitTileHeaders = normalizeImplicitTileHeaders;
142
151
  * @param options
143
152
  * @returns
144
153
  */
145
- async function normalizeImplicitTileData(tile, rootSubtree, options) {
154
+ async function normalizeImplicitTileData(tile, basePath, rootSubtree, options) {
146
155
  if (!tile) {
147
156
  return null;
148
157
  }
149
- tile.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
150
- tile.lodMetricValue = tile.geometricError;
151
- tile.transformMatrix = tile.transform;
152
158
  const { children, contentUrl } = await (0, parse_3d_implicit_tiles_1.parseImplicitTiles)({
153
159
  subtree: rootSubtree,
154
- options,
155
- s2VolumeBox: tile
160
+ options
156
161
  });
162
+ let tileContentUrl;
163
+ let tileContent = null;
157
164
  if (contentUrl) {
158
- tile.contentUrl = contentUrl;
159
- tile.content = { uri: contentUrl.replace(`${options.basePath}/`, '') };
165
+ tileContentUrl = contentUrl;
166
+ tileContent = { uri: contentUrl.replace(`${basePath}/`, '') };
160
167
  }
161
- tile.refine = getRefine(tile.refine);
162
- tile.type = getTileType(tile);
163
- tile.children = children;
164
- tile.id = tile.contentUrl;
165
- return tile;
168
+ const tilePostprocessed = {
169
+ ...tile,
170
+ id: tileContentUrl,
171
+ contentUrl: tileContentUrl,
172
+ lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
173
+ lodMetricValue: tile.geometricError,
174
+ transformMatrix: tile.transform,
175
+ type: getTileType(tile, tileContentUrl),
176
+ refine: getRefine(tile.refine),
177
+ content: tileContent || tile.content,
178
+ children
179
+ };
180
+ return tilePostprocessed;
166
181
  }
167
182
  exports.normalizeImplicitTileData = normalizeImplicitTileData;
168
183
  /**
@@ -1,2 +1,5 @@
1
- export declare function parseInstancedModel3DTile(tile: any, arrayBuffer: any, byteOffset: any, options: any, context: any): Promise<any>;
1
+ import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
2
+ import { LoaderContext } from '@loaders.gl/loader-utils';
3
+ import { Tiles3DTileContent } from '../../types';
4
+ export declare function parseInstancedModel3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
2
5
  //# sourceMappingURL=parse-3d-tile-instanced-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-instanced-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-instanced-model.ts"],"names":[],"mappings":"AAaA,wBAAsB,yBAAyB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,gBAI9F"}
1
+ {"version":3,"file":"parse-3d-tile-instanced-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-instanced-model.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAIjB"}
@@ -16,7 +16,7 @@ const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
16
16
  const parse_3d_tile_gltf_view_1 = require("./helpers/parse-3d-tile-gltf-view");
17
17
  async function parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
18
18
  byteOffset = parseInstancedModel(tile, arrayBuffer, byteOffset, options, context);
19
- await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, tile.gltfFormat, options, context);
19
+ await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, tile.gltfFormat || 0, options, context);
20
20
  return byteOffset;
21
21
  }
22
22
  exports.parseInstancedModel3DTile = parseInstancedModel3DTile;
@@ -33,7 +33,7 @@ function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
33
33
  byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
34
34
  byteOffset = (0, parse_3d_tile_gltf_view_1.parse3DTileGLTFViewSync)(tile, arrayBuffer, byteOffset, options);
35
35
  // TODO - Is the feature table sometimes optional or can check be moved into table header parser?
36
- if (tile.featureTableJsonByteLength === 0) {
36
+ if (!tile?.header?.featureTableJsonByteLength || tile.header.featureTableJsonByteLength === 0) {
37
37
  throw new Error('i3dm parser: featureTableJsonByteLength is zero.');
38
38
  }
39
39
  const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
@@ -50,21 +50,7 @@ function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
50
50
  }
51
51
  // eslint-disable-next-line max-statements, complexity
52
52
  function extractInstancedAttributes(tile, featureTable, batchTable, instancesLength) {
53
- // Create model instance collection
54
- const collectionOptions = {
55
- instances: new Array(instancesLength),
56
- batchTable: tile._batchTable,
57
- cull: false,
58
- url: undefined,
59
- // requestType: RequestType.TILES3D,
60
- gltf: undefined,
61
- basePath: undefined,
62
- incrementallyLoadTextures: false,
63
- // TODO - tileset is not available at this stage, tile is parsed independently
64
- // upAxis: (tileset && tileset._gltfUpAxis) || [0, 1, 0],
65
- forwardAxis: [1, 0, 0]
66
- };
67
- const instances = collectionOptions.instances;
53
+ const instances = new Array(instancesLength);
68
54
  const instancePosition = new core_1.Vector3();
69
55
  const instanceNormalRight = new core_1.Vector3();
70
56
  const instanceNormalUp = new core_1.Vector3();
@@ -76,8 +62,8 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
76
62
  const instanceTransform = new core_1.Matrix4();
77
63
  const scratch1 = [];
78
64
  const scratch2 = [];
79
- const scratchVector1 = new core_1.Vector3();
80
- const scratchVector2 = new core_1.Vector3();
65
+ const scratch3 = [];
66
+ const scratch4 = [];
81
67
  for (let i = 0; i < instancesLength; i++) {
82
68
  let position;
83
69
  // Get the instance position
@@ -86,11 +72,11 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
86
72
  }
87
73
  else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
88
74
  position = featureTable.getProperty('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3, i, instancePosition);
89
- const quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3, scratchVector1);
75
+ const quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
90
76
  if (!quantizedVolumeOffset) {
91
77
  throw new Error('i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
92
78
  }
93
- const quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3, scratchVector2);
79
+ const quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
94
80
  if (!quantizedVolumeScale) {
95
81
  throw new Error('i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
96
82
  }
@@ -119,8 +105,8 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
119
105
  tile.hasCustomOrientation = true;
120
106
  }
121
107
  else {
122
- tile.octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, scratch1);
123
- tile.octNormalRight = featureTable.getProperty('NORMAL_RIGHT_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, scratch2);
108
+ tile.octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch1);
109
+ tile.octNormalRight = featureTable.getProperty('NORMAL_RIGHT_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch2);
124
110
  if (tile.octNormalUp) {
125
111
  if (!tile.octNormalRight) {
126
112
  throw new Error('i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P');
@@ -151,7 +137,7 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
151
137
  instanceTranslationRotationScale.rotation = instanceQuaternion;
152
138
  // Get the instance scale
153
139
  instanceScale.set(1.0, 1.0, 1.0);
154
- const scale = featureTable.getProperty('SCALE', math_1.GL.FLOAT, 1, i);
140
+ const scale = featureTable.getProperty('SCALE', math_1.GL.FLOAT, 1, i, scratch3);
155
141
  if (Number.isFinite(scale)) {
156
142
  instanceScale.multiplyByScalar(scale);
157
143
  }
@@ -162,7 +148,7 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
162
148
  // @ts-expect-error
163
149
  instanceTranslationRotationScale.scale = instanceScale;
164
150
  // Get the batchId
165
- let batchId = featureTable.getProperty('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1, i);
151
+ let batchId = featureTable.getProperty('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1, i, scratch4);
166
152
  if (batchId === undefined) {
167
153
  // If BATCH_ID semantic is undefined, batchId is just the instance number
168
154
  batchId = i;
@@ -1,3 +1,6 @@
1
- export declare function parsePointCloud3DTile(tile: any, arrayBuffer: any, byteOffset: any, options: any, context: any): Promise<any>;
2
- export declare function loadDraco(tile: any, dracoData: any, options: any, context: any): Promise<void>;
1
+ import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
2
+ import { LoaderContext } from '@loaders.gl/loader-utils';
3
+ import { Tiles3DTileContent } from '../../types';
4
+ export declare function parsePointCloud3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
5
+ export declare function loadDraco(tile: Tiles3DTileContent, dracoData: any, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
3
6
  //# sourceMappingURL=parse-3d-tile-point-cloud.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAeA,wBAAsB,qBAAqB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,gBAe1F;AA8KD,wBAAsB,SAAS,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,iBAqDhE"}
1
+ {"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAuND,wBAAsB,SAAS,CAC7B,IAAI,EAAE,kBAAkB,EACxB,SAAS,KAAA,EACT,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
@@ -24,6 +24,7 @@ async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, con
24
24
  const { featureTable, batchTable } = parsePointCloudTables(tile);
25
25
  await parseDraco(tile, featureTable, batchTable, options, context);
26
26
  parsePositions(tile, featureTable, options);
27
+ // @ts-expect-error TODO - do we need to assert on the batch table?
27
28
  parseColors(tile, featureTable, batchTable);
28
29
  parseNormals(tile, featureTable);
29
30
  return byteOffset;
@@ -57,6 +58,12 @@ function parsePointCloudTables(tile) {
57
58
  return { featureTable, batchTable };
58
59
  }
59
60
  function parsePositions(tile, featureTable, options) {
61
+ tile.attributes = tile.attributes || {
62
+ positions: null,
63
+ colors: null,
64
+ normals: null,
65
+ batchIds: null
66
+ };
60
67
  if (!tile.attributes.positions) {
61
68
  if (featureTable.hasProperty('POSITION')) {
62
69
  tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
@@ -81,6 +88,12 @@ function parsePositions(tile, featureTable, options) {
81
88
  }
82
89
  }
83
90
  function parseColors(tile, featureTable, batchTable) {
91
+ tile.attributes = tile.attributes || {
92
+ positions: null,
93
+ colors: null,
94
+ normals: null,
95
+ batchIds: null
96
+ };
84
97
  if (!tile.attributes.colors) {
85
98
  let colors = null;
86
99
  if (featureTable.hasProperty('RGBA')) {
@@ -101,6 +114,12 @@ function parseColors(tile, featureTable, batchTable) {
101
114
  }
102
115
  }
103
116
  function parseNormals(tile, featureTable) {
117
+ tile.attributes = tile.attributes || {
118
+ positions: null,
119
+ colors: null,
120
+ normals: null,
121
+ batchIds: null
122
+ };
104
123
  if (!tile.attributes.normals) {
105
124
  let normals = null;
106
125
  if (featureTable.hasProperty('NORMAL')) {
@@ -147,7 +166,7 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
147
166
  if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
148
167
  throw new Error('Draco properties, byteOffset, and byteLength must be defined');
149
168
  }
150
- dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
169
+ dracoBuffer = (tile.featureTableBinary || []).slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
151
170
  tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
152
171
  tile.hasColors =
153
172
  Number.isFinite(dracoFeatureTableProperties.RGB) ||
@@ -170,11 +189,14 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
170
189
  }
171
190
  // eslint-disable-next-line complexity, max-statements
172
191
  async function loadDraco(tile, dracoData, options, context) {
192
+ if (!context) {
193
+ return;
194
+ }
173
195
  const { parse } = context;
174
196
  const dracoOptions = {
175
197
  ...options,
176
198
  draco: {
177
- ...options.draco,
199
+ ...options?.draco,
178
200
  extraAttributes: dracoData.batchTableProperties || {}
179
201
  }
180
202
  };
@@ -1,2 +1,5 @@
1
- export declare function parse3DTile(arrayBuffer: any, byteOffset: number | undefined, options: any, context: any, tile?: {}): Promise<any>;
1
+ import { LoaderContext } from '@loaders.gl/loader-utils';
2
+ import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
3
+ import { Tiles3DTileContent } from '../../types';
4
+ export declare function parse3DTile(arrayBuffer: ArrayBuffer, byteOffset: number | undefined, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, tile?: Tiles3DTileContent): Promise<number | void>;
2
5
  //# sourceMappingURL=parse-3d-tile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-3d-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile.ts"],"names":[],"mappings":"AAaA,wBAAsB,WAAW,CAAC,WAAW,KAAA,EAAE,UAAU,oBAAI,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,EAAE,IAAI,KAAK,gBAmCzF"}
1
+ {"version":3,"file":"parse-3d-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile.ts"],"names":[],"mappings":"AAWA,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAG/C,wBAAsB,WAAW,CAC/B,WAAW,EAAE,WAAW,EACxB,UAAU,oBAAI,EACd,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,IAAI,GAAE,kBAAuB,0BAgC9B"}
@@ -12,11 +12,8 @@ const parse_3d_tile_composite_1 = require("./parse-3d-tile-composite");
12
12
  const parse_3d_tile_gltf_1 = require("./parse-3d-tile-gltf");
13
13
  // Extracts
14
14
  async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
15
- // @ts-expect-error
16
15
  tile.byteOffset = byteOffset;
17
- // @ts-expect-error
18
16
  tile.type = (0, parse_utils_1.getMagicString)(arrayBuffer, byteOffset);
19
- // @ts-expect-error
20
17
  switch (tile.type) {
21
18
  case constants_1.TILE3D_TYPE.COMPOSITE:
22
19
  // Note: We pass this function as argument so that embedded tiles can be parsed recursively
@@ -30,7 +27,6 @@ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile =
30
27
  case constants_1.TILE3D_TYPE.POINT_CLOUD:
31
28
  return await (0, parse_3d_tile_point_cloud_1.parsePointCloud3DTile)(tile, arrayBuffer, byteOffset, options, context);
32
29
  default:
33
- // @ts-expect-error
34
30
  throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line
35
31
  }
36
32
  }
@@ -1,4 +1,18 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { DracoLoaderOptions } from '@loaders.gl/draco';
3
+ import type { ImageLoaderOptions } from '@loaders.gl/images';
4
+ export type Tiles3DLoaderOptions = LoaderOptions & DracoLoaderOptions & ImageLoaderOptions & {
5
+ '3d-tiles'?: {
6
+ /** Whether to parse any embedded glTF binaries (or extract memory for independent glTF parsing) */
7
+ loadGLTF?: boolean;
8
+ /** If renderer doesn't support quantized positions, loader can decode them on CPU */
9
+ decodeQuantizedPositions?: boolean;
10
+ /** Whether this is a tileset or a tile */
11
+ isTileset?: boolean | 'auto';
12
+ /** Controls which axis is "up" in glTF files */
13
+ assetGltfUpAxis?: 'x' | 'y' | 'z' | null;
14
+ };
15
+ };
2
16
  /**
3
17
  * Loader for 3D Tiles
4
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAO/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
1
+ {"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE7F,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAS3D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAE9C,kBAAkB,GAClB,kBAAkB,GAAG;IACnB,UAAU,CAAC,EAAE;QACX,mGAAmG;QACnG,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,qFAAqF;QACrF,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,0CAA0C;QAC1C,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QAC7B,gDAAgD;QAChD,eAAe,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;KAC1C,CAAC;CACH,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}