@loaders.gl/3d-tiles 3.1.0-alpha.5 → 3.1.0-beta.1

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 (208) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +9973 -0
  4. package/dist/cesium-ion-loader.d.ts +1 -0
  5. package/dist/cesium-ion-loader.d.ts.map +1 -0
  6. package/dist/cesium-ion-loader.js +40 -0
  7. package/dist/es5/index.js +8 -0
  8. package/dist/es5/index.js.map +1 -1
  9. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  10. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  11. package/dist/es5/lib/classes/tile-3d-batch-table.js +12 -1
  12. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
  13. package/dist/es5/lib/classes/tile-3d-feature-table.js +8 -2
  14. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
  15. package/dist/es5/lib/constants.js.map +1 -1
  16. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
  17. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
  18. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
  19. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
  20. package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
  21. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
  22. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  23. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  24. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  25. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +1 -1
  26. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  27. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  28. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +73 -0
  29. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  30. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +1 -1
  31. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  32. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
  33. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  34. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  35. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
  36. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  37. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +1 -1
  38. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  39. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
  40. package/dist/es5/lib/utils/version.js +1 -1
  41. package/dist/es5/lib/utils/version.js.map +1 -1
  42. package/dist/es5/tile-3d-subtree-loader.js +26 -0
  43. package/dist/es5/tile-3d-subtree-loader.js.map +1 -0
  44. package/dist/esm/index.js +1 -0
  45. package/dist/esm/index.js.map +1 -1
  46. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
  47. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
  48. package/dist/esm/lib/classes/tile-3d-batch-table.js +16 -1
  49. package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -1
  50. package/dist/esm/lib/classes/tile-3d-feature-table.js +9 -2
  51. package/dist/esm/lib/classes/tile-3d-feature-table.js.map +1 -1
  52. package/dist/esm/lib/constants.js.map +1 -1
  53. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
  54. package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +1 -1
  55. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
  56. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
  57. package/dist/esm/lib/encoders/encode-3d-tile.js.map +1 -1
  58. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
  59. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
  60. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
  61. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
  62. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +1 -1
  63. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
  64. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
  65. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +64 -0
  66. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  67. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +1 -1
  68. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
  69. package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -1
  70. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
  71. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
  72. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
  73. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  74. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +1 -1
  75. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
  76. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
  77. package/dist/esm/lib/utils/version.js +1 -1
  78. package/dist/esm/lib/utils/version.js.map +1 -1
  79. package/dist/esm/tile-3d-subtree-loader.js +14 -0
  80. package/dist/esm/tile-3d-subtree-loader.js.map +1 -0
  81. package/dist/index.d.ts +2 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +26 -0
  84. package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts +3 -2
  85. package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -0
  86. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +113 -0
  87. package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts +4 -3
  88. package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -0
  89. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +197 -0
  90. package/dist/lib/classes/tile-3d-batch-table.d.ts +8 -14
  91. package/dist/lib/classes/tile-3d-batch-table.d.ts.map +1 -0
  92. package/dist/lib/classes/tile-3d-batch-table.js +245 -0
  93. package/dist/lib/classes/tile-3d-feature-table.d.ts +2 -1
  94. package/dist/lib/classes/tile-3d-feature-table.d.ts.map +1 -0
  95. package/dist/lib/classes/tile-3d-feature-table.js +72 -0
  96. package/dist/lib/constants.d.ts +21 -22
  97. package/dist/lib/constants.d.ts.map +1 -0
  98. package/dist/lib/constants.js +25 -0
  99. package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts +2 -1
  100. package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts.map +1 -0
  101. package/dist/lib/encoders/encode-3d-tile-batched-model.js +46 -0
  102. package/dist/lib/encoders/encode-3d-tile-composite.d.ts +2 -1
  103. package/dist/lib/encoders/encode-3d-tile-composite.d.ts.map +1 -0
  104. package/dist/lib/encoders/encode-3d-tile-composite.js +24 -0
  105. package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts +2 -1
  106. package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts.map +1 -0
  107. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +38 -0
  108. package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts +2 -1
  109. package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts.map +1 -0
  110. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +39 -0
  111. package/dist/lib/encoders/encode-3d-tile.d.ts +1 -0
  112. package/dist/lib/encoders/encode-3d-tile.d.ts.map +1 -0
  113. package/dist/lib/encoders/encode-3d-tile.js +33 -0
  114. package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts +3 -2
  115. package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts.map +1 -0
  116. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +30 -0
  117. package/dist/lib/ion/ion.d.ts +1 -0
  118. package/dist/lib/ion/ion.d.ts.map +1 -0
  119. package/dist/lib/ion/ion.js +68 -0
  120. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +2 -1
  121. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -0
  122. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +65 -0
  123. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +2 -1
  124. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -0
  125. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +30 -0
  126. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts +2 -1
  127. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -0
  128. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +42 -0
  129. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +7 -6
  130. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -0
  131. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +88 -0
  132. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
  133. package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -0
  134. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +28 -0
  135. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +9 -0
  136. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -0
  137. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +74 -0
  138. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +3 -2
  139. package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -0
  140. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +93 -0
  141. package/dist/lib/parsers/helpers/parse-utils.d.ts +4 -3
  142. package/dist/lib/parsers/helpers/parse-utils.d.ts.map +1 -0
  143. package/dist/lib/parsers/helpers/parse-utils.js +32 -0
  144. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +2 -1
  145. package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -0
  146. package/dist/lib/parsers/parse-3d-tile-batched-model.js +33 -0
  147. package/dist/lib/parsers/parse-3d-tile-composite.d.ts +2 -1
  148. package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -0
  149. package/dist/lib/parsers/parse-3d-tile-composite.js +26 -0
  150. package/dist/lib/parsers/parse-3d-tile-header.d.ts +3 -2
  151. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -0
  152. package/dist/lib/parsers/parse-3d-tile-header.js +66 -0
  153. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +2 -1
  154. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -0
  155. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +186 -0
  156. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +3 -2
  157. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -0
  158. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +411 -0
  159. package/dist/lib/parsers/parse-3d-tile.d.ts +2 -1
  160. package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -0
  161. package/dist/lib/parsers/parse-3d-tile.js +34 -0
  162. package/dist/lib/utils/version.d.ts +2 -1
  163. package/dist/lib/utils/version.d.ts.map +1 -0
  164. package/dist/lib/utils/version.js +7 -0
  165. package/dist/tile-3d-subtree-loader.d.ts +7 -0
  166. package/dist/tile-3d-subtree-loader.d.ts.map +1 -0
  167. package/dist/tile-3d-subtree-loader.js +23 -0
  168. package/dist/tile-3d-writer.d.ts +1 -0
  169. package/dist/tile-3d-writer.d.ts.map +1 -0
  170. package/dist/tile-3d-writer.js +27 -0
  171. package/dist/tiles-3d-loader.d.ts +1 -0
  172. package/dist/tiles-3d-loader.d.ts.map +1 -0
  173. package/dist/tiles-3d-loader.js +73 -0
  174. package/dist/types.d.ts +28 -0
  175. package/dist/types.d.ts.map +1 -0
  176. package/dist/types.js +2 -0
  177. package/package.json +9 -10
  178. package/src/index.ts +1 -0
  179. package/src/lib/classes/helpers/{tile-3d-accessor-utils.js → tile-3d-accessor-utils.ts} +0 -0
  180. package/src/lib/classes/{tile-3d-batch-table-hierarchy.js → tile-3d-batch-table-hierarchy.ts} +0 -0
  181. package/src/lib/classes/{tile-3d-batch-table.js → tile-3d-batch-table.ts} +14 -4
  182. package/src/lib/classes/{tile-3d-feature-table.js → tile-3d-feature-table.ts} +5 -2
  183. package/src/lib/{constants.js → constants.ts} +0 -0
  184. package/src/lib/encoders/{encode-3d-tile-batched-model.js → encode-3d-tile-batched-model.ts} +0 -0
  185. package/src/lib/encoders/{encode-3d-tile-composite.js → encode-3d-tile-composite.ts} +0 -0
  186. package/src/lib/encoders/{encode-3d-tile-instanced-model.js → encode-3d-tile-instanced-model.ts} +0 -0
  187. package/src/lib/encoders/{encode-3d-tile-point-cloud.js → encode-3d-tile-point-cloud.ts} +0 -0
  188. package/src/lib/encoders/{encode-3d-tile.js → encode-3d-tile.ts} +0 -0
  189. package/src/lib/encoders/helpers/{encode-3d-tile-header.js → encode-3d-tile-header.ts} +0 -0
  190. package/src/lib/parsers/helpers/{normalize-3d-tile-colors.js → normalize-3d-tile-colors.ts} +1 -1
  191. package/src/lib/parsers/helpers/{normalize-3d-tile-normals.js → normalize-3d-tile-normals.ts} +0 -0
  192. package/src/lib/parsers/helpers/{normalize-3d-tile-positions.js → normalize-3d-tile-positions.ts} +0 -0
  193. package/src/lib/parsers/helpers/{parse-3d-tile-gltf-view.js → parse-3d-tile-gltf-view.ts} +1 -1
  194. package/src/lib/parsers/helpers/{parse-3d-tile-header.js → parse-3d-tile-header.ts} +0 -0
  195. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +104 -0
  196. package/src/lib/parsers/helpers/{parse-3d-tile-tables.js → parse-3d-tile-tables.ts} +1 -1
  197. package/src/lib/parsers/helpers/{parse-utils.js → parse-utils.ts} +0 -0
  198. package/src/lib/parsers/{parse-3d-tile-batched-model.js → parse-3d-tile-batched-model.ts} +0 -0
  199. package/src/lib/parsers/{parse-3d-tile-composite.js → parse-3d-tile-composite.ts} +0 -0
  200. package/src/lib/parsers/{parse-3d-tile-header.js → parse-3d-tile-header.ts} +1 -1
  201. package/src/lib/parsers/{parse-3d-tile-instanced-model.js → parse-3d-tile-instanced-model.ts} +6 -0
  202. package/src/lib/parsers/{parse-3d-tile-point-cloud.js → parse-3d-tile-point-cloud.ts} +2 -2
  203. package/src/lib/parsers/{parse-3d-tile.js → parse-3d-tile.ts} +4 -0
  204. package/src/lib/utils/{version.js → version.ts} +0 -0
  205. package/src/tile-3d-subtree-loader.ts +19 -0
  206. package/src/types.ts +33 -0
  207. package/dist/dist.min.js +0 -2
  208. package/dist/dist.min.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encode-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/encoders/helpers/encode-3d-tile-header.ts"],"names":[],"mappings":"AAGA,wBAAgB,kBAAkB,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA,EAAE,UAAU,KAAA,OAqB5D;AAGD,wBAAgB,sBAAsB,CAAC,QAAQ,KAAA,EAAE,mBAAmB,KAAA,EAAE,UAAU,KAAA,QAM/E"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.encode3DTileByteLength = exports.encode3DTileHeader = void 0;
4
+ // HELPER ENCODERS
5
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
6
+ function encode3DTileHeader(tile, dataView, byteOffset) {
7
+ const HEADER_SIZE = 12;
8
+ if (!dataView) {
9
+ return byteOffset + HEADER_SIZE;
10
+ }
11
+ const { magic, version = 1, byteLength = 12 } = tile;
12
+ (0, loader_utils_1.assert)(Array.isArray(magic) && Number.isFinite(version) && Number.isFinite(byteLength));
13
+ dataView.setUint8(byteOffset + 0, magic[0]);
14
+ dataView.setUint8(byteOffset + 1, magic[1]);
15
+ dataView.setUint8(byteOffset + 2, magic[2]);
16
+ dataView.setUint8(byteOffset + 3, magic[3]);
17
+ dataView.setUint32(byteOffset + 4, version, true); // version
18
+ dataView.setUint32(byteOffset + 8, byteLength, true); // byteLength
19
+ byteOffset += HEADER_SIZE;
20
+ return byteOffset;
21
+ }
22
+ exports.encode3DTileHeader = encode3DTileHeader;
23
+ // Bytelength is sometimes only known at the end of writing a tile
24
+ function encode3DTileByteLength(dataView, byteOffsetTileStart, byteLength) {
25
+ if (!dataView) {
26
+ return;
27
+ }
28
+ dataView.setUint32(byteOffsetTileStart + 8, byteLength, true); // byteLength
29
+ }
30
+ exports.encode3DTileByteLength = encode3DTileByteLength;
@@ -1,3 +1,4 @@
1
1
  export function getIonTilesetMetadata(accessToken: any, assetId: any): Promise<any>;
2
2
  export function getIonAssets(accessToken: any): Promise<any>;
3
3
  export function getIonAssetMetadata(accessToken: any, assetId: any): Promise<any>;
4
+ //# sourceMappingURL=ion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ion.d.ts","sourceRoot":"","sources":["../../../src/lib/ion/ion.js"],"names":[],"mappings":"AAQA,oFAqBC;AAGD,6DASC;AAGD,kFA4BC"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ // Minimal support to load tilsets from the Cesium ION services
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.getIonAssetMetadata = exports.getIonAssets = exports.getIonTilesetMetadata = void 0;
5
+ const core_1 = require("@loaders.gl/core");
6
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
7
+ const CESIUM_ION_URL = 'https://api.cesium.com/v1/assets';
8
+ // Returns `{url, headers, type, attributions}` for an ion tileset
9
+ async function getIonTilesetMetadata(accessToken, assetId) {
10
+ // Step 1, if no asset id, look for first 3DTILES asset associated with this token.
11
+ if (!assetId) {
12
+ const assets = await getIonAssets(accessToken);
13
+ for (const item of assets.items) {
14
+ if (item.type === '3DTILES') {
15
+ assetId = item.id;
16
+ }
17
+ }
18
+ }
19
+ // Step 2: Query metdatadata for this asset.
20
+ const ionAssetMetadata = await getIonAssetMetadata(accessToken, assetId);
21
+ const { type, url } = ionAssetMetadata;
22
+ (0, loader_utils_1.assert)(type === '3DTILES' && url);
23
+ // Prepare a headers object for fetch
24
+ ionAssetMetadata.headers = {
25
+ Authorization: `Bearer ${ionAssetMetadata.accessToken}`
26
+ };
27
+ return ionAssetMetadata;
28
+ }
29
+ exports.getIonTilesetMetadata = getIonTilesetMetadata;
30
+ // Return a list of all assets associated with accessToken
31
+ async function getIonAssets(accessToken) {
32
+ (0, loader_utils_1.assert)(accessToken);
33
+ const url = CESIUM_ION_URL;
34
+ const headers = { Authorization: `Bearer ${accessToken}` };
35
+ const response = await (0, core_1.fetchFile)(url, { fetch: { headers } });
36
+ if (!response.ok) {
37
+ throw new Error(response.statusText);
38
+ }
39
+ return await response.json();
40
+ }
41
+ exports.getIonAssets = getIonAssets;
42
+ // Return metadata for a specific asset associated with token
43
+ async function getIonAssetMetadata(accessToken, assetId) {
44
+ (0, loader_utils_1.assert)(accessToken, assetId);
45
+ const headers = { Authorization: `Bearer ${accessToken}` };
46
+ const url = `${CESIUM_ION_URL}/${assetId}`;
47
+ // https://cesium.com/docs/rest-api/#operation/getAsset
48
+ // Retrieves metadata information about a specific asset.
49
+ let response = await (0, core_1.fetchFile)(`${url}`, { fetch: { headers } });
50
+ if (!response.ok) {
51
+ throw new Error(response.statusText);
52
+ }
53
+ let metadata = await response.json();
54
+ // https://cesium.com/docs/rest-api/#operation/getAssetEndpoint
55
+ // Retrieves information and credentials that allow you to access the tiled asset data for visualization and analysis.
56
+ response = await (0, core_1.fetchFile)(`${url}/endpoint`, { fetch: { headers } });
57
+ if (!response.ok) {
58
+ throw new Error(response.statusText);
59
+ }
60
+ const tilesetInfo = await response.json();
61
+ // extract dataset description
62
+ metadata = {
63
+ ...metadata,
64
+ ...tilesetInfo
65
+ };
66
+ return metadata;
67
+ }
68
+ exports.getIonAssetMetadata = getIonAssetMetadata;
@@ -1,6 +1,7 @@
1
- export function normalize3DTileColorAttribute(tile: any, colors: any, batchTable: any): {
1
+ export declare function normalize3DTileColorAttribute(tile: any, colors: any, batchTable?: any): {
2
2
  type: number;
3
3
  value: any;
4
4
  size: number;
5
5
  normalized: boolean;
6
6
  } | null;
7
+ //# sourceMappingURL=normalize-3d-tile-colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-3d-tile-colors.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/normalize-3d-tile-colors.ts"],"names":[],"mappings":"AAGA,wBAAgB,6BAA6B,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,EAAE,UAAU,CAAC,KAAA;;;;;SA6DtE"}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalize3DTileColorAttribute = void 0;
4
+ const math_1 = require("@loaders.gl/math");
5
+ /* eslint-disable complexity*/
6
+ function normalize3DTileColorAttribute(tile, colors, batchTable) {
7
+ // no colors defined
8
+ if (!colors && (!tile || !tile.batchIds || !batchTable)) {
9
+ return null;
10
+ }
11
+ const { batchIds, isRGB565, pointCount } = tile;
12
+ // Batch table, look up colors in table
13
+ if (batchIds && batchTable) {
14
+ const colorArray = new Uint8ClampedArray(pointCount * 3);
15
+ for (let i = 0; i < pointCount; i++) {
16
+ const batchId = batchIds[i];
17
+ // TODO figure out what is `dimensions` used for
18
+ const dimensions = batchTable.getProperty(batchId, 'dimensions');
19
+ const color = dimensions.map((d) => d * 255);
20
+ colorArray[i * 3] = color[0];
21
+ colorArray[i * 3 + 1] = color[1];
22
+ colorArray[i * 3 + 2] = color[2];
23
+ }
24
+ return {
25
+ type: math_1.GL.UNSIGNED_BYTE,
26
+ value: colorArray,
27
+ size: 3,
28
+ normalized: true
29
+ };
30
+ }
31
+ // RGB565 case, convert to RGB
32
+ if (isRGB565) {
33
+ const colorArray = new Uint8ClampedArray(pointCount * 3);
34
+ for (let i = 0; i < pointCount; i++) {
35
+ const color = (0, math_1.decodeRGB565)(colors[i]);
36
+ colorArray[i * 3] = color[0];
37
+ colorArray[i * 3 + 1] = color[1];
38
+ colorArray[i * 3 + 2] = color[2];
39
+ }
40
+ return {
41
+ type: math_1.GL.UNSIGNED_BYTE,
42
+ value: colorArray,
43
+ size: 3,
44
+ normalized: true
45
+ };
46
+ }
47
+ // RGB case (tile.isTranslucent)
48
+ if (colors && colors.length === pointCount * 3) {
49
+ return {
50
+ type: math_1.GL.UNSIGNED_BYTE,
51
+ value: colors,
52
+ size: 3,
53
+ normalized: true
54
+ };
55
+ }
56
+ // DEFAULT: RGBA case
57
+ return {
58
+ type: math_1.GL.UNSIGNED_BYTE,
59
+ value: colors,
60
+ size: 4,
61
+ normalized: true
62
+ };
63
+ }
64
+ exports.normalize3DTileColorAttribute = normalize3DTileColorAttribute;
65
+ /* eslint-enable complexity*/
@@ -1,5 +1,6 @@
1
- export function normalize3DTileNormalAttribute(tile: any, normals: any): {
1
+ export declare function normalize3DTileNormalAttribute(tile: any, normals: any): {
2
2
  type: number;
3
3
  size: number;
4
4
  value: any;
5
5
  } | null;
6
+ //# sourceMappingURL=normalize-3d-tile-normals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-3d-tile-normals.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/normalize-3d-tile-normals.ts"],"names":[],"mappings":"AAKA,wBAAgB,8BAA8B,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA;;;;SAyB3D"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalize3DTileNormalAttribute = void 0;
4
+ const core_1 = require("@math.gl/core");
5
+ const math_1 = require("@loaders.gl/math");
6
+ const scratchNormal = new core_1.Vector3();
7
+ function normalize3DTileNormalAttribute(tile, normals) {
8
+ if (!normals) {
9
+ return null;
10
+ }
11
+ if (tile.isOctEncoded16P) {
12
+ const decodedArray = new Float32Array(tile.pointsLength * 3);
13
+ for (let i = 0; i < tile.pointsLength; i++) {
14
+ (0, math_1.octDecode)(normals[i * 2], normals[i * 2 + 1], scratchNormal);
15
+ // @ts-ignore
16
+ scratchNormal.toArray(decodedArray, i * 3);
17
+ }
18
+ return {
19
+ type: math_1.GL.FLOAT,
20
+ size: 2,
21
+ value: decodedArray
22
+ };
23
+ }
24
+ return {
25
+ type: math_1.GL.FLOAT,
26
+ size: 2,
27
+ value: normals
28
+ };
29
+ }
30
+ exports.normalize3DTileNormalAttribute = normalize3DTileNormalAttribute;
@@ -1 +1,2 @@
1
- export function normalize3DTilePositionAttribute(tile: any, positions: any, options: any): any;
1
+ export declare function normalize3DTilePositionAttribute(tile: any, positions: any, options: any): any;
2
+ //# sourceMappingURL=normalize-3d-tile-positions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-3d-tile-positions.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/normalize-3d-tile-positions.ts"],"names":[],"mappings":"AAIA,wBAAgB,gCAAgC,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,EAAE,OAAO,KAAA,OAsBxE"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalize3DTilePositionAttribute = void 0;
4
+ const core_1 = require("@math.gl/core");
5
+ const math_1 = require("@loaders.gl/math");
6
+ // Prepare attribute for positions
7
+ function normalize3DTilePositionAttribute(tile, positions, options) {
8
+ if (!tile.isQuantized) {
9
+ return positions;
10
+ }
11
+ // For quantized posititions, either expand to Float32Array or return custom accessor
12
+ // https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/Instanced3DModel/README.md#quantized-positions
13
+ // Optionally decodes quantized positions on GPU, for simpler renderers that don't accept normalized attributes
14
+ if (options['3d-tiles'] && options['3d-tiles'].decodeQuantizedPositions) {
15
+ tile.isQuantized = false;
16
+ return decodeQuantizedPositions(tile, positions);
17
+ }
18
+ // Default: Use normalized shorts directly, no copying/processing.
19
+ // NOTE: The "missing" offset/scaling operations are automatically added to modelMatrix if `tile.isQuantized === true`
20
+ return {
21
+ type: math_1.GL.UNSIGNED_SHORT,
22
+ value: positions,
23
+ size: 3,
24
+ normalized: true
25
+ };
26
+ }
27
+ exports.normalize3DTilePositionAttribute = normalize3DTilePositionAttribute;
28
+ // Pre-scale quantized positions on CPU
29
+ function decodeQuantizedPositions(tile, positions) {
30
+ const scratchPosition = new core_1.Vector3();
31
+ const decodedArray = new Float32Array(tile.pointCount * 3);
32
+ for (let i = 0; i < tile.pointCount; i++) {
33
+ // POSITION = POSITION_QUANTIZED / 65535.0 * QUANTIZED_VOLUME_SCALE + QUANTIZED_VOLUME_OFFSET
34
+ scratchPosition
35
+ .set(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2])
36
+ .scale(1 / tile.quantizedRange)
37
+ .multiply(tile.quantizedVolumeScale)
38
+ .add(tile.quantizedVolumeOffset)
39
+ .toArray(decodedArray, i * 3);
40
+ }
41
+ return decodedArray;
42
+ }
@@ -1,6 +1,7 @@
1
- export function parse3DTileGLTFViewSync(tile: any, arrayBuffer: any, byteOffset: any, options: any): any;
2
- export function extractGLTF(tile: any, gltfFormat: any, options: any, context: any): Promise<void>;
3
- export namespace GLTF_FORMAT {
4
- const URI: number;
5
- const EMBEDDED: number;
6
- }
1
+ export declare const GLTF_FORMAT: {
2
+ URI: number;
3
+ EMBEDDED: number;
4
+ };
5
+ export declare function parse3DTileGLTFViewSync(tile: any, arrayBuffer: any, byteOffset: any, options: any): any;
6
+ export declare function extractGLTF(tile: any, gltfFormat: any, options: any, context: any): Promise<void>;
7
+ //# sourceMappingURL=parse-3d-tile-gltf-view.d.ts.map
@@ -0,0 +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":"AAYA,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,OAoC7E;AAED,wBAAsB,WAAW,CAAC,IAAI,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,iBAmBnE"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.extractGLTF = exports.parse3DTileGLTFViewSync = exports.GLTF_FORMAT = void 0;
6
+ // TODO - should we automatically parse the embedded glTF or leave it to the app?
7
+ // - I.e. some apps might work directly on a GLB, in that case no need for us to decode...
8
+ // - And if we decode, do we still keep the GLB in case it is needed?
9
+ // - Do we add an option to control this?
10
+ // - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?
11
+ const gltf_1 = require("@loaders.gl/gltf");
12
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
13
+ exports.GLTF_FORMAT = {
14
+ URI: 0,
15
+ EMBEDDED: 1
16
+ };
17
+ function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
18
+ // Set flags
19
+ // glTF models need to be rotated from Y to Z up
20
+ // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
21
+ tile.rotateYtoZ = true;
22
+ // Assume glTF consumes rest of tile
23
+ const gltfByteLength = tile.byteOffset + tile.byteLength - byteOffset;
24
+ if (gltfByteLength === 0) {
25
+ throw new Error('glTF byte length must be greater than 0.');
26
+ }
27
+ // Save gltf up axis
28
+ tile.gltfUpAxis =
29
+ options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
30
+ ? options['3d-tiles'].assetGltfUpAxis
31
+ : 'Y';
32
+ // TODO - We can avoid copy if already 4-byte aligned...
33
+ // However the rest of the code may not be able to accept byteOffsets, so copy anyway
34
+ tile.gltfArrayBuffer = (0, loader_utils_1.sliceArrayBuffer)(arrayBuffer, byteOffset, gltfByteLength);
35
+ tile.gltfByteOffset = 0;
36
+ tile.gltfByteLength = gltfByteLength;
37
+ if (byteOffset % 4 === 0) {
38
+ // tile.gltfArrayBuffer = arrayBuffer;
39
+ // tile.gltfByteOffset = byteOffset;
40
+ // tile.gltfByteLength = gltfByteLength;
41
+ }
42
+ else {
43
+ // Create a copy of the glb so that it is 4-byte aligned
44
+ // eslint-disable-next-line
45
+ console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);
46
+ }
47
+ // Entire tile is consumed
48
+ return tile.byteOffset + tile.byteLength;
49
+ }
50
+ exports.parse3DTileGLTFViewSync = parse3DTileGLTFViewSync;
51
+ async function extractGLTF(tile, gltfFormat, options, context) {
52
+ const tile3DOptions = options['3d-tiles'] || {};
53
+ extractGLTFBufferOrURL(tile, gltfFormat, options);
54
+ if (tile3DOptions.loadGLTF) {
55
+ const { parse, fetch } = context;
56
+ if (tile.gltfUrl) {
57
+ tile.gltfArrayBuffer = await fetch(tile.gltfUrl, options);
58
+ tile.gltfByteOffset = 0;
59
+ }
60
+ if (tile.gltfArrayBuffer) {
61
+ // TODO - Should handle byteOffset... However, not used now...
62
+ tile.gltf = await parse(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
63
+ delete tile.gltfArrayBuffer;
64
+ delete tile.gltfByteOffset;
65
+ delete tile.gltfByteLength;
66
+ }
67
+ }
68
+ }
69
+ exports.extractGLTF = extractGLTF;
70
+ function extractGLTFBufferOrURL(tile, gltfFormat, options) {
71
+ switch (gltfFormat) {
72
+ case exports.GLTF_FORMAT.URI:
73
+ // We need to remove padding from the end of the model URL in case this tile was part of a composite tile.
74
+ // This removes all white space and null characters from the end of the string.
75
+ const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);
76
+ const textDecoder = new TextDecoder();
77
+ const gltfUrl = textDecoder.decode(gltfUrlBytes);
78
+ tile.gltfUrl = gltfUrl.replace(/[\s\0]+$/, '');
79
+ delete tile.gltfArrayBuffer;
80
+ delete tile.gltfByteOffset;
81
+ delete tile.gltfByteLength;
82
+ break;
83
+ case exports.GLTF_FORMAT.EMBEDDED:
84
+ break;
85
+ default:
86
+ throw new Error('b3dm: Illegal glTF format field');
87
+ }
88
+ }
@@ -1 +1,2 @@
1
- export function parse3DTileHeaderSync(tile: any, arrayBuffer: any, byteOffset?: number): number;
1
+ export declare function parse3DTileHeaderSync(tile: any, arrayBuffer: any, byteOffset?: number): number;
2
+ //# sourceMappingURL=parse-3d-tile-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAYA,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,SAAI,UAkBtE"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.parse3DTileHeaderSync = void 0;
6
+ const SIZEOF_UINT32 = 4;
7
+ /* PARSE FIXED HEADER:
8
+ Populates
9
+ magic, // identifies type of tile
10
+ type, // String version of magic
11
+ version,
12
+ byteLength
13
+ */
14
+ function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {
15
+ const view = new DataView(arrayBuffer);
16
+ tile.magic = view.getUint32(byteOffset, true);
17
+ byteOffset += SIZEOF_UINT32;
18
+ tile.version = view.getUint32(byteOffset, true);
19
+ byteOffset += SIZEOF_UINT32;
20
+ tile.byteLength = view.getUint32(byteOffset, true);
21
+ byteOffset += SIZEOF_UINT32;
22
+ // TODO - move version check into each tile parser?
23
+ if (tile.version !== 1) {
24
+ throw new Error(`3D Tile Version ${tile.version} not supported`);
25
+ }
26
+ return byteOffset; // Indicates where the parsing ended
27
+ }
28
+ exports.parse3DTileHeaderSync = parse3DTileHeaderSync;
@@ -0,0 +1,9 @@
1
+ import type { SubtreeAvailability } from '../../../types';
2
+ /**
3
+ * Parse subtree file
4
+ * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format
5
+ * @param data
6
+ * @returns
7
+ */
8
+ export default function parse3DTilesSubtree(data: ArrayBuffer): Promise<SubtreeAvailability>;
9
+ //# sourceMappingURL=parse-3d-tile-subtree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-3d-tile-subtree.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAoB,MAAM,gBAAgB,CAAC;AAM3E;;;;;GAKG;AACH,wBAA8B,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoDjG"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@loaders.gl/core");
4
+ const SUBTREE_FILE_MAGIC = 0x74627573;
5
+ const SUBTREE_FILE_VERSION = 1;
6
+ /**
7
+ * Parse subtree file
8
+ * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format
9
+ * @param data
10
+ * @returns
11
+ */
12
+ async function parse3DTilesSubtree(data) {
13
+ const magic = new Uint32Array(data.slice(0, 4));
14
+ if (magic[0] !== SUBTREE_FILE_MAGIC) {
15
+ throw new Error('Wrong subtree file magic number');
16
+ }
17
+ const version = new Uint32Array(data.slice(4, 8));
18
+ if (version[0] !== SUBTREE_FILE_VERSION) {
19
+ throw new Error('Wrong subtree file verson, must be 1');
20
+ }
21
+ const jsonByteLength = parseUint64Value(data.slice(8, 16));
22
+ const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
23
+ const textDecoder = new TextDecoder('utf8');
24
+ const string = textDecoder.decode(stringAttribute);
25
+ const subtree = JSON.parse(string);
26
+ const binaryByteLength = parseUint64Value(data.slice(16, 24));
27
+ let internalBinaryBuffer = new ArrayBuffer(0);
28
+ if (binaryByteLength) {
29
+ internalBinaryBuffer = data.slice(24 + jsonByteLength);
30
+ }
31
+ if ('bufferView' in subtree.tileAvailability) {
32
+ subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer);
33
+ }
34
+ if ('bufferView' in subtree.contentAvailability) {
35
+ subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer);
36
+ }
37
+ if ('bufferView' in subtree.childSubtreeAvailability) {
38
+ subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer);
39
+ }
40
+ return subtree;
41
+ }
42
+ exports.default = parse3DTilesSubtree;
43
+ /**
44
+ * Get explicit bitstream for subtree availability data.
45
+ * @param subtree
46
+ * @param name
47
+ * @param internalBinaryBuffer
48
+ */
49
+ async function getExplicitBitstream(subtree, name, internalBinaryBuffer) {
50
+ const bufferViewIndex = subtree[name].bufferView;
51
+ const bufferView = subtree.bufferViews[bufferViewIndex];
52
+ const buffer = subtree.buffers[bufferView.buffer];
53
+ // External bitstream loading
54
+ if (buffer.uri) {
55
+ const response = await (0, core_1.fetchFile)(buffer.uri);
56
+ const data = await response.arrayBuffer();
57
+ // Return view of bitstream.
58
+ return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
59
+ }
60
+ // Return view of bitstream.
61
+ return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
62
+ }
63
+ /**
64
+ * Parse buffer to return uint64 value
65
+ * @param buffer
66
+ * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER
67
+ */
68
+ function parseUint64Value(buffer) {
69
+ const dataView = new DataView(buffer);
70
+ const left = dataView.getUint32(0, true);
71
+ const right = dataView.getUint32(4, true);
72
+ // combine the two 32-bit values
73
+ return left + 2 ** 32 * right;
74
+ }
@@ -1,2 +1,3 @@
1
- export function parse3DTileTablesHeaderSync(tile: any, arrayBuffer: any, byteOffset: any): any;
2
- export function parse3DTileTablesSync(tile: any, arrayBuffer: any, byteOffset: any, options: any): any;
1
+ export declare function parse3DTileTablesHeaderSync(tile: any, arrayBuffer: any, byteOffset: any): any;
2
+ export declare function parse3DTileTablesSync(tile: any, arrayBuffer: any, byteOffset: any, options: any): any;
3
+ //# sourceMappingURL=parse-3d-tile-tables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-3d-tile-tables.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-tables.ts"],"names":[],"mappings":"AASA,wBAAgB,2BAA2B,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,OAiDxE;AAED,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,OAAO,KAAA,OAI3E"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ // This file is derived from the Cesium code base under Apache 2 license
3
+ // See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.parse3DTileTablesSync = exports.parse3DTileTablesHeaderSync = void 0;
6
+ const parse_utils_1 = require("./parse-utils");
7
+ const SIZEOF_UINT32 = 4;
8
+ const DEPRECATION_WARNING = 'b3dm tile in legacy format.';
9
+ // eslint-disable-next-line max-statements
10
+ function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
11
+ const view = new DataView(arrayBuffer);
12
+ let batchLength;
13
+ tile.header = tile.header || {};
14
+ let featureTableJsonByteLength = view.getUint32(byteOffset, true);
15
+ byteOffset += SIZEOF_UINT32;
16
+ let featureTableBinaryByteLength = view.getUint32(byteOffset, true);
17
+ byteOffset += SIZEOF_UINT32;
18
+ let batchTableJsonByteLength = view.getUint32(byteOffset, true);
19
+ byteOffset += SIZEOF_UINT32;
20
+ let batchTableBinaryByteLength = view.getUint32(byteOffset, true);
21
+ byteOffset += SIZEOF_UINT32;
22
+ // First legacy header format - [batchLength] [batchTableByteLength] ('batchTableJsonByteLength': JSON starts with a quotation mark or the glTF magic)
23
+ // Second legacy format - [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength] (Second legacy format is similar as first but here we check 'batchTableBinaryByteLength' instead)
24
+ // Current header format - [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength]
25
+ // First byte will be 0x22 or 0x67. The minimum uint32 expected is 0x22000000 = 570425344 = 570MB.
26
+ if (batchTableJsonByteLength >= 570425344) {
27
+ byteOffset -= SIZEOF_UINT32 * 2;
28
+ batchLength = featureTableJsonByteLength;
29
+ batchTableJsonByteLength = featureTableBinaryByteLength;
30
+ batchTableBinaryByteLength = 0;
31
+ featureTableJsonByteLength = 0;
32
+ featureTableBinaryByteLength = 0;
33
+ console.warn(DEPRECATION_WARNING); // eslint-disable-line
34
+ }
35
+ else if (batchTableBinaryByteLength >= 570425344) {
36
+ byteOffset -= SIZEOF_UINT32;
37
+ batchLength = batchTableJsonByteLength;
38
+ batchTableJsonByteLength = featureTableJsonByteLength;
39
+ batchTableBinaryByteLength = featureTableBinaryByteLength;
40
+ featureTableJsonByteLength = 0;
41
+ featureTableBinaryByteLength = 0;
42
+ console.warn(DEPRECATION_WARNING); // eslint-disable-line
43
+ }
44
+ tile.header.featureTableJsonByteLength = featureTableJsonByteLength;
45
+ tile.header.featureTableBinaryByteLength = featureTableBinaryByteLength;
46
+ tile.header.batchTableJsonByteLength = batchTableJsonByteLength;
47
+ tile.header.batchTableBinaryByteLength = batchTableBinaryByteLength;
48
+ tile.header.batchLength = batchLength;
49
+ return byteOffset;
50
+ }
51
+ exports.parse3DTileTablesHeaderSync = parse3DTileTablesHeaderSync;
52
+ function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {
53
+ byteOffset = parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options);
54
+ byteOffset = parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options);
55
+ return byteOffset;
56
+ }
57
+ exports.parse3DTileTablesSync = parse3DTileTablesSync;
58
+ function parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {
59
+ const { featureTableJsonByteLength, featureTableBinaryByteLength, batchLength } = tile.header;
60
+ tile.featureTableJson = {
61
+ BATCH_LENGTH: batchLength || 0
62
+ };
63
+ if (featureTableJsonByteLength > 0) {
64
+ const featureTableString = (0, parse_utils_1.getStringFromArrayBuffer)(arrayBuffer, byteOffset, featureTableJsonByteLength);
65
+ tile.featureTableJson = JSON.parse(featureTableString);
66
+ }
67
+ byteOffset += featureTableJsonByteLength;
68
+ tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
69
+ byteOffset += featureTableBinaryByteLength;
70
+ /*
71
+ const featureTable = parseFeatureTable(featureTableJson, featureTableBinary);
72
+
73
+ const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');
74
+ featureTable.featuresLength = batchLength;
75
+ */
76
+ return byteOffset;
77
+ }
78
+ function parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {
79
+ const { batchTableJsonByteLength, batchTableBinaryByteLength } = tile.header;
80
+ if (batchTableJsonByteLength > 0) {
81
+ const batchTableString = (0, parse_utils_1.getStringFromArrayBuffer)(arrayBuffer, byteOffset, batchTableJsonByteLength);
82
+ tile.batchTableJson = JSON.parse(batchTableString);
83
+ byteOffset += batchTableJsonByteLength;
84
+ if (batchTableBinaryByteLength > 0) {
85
+ // Has a batch table binary
86
+ tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);
87
+ // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
88
+ tile.batchTableBinary = new Uint8Array(tile.batchTableBinary);
89
+ byteOffset += batchTableBinaryByteLength;
90
+ }
91
+ }
92
+ return byteOffset;
93
+ }
@@ -1,3 +1,4 @@
1
- export function getStringFromArrayBuffer(arrayBuffer: any, byteOffset: any, byteLength: any): string;
2
- export function getStringFromTypedArray(typedArray: any): string;
3
- export function getMagicString(arrayBuffer: any, byteOffset?: number): string;
1
+ export declare function getStringFromArrayBuffer(arrayBuffer: any, byteOffset: any, byteLength: any): string;
2
+ export declare function getStringFromTypedArray(typedArray: any): string;
3
+ export declare function getMagicString(arrayBuffer: any, byteOffset?: number): string;
4
+ //# sourceMappingURL=parse-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-utils.d.ts","sourceRoot":"","sources":["../../../../src/lib/parsers/helpers/parse-utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,CAAC,WAAW,KAAA,EAAE,UAAU,KAAA,EAAE,UAAU,KAAA,UAM3E;AAGD,wBAAgB,uBAAuB,CAAC,UAAU,KAAA,UAKjD;AAED,wBAAgB,cAAc,CAAC,WAAW,KAAA,EAAE,UAAU,SAAI,UAOzD"}