@loaders.gl/3d-tiles 3.1.3 → 4.0.0-alpha.5

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 (224) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/cesium-ion-loader.js +32 -36
  4. package/dist/cesium-ion-loader.js.map +1 -0
  5. package/dist/dist.min.js +88 -40
  6. package/dist/index.js +9 -26
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +89 -106
  9. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  10. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +202 -184
  11. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  12. package/dist/lib/classes/tile-3d-batch-table.js +282 -223
  13. package/dist/lib/classes/tile-3d-batch-table.js.map +1 -0
  14. package/dist/lib/classes/tile-3d-feature-table.js +86 -64
  15. package/dist/lib/classes/tile-3d-feature-table.js.map +1 -0
  16. package/dist/lib/constants.js +19 -23
  17. package/dist/lib/constants.js.map +1 -0
  18. package/dist/lib/encoders/encode-3d-tile-batched-model.js +45 -45
  19. package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  20. package/dist/lib/encoders/encode-3d-tile-composite.js +24 -23
  21. package/dist/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  22. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +37 -37
  23. package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  24. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +38 -36
  25. package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  26. package/dist/lib/encoders/encode-3d-tile.js +32 -30
  27. package/dist/lib/encoders/encode-3d-tile.js.map +1 -0
  28. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +29 -28
  29. package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  30. package/dist/lib/ion/ion.js +69 -60
  31. package/dist/lib/ion/ion.js.map +1 -0
  32. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +62 -60
  33. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  34. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -26
  35. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  36. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +28 -39
  37. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  38. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +18 -11
  39. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  40. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +203 -170
  41. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  42. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +63 -82
  43. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  44. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +15 -26
  45. package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  46. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +57 -68
  47. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  48. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +80 -84
  49. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  50. package/dist/lib/parsers/helpers/parse-utils.js +16 -29
  51. package/dist/lib/parsers/helpers/parse-utils.js.map +1 -0
  52. package/dist/lib/parsers/parse-3d-tile-batched-model.js +26 -30
  53. package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  54. package/dist/lib/parsers/parse-3d-tile-composite.js +16 -25
  55. package/dist/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  56. package/dist/lib/parsers/parse-3d-tile-gltf.js +9 -17
  57. package/dist/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  58. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  59. package/dist/lib/parsers/parse-3d-tile-header.js +139 -122
  60. package/dist/lib/parsers/parse-3d-tile-header.js.map +1 -0
  61. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +170 -179
  62. package/dist/{es5/lib → lib}/parsers/parse-3d-tile-instanced-model.js.map +1 -1
  63. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +184 -350
  64. package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  65. package/dist/lib/parsers/parse-3d-tile.js +31 -36
  66. package/dist/lib/parsers/parse-3d-tile.js.map +1 -0
  67. package/dist/lib/utils/version.js +2 -7
  68. package/dist/lib/utils/version.js.map +1 -0
  69. package/dist/tile-3d-subtree-loader.js +13 -22
  70. package/dist/tile-3d-subtree-loader.js.map +1 -0
  71. package/dist/tile-3d-writer.js +17 -24
  72. package/dist/tile-3d-writer.js.map +1 -0
  73. package/dist/tiles-3d-loader.js +66 -67
  74. package/dist/tiles-3d-loader.js.map +1 -0
  75. package/dist/types.d.ts +2 -1
  76. package/dist/types.d.ts.map +1 -1
  77. package/dist/types.js +2 -2
  78. package/dist/{es5/types.js.map → types.js.map} +0 -0
  79. package/package.json +10 -10
  80. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +95 -31
  81. package/src/lib/parsers/parse-3d-tile-header.ts +3 -1
  82. package/src/types.ts +2 -1
  83. package/dist/es5/bundle.js +0 -7
  84. package/dist/es5/bundle.js.map +0 -1
  85. package/dist/es5/cesium-ion-loader.js +0 -100
  86. package/dist/es5/cesium-ion-loader.js.map +0 -1
  87. package/dist/es5/index.js +0 -72
  88. package/dist/es5/index.js.map +0 -1
  89. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +0 -120
  90. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
  91. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +0 -225
  92. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
  93. package/dist/es5/lib/classes/tile-3d-batch-table.js +0 -349
  94. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +0 -1
  95. package/dist/es5/lib/classes/tile-3d-feature-table.js +0 -119
  96. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +0 -1
  97. package/dist/es5/lib/constants.js +0 -32
  98. package/dist/es5/lib/constants.js.map +0 -1
  99. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +0 -63
  100. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
  101. package/dist/es5/lib/encoders/encode-3d-tile-composite.js +0 -41
  102. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +0 -1
  103. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +0 -57
  104. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
  105. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +0 -59
  106. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
  107. package/dist/es5/lib/encoders/encode-3d-tile.js +0 -48
  108. package/dist/es5/lib/encoders/encode-3d-tile.js.map +0 -1
  109. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +0 -41
  110. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
  111. package/dist/es5/lib/ion/ion.js +0 -219
  112. package/dist/es5/lib/ion/ion.js.map +0 -1
  113. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -76
  114. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
  115. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -40
  116. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
  117. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -40
  118. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
  119. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -270
  120. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
  121. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -123
  122. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
  123. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +0 -25
  124. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
  125. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -161
  126. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
  127. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +0 -98
  128. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
  129. package/dist/es5/lib/parsers/helpers/parse-utils.js +0 -32
  130. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +0 -1
  131. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +0 -69
  132. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
  133. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +0 -61
  134. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +0 -1
  135. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +0 -45
  136. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
  137. package/dist/es5/lib/parsers/parse-3d-tile-header.js +0 -233
  138. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +0 -1
  139. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +0 -220
  140. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +0 -346
  141. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
  142. package/dist/es5/lib/parsers/parse-3d-tile.js +0 -100
  143. package/dist/es5/lib/parsers/parse-3d-tile.js.map +0 -1
  144. package/dist/es5/lib/utils/version.js +0 -9
  145. package/dist/es5/lib/utils/version.js.map +0 -1
  146. package/dist/es5/tile-3d-subtree-loader.js +0 -26
  147. package/dist/es5/tile-3d-subtree-loader.js.map +0 -1
  148. package/dist/es5/tile-3d-writer.js +0 -32
  149. package/dist/es5/tile-3d-writer.js.map +0 -1
  150. package/dist/es5/tiles-3d-loader.js +0 -190
  151. package/dist/es5/tiles-3d-loader.js.map +0 -1
  152. package/dist/es5/types.js +0 -2
  153. package/dist/esm/bundle.js +0 -5
  154. package/dist/esm/bundle.js.map +0 -1
  155. package/dist/esm/cesium-ion-loader.js +0 -36
  156. package/dist/esm/cesium-ion-loader.js.map +0 -1
  157. package/dist/esm/index.js +0 -9
  158. package/dist/esm/index.js.map +0 -1
  159. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js +0 -96
  160. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
  161. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +0 -215
  162. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
  163. package/dist/esm/lib/classes/tile-3d-batch-table.js +0 -304
  164. package/dist/esm/lib/classes/tile-3d-batch-table.js.map +0 -1
  165. package/dist/esm/lib/classes/tile-3d-feature-table.js +0 -94
  166. package/dist/esm/lib/classes/tile-3d-feature-table.js.map +0 -1
  167. package/dist/esm/lib/constants.js +0 -22
  168. package/dist/esm/lib/constants.js.map +0 -1
  169. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js +0 -46
  170. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
  171. package/dist/esm/lib/encoders/encode-3d-tile-composite.js +0 -25
  172. package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +0 -1
  173. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
  174. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
  175. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js +0 -41
  176. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
  177. package/dist/esm/lib/encoders/encode-3d-tile.js +0 -35
  178. package/dist/esm/lib/encoders/encode-3d-tile.js.map +0 -1
  179. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js +0 -31
  180. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
  181. package/dist/esm/lib/ion/ion.js +0 -77
  182. package/dist/esm/lib/ion/ion.js.map +0 -1
  183. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -67
  184. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
  185. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
  186. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
  187. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -31
  188. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
  189. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -173
  190. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
  191. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -69
  192. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
  193. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +0 -17
  194. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
  195. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -64
  196. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
  197. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +0 -89
  198. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
  199. package/dist/esm/lib/parsers/helpers/parse-utils.js +0 -19
  200. package/dist/esm/lib/parsers/helpers/parse-utils.js.map +0 -1
  201. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js +0 -29
  202. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
  203. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +0 -17
  204. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +0 -1
  205. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +0 -10
  206. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
  207. package/dist/esm/lib/parsers/parse-3d-tile-header.js +0 -144
  208. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +0 -1
  209. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +0 -177
  210. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +0 -1
  211. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +0 -245
  212. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
  213. package/dist/esm/lib/parsers/parse-3d-tile.js +0 -32
  214. package/dist/esm/lib/parsers/parse-3d-tile.js.map +0 -1
  215. package/dist/esm/lib/utils/version.js +0 -2
  216. package/dist/esm/lib/utils/version.js.map +0 -1
  217. package/dist/esm/tile-3d-subtree-loader.js +0 -14
  218. package/dist/esm/tile-3d-subtree-loader.js.map +0 -1
  219. package/dist/esm/tile-3d-writer.js +0 -20
  220. package/dist/esm/tile-3d-writer.js.map +0 -1
  221. package/dist/esm/tiles-3d-loader.js +0 -79
  222. package/dist/esm/tiles-3d-loader.js.map +0 -1
  223. package/dist/esm/types.js +0 -2
  224. package/dist/esm/types.js.map +0 -1
@@ -1,28 +1,17 @@
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
1
  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
2
+ export function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {
3
+ const view = new DataView(arrayBuffer);
4
+ tile.magic = view.getUint32(byteOffset, true);
5
+ byteOffset += SIZEOF_UINT32;
6
+ tile.version = view.getUint32(byteOffset, true);
7
+ byteOffset += SIZEOF_UINT32;
8
+ tile.byteLength = view.getUint32(byteOffset, true);
9
+ byteOffset += SIZEOF_UINT32;
10
+
11
+ if (tile.version !== 1) {
12
+ throw new Error("3D Tile Version ".concat(tile.version, " not supported"));
13
+ }
14
+
15
+ return byteOffset;
27
16
  }
28
- exports.parse3DTileHeaderSync = parse3DTileHeaderSync;
17
+ //# sourceMappingURL=parse-3d-tile-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-header.ts"],"names":["SIZEOF_UINT32","parse3DTileHeaderSync","tile","arrayBuffer","byteOffset","view","DataView","magic","getUint32","version","byteLength","Error"],"mappings":"AAGA,MAAMA,aAAa,GAAG,CAAtB;AASA,OAAO,SAASC,qBAAT,CAA+BC,IAA/B,EAAqCC,WAArC,EAAkDC,UAAU,GAAG,CAA/D,EAAkE;AACvE,QAAMC,IAAI,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAb;AAEAD,EAAAA,IAAI,CAACK,KAAL,GAAaF,IAAI,CAACG,SAAL,CAAeJ,UAAf,EAA2B,IAA3B,CAAb;AACAA,EAAAA,UAAU,IAAIJ,aAAd;AAEAE,EAAAA,IAAI,CAACO,OAAL,GAAeJ,IAAI,CAACG,SAAL,CAAeJ,UAAf,EAA2B,IAA3B,CAAf;AACAA,EAAAA,UAAU,IAAIJ,aAAd;AAEAE,EAAAA,IAAI,CAACQ,UAAL,GAAkBL,IAAI,CAACG,SAAL,CAAeJ,UAAf,EAA2B,IAA3B,CAAlB;AACAA,EAAAA,UAAU,IAAIJ,aAAd;;AAGA,MAAIE,IAAI,CAACO,OAAL,KAAiB,CAArB,EAAwB;AACtB,UAAM,IAAIE,KAAJ,2BAA6BT,IAAI,CAACO,OAAlC,oBAAN;AACD;;AAED,SAAOL,UAAP;AACD","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\nconst SIZEOF_UINT32 = 4;\n\n/* PARSE FIXED HEADER:\nPopulates\n magic, // identifies type of tile\n type, // String version of magic\n version,\n byteLength\n */\nexport function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {\n const view = new DataView(arrayBuffer);\n\n tile.magic = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.version = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n tile.byteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n // TODO - move version check into each tile parser?\n if (tile.version !== 1) {\n throw new Error(`3D Tile Version ${tile.version} not supported`);\n }\n\n return byteOffset; // Indicates where the parsing ended\n}\n"],"file":"parse-3d-tile-header.js"}
@@ -1,75 +1,64 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@loaders.gl/core");
1
+ import { fetchFile } from '@loaders.gl/core';
4
2
  const SUBTREE_FILE_MAGIC = 0x74627573;
5
3
  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
- // eslint-disable-next-line max-statements
13
- async function parse3DTilesSubtree(data) {
14
- const magic = new Uint32Array(data.slice(0, 4));
15
- if (magic[0] !== SUBTREE_FILE_MAGIC) {
16
- throw new Error('Wrong subtree file magic number');
17
- }
18
- const version = new Uint32Array(data.slice(4, 8));
19
- if (version[0] !== SUBTREE_FILE_VERSION) {
20
- throw new Error('Wrong subtree file verson, must be 1');
21
- }
22
- const jsonByteLength = parseUint64Value(data.slice(8, 16));
23
- const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
24
- const textDecoder = new TextDecoder('utf8');
25
- const string = textDecoder.decode(stringAttribute);
26
- const subtree = JSON.parse(string);
27
- const binaryByteLength = parseUint64Value(data.slice(16, 24));
28
- let internalBinaryBuffer = new ArrayBuffer(0);
29
- if (binaryByteLength) {
30
- internalBinaryBuffer = data.slice(24 + jsonByteLength);
31
- }
32
- if ('bufferView' in subtree.tileAvailability) {
33
- subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer);
34
- }
35
- if ('bufferView' in subtree.contentAvailability) {
36
- subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer);
37
- }
38
- if ('bufferView' in subtree.childSubtreeAvailability) {
39
- subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer);
40
- }
41
- return subtree;
4
+ export default async function parse3DTilesSubtree(data) {
5
+ const magic = new Uint32Array(data.slice(0, 4));
6
+
7
+ if (magic[0] !== SUBTREE_FILE_MAGIC) {
8
+ throw new Error('Wrong subtree file magic number');
9
+ }
10
+
11
+ const version = new Uint32Array(data.slice(4, 8));
12
+
13
+ if (version[0] !== SUBTREE_FILE_VERSION) {
14
+ throw new Error('Wrong subtree file verson, must be 1');
15
+ }
16
+
17
+ const jsonByteLength = parseUint64Value(data.slice(8, 16));
18
+ const stringAttribute = new Uint8Array(data, 24, jsonByteLength);
19
+ const textDecoder = new TextDecoder('utf8');
20
+ const string = textDecoder.decode(stringAttribute);
21
+ const subtree = JSON.parse(string);
22
+ const binaryByteLength = parseUint64Value(data.slice(16, 24));
23
+ let internalBinaryBuffer = new ArrayBuffer(0);
24
+
25
+ if (binaryByteLength) {
26
+ internalBinaryBuffer = data.slice(24 + jsonByteLength);
27
+ }
28
+
29
+ if ('bufferView' in subtree.tileAvailability) {
30
+ subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'tileAvailability', internalBinaryBuffer);
31
+ }
32
+
33
+ if ('bufferView' in subtree.contentAvailability) {
34
+ subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'contentAvailability', internalBinaryBuffer);
35
+ }
36
+
37
+ if ('bufferView' in subtree.childSubtreeAvailability) {
38
+ subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, 'childSubtreeAvailability', internalBinaryBuffer);
39
+ }
40
+
41
+ return subtree;
42
42
  }
43
- exports.default = parse3DTilesSubtree;
44
- /**
45
- * Get explicit bitstream for subtree availability data.
46
- * @param subtree
47
- * @param name
48
- * @param internalBinaryBuffer
49
- */
43
+
50
44
  async function getExplicitBitstream(subtree, name, internalBinaryBuffer) {
51
- const bufferViewIndex = subtree[name].bufferView;
52
- const bufferView = subtree.bufferViews[bufferViewIndex];
53
- const buffer = subtree.buffers[bufferView.buffer];
54
- // External bitstream loading
55
- if (buffer.uri) {
56
- const response = await (0, core_1.fetchFile)(buffer.uri);
57
- const data = await response.arrayBuffer();
58
- // Return view of bitstream.
59
- return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
60
- }
61
- // Return view of bitstream.
62
- return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
45
+ const bufferViewIndex = subtree[name].bufferView;
46
+ const bufferView = subtree.bufferViews[bufferViewIndex];
47
+ const buffer = subtree.buffers[bufferView.buffer];
48
+
49
+ if (buffer.uri) {
50
+ const response = await fetchFile(buffer.uri);
51
+ const data = await response.arrayBuffer();
52
+ return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
53
+ }
54
+
55
+ return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);
63
56
  }
64
- /**
65
- * Parse buffer to return uint64 value
66
- * @param buffer
67
- * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER
68
- */
57
+
69
58
  function parseUint64Value(buffer) {
70
- const dataView = new DataView(buffer);
71
- const left = dataView.getUint32(0, true);
72
- const right = dataView.getUint32(4, true);
73
- // combine the two 32-bit values
74
- return left + 2 ** 32 * right;
59
+ const dataView = new DataView(buffer);
60
+ const left = dataView.getUint32(0, true);
61
+ const right = dataView.getUint32(4, true);
62
+ return left + 2 ** 32 * right;
75
63
  }
64
+ //# sourceMappingURL=parse-3d-tile-subtree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-subtree.ts"],"names":["fetchFile","SUBTREE_FILE_MAGIC","SUBTREE_FILE_VERSION","parse3DTilesSubtree","data","magic","Uint32Array","slice","Error","version","jsonByteLength","parseUint64Value","stringAttribute","Uint8Array","textDecoder","TextDecoder","string","decode","subtree","JSON","parse","binaryByteLength","internalBinaryBuffer","ArrayBuffer","tileAvailability","explicitBitstream","getExplicitBitstream","contentAvailability","childSubtreeAvailability","name","bufferViewIndex","bufferView","bufferViews","buffer","buffers","uri","response","arrayBuffer","byteOffset","byteLength","dataView","DataView","left","getUint32","right"],"mappings":"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","sourcesContent":["import type {Subtree, ExplicitBitstream} from '../../../types';\nimport {fetchFile} from '@loaders.gl/core';\n\nconst SUBTREE_FILE_MAGIC = 0x74627573;\nconst SUBTREE_FILE_VERSION = 1;\n\n/**\n * Parse subtree file\n * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format\n * @param data\n * @returns\n */\n// eslint-disable-next-line max-statements\nexport default async function parse3DTilesSubtree(data: ArrayBuffer): Promise<Subtree> {\n const magic = new Uint32Array(data.slice(0, 4));\n\n if (magic[0] !== SUBTREE_FILE_MAGIC) {\n throw new Error('Wrong subtree file magic number');\n }\n\n const version = new Uint32Array(data.slice(4, 8));\n\n if (version[0] !== SUBTREE_FILE_VERSION) {\n throw new Error('Wrong subtree file verson, must be 1');\n }\n\n const jsonByteLength = parseUint64Value(data.slice(8, 16));\n const stringAttribute = new Uint8Array(data, 24, jsonByteLength);\n\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(stringAttribute);\n const subtree = JSON.parse(string);\n\n const binaryByteLength = parseUint64Value(data.slice(16, 24));\n let internalBinaryBuffer = new ArrayBuffer(0);\n\n if (binaryByteLength) {\n internalBinaryBuffer = data.slice(24 + jsonByteLength);\n }\n\n if ('bufferView' in subtree.tileAvailability) {\n subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'tileAvailability',\n internalBinaryBuffer\n );\n }\n\n if ('bufferView' in subtree.contentAvailability) {\n subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'contentAvailability',\n internalBinaryBuffer\n );\n }\n\n if ('bufferView' in subtree.childSubtreeAvailability) {\n subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(\n subtree,\n 'childSubtreeAvailability',\n internalBinaryBuffer\n );\n }\n\n return subtree;\n}\n\n/**\n * Get explicit bitstream for subtree availability data.\n * @param subtree\n * @param name\n * @param internalBinaryBuffer\n */\nasync function getExplicitBitstream(\n subtree: Subtree,\n name: string,\n internalBinaryBuffer: ArrayBuffer\n): Promise<ExplicitBitstream> {\n const bufferViewIndex = subtree[name].bufferView;\n const bufferView = subtree.bufferViews[bufferViewIndex];\n const buffer = subtree.buffers[bufferView.buffer];\n\n // External bitstream loading\n if (buffer.uri) {\n const response = await fetchFile(buffer.uri);\n const data = await response.arrayBuffer();\n // Return view of bitstream.\n return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);\n }\n // Return view of bitstream.\n return new Uint8Array(internalBinaryBuffer, bufferView.byteOffset, bufferView.byteLength);\n}\n\n/**\n * Parse buffer to return uint64 value\n * @param buffer\n * @returns 64-bit value until precision is lost after Number.MAX_SAFE_INTEGER\n */\nfunction parseUint64Value(buffer: ArrayBuffer): number {\n const dataView = new DataView(buffer);\n const left = dataView.getUint32(0, true);\n const right = dataView.getUint32(4, true);\n // combine the two 32-bit values\n return left + 2 ** 32 * right;\n}\n"],"file":"parse-3d-tile-subtree.js"}
@@ -1,93 +1,89 @@
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");
1
+ import { getStringFromArrayBuffer } from './parse-utils';
7
2
  const SIZEOF_UINT32 = 4;
8
3
  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;
4
+ export function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {
5
+ const view = new DataView(arrayBuffer);
6
+ let batchLength;
7
+ tile.header = tile.header || {};
8
+ let featureTableJsonByteLength = view.getUint32(byteOffset, true);
9
+ byteOffset += SIZEOF_UINT32;
10
+ let featureTableBinaryByteLength = view.getUint32(byteOffset, true);
11
+ byteOffset += SIZEOF_UINT32;
12
+ let batchTableJsonByteLength = view.getUint32(byteOffset, true);
13
+ byteOffset += SIZEOF_UINT32;
14
+ let batchTableBinaryByteLength = view.getUint32(byteOffset, true);
15
+ byteOffset += SIZEOF_UINT32;
16
+
17
+ if (batchTableJsonByteLength >= 570425344) {
18
+ byteOffset -= SIZEOF_UINT32 * 2;
19
+ batchLength = featureTableJsonByteLength;
20
+ batchTableJsonByteLength = featureTableBinaryByteLength;
21
+ batchTableBinaryByteLength = 0;
22
+ featureTableJsonByteLength = 0;
23
+ featureTableBinaryByteLength = 0;
24
+ console.warn(DEPRECATION_WARNING);
25
+ } else if (batchTableBinaryByteLength >= 570425344) {
26
+ byteOffset -= SIZEOF_UINT32;
27
+ batchLength = batchTableJsonByteLength;
28
+ batchTableJsonByteLength = featureTableJsonByteLength;
29
+ batchTableBinaryByteLength = featureTableBinaryByteLength;
30
+ featureTableJsonByteLength = 0;
31
+ featureTableBinaryByteLength = 0;
32
+ console.warn(DEPRECATION_WARNING);
33
+ }
34
+
35
+ tile.header.featureTableJsonByteLength = featureTableJsonByteLength;
36
+ tile.header.featureTableBinaryByteLength = featureTableBinaryByteLength;
37
+ tile.header.batchTableJsonByteLength = batchTableJsonByteLength;
38
+ tile.header.batchTableBinaryByteLength = batchTableBinaryByteLength;
39
+ tile.header.batchLength = batchLength;
40
+ return byteOffset;
50
41
  }
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;
42
+ export function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {
43
+ byteOffset = parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options);
44
+ byteOffset = parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options);
45
+ return byteOffset;
56
46
  }
57
- exports.parse3DTileTablesSync = parse3DTileTablesSync;
47
+
58
48
  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;
49
+ const {
50
+ featureTableJsonByteLength,
51
+ featureTableBinaryByteLength,
52
+ batchLength
53
+ } = tile.header;
54
+ tile.featureTableJson = {
55
+ BATCH_LENGTH: batchLength || 0
56
+ };
57
+
58
+ if (featureTableJsonByteLength > 0) {
59
+ const featureTableString = getStringFromArrayBuffer(arrayBuffer, byteOffset, featureTableJsonByteLength);
60
+ tile.featureTableJson = JSON.parse(featureTableString);
61
+ }
62
+
63
+ byteOffset += featureTableJsonByteLength;
64
+ tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);
65
+ byteOffset += featureTableBinaryByteLength;
66
+ return byteOffset;
77
67
  }
68
+
78
69
  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
- }
70
+ const {
71
+ batchTableJsonByteLength,
72
+ batchTableBinaryByteLength
73
+ } = tile.header;
74
+
75
+ if (batchTableJsonByteLength > 0) {
76
+ const batchTableString = getStringFromArrayBuffer(arrayBuffer, byteOffset, batchTableJsonByteLength);
77
+ tile.batchTableJson = JSON.parse(batchTableString);
78
+ byteOffset += batchTableJsonByteLength;
79
+
80
+ if (batchTableBinaryByteLength > 0) {
81
+ tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);
82
+ tile.batchTableBinary = new Uint8Array(tile.batchTableBinary);
83
+ byteOffset += batchTableBinaryByteLength;
91
84
  }
92
- return byteOffset;
85
+ }
86
+
87
+ return byteOffset;
93
88
  }
89
+ //# sourceMappingURL=parse-3d-tile-tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/parsers/helpers/parse-3d-tile-tables.ts"],"names":["getStringFromArrayBuffer","SIZEOF_UINT32","DEPRECATION_WARNING","parse3DTileTablesHeaderSync","tile","arrayBuffer","byteOffset","view","DataView","batchLength","header","featureTableJsonByteLength","getUint32","featureTableBinaryByteLength","batchTableJsonByteLength","batchTableBinaryByteLength","console","warn","parse3DTileTablesSync","options","parse3DTileFeatureTable","parse3DTileBatchTable","featureTableJson","BATCH_LENGTH","featureTableString","JSON","parse","featureTableBinary","Uint8Array","batchTableString","batchTableJson","batchTableBinary"],"mappings":"AAGA,SAAQA,wBAAR,QAAuC,eAAvC;AAEA,MAAMC,aAAa,GAAG,CAAtB;AACA,MAAMC,mBAAmB,GAAG,6BAA5B;AAGA,OAAO,SAASC,2BAAT,CAAqCC,IAArC,EAA2CC,WAA3C,EAAwDC,UAAxD,EAAoE;AACzE,QAAMC,IAAI,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAb;AACA,MAAII,WAAJ;AAEAL,EAAAA,IAAI,CAACM,MAAL,GAAcN,IAAI,CAACM,MAAL,IAAe,EAA7B;AAEA,MAAIC,0BAA0B,GAAGJ,IAAI,CAACK,SAAL,CAAeN,UAAf,EAA2B,IAA3B,CAAjC;AACAA,EAAAA,UAAU,IAAIL,aAAd;AAEA,MAAIY,4BAA4B,GAAGN,IAAI,CAACK,SAAL,CAAeN,UAAf,EAA2B,IAA3B,CAAnC;AACAA,EAAAA,UAAU,IAAIL,aAAd;AAEA,MAAIa,wBAAwB,GAAGP,IAAI,CAACK,SAAL,CAAeN,UAAf,EAA2B,IAA3B,CAA/B;AACAA,EAAAA,UAAU,IAAIL,aAAd;AAEA,MAAIc,0BAA0B,GAAGR,IAAI,CAACK,SAAL,CAAeN,UAAf,EAA2B,IAA3B,CAAjC;AACAA,EAAAA,UAAU,IAAIL,aAAd;;AAMA,MAAIa,wBAAwB,IAAI,SAAhC,EAA2C;AACzCR,IAAAA,UAAU,IAAIL,aAAa,GAAG,CAA9B;AACAQ,IAAAA,WAAW,GAAGE,0BAAd;AACAG,IAAAA,wBAAwB,GAAGD,4BAA3B;AACAE,IAAAA,0BAA0B,GAAG,CAA7B;AACAJ,IAAAA,0BAA0B,GAAG,CAA7B;AACAE,IAAAA,4BAA4B,GAAG,CAA/B;AAEAG,IAAAA,OAAO,CAACC,IAAR,CAAaf,mBAAb;AACD,GATD,MASO,IAAIa,0BAA0B,IAAI,SAAlC,EAA6C;AAClDT,IAAAA,UAAU,IAAIL,aAAd;AACAQ,IAAAA,WAAW,GAAGK,wBAAd;AACAA,IAAAA,wBAAwB,GAAGH,0BAA3B;AACAI,IAAAA,0BAA0B,GAAGF,4BAA7B;AACAF,IAAAA,0BAA0B,GAAG,CAA7B;AACAE,IAAAA,4BAA4B,GAAG,CAA/B;AAEAG,IAAAA,OAAO,CAACC,IAAR,CAAaf,mBAAb;AACD;;AAEDE,EAAAA,IAAI,CAACM,MAAL,CAAYC,0BAAZ,GAAyCA,0BAAzC;AACAP,EAAAA,IAAI,CAACM,MAAL,CAAYG,4BAAZ,GAA2CA,4BAA3C;AACAT,EAAAA,IAAI,CAACM,MAAL,CAAYI,wBAAZ,GAAuCA,wBAAvC;AACAV,EAAAA,IAAI,CAACM,MAAL,CAAYK,0BAAZ,GAAyCA,0BAAzC;AACAX,EAAAA,IAAI,CAACM,MAAL,CAAYD,WAAZ,GAA0BA,WAA1B;AAEA,SAAOH,UAAP;AACD;AAED,OAAO,SAASY,qBAAT,CAA+Bd,IAA/B,EAAqCC,WAArC,EAAkDC,UAAlD,EAA8Da,OAA9D,EAAuE;AAC5Eb,EAAAA,UAAU,GAAGc,uBAAuB,CAAChB,IAAD,EAAOC,WAAP,EAAoBC,UAApB,EAAgCa,OAAhC,CAApC;AACAb,EAAAA,UAAU,GAAGe,qBAAqB,CAACjB,IAAD,EAAOC,WAAP,EAAoBC,UAApB,EAAgCa,OAAhC,CAAlC;AACA,SAAOb,UAAP;AACD;;AAED,SAASc,uBAAT,CAAiChB,IAAjC,EAAuCC,WAAvC,EAAoDC,UAApD,EAAgEa,OAAhE,EAAyE;AACvE,QAAM;AAACR,IAAAA,0BAAD;AAA6BE,IAAAA,4BAA7B;AAA2DJ,IAAAA;AAA3D,MAA0EL,IAAI,CAACM,MAArF;AAEAN,EAAAA,IAAI,CAACkB,gBAAL,GAAwB;AACtBC,IAAAA,YAAY,EAAEd,WAAW,IAAI;AADP,GAAxB;;AAIA,MAAIE,0BAA0B,GAAG,CAAjC,EAAoC;AAClC,UAAMa,kBAAkB,GAAGxB,wBAAwB,CACjDK,WADiD,EAEjDC,UAFiD,EAGjDK,0BAHiD,CAAnD;AAKAP,IAAAA,IAAI,CAACkB,gBAAL,GAAwBG,IAAI,CAACC,KAAL,CAAWF,kBAAX,CAAxB;AACD;;AACDlB,EAAAA,UAAU,IAAIK,0BAAd;AAEAP,EAAAA,IAAI,CAACuB,kBAAL,GAA0B,IAAIC,UAAJ,CAAevB,WAAf,EAA4BC,UAA5B,EAAwCO,4BAAxC,CAA1B;AACAP,EAAAA,UAAU,IAAIO,4BAAd;AASA,SAAOP,UAAP;AACD;;AAED,SAASe,qBAAT,CAA+BjB,IAA/B,EAAqCC,WAArC,EAAkDC,UAAlD,EAA8Da,OAA9D,EAAuE;AACrE,QAAM;AAACL,IAAAA,wBAAD;AAA2BC,IAAAA;AAA3B,MAAyDX,IAAI,CAACM,MAApE;;AAEA,MAAII,wBAAwB,GAAG,CAA/B,EAAkC;AAChC,UAAMe,gBAAgB,GAAG7B,wBAAwB,CAC/CK,WAD+C,EAE/CC,UAF+C,EAG/CQ,wBAH+C,CAAjD;AAKAV,IAAAA,IAAI,CAAC0B,cAAL,GAAsBL,IAAI,CAACC,KAAL,CAAWG,gBAAX,CAAtB;AACAvB,IAAAA,UAAU,IAAIQ,wBAAd;;AAEA,QAAIC,0BAA0B,GAAG,CAAjC,EAAoC;AAElCX,MAAAA,IAAI,CAAC2B,gBAAL,GAAwB,IAAIH,UAAJ,CAAevB,WAAf,EAA4BC,UAA5B,EAAwCS,0BAAxC,CAAxB;AAEAX,MAAAA,IAAI,CAAC2B,gBAAL,GAAwB,IAAIH,UAAJ,CAAexB,IAAI,CAAC2B,gBAApB,CAAxB;AAEAzB,MAAAA,UAAU,IAAIS,0BAAd;AACD;AACF;;AAED,SAAOT,UAAP;AACD","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 {getStringFromArrayBuffer} from './parse-utils';\n\nconst SIZEOF_UINT32 = 4;\nconst DEPRECATION_WARNING = 'b3dm tile in legacy format.';\n\n// eslint-disable-next-line max-statements\nexport function parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset) {\n const view = new DataView(arrayBuffer);\n let batchLength;\n\n tile.header = tile.header || {};\n\n let featureTableJsonByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let featureTableBinaryByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let batchTableJsonByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n let batchTableBinaryByteLength = view.getUint32(byteOffset, true);\n byteOffset += SIZEOF_UINT32;\n\n // First legacy header format - [batchLength] [batchTableByteLength] ('batchTableJsonByteLength': JSON starts with a quotation mark or the glTF magic)\n // Second legacy format - [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength] (Second legacy format is similar as first but here we check 'batchTableBinaryByteLength' instead)\n // Current header format - [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength]\n // First byte will be 0x22 or 0x67. The minimum uint32 expected is 0x22000000 = 570425344 = 570MB.\n if (batchTableJsonByteLength >= 570425344) {\n byteOffset -= SIZEOF_UINT32 * 2;\n batchLength = featureTableJsonByteLength;\n batchTableJsonByteLength = featureTableBinaryByteLength;\n batchTableBinaryByteLength = 0;\n featureTableJsonByteLength = 0;\n featureTableBinaryByteLength = 0;\n\n console.warn(DEPRECATION_WARNING); // eslint-disable-line\n } else if (batchTableBinaryByteLength >= 570425344) {\n byteOffset -= SIZEOF_UINT32;\n batchLength = batchTableJsonByteLength;\n batchTableJsonByteLength = featureTableJsonByteLength;\n batchTableBinaryByteLength = featureTableBinaryByteLength;\n featureTableJsonByteLength = 0;\n featureTableBinaryByteLength = 0;\n\n console.warn(DEPRECATION_WARNING); // eslint-disable-line\n }\n\n tile.header.featureTableJsonByteLength = featureTableJsonByteLength;\n tile.header.featureTableBinaryByteLength = featureTableBinaryByteLength;\n tile.header.batchTableJsonByteLength = batchTableJsonByteLength;\n tile.header.batchTableBinaryByteLength = batchTableBinaryByteLength;\n tile.header.batchLength = batchLength;\n\n return byteOffset;\n}\n\nexport function parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options) {\n byteOffset = parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options);\n byteOffset = parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options);\n return byteOffset;\n}\n\nfunction parse3DTileFeatureTable(tile, arrayBuffer, byteOffset, options) {\n const {featureTableJsonByteLength, featureTableBinaryByteLength, batchLength} = tile.header;\n\n tile.featureTableJson = {\n BATCH_LENGTH: batchLength || 0\n };\n\n if (featureTableJsonByteLength > 0) {\n const featureTableString = getStringFromArrayBuffer(\n arrayBuffer,\n byteOffset,\n featureTableJsonByteLength\n );\n tile.featureTableJson = JSON.parse(featureTableString);\n }\n byteOffset += featureTableJsonByteLength;\n\n tile.featureTableBinary = new Uint8Array(arrayBuffer, byteOffset, featureTableBinaryByteLength);\n byteOffset += featureTableBinaryByteLength;\n\n /*\n const featureTable = parseFeatureTable(featureTableJson, featureTableBinary);\n\n const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');\n featureTable.featuresLength = batchLength;\n */\n\n return byteOffset;\n}\n\nfunction parse3DTileBatchTable(tile, arrayBuffer, byteOffset, options) {\n const {batchTableJsonByteLength, batchTableBinaryByteLength} = tile.header;\n\n if (batchTableJsonByteLength > 0) {\n const batchTableString = getStringFromArrayBuffer(\n arrayBuffer,\n byteOffset,\n batchTableJsonByteLength\n );\n tile.batchTableJson = JSON.parse(batchTableString);\n byteOffset += batchTableJsonByteLength;\n\n if (batchTableBinaryByteLength > 0) {\n // Has a batch table binary\n tile.batchTableBinary = new Uint8Array(arrayBuffer, byteOffset, batchTableBinaryByteLength);\n // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed\n tile.batchTableBinary = new Uint8Array(tile.batchTableBinary);\n\n byteOffset += batchTableBinaryByteLength;\n }\n }\n\n return byteOffset;\n}\n"],"file":"parse-3d-tile-tables.js"}
@@ -1,32 +1,19 @@
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.getMagicString = exports.getStringFromTypedArray = exports.getStringFromArrayBuffer = void 0;
6
- const loader_utils_1 = require("@loaders.gl/loader-utils");
7
- // Decode the JSON binary array into clear text
8
- function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {
9
- (0, loader_utils_1.assert)(arrayBuffer instanceof ArrayBuffer);
10
- const textDecoder = new TextDecoder('utf8');
11
- const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);
12
- const string = textDecoder.decode(typedArray);
13
- return string;
1
+ import { assert } from '@loaders.gl/loader-utils';
2
+ export function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {
3
+ assert(arrayBuffer instanceof ArrayBuffer);
4
+ const textDecoder = new TextDecoder('utf8');
5
+ const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);
6
+ const string = textDecoder.decode(typedArray);
7
+ return string;
14
8
  }
15
- exports.getStringFromArrayBuffer = getStringFromArrayBuffer;
16
- // Decode the JSON binary array into clear text
17
- function getStringFromTypedArray(typedArray) {
18
- (0, loader_utils_1.assert)(ArrayBuffer.isView(typedArray));
19
- const textDecoder = new TextDecoder('utf8');
20
- const string = textDecoder.decode(typedArray);
21
- return string;
9
+ export function getStringFromTypedArray(typedArray) {
10
+ assert(ArrayBuffer.isView(typedArray));
11
+ const textDecoder = new TextDecoder('utf8');
12
+ const string = textDecoder.decode(typedArray);
13
+ return string;
22
14
  }
23
- exports.getStringFromTypedArray = getStringFromTypedArray;
24
- function getMagicString(arrayBuffer, byteOffset = 0) {
25
- const dataView = new DataView(arrayBuffer);
26
- return `\
27
- ${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\
28
- ${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\
29
- ${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\
30
- ${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;
15
+ export function getMagicString(arrayBuffer, byteOffset = 0) {
16
+ const dataView = new DataView(arrayBuffer);
17
+ return "".concat(String.fromCharCode(dataView.getUint8(byteOffset + 0))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 1))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 2))).concat(String.fromCharCode(dataView.getUint8(byteOffset + 3)));
31
18
  }
32
- exports.getMagicString = getMagicString;
19
+ //# sourceMappingURL=parse-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/parsers/helpers/parse-utils.ts"],"names":["assert","getStringFromArrayBuffer","arrayBuffer","byteOffset","byteLength","ArrayBuffer","textDecoder","TextDecoder","typedArray","Uint8Array","string","decode","getStringFromTypedArray","isView","getMagicString","dataView","DataView","String","fromCharCode","getUint8"],"mappings":"AAGA,SAAQA,MAAR,QAAqB,0BAArB;AAGA,OAAO,SAASC,wBAAT,CAAkCC,WAAlC,EAA+CC,UAA/C,EAA2DC,UAA3D,EAAuE;AAC5EJ,EAAAA,MAAM,CAACE,WAAW,YAAYG,WAAxB,CAAN;AACA,QAAMC,WAAW,GAAG,IAAIC,WAAJ,CAAgB,MAAhB,CAApB;AACA,QAAMC,UAAU,GAAG,IAAIC,UAAJ,CAAeP,WAAf,EAA4BC,UAA5B,EAAwCC,UAAxC,CAAnB;AACA,QAAMM,MAAM,GAAGJ,WAAW,CAACK,MAAZ,CAAmBH,UAAnB,CAAf;AACA,SAAOE,MAAP;AACD;AAGD,OAAO,SAASE,uBAAT,CAAiCJ,UAAjC,EAA6C;AAClDR,EAAAA,MAAM,CAACK,WAAW,CAACQ,MAAZ,CAAmBL,UAAnB,CAAD,CAAN;AACA,QAAMF,WAAW,GAAG,IAAIC,WAAJ,CAAgB,MAAhB,CAApB;AACA,QAAMG,MAAM,GAAGJ,WAAW,CAACK,MAAZ,CAAmBH,UAAnB,CAAf;AACA,SAAOE,MAAP;AACD;AAED,OAAO,SAASI,cAAT,CAAwBZ,WAAxB,EAAqCC,UAAU,GAAG,CAAlD,EAAqD;AAC1D,QAAMY,QAAQ,GAAG,IAAIC,QAAJ,CAAad,WAAb,CAAjB;AACA,mBACAe,MAAM,CAACC,YAAP,CAAoBH,QAAQ,CAACI,QAAT,CAAkBhB,UAAU,GAAG,CAA/B,CAApB,CADA,SAEAc,MAAM,CAACC,YAAP,CAAoBH,QAAQ,CAACI,QAAT,CAAkBhB,UAAU,GAAG,CAA/B,CAApB,CAFA,SAGAc,MAAM,CAACC,YAAP,CAAoBH,QAAQ,CAACI,QAAT,CAAkBhB,UAAU,GAAG,CAA/B,CAApB,CAHA,SAIAc,MAAM,CAACC,YAAP,CAAoBH,QAAQ,CAACI,QAAT,CAAkBhB,UAAU,GAAG,CAA/B,CAApB,CAJA;AAKD","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 {assert} from '@loaders.gl/loader-utils';\n\n// Decode the JSON binary array into clear text\nexport function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {\n assert(arrayBuffer instanceof ArrayBuffer);\n const textDecoder = new TextDecoder('utf8');\n const typedArray = new Uint8Array(arrayBuffer, byteOffset, byteLength);\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\n// Decode the JSON binary array into clear text\nexport function getStringFromTypedArray(typedArray) {\n assert(ArrayBuffer.isView(typedArray));\n const textDecoder = new TextDecoder('utf8');\n const string = textDecoder.decode(typedArray);\n return string;\n}\n\nexport function getMagicString(arrayBuffer, byteOffset = 0) {\n const dataView = new DataView(arrayBuffer);\n return `\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 0))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 1))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 2))}\\\n${String.fromCharCode(dataView.getUint8(byteOffset + 3))}`;\n}\n"],"file":"parse-utils.js"}
@@ -1,33 +1,29 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.parseBatchedModel3DTile = void 0;
9
- const math_1 = require("@loaders.gl/math"); // math.gl/geometry;
10
- const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
11
- // import Tile3DBatchTable from '../classes/tile-3d-batch-table.js';
12
- const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
13
- const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
14
- const parse_3d_tile_gltf_view_1 = require("./helpers/parse-3d-tile-gltf-view");
15
- async function parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
16
- byteOffset = parseBatchedModel(tile, arrayBuffer, byteOffset, options, context);
17
- await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, parse_3d_tile_gltf_view_1.GLTF_FORMAT.EMBEDDED, options, context);
18
- const extensions = tile?.gltf?.extensions;
19
- if (extensions && extensions.CESIUM_RTC) {
20
- tile.rtcCenter = extensions.CESIUM_RTC.center;
21
- }
22
- return byteOffset;
1
+ import { GL } from '@loaders.gl/math';
2
+ import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
3
+ import { parse3DTileHeaderSync } from './helpers/parse-3d-tile-header';
4
+ import { parse3DTileTablesHeaderSync, parse3DTileTablesSync } from './helpers/parse-3d-tile-tables';
5
+ import { parse3DTileGLTFViewSync, extractGLTF, GLTF_FORMAT } from './helpers/parse-3d-tile-gltf-view';
6
+ export async function parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
7
+ var _tile$gltf;
8
+
9
+ byteOffset = parseBatchedModel(tile, arrayBuffer, byteOffset, options, context);
10
+ await extractGLTF(tile, GLTF_FORMAT.EMBEDDED, options, context);
11
+ const extensions = tile === null || tile === void 0 ? void 0 : (_tile$gltf = tile.gltf) === null || _tile$gltf === void 0 ? void 0 : _tile$gltf.extensions;
12
+
13
+ if (extensions && extensions.CESIUM_RTC) {
14
+ tile.rtcCenter = extensions.CESIUM_RTC.center;
15
+ }
16
+
17
+ return byteOffset;
23
18
  }
24
- exports.parseBatchedModel3DTile = parseBatchedModel3DTile;
19
+
25
20
  function parseBatchedModel(tile, arrayBuffer, byteOffset, options, context) {
26
- byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
27
- byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
28
- byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
29
- byteOffset = (0, parse_3d_tile_gltf_view_1.parse3DTileGLTFViewSync)(tile, arrayBuffer, byteOffset, options);
30
- const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
31
- tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
32
- return byteOffset;
21
+ byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
22
+ byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
23
+ byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
24
+ byteOffset = parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options);
25
+ const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
26
+ tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);
27
+ return byteOffset;
33
28
  }
29
+ //# sourceMappingURL=parse-3d-tile-batched-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/parsers/parse-3d-tile-batched-model.ts"],"names":["GL","Tile3DFeatureTable","parse3DTileHeaderSync","parse3DTileTablesHeaderSync","parse3DTileTablesSync","parse3DTileGLTFViewSync","extractGLTF","GLTF_FORMAT","parseBatchedModel3DTile","tile","arrayBuffer","byteOffset","options","context","parseBatchedModel","EMBEDDED","extensions","gltf","CESIUM_RTC","rtcCenter","center","featureTable","featureTableJson","featureTableBinary","getGlobalProperty","FLOAT"],"mappings":"AAGA,SAAQA,EAAR,QAAiB,kBAAjB;AACA,OAAOC,kBAAP,MAA+B,kCAA/B;AAGA,SAAQC,qBAAR,QAAoC,gCAApC;AACA,SAAQC,2BAAR,EAAqCC,qBAArC,QAAiE,gCAAjE;AACA,SAAQC,uBAAR,EAAiCC,WAAjC,EAA8CC,WAA9C,QAAgE,mCAAhE;AAEA,OAAO,eAAeC,uBAAf,CAAuCC,IAAvC,EAA6CC,WAA7C,EAA0DC,UAA1D,EAAsEC,OAAtE,EAA+EC,OAA/E,EAAwF;AAAA;;AAC7FF,EAAAA,UAAU,GAAGG,iBAAiB,CAACL,IAAD,EAAOC,WAAP,EAAoBC,UAApB,EAAgCC,OAAhC,EAAyCC,OAAzC,CAA9B;AACA,QAAMP,WAAW,CAACG,IAAD,EAAOF,WAAW,CAACQ,QAAnB,EAA6BH,OAA7B,EAAsCC,OAAtC,CAAjB;AAEA,QAAMG,UAAU,GAAGP,IAAH,aAAGA,IAAH,qCAAGA,IAAI,CAAEQ,IAAT,+CAAG,WAAYD,UAA/B;;AACA,MAAIA,UAAU,IAAIA,UAAU,CAACE,UAA7B,EAAyC;AACvCT,IAAAA,IAAI,CAACU,SAAL,GAAiBH,UAAU,CAACE,UAAX,CAAsBE,MAAvC;AACD;;AAED,SAAOT,UAAP;AACD;;AAED,SAASG,iBAAT,CAA2BL,IAA3B,EAAiCC,WAAjC,EAA8CC,UAA9C,EAA0DC,OAA1D,EAAmEC,OAAnE,EAA4E;AAC1EF,EAAAA,UAAU,GAAGT,qBAAqB,CAACO,IAAD,EAAOC,WAAP,EAAoBC,UAApB,CAAlC;AAEAA,EAAAA,UAAU,GAAGR,2BAA2B,CAACM,IAAD,EAAOC,WAAP,EAAoBC,UAApB,CAAxC;AACAA,EAAAA,UAAU,GAAGP,qBAAqB,CAACK,IAAD,EAAOC,WAAP,EAAoBC,UAApB,EAAgCC,OAAhC,CAAlC;AAEAD,EAAAA,UAAU,GAAGN,uBAAuB,CAACI,IAAD,EAAOC,WAAP,EAAoBC,UAApB,EAAgCC,OAAhC,CAApC;AAEA,QAAMS,YAAY,GAAG,IAAIpB,kBAAJ,CAAuBQ,IAAI,CAACa,gBAA5B,EAA8Cb,IAAI,CAACc,kBAAnD,CAArB;AACAd,EAAAA,IAAI,CAACU,SAAL,GAAiBE,YAAY,CAACG,iBAAb,CAA+B,YAA/B,EAA6CxB,EAAE,CAACyB,KAAhD,EAAuD,CAAvD,CAAjB;AAEA,SAAOd,UAAP;AACD","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 {GL} from '@loaders.gl/math'; // math.gl/geometry;\nimport Tile3DFeatureTable from '../classes/tile-3d-feature-table';\n// import Tile3DBatchTable from '../classes/tile-3d-batch-table';\n\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\nimport {parse3DTileTablesHeaderSync, parse3DTileTablesSync} from './helpers/parse-3d-tile-tables';\nimport {parse3DTileGLTFViewSync, extractGLTF, GLTF_FORMAT} from './helpers/parse-3d-tile-gltf-view';\n\nexport async function parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {\n byteOffset = parseBatchedModel(tile, arrayBuffer, byteOffset, options, context);\n await extractGLTF(tile, GLTF_FORMAT.EMBEDDED, options, context);\n\n const extensions = tile?.gltf?.extensions;\n if (extensions && extensions.CESIUM_RTC) {\n tile.rtcCenter = extensions.CESIUM_RTC.center;\n }\n\n return byteOffset;\n}\n\nfunction parseBatchedModel(tile, arrayBuffer, byteOffset, options, context) {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n\n byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);\n byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);\n\n byteOffset = parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options);\n\n const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);\n tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);\n\n return byteOffset;\n}\n"],"file":"parse-3d-tile-batched-model.js"}
@@ -1,26 +1,17 @@
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.parseComposite3DTile = void 0;
6
- // Reference code:
7
- // https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Composite3DTileContent.js#L182
8
- const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
9
- // eslint-disable-next-line max-params
10
- async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile) {
11
- byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
12
- const view = new DataView(arrayBuffer);
13
- // Extract number of tiles
14
- tile.tilesLength = view.getUint32(byteOffset, true);
15
- byteOffset += 4;
16
- // extract each tile from the byte stream
17
- tile.tiles = [];
18
- while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {
19
- const subtile = {};
20
- tile.tiles.push(subtile);
21
- byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);
22
- // TODO - do we need to add any padding in between tiles?
23
- }
24
- return byteOffset;
1
+ import { parse3DTileHeaderSync } from './helpers/parse-3d-tile-header';
2
+ export async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile) {
3
+ byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
4
+ const view = new DataView(arrayBuffer);
5
+ tile.tilesLength = view.getUint32(byteOffset, true);
6
+ byteOffset += 4;
7
+ tile.tiles = [];
8
+
9
+ while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {
10
+ const subtile = {};
11
+ tile.tiles.push(subtile);
12
+ byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);
13
+ }
14
+
15
+ return byteOffset;
25
16
  }
26
- exports.parseComposite3DTile = parseComposite3DTile;
17
+ //# sourceMappingURL=parse-3d-tile-composite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":["parse3DTileHeaderSync","parseComposite3DTile","tile","arrayBuffer","byteOffset","options","context","parse3DTile","view","DataView","tilesLength","getUint32","tiles","length","byteLength","subtile","push"],"mappings":"AAMA,SAAQA,qBAAR,QAAoC,gCAApC;AAGA,OAAO,eAAeC,oBAAf,CACLC,IADK,EAELC,WAFK,EAGLC,UAHK,EAILC,OAJK,EAKLC,OALK,EAMLC,WANK,EAOL;AACAH,EAAAA,UAAU,GAAGJ,qBAAqB,CAACE,IAAD,EAAOC,WAAP,EAAoBC,UAApB,CAAlC;AAEA,QAAMI,IAAI,GAAG,IAAIC,QAAJ,CAAaN,WAAb,CAAb;AAGAD,EAAAA,IAAI,CAACQ,WAAL,GAAmBF,IAAI,CAACG,SAAL,CAAeP,UAAf,EAA2B,IAA3B,CAAnB;AACAA,EAAAA,UAAU,IAAI,CAAd;AAGAF,EAAAA,IAAI,CAACU,KAAL,GAAa,EAAb;;AACA,SAAOV,IAAI,CAACU,KAAL,CAAWC,MAAX,GAAoBX,IAAI,CAACQ,WAAzB,IAAwCR,IAAI,CAACY,UAAL,GAAkBV,UAAlB,GAA+B,EAA9E,EAAkF;AAChF,UAAMW,OAAO,GAAG,EAAhB;AACAb,IAAAA,IAAI,CAACU,KAAL,CAAWI,IAAX,CAAgBD,OAAhB;AACAX,IAAAA,UAAU,GAAG,MAAMG,WAAW,CAACJ,WAAD,EAAcC,UAAd,EAA0BC,OAA1B,EAAmCC,OAAnC,EAA4CS,OAA5C,CAA9B;AAED;;AAED,SAAOX,UAAP;AACD","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// Reference code:\n// https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Composite3DTileContent.js#L182\n\nimport {parse3DTileHeaderSync} from './helpers/parse-3d-tile-header';\n\n// eslint-disable-next-line max-params\nexport async function parseComposite3DTile(\n tile,\n arrayBuffer,\n byteOffset,\n options,\n context,\n parse3DTile\n) {\n byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);\n\n const view = new DataView(arrayBuffer);\n\n // Extract number of tiles\n tile.tilesLength = view.getUint32(byteOffset, true);\n byteOffset += 4;\n\n // extract each tile from the byte stream\n tile.tiles = [];\n while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {\n const subtile = {};\n tile.tiles.push(subtile);\n byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);\n // TODO - do we need to add any padding in between tiles?\n }\n\n return byteOffset;\n}\n"],"file":"parse-3d-tile-composite.js"}