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

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 (327) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/cesium-ion-loader.d.ts.map +1 -1
  3. package/dist/cesium-ion-loader.js +37 -32
  4. package/dist/dist.min.js +5345 -2938
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/cesium-ion-loader.js +77 -0
  8. package/dist/es5/cesium-ion-loader.js.map +1 -0
  9. package/dist/es5/index.js +63 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +114 -0
  12. package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  13. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +180 -0
  14. package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  15. package/dist/es5/lib/classes/tile-3d-batch-table.js +285 -0
  16. package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -0
  17. package/dist/es5/lib/classes/tile-3d-feature-table.js +97 -0
  18. package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -0
  19. package/dist/es5/lib/constants.js +32 -0
  20. package/dist/es5/lib/constants.js.map +1 -0
  21. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +49 -0
  22. package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  23. package/dist/es5/lib/encoders/encode-3d-tile-composite.js +30 -0
  24. package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  25. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +47 -0
  26. package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  27. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +48 -0
  28. package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  29. package/dist/es5/lib/encoders/encode-3d-tile.js +35 -0
  30. package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -0
  31. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +35 -0
  32. package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  33. package/dist/es5/lib/ion/ion.js +170 -0
  34. package/dist/es5/lib/ion/ion.js.map +1 -0
  35. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +64 -0
  36. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  37. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +32 -0
  38. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  39. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +32 -0
  40. package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  41. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +280 -0
  42. package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  43. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +98 -0
  44. package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  45. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +22 -0
  46. package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  47. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +145 -0
  48. package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  49. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +85 -0
  50. package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  51. package/dist/es5/lib/parsers/helpers/parse-utils.js +28 -0
  52. package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -0
  53. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +51 -0
  54. package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  55. package/dist/es5/lib/parsers/parse-3d-tile-composite.js +48 -0
  56. package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  57. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +37 -0
  58. package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  59. package/dist/es5/lib/parsers/parse-3d-tile-header.js +271 -0
  60. package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -0
  61. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +172 -0
  62. package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
  63. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +271 -0
  64. package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  65. package/dist/es5/lib/parsers/parse-3d-tile.js +74 -0
  66. package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -0
  67. package/dist/es5/lib/utils/obb/s2-corners-to-obb.js +30 -0
  68. package/dist/es5/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
  69. package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js +44 -0
  70. package/dist/es5/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
  71. package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js +30 -0
  72. package/dist/es5/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
  73. package/dist/es5/lib/utils/s2/converters/s2-to-region.js +52 -0
  74. package/dist/es5/lib/utils/s2/converters/s2-to-region.js.map +1 -0
  75. package/dist/es5/lib/utils/s2/index.js +90 -0
  76. package/dist/es5/lib/utils/s2/index.js.map +1 -0
  77. package/dist/es5/lib/utils/s2/s2-geometry-functions.js +19 -0
  78. package/dist/es5/lib/utils/s2/s2-geometry-functions.js.map +1 -0
  79. package/dist/es5/lib/utils/s2/s2-token-functions.js +41 -0
  80. package/dist/es5/lib/utils/s2/s2-token-functions.js.map +1 -0
  81. package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js +22 -0
  82. package/dist/es5/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
  83. package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js +207 -0
  84. package/dist/es5/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
  85. package/dist/es5/lib/utils/version.js +9 -0
  86. package/dist/es5/lib/utils/version.js.map +1 -0
  87. package/dist/es5/tile-3d-subtree-loader.js +22 -0
  88. package/dist/es5/tile-3d-subtree-loader.js.map +1 -0
  89. package/dist/es5/tile-3d-writer.js +26 -0
  90. package/dist/es5/tile-3d-writer.js.map +1 -0
  91. package/dist/es5/tiles-3d-loader.js +138 -0
  92. package/dist/es5/tiles-3d-loader.js.map +1 -0
  93. package/dist/es5/types.js +2 -0
  94. package/dist/es5/types.js.map +1 -0
  95. package/dist/esm/bundle.js +4 -0
  96. package/dist/esm/bundle.js.map +1 -0
  97. package/dist/esm/cesium-ion-loader.js +36 -0
  98. package/dist/esm/cesium-ion-loader.js.map +1 -0
  99. package/dist/esm/index.js +9 -0
  100. package/dist/esm/index.js.map +1 -0
  101. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js +96 -0
  102. package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -0
  103. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js +171 -0
  104. package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -0
  105. package/dist/esm/lib/classes/tile-3d-batch-table.js +231 -0
  106. package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -0
  107. package/dist/esm/lib/classes/tile-3d-feature-table.js +70 -0
  108. package/dist/esm/lib/classes/tile-3d-feature-table.js.map +1 -0
  109. package/dist/esm/lib/constants.js +22 -0
  110. package/dist/esm/lib/constants.js.map +1 -0
  111. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js +40 -0
  112. package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +1 -0
  113. package/dist/esm/lib/encoders/encode-3d-tile-composite.js +21 -0
  114. package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +1 -0
  115. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js +36 -0
  116. package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -0
  117. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js +39 -0
  118. package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -0
  119. package/dist/esm/lib/encoders/encode-3d-tile.js +29 -0
  120. package/dist/esm/lib/encoders/encode-3d-tile.js.map +1 -0
  121. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js +28 -0
  122. package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -0
  123. package/dist/esm/lib/ion/ion.js +70 -0
  124. package/dist/esm/lib/ion/ion.js.map +1 -0
  125. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +58 -0
  126. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -0
  127. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -0
  128. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -0
  129. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js +26 -0
  130. package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -0
  131. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +241 -0
  132. package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
  133. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +61 -0
  134. package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -0
  135. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js +16 -0
  136. package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -0
  137. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +67 -0
  138. package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
  139. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +80 -0
  140. package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -0
  141. package/dist/esm/lib/parsers/helpers/parse-utils.js +20 -0
  142. package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -0
  143. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js +25 -0
  144. package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -0
  145. package/dist/esm/lib/parsers/parse-3d-tile-composite.js +15 -0
  146. package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -0
  147. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +12 -0
  148. package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
  149. package/dist/esm/lib/parsers/parse-3d-tile-header.js +164 -0
  150. package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -0
  151. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +147 -0
  152. package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -0
  153. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +211 -0
  154. package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -0
  155. package/dist/esm/lib/parsers/parse-3d-tile.js +30 -0
  156. package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -0
  157. package/dist/esm/lib/utils/obb/s2-corners-to-obb.js +23 -0
  158. package/dist/esm/lib/utils/obb/s2-corners-to-obb.js.map +1 -0
  159. package/dist/esm/lib/utils/s2/converters/s2-to-boundary.js +40 -0
  160. package/dist/esm/lib/utils/s2/converters/s2-to-boundary.js.map +1 -0
  161. package/dist/esm/lib/utils/s2/converters/s2-to-obb-points.js +24 -0
  162. package/dist/esm/lib/utils/s2/converters/s2-to-obb-points.js.map +1 -0
  163. package/dist/esm/lib/utils/s2/converters/s2-to-region.js +42 -0
  164. package/dist/esm/lib/utils/s2/converters/s2-to-region.js.map +1 -0
  165. package/dist/esm/lib/utils/s2/index.js +7 -0
  166. package/dist/esm/lib/utils/s2/index.js.map +1 -0
  167. package/dist/esm/lib/utils/s2/s2-geometry-functions.js +12 -0
  168. package/dist/esm/lib/utils/s2/s2-geometry-functions.js.map +1 -0
  169. package/dist/esm/lib/utils/s2/s2-token-functions.js +32 -0
  170. package/dist/esm/lib/utils/s2/s2-token-functions.js.map +1 -0
  171. package/dist/esm/lib/utils/s2/s2geometry/s2-cell-utils.js +15 -0
  172. package/dist/esm/lib/utils/s2/s2geometry/s2-cell-utils.js.map +1 -0
  173. package/dist/esm/lib/utils/s2/s2geometry/s2-geometry.js +186 -0
  174. package/dist/esm/lib/utils/s2/s2geometry/s2-geometry.js.map +1 -0
  175. package/dist/esm/lib/utils/version.js +2 -0
  176. package/dist/esm/lib/utils/version.js.map +1 -0
  177. package/dist/esm/tile-3d-subtree-loader.js +14 -0
  178. package/dist/esm/tile-3d-subtree-loader.js.map +1 -0
  179. package/dist/esm/tile-3d-writer.js +19 -0
  180. package/dist/esm/tile-3d-writer.js.map +1 -0
  181. package/dist/esm/tiles-3d-loader.js +62 -0
  182. package/dist/esm/tiles-3d-loader.js.map +1 -0
  183. package/dist/esm/types.js +2 -0
  184. package/dist/esm/types.js.map +1 -0
  185. package/dist/index.d.ts +1 -1
  186. package/dist/index.d.ts.map +1 -1
  187. package/dist/index.js +26 -9
  188. package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts +1 -1
  189. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +106 -89
  190. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +184 -202
  191. package/dist/lib/classes/tile-3d-batch-table.d.ts +1 -1
  192. package/dist/lib/classes/tile-3d-batch-table.js +223 -282
  193. package/dist/lib/classes/tile-3d-feature-table.js +64 -86
  194. package/dist/lib/constants.js +23 -19
  195. package/dist/lib/encoders/encode-3d-tile-batched-model.js +45 -45
  196. package/dist/lib/encoders/encode-3d-tile-composite.js +23 -24
  197. package/dist/lib/encoders/encode-3d-tile-instanced-model.js +37 -37
  198. package/dist/lib/encoders/encode-3d-tile-point-cloud.js +36 -38
  199. package/dist/lib/encoders/encode-3d-tile.js +30 -32
  200. package/dist/lib/encoders/helpers/encode-3d-tile-header.js +28 -29
  201. package/dist/lib/ion/ion.js +60 -69
  202. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +60 -62
  203. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +26 -26
  204. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +39 -28
  205. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +11 -0
  206. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
  207. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +247 -203
  208. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
  209. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +84 -63
  210. package/dist/lib/parsers/helpers/parse-3d-tile-header.js +26 -15
  211. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +2 -1
  212. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
  213. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +98 -58
  214. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +84 -80
  215. package/dist/lib/parsers/helpers/parse-utils.js +29 -16
  216. package/dist/lib/parsers/parse-3d-tile-batched-model.js +30 -26
  217. package/dist/lib/parsers/parse-3d-tile-composite.d.ts +6 -1
  218. package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
  219. package/dist/lib/parsers/parse-3d-tile-composite.js +23 -16
  220. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +3 -1
  221. package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
  222. package/dist/lib/parsers/parse-3d-tile-gltf.js +19 -9
  223. package/dist/lib/parsers/parse-3d-tile-header.d.ts +6 -4
  224. package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
  225. package/dist/lib/parsers/parse-3d-tile-header.js +166 -138
  226. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +3 -1
  227. package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
  228. package/dist/lib/parsers/parse-3d-tile-instanced-model.js +179 -170
  229. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +4 -2
  230. package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
  231. package/dist/lib/parsers/parse-3d-tile-point-cloud.js +351 -184
  232. package/dist/lib/parsers/parse-3d-tile.js +36 -31
  233. package/dist/lib/utils/obb/s2-corners-to-obb.d.ts +15 -0
  234. package/dist/lib/utils/obb/s2-corners-to-obb.d.ts.map +1 -0
  235. package/dist/lib/utils/obb/s2-corners-to-obb.js +37 -0
  236. package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts +9 -0
  237. package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts.map +1 -0
  238. package/dist/lib/utils/s2/converters/s2-to-boundary.js +61 -0
  239. package/dist/lib/utils/s2/converters/s2-to-obb-points.d.ts +15 -0
  240. package/dist/lib/utils/s2/converters/s2-to-obb-points.d.ts.map +1 -0
  241. package/dist/lib/utils/s2/converters/s2-to-obb-points.js +36 -0
  242. package/dist/lib/utils/s2/converters/s2-to-region.d.ts +13 -0
  243. package/dist/lib/utils/s2/converters/s2-to-region.d.ts.map +1 -0
  244. package/dist/lib/utils/s2/converters/s2-to-region.js +59 -0
  245. package/dist/lib/utils/s2/index.d.ts +8 -0
  246. package/dist/lib/utils/s2/index.d.ts.map +1 -0
  247. package/dist/lib/utils/s2/index.js +23 -0
  248. package/dist/lib/utils/s2/s2-geometry-functions.d.ts +14 -0
  249. package/dist/lib/utils/s2/s2-geometry-functions.d.ts.map +1 -0
  250. package/dist/lib/utils/s2/s2-geometry-functions.js +29 -0
  251. package/dist/lib/utils/s2/s2-token-functions.d.ts +23 -0
  252. package/dist/lib/utils/s2/s2-token-functions.d.ts.map +1 -0
  253. package/dist/lib/utils/s2/s2-token-functions.js +68 -0
  254. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts +14 -0
  255. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts.map +1 -0
  256. package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +32 -0
  257. package/dist/lib/utils/s2/s2geometry/s2-geometry.d.ts +52 -0
  258. package/dist/lib/utils/s2/s2geometry/s2-geometry.d.ts.map +1 -0
  259. package/dist/lib/utils/s2/s2geometry/s2-geometry.js +260 -0
  260. package/dist/lib/utils/version.js +7 -2
  261. package/dist/tile-3d-subtree-loader.js +22 -13
  262. package/dist/tile-3d-writer.js +24 -17
  263. package/dist/tiles-3d-loader.d.ts +15 -1
  264. package/dist/tiles-3d-loader.d.ts.map +1 -1
  265. package/dist/tiles-3d-loader.js +67 -71
  266. package/dist/types.d.ts +28 -15
  267. package/dist/types.d.ts.map +1 -1
  268. package/dist/types.js +2 -2
  269. package/package.json +12 -11
  270. package/src/cesium-ion-loader.ts +1 -0
  271. package/src/index.ts +1 -1
  272. package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +104 -27
  273. package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +4 -2
  274. package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +50 -7
  275. package/src/lib/parsers/parse-3d-tile-composite.ts +17 -6
  276. package/src/lib/parsers/parse-3d-tile-gltf.ts +25 -0
  277. package/src/lib/parsers/parse-3d-tile-header.ts +93 -24
  278. package/src/lib/parsers/parse-3d-tile-instanced-model.ts +17 -3
  279. package/src/lib/parsers/parse-3d-tile-point-cloud.ts +37 -10
  280. package/src/lib/utils/obb/s2-corners-to-obb.ts +51 -0
  281. package/src/lib/utils/s2/converters/s2-to-boundary.ts +67 -0
  282. package/src/lib/utils/s2/converters/s2-to-obb-points.ts +46 -0
  283. package/src/lib/utils/s2/converters/s2-to-region.ts +69 -0
  284. package/src/lib/utils/s2/index.ts +17 -0
  285. package/src/lib/utils/s2/s2-geometry-functions.ts +28 -0
  286. package/src/lib/utils/s2/s2-token-functions.ts +67 -0
  287. package/src/lib/utils/s2/s2geometry/s2-cell-utils.ts +33 -0
  288. package/src/lib/utils/s2/s2geometry/s2-geometry.ts +296 -0
  289. package/src/tiles-3d-loader.ts +64 -46
  290. package/src/types.ts +20 -5
  291. package/dist/bundle.js.map +0 -1
  292. package/dist/cesium-ion-loader.js.map +0 -1
  293. package/dist/index.js.map +0 -1
  294. package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
  295. package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
  296. package/dist/lib/classes/tile-3d-batch-table.js.map +0 -1
  297. package/dist/lib/classes/tile-3d-feature-table.js.map +0 -1
  298. package/dist/lib/constants.js.map +0 -1
  299. package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
  300. package/dist/lib/encoders/encode-3d-tile-composite.js.map +0 -1
  301. package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
  302. package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
  303. package/dist/lib/encoders/encode-3d-tile.js.map +0 -1
  304. package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
  305. package/dist/lib/ion/ion.js.map +0 -1
  306. package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
  307. package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
  308. package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
  309. package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
  310. package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
  311. package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
  312. package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
  313. package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
  314. package/dist/lib/parsers/helpers/parse-utils.js.map +0 -1
  315. package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
  316. package/dist/lib/parsers/parse-3d-tile-composite.js.map +0 -1
  317. package/dist/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
  318. package/dist/lib/parsers/parse-3d-tile-header.js.map +0 -1
  319. package/dist/lib/parsers/parse-3d-tile-instanced-model.js.map +0 -1
  320. package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
  321. package/dist/lib/parsers/parse-3d-tile.js.map +0 -1
  322. package/dist/lib/utils/version.js.map +0 -1
  323. package/dist/tile-3d-subtree-loader.js.map +0 -1
  324. package/dist/tile-3d-writer.js.map +0 -1
  325. package/dist/tiles-3d-loader.js.map +0 -1
  326. package/dist/types.js.map +0 -1
  327. package/src/lib/parsers/parse-3d-tile-gltf.js +0 -16
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ // math.gl, MIT license
3
+ /*
4
+ Adapted from s2-geometry under ISC License (ISC)
5
+ Copyright (c) 2012-2016, Jon Atkins <github@jonatkins.com>
6
+ Copyright (c) 2016, AJ ONeal <aj@daplie.com>
7
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
9
+ */
10
+ var __importDefault = (this && this.__importDefault) || function (mod) {
11
+ return (mod && mod.__esModule) ? mod : { "default": mod };
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getCornerLngLats = exports.getS2LngLatFromS2Cell = exports.XYZToLngLat = exports.FaceUVToXYZ = exports.STToUV = exports.IJToST = exports.getS2CellIdFromQuadkey = exports.getS2QuadkeyFromCellId = exports.getS2CellFromQuadKey = void 0;
15
+ const long_1 = __importDefault(require("long"));
16
+ //
17
+ // Functional Style
18
+ //
19
+ const FACE_BITS = 3;
20
+ const MAX_LEVEL = 30;
21
+ const POS_BITS = 2 * MAX_LEVEL + 1; // 61 (60 bits of data, 1 bit lsb marker)
22
+ const RADIAN_TO_DEGREE = 180 / Math.PI;
23
+ /**
24
+ * Return the S2Cell
25
+ * @param hilbertQuadkey {string} A string that is the Hilbert quad key (containing /)
26
+ * @returns {@link S2Cell}
27
+ */
28
+ // eslint-disable-next-line max-statements
29
+ function getS2CellFromQuadKey(hilbertQuadkey) {
30
+ if (hilbertQuadkey.length === 0) {
31
+ throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
32
+ }
33
+ const parts = hilbertQuadkey.split('/');
34
+ const face = parseInt(parts[0], 10); // face is in the range [0..5]
35
+ const position = parts[1]; // position is in the range [0..4**30-1]
36
+ const maxLevel = position.length;
37
+ let level = 0;
38
+ const point = [0, 0];
39
+ for (let i = maxLevel - 1; i >= 0; i--) {
40
+ level = maxLevel - i;
41
+ const bit = position[i];
42
+ let rx = 0;
43
+ let ry = 0;
44
+ if (bit === '1') {
45
+ ry = 1;
46
+ }
47
+ else if (bit === '2') {
48
+ rx = 1;
49
+ ry = 1;
50
+ }
51
+ else if (bit === '3') {
52
+ rx = 1;
53
+ }
54
+ const val = Math.pow(2, level - 1);
55
+ rotateAndFlipQuadrant(val, point, rx, ry);
56
+ point[0] += val * rx;
57
+ point[1] += val * ry;
58
+ }
59
+ if (face % 2 === 1) {
60
+ const t = point[0];
61
+ point[0] = point[1];
62
+ point[1] = t;
63
+ }
64
+ return { face, ij: point, level };
65
+ }
66
+ exports.getS2CellFromQuadKey = getS2CellFromQuadKey;
67
+ /**
68
+ * Convets S2 cell ID to the Hilbert quad key
69
+ * @param cellId {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face
70
+ * @returns {string} the Hilbert quad key (containing /) as a string in the format 'face/pos', where
71
+ * - face is a 10-base representation of the face number
72
+ * - pos is a 4-base representation of the position along the Hilbert curve. For example,
73
+ * pos == '13' means the following:
74
+ * The face is divided two times. After the first time the child cell with position 1 will be selected.
75
+ * Then, this cell will be divided the second time, and the child cell with position 3 will be selected.
76
+ */
77
+ function getS2QuadkeyFromCellId(cellId) {
78
+ if (cellId.isZero()) {
79
+ // Invalid token
80
+ return '';
81
+ }
82
+ let bin = cellId.toString(2);
83
+ while (bin.length < FACE_BITS + POS_BITS) {
84
+ // eslint-disable-next-line prefer-template
85
+ bin = '0' + bin;
86
+ }
87
+ // MUST come AFTER binstr has been left-padded with '0's
88
+ const lsbIndex = bin.lastIndexOf('1');
89
+ // substring(start, end) // includes start, does not include end
90
+ const faceB = bin.substring(0, 3);
91
+ // posB will always be a multiple of 2 (or it's invalid)
92
+ const posB = bin.substring(3, lsbIndex);
93
+ const levelN = posB.length / 2;
94
+ const faceS = long_1.default.fromString(faceB, true, 2).toString(10);
95
+ /*
96
+ Here is a fix for the case when posB is an empty string that causes an exception in Long.fromString
97
+ */
98
+ let posS = '';
99
+ if (levelN !== 0) {
100
+ // posB is not an empty string, because levelN !== 0
101
+ posS = long_1.default.fromString(posB, true, 2).toString(4);
102
+ while (posS.length < levelN) {
103
+ // eslint-disable-next-line prefer-template
104
+ posS = '0' + posS;
105
+ }
106
+ }
107
+ // Note, posS will be "" for the level==0, which corresponds to the full face.
108
+ // Example: Full face 0 (No subdivision, so level==0): Returns "0/"
109
+ // TODO: Is it ok?
110
+ return `${faceS}/${posS}`;
111
+ }
112
+ exports.getS2QuadkeyFromCellId = getS2QuadkeyFromCellId;
113
+ /**
114
+ * Convets S2 the Hilbert quad key to cell ID.
115
+ * @param quadkey {string} The Hilbert quad key (containing /) as a string in the format 'face/pos'
116
+ * @returns {Long} Cell id that is a 64-bit encoding of a face and a Hilbert curve parameter on that face
117
+ */
118
+ /* eslint complexity: ["error", { "max": 14 }] */
119
+ function getS2CellIdFromQuadkey(hilbertQuadkey) {
120
+ if (hilbertQuadkey.length === 0 || hilbertQuadkey.indexOf('/') !== 1) {
121
+ throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
122
+ }
123
+ let idS = '';
124
+ const faceS = hilbertQuadkey[0];
125
+ switch (faceS) {
126
+ case '0':
127
+ idS += '000';
128
+ break;
129
+ case '1':
130
+ idS += '001';
131
+ break;
132
+ case '2':
133
+ idS += '010';
134
+ break;
135
+ case '3':
136
+ idS += '011';
137
+ break;
138
+ case '4':
139
+ idS += '100';
140
+ break;
141
+ case '5':
142
+ idS += '101';
143
+ break;
144
+ default:
145
+ throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
146
+ }
147
+ const maxLevel = hilbertQuadkey.length;
148
+ // Don't convert position to Long, because it can contain leading zeros, which makes you handle it later.
149
+ for (let i = 2; i < maxLevel; i++) {
150
+ // The first char is a face, the second char is '/'
151
+ const p = hilbertQuadkey[i];
152
+ switch (p) {
153
+ case '0':
154
+ idS += '00';
155
+ break;
156
+ case '1':
157
+ idS += '01';
158
+ break;
159
+ case '2':
160
+ idS += '10';
161
+ break;
162
+ case '3':
163
+ idS += '11';
164
+ break;
165
+ default:
166
+ throw new Error(`Invalid Hilbert quad key ${hilbertQuadkey}`);
167
+ }
168
+ }
169
+ // Append the sentinel bit
170
+ idS += '1';
171
+ const paddedId = idS.padEnd(64, '0');
172
+ const id = long_1.default.fromString(paddedId, true, 2);
173
+ return id;
174
+ }
175
+ exports.getS2CellIdFromQuadkey = getS2CellIdFromQuadkey;
176
+ function IJToST(ij, level, offsets) {
177
+ const maxSize = 1 << level;
178
+ return [(ij[0] + offsets[0]) / maxSize, (ij[1] + offsets[1]) / maxSize];
179
+ }
180
+ exports.IJToST = IJToST;
181
+ function singleSTtoUV(st) {
182
+ if (st >= 0.5) {
183
+ return (1 / 3.0) * (4 * st * st - 1);
184
+ }
185
+ return (1 / 3.0) * (1 - 4 * (1 - st) * (1 - st));
186
+ }
187
+ function STToUV(st) {
188
+ return [singleSTtoUV(st[0]), singleSTtoUV(st[1])];
189
+ }
190
+ exports.STToUV = STToUV;
191
+ function FaceUVToXYZ(face, [u, v]) {
192
+ switch (face) {
193
+ case 0:
194
+ return [1, u, v];
195
+ case 1:
196
+ return [-u, 1, v];
197
+ case 2:
198
+ return [-u, -v, 1];
199
+ case 3:
200
+ return [-1, -v, -u];
201
+ case 4:
202
+ return [v, -1, -u];
203
+ case 5:
204
+ return [v, u, -1];
205
+ default:
206
+ throw new Error('Invalid face');
207
+ }
208
+ }
209
+ exports.FaceUVToXYZ = FaceUVToXYZ;
210
+ function XYZToLngLat([x, y, z]) {
211
+ const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
212
+ const lng = Math.atan2(y, x);
213
+ return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
214
+ }
215
+ exports.XYZToLngLat = XYZToLngLat;
216
+ function rotateAndFlipQuadrant(n, point, rx, ry) {
217
+ if (ry === 0) {
218
+ if (rx === 1) {
219
+ point[0] = n - 1 - point[0];
220
+ point[1] = n - 1 - point[1];
221
+ }
222
+ const x = point[0];
223
+ point[0] = point[1];
224
+ point[1] = x;
225
+ }
226
+ }
227
+ /**
228
+ * Retrieve S2 geometry center
229
+ * @param s2cell {S2Cell} S2 cell
230
+ * @returns {[number, number]} Longitude and Latitude coordinates of the S2 cell's center
231
+ */
232
+ function getS2LngLatFromS2Cell(s2Cell) {
233
+ const st = IJToST(s2Cell.ij, s2Cell.level, [0.5, 0.5]);
234
+ const uv = STToUV(st);
235
+ const xyz = FaceUVToXYZ(s2Cell.face, uv);
236
+ return XYZToLngLat(xyz);
237
+ }
238
+ exports.getS2LngLatFromS2Cell = getS2LngLatFromS2Cell;
239
+ /**
240
+ * Return longitude and latitude of four corners of the cell.
241
+ * @param s2Cell {S2Cell} S2 cell
242
+ * @returns {Array<[number, number]>} Array of longitude and latitude pairs (in degrees) for four corners of the cell.
243
+ */
244
+ function getCornerLngLats(s2Cell) {
245
+ const result = [];
246
+ const offsets = [
247
+ [0.0, 0.0],
248
+ [0.0, 1.0],
249
+ [1.0, 1.0],
250
+ [1.0, 0.0]
251
+ ];
252
+ for (let i = 0; i < 4; i++) {
253
+ const st = IJToST(s2Cell.ij, s2Cell.level, offsets[i]);
254
+ const uv = STToUV(st);
255
+ const xyz = FaceUVToXYZ(s2Cell.face, uv);
256
+ result.push(XYZToLngLat(xyz));
257
+ }
258
+ return result;
259
+ }
260
+ exports.getCornerLngLats = getCornerLngLats;
@@ -1,2 +1,7 @@
1
- export const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
2
- //# sourceMappingURL=version.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
+ // __VERSION__ is injected by babel-plugin-version-inline
6
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
+ exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
@@ -1,14 +1,23 @@
1
- import parse3DTilesSubtree from './lib/parsers/helpers/parse-3d-tile-subtree';
2
- import { VERSION } from './lib/utils/version';
3
- export const Tile3DSubtreeLoader = {
4
- id: '3d-tiles-subtree',
5
- name: '3D Tiles Subtree',
6
- module: '3d-tiles',
7
- version: VERSION,
8
- extensions: ['subtree'],
9
- mimeTypes: ['application/octet-stream'],
10
- tests: ['subtree'],
11
- parse: parse3DTilesSubtree,
12
- options: {}
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tile3DSubtreeLoader = void 0;
7
+ const parse_3d_tile_subtree_1 = __importDefault(require("./lib/parsers/helpers/parse-3d-tile-subtree"));
8
+ const version_1 = require("./lib/utils/version");
9
+ /**
10
+ * Loader for 3D Tiles Subtree
11
+ *
12
+ */
13
+ exports.Tile3DSubtreeLoader = {
14
+ id: '3d-tiles-subtree',
15
+ name: '3D Tiles Subtree',
16
+ module: '3d-tiles',
17
+ version: version_1.VERSION,
18
+ extensions: ['subtree'],
19
+ mimeTypes: ['application/octet-stream'],
20
+ tests: ['subtree'],
21
+ parse: parse_3d_tile_subtree_1.default,
22
+ options: {}
13
23
  };
14
- //# sourceMappingURL=tile-3d-subtree-loader.js.map
@@ -1,20 +1,27 @@
1
- import { VERSION } from './lib/utils/version';
2
- import encode3DTile from './lib/encoders/encode-3d-tile';
3
- export const Tile3DWriter = {
4
- name: '3D Tile',
5
- id: '3d-tiles',
6
- module: '3d-tiles',
7
- version: VERSION,
8
- extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
9
- mimeTypes: ['application/octet-stream'],
10
- encodeSync,
11
- binary: true,
12
- options: {
13
- ['3d-tiles']: {}
14
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Tile3DWriter = void 0;
7
+ const version_1 = require("./lib/utils/version");
8
+ const encode_3d_tile_1 = __importDefault(require("./lib/encoders/encode-3d-tile"));
9
+ /**
10
+ * Exporter for 3D Tiles
11
+ */
12
+ exports.Tile3DWriter = {
13
+ name: '3D Tile',
14
+ id: '3d-tiles',
15
+ module: '3d-tiles',
16
+ version: version_1.VERSION,
17
+ extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
18
+ mimeTypes: ['application/octet-stream'],
19
+ encodeSync,
20
+ binary: true,
21
+ options: {
22
+ ['3d-tiles']: {}
23
+ }
15
24
  };
16
-
17
25
  function encodeSync(tile, options) {
18
- return encode3DTile(tile, options);
26
+ return (0, encode_3d_tile_1.default)(tile, options);
19
27
  }
20
- //# sourceMappingURL=tile-3d-writer.js.map
@@ -1,4 +1,18 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ import type { DracoLoaderOptions } from '@loaders.gl/draco';
3
+ import type { ImageLoaderOptions } from '@loaders.gl/images';
4
+ export type Tiles3DLoaderOptions = LoaderOptions & DracoLoaderOptions & ImageLoaderOptions & {
5
+ '3d-tiles'?: {
6
+ /** Whether to parse any embedded glTF binaries (or extract memory for independent glTF parsing) */
7
+ loadGLTF?: boolean;
8
+ /** If renderer doesn't support quantized positions, loader can decode them on CPU */
9
+ decodeQuantizedPositions?: boolean;
10
+ /** Whether this is a tileset or a tile */
11
+ isTileset?: boolean | 'auto';
12
+ /** Controls which axis is "up" in glTF files */
13
+ assetGltfUpAxis?: 'x' | 'y' | 'z' | null;
14
+ };
15
+ };
2
16
  /**
3
17
  * Loader for 3D Tiles
4
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAY/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
1
+ {"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE7F,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAQ3D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAE9C,kBAAkB,GAClB,kBAAkB,GAAG;IACnB,UAAU,CAAC,EAAE;QACX,mGAAmG;QACnG,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,qFAAqF;QACrF,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,0CAA0C;QAC1C,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QAC7B,gDAAgD;QAChD,eAAe,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;KAC1C,CAAC;CACH,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
@@ -1,79 +1,75 @@
1
- import { path } from '@loaders.gl/loader-utils';
2
- import { TILESET_TYPE, LOD_METRIC_TYPE } from '@loaders.gl/tiles';
3
- import { VERSION } from './lib/utils/version';
4
- import { parse3DTile } from './lib/parsers/parse-3d-tile';
5
- import { normalizeTileHeaders, normalizeImplicitTileHeaders } from './lib/parsers/parse-3d-tile-header';
6
- const IMPLICIT_TILING_EXTENSION_NAME = '3DTILES_implicit_tiling';
7
- export const Tiles3DLoader = {
8
- id: '3d-tiles',
9
- name: '3D Tiles',
10
- module: '3d-tiles',
11
- version: VERSION,
12
- extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
13
- mimeTypes: ['application/octet-stream'],
14
- tests: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
15
- parse,
16
- options: {
17
- '3d-tiles': {
18
- loadGLTF: true,
19
- decodeQuantizedPositions: false,
20
- isTileset: 'auto',
21
- assetGltfUpAxis: null
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Tiles3DLoader = void 0;
4
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
5
+ const tiles_1 = require("@loaders.gl/tiles");
6
+ const version_1 = require("./lib/utils/version");
7
+ const parse_3d_tile_1 = require("./lib/parsers/parse-3d-tile");
8
+ const parse_3d_tile_header_1 = require("./lib/parsers/parse-3d-tile-header");
9
+ /**
10
+ * Loader for 3D Tiles
11
+ */
12
+ exports.Tiles3DLoader = {
13
+ id: '3d-tiles',
14
+ name: '3D Tiles',
15
+ module: '3d-tiles',
16
+ version: version_1.VERSION,
17
+ extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
18
+ mimeTypes: ['application/octet-stream'],
19
+ tests: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
20
+ parse,
21
+ options: {
22
+ '3d-tiles': {
23
+ loadGLTF: true,
24
+ decodeQuantizedPositions: false,
25
+ isTileset: 'auto',
26
+ assetGltfUpAxis: null
27
+ }
22
28
  }
23
- }
24
29
  };
25
-
26
- function getBaseUri(tileset) {
27
- return path.dirname(tileset.url);
28
- }
29
-
30
- async function parseTile(arrayBuffer, options, context) {
31
- const tile = {
32
- content: {
33
- featureIds: null
30
+ /** Parses a tileset or tile */
31
+ async function parse(data, options = {}, context) {
32
+ // auto detect file type
33
+ const loaderOptions = options['3d-tiles'] || {};
34
+ let isTileset;
35
+ if (loaderOptions.isTileset === 'auto') {
36
+ isTileset = context?.url && context.url.indexOf('.json') !== -1;
34
37
  }
35
- };
36
- const byteOffset = 0;
37
- await parse3DTile(arrayBuffer, byteOffset, options, context, tile.content);
38
- return tile.content;
38
+ else {
39
+ isTileset = loaderOptions.isTileset;
40
+ }
41
+ return (await isTileset)
42
+ ? parseTileset(data, options, context)
43
+ : parseTile(data, options, context);
39
44
  }
40
-
45
+ /** Parse a tileset */
41
46
  async function parseTileset(data, options, context) {
42
- var _tilesetJson$root;
43
-
44
- const tilesetJson = JSON.parse(new TextDecoder().decode(data));
45
- tilesetJson.loader = options.loader || Tiles3DLoader;
46
- tilesetJson.url = context.url;
47
- tilesetJson.basePath = getBaseUri(tilesetJson);
48
- tilesetJson.root = hasImplicitTilingExtension(tilesetJson) ? await normalizeImplicitTileHeaders(tilesetJson) : normalizeTileHeaders(tilesetJson);
49
- tilesetJson.type = TILESET_TYPE.TILES3D;
50
- tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
51
- tilesetJson.lodMetricValue = ((_tilesetJson$root = tilesetJson.root) === null || _tilesetJson$root === void 0 ? void 0 : _tilesetJson$root.lodMetricValue) || 0;
52
- return tilesetJson;
47
+ const tilesetJson = JSON.parse(new TextDecoder().decode(data));
48
+ // eslint-disable-next-line no-use-before-define
49
+ tilesetJson.loader = options?.loader || exports.Tiles3DLoader;
50
+ tilesetJson.url = context?.url || '';
51
+ tilesetJson.queryString = context?.queryString || '';
52
+ // base path that non-absolute paths in tileset are relative to.
53
+ tilesetJson.basePath = getBaseUri(tilesetJson);
54
+ // TODO - check option types in normalizeTileHeaders
55
+ tilesetJson.root = await (0, parse_3d_tile_header_1.normalizeTileHeaders)(tilesetJson, options || {});
56
+ tilesetJson.type = tiles_1.TILESET_TYPE.TILES3D;
57
+ tilesetJson.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
58
+ tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
59
+ return tilesetJson;
53
60
  }
54
-
55
- async function parse(data, options, context) {
56
- const loaderOptions = options['3d-tiles'] || {};
57
- let isTileset;
58
-
59
- if (loaderOptions.isTileset === 'auto') {
60
- isTileset = context.url && context.url.indexOf('.json') !== -1;
61
- } else {
62
- isTileset = loaderOptions.isTileset;
63
- }
64
-
65
- if (isTileset) {
66
- data = await parseTileset(data, options, context);
67
- } else {
68
- data = await parseTile(data, options, context);
69
- }
70
-
71
- return data;
61
+ /** Parse a tile */
62
+ async function parseTile(arrayBuffer, options, context) {
63
+ const tile = {
64
+ content: {
65
+ featureIds: null
66
+ }
67
+ };
68
+ const byteOffset = 0;
69
+ await (0, parse_3d_tile_1.parse3DTile)(arrayBuffer, byteOffset, options, context, tile.content);
70
+ return tile.content;
72
71
  }
73
-
74
- function hasImplicitTilingExtension(tilesetJson) {
75
- var _tilesetJson$extensio, _tilesetJson$extensio2;
76
-
77
- return (tilesetJson === null || tilesetJson === void 0 ? void 0 : (_tilesetJson$extensio = tilesetJson.extensionsRequired) === null || _tilesetJson$extensio === void 0 ? void 0 : _tilesetJson$extensio.includes(IMPLICIT_TILING_EXTENSION_NAME)) && (tilesetJson === null || tilesetJson === void 0 ? void 0 : (_tilesetJson$extensio2 = tilesetJson.extensionsUsed) === null || _tilesetJson$extensio2 === void 0 ? void 0 : _tilesetJson$extensio2.includes(IMPLICIT_TILING_EXTENSION_NAME));
72
+ /** Get base name */
73
+ function getBaseUri(tileset) {
74
+ return loader_utils_1.path.dirname(tileset.url);
78
75
  }
79
- //# sourceMappingURL=tiles-3d-loader.js.map
package/dist/types.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import type { GLTFObject } from '@loaders.gl/gltf';
1
+ import type { GLTFPostprocessed } from '@loaders.gl/gltf';
2
2
  import { Matrix4, Vector3 } from '@math.gl/core';
3
- export declare type BatchTableJson = {
3
+ export type FeatureTableJson = {
4
4
  [key: string]: any[];
5
5
  };
6
- export declare type B3DMContent = {
7
- batchTableJson?: BatchTableJson;
6
+ export type B3DMContent = {
7
+ batchTableJson?: FeatureTableJson;
8
8
  byteLength: number;
9
9
  byteOffset: number;
10
10
  cartesianModelMatrix: Matrix4;
@@ -13,8 +13,8 @@ export declare type B3DMContent = {
13
13
  cartographicOrigin: Vector3;
14
14
  featureIds?: number[] | null;
15
15
  featureTableBinary?: Uint8Array;
16
- featureTableJson?: BatchTableJson;
17
- gltf?: GLTFObject;
16
+ featureTableJson?: FeatureTableJson;
17
+ gltf?: GLTFPostprocessed;
18
18
  gltfUpAxis: string;
19
19
  header: GLTFHeader;
20
20
  magic: number;
@@ -24,14 +24,14 @@ export declare type B3DMContent = {
24
24
  type: string;
25
25
  version: number;
26
26
  };
27
- export declare type GLTFHeader = {
27
+ export type GLTFHeader = {
28
28
  batchLength?: number;
29
29
  batchTableBinaryByteLength: number;
30
30
  batchTableJsonByteLength: number;
31
31
  featureTableBinaryByteLength: number;
32
32
  featureTableJsonByteLength: number;
33
33
  };
34
- export declare type Node3D = {
34
+ export type Node3D = {
35
35
  boundingVolume: BoundingVolume;
36
36
  children: any;
37
37
  geometricError: number;
@@ -40,7 +40,7 @@ export declare type Node3D = {
40
40
  boundingVolume: BoundingVolume;
41
41
  };
42
42
  };
43
- export declare type BoundingVolume = {
43
+ export type BoundingVolume = {
44
44
  box?: number[];
45
45
  sphere?: number[];
46
46
  region?: number[];
@@ -49,32 +49,45 @@ export declare type BoundingVolume = {
49
49
  * 3DTILES_implicit_tiling types
50
50
  * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format
51
51
  */
52
- export declare type Subtree = {
52
+ export type Subtree = {
53
53
  buffers: Buffer[];
54
54
  bufferViews: BufferView[];
55
55
  tileAvailability: Availability;
56
56
  contentAvailability: Availability;
57
57
  childSubtreeAvailability: Availability;
58
58
  };
59
- export declare type Availability = {
59
+ export type Availability = {
60
60
  constant?: 0 | 1;
61
61
  bufferView?: number;
62
62
  explicitBitstream?: ExplicitBitstream;
63
63
  };
64
- export declare type ExplicitBitstream = Uint8Array;
64
+ export type ExplicitBitstream = Uint8Array;
65
65
  /**
66
66
  * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-scheme
67
67
  */
68
- export declare type SubdivisionScheme = 'QUADTREE' | 'OCTREE';
69
- declare type Buffer = {
68
+ export type SubdivisionScheme = 'QUADTREE' | 'OCTREE';
69
+ type Buffer = {
70
70
  name: string;
71
71
  uri?: string;
72
72
  byteLength: number;
73
73
  };
74
- declare type BufferView = {
74
+ type BufferView = {
75
75
  buffer: number;
76
76
  byteOffset: number;
77
77
  byteLength: number;
78
78
  };
79
+ /**
80
+ * Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
81
+ */
82
+ export type ImplicitTilingExtension = {
83
+ subdivisionScheme: 'QUADTREE' | 'OCTREE';
84
+ maximumLevel?: number;
85
+ availableLevels: number;
86
+ subtreeLevels: number;
87
+ subtrees: SubtreeUri;
88
+ };
89
+ type SubtreeUri = {
90
+ uri: string;
91
+ };
79
92
  export {};
80
93
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAA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BAAuB,GAAG;IACpC,iBAAiB,EAAE,UAAU,GAAG,QAAQ,CAAC;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF,KAAK,UAAU,GAAG;IAChB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"}
package/dist/types.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });