@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
@@ -1,245 +1,412 @@
1
- import { DracoLoader } from '@loaders.gl/draco';
2
- import { GL } from '@loaders.gl/math';
3
- import { Vector3 } from '@math.gl/core';
4
- import Tile3DFeatureTable from '../classes/tile-3d-feature-table';
5
- import Tile3DBatchTable from '../classes/tile-3d-batch-table';
6
- import { parse3DTileHeaderSync } from './helpers/parse-3d-tile-header';
7
- import { parse3DTileTablesHeaderSync, parse3DTileTablesSync } from './helpers/parse-3d-tile-tables';
8
- import { normalize3DTileColorAttribute } from './helpers/normalize-3d-tile-colors';
9
- import { normalize3DTileNormalAttribute } from './helpers/normalize-3d-tile-normals';
10
- import { normalize3DTilePositionAttribute } from './helpers/normalize-3d-tile-positions';
11
- export async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
12
- byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
13
- byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
14
- byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
15
- initializeTile(tile);
16
- const {
17
- featureTable,
18
- batchTable
19
- } = parsePointCloudTables(tile);
20
- await parseDraco(tile, featureTable, batchTable, options, context);
21
- parsePositions(tile, featureTable, options);
22
- parseColors(tile, featureTable, batchTable);
23
- parseNormals(tile, featureTable);
24
- return byteOffset;
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.loadDraco = exports.parsePointCloud3DTile = void 0;
9
+ const draco_1 = require("@loaders.gl/draco");
10
+ const math_1 = require("@loaders.gl/math");
11
+ const core_1 = require("@math.gl/core");
12
+ const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
13
+ const tile_3d_batch_table_1 = __importDefault(require("../classes/tile-3d-batch-table"));
14
+ const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
15
+ const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
16
+ const normalize_3d_tile_colors_1 = require("./helpers/normalize-3d-tile-colors");
17
+ const normalize_3d_tile_normals_1 = require("./helpers/normalize-3d-tile-normals");
18
+ const normalize_3d_tile_positions_1 = require("./helpers/normalize-3d-tile-positions");
19
+ async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
20
+ byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
21
+ byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
22
+ byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
23
+ initializeTile(tile);
24
+ const { featureTable, batchTable } = parsePointCloudTables(tile);
25
+ await parseDraco(tile, featureTable, batchTable, options, context);
26
+ parsePositions(tile, featureTable, options);
27
+ // @ts-expect-error TODO - do we need to assert on the batch table?
28
+ parseColors(tile, featureTable, batchTable);
29
+ parseNormals(tile, featureTable);
30
+ return byteOffset;
25
31
  }
26
-
32
+ exports.parsePointCloud3DTile = parsePointCloud3DTile;
27
33
  function initializeTile(tile) {
28
- tile.attributes = {
29
- positions: null,
30
- colors: null,
31
- normals: null,
32
- batchIds: null
33
- };
34
- tile.isQuantized = false;
35
- tile.isTranslucent = false;
36
- tile.isRGB565 = false;
37
- tile.isOctEncoded16P = false;
34
+ // Initialize point cloud tile defaults
35
+ tile.attributes = {
36
+ positions: null,
37
+ colors: null,
38
+ normals: null,
39
+ batchIds: null
40
+ };
41
+ tile.isQuantized = false;
42
+ tile.isTranslucent = false;
43
+ tile.isRGB565 = false;
44
+ tile.isOctEncoded16P = false;
38
45
  }
39
-
40
46
  function parsePointCloudTables(tile) {
41
- const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
42
- const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
43
-
44
- if (!Number.isFinite(pointsLength)) {
45
- throw new Error('POINTS_LENGTH must be defined');
46
- }
47
-
48
- featureTable.featuresLength = pointsLength;
49
- tile.featuresLength = pointsLength;
50
- tile.pointsLength = pointsLength;
51
- tile.pointCount = pointsLength;
52
- tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);
53
- const batchTable = parseBatchIds(tile, featureTable);
54
- return {
55
- featureTable,
56
- batchTable
57
- };
47
+ const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
48
+ const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
49
+ if (!Number.isFinite(pointsLength)) {
50
+ throw new Error('POINTS_LENGTH must be defined');
51
+ }
52
+ featureTable.featuresLength = pointsLength;
53
+ tile.featuresLength = pointsLength;
54
+ tile.pointsLength = pointsLength;
55
+ tile.pointCount = pointsLength;
56
+ tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
57
+ const batchTable = parseBatchIds(tile, featureTable);
58
+ return { featureTable, batchTable };
58
59
  }
59
-
60
60
  function parsePositions(tile, featureTable, options) {
61
- if (!tile.attributes.positions) {
62
- if (featureTable.hasProperty('POSITION')) {
63
- tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
64
- } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
65
- const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
66
- tile.isQuantized = true;
67
- tile.quantizedRange = (1 << 16) - 1;
68
- tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', GL.FLOAT, 3);
69
-
70
- if (!tile.quantizedVolumeScale) {
71
- throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
72
- }
73
-
74
- tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', GL.FLOAT, 3);
75
-
76
- if (!tile.quantizedVolumeOffset) {
77
- throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
78
- }
79
-
80
- tile.attributes.positions = normalize3DTilePositionAttribute(tile, positions, options);
61
+ if (!tile.attributes.positions) {
62
+ if (featureTable.hasProperty('POSITION')) {
63
+ tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
64
+ }
65
+ else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
66
+ const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3);
67
+ tile.isQuantized = true;
68
+ tile.quantizedRange = (1 << 16) - 1;
69
+ tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
70
+ if (!tile.quantizedVolumeScale) {
71
+ throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
72
+ }
73
+ tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
74
+ if (!tile.quantizedVolumeOffset) {
75
+ throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
76
+ }
77
+ tile.attributes.positions = (0, normalize_3d_tile_positions_1.normalize3DTilePositionAttribute)(tile, positions, options);
78
+ }
81
79
  }
82
- }
80
+ if (!tile.attributes.positions) {
81
+ throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
82
+ }
83
+ }
84
+ function parseColors(tile, featureTable, batchTable) {
85
+ if (!tile.attributes.colors) {
86
+ let colors = null;
87
+ if (featureTable.hasProperty('RGBA')) {
88
+ colors = featureTable.getPropertyArray('RGBA', math_1.GL.UNSIGNED_BYTE, 4);
89
+ tile.isTranslucent = true;
90
+ }
91
+ else if (featureTable.hasProperty('RGB')) {
92
+ colors = featureTable.getPropertyArray('RGB', math_1.GL.UNSIGNED_BYTE, 3);
93
+ }
94
+ else if (featureTable.hasProperty('RGB565')) {
95
+ colors = featureTable.getPropertyArray('RGB565', math_1.GL.UNSIGNED_SHORT, 1);
96
+ tile.isRGB565 = true;
97
+ }
98
+ tile.attributes.colors = (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, colors, batchTable);
99
+ }
100
+ if (featureTable.hasProperty('CONSTANT_RGBA')) {
101
+ tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', math_1.GL.UNSIGNED_BYTE, 4);
102
+ }
103
+ }
104
+ function parseNormals(tile, featureTable) {
105
+ if (!tile.attributes.normals) {
106
+ let normals = null;
107
+ if (featureTable.hasProperty('NORMAL')) {
108
+ normals = featureTable.getPropertyArray('NORMAL', math_1.GL.FLOAT, 3);
109
+ }
110
+ else if (featureTable.hasProperty('NORMAL_OCT16P')) {
111
+ normals = featureTable.getPropertyArray('NORMAL_OCT16P', math_1.GL.UNSIGNED_BYTE, 2);
112
+ tile.isOctEncoded16P = true;
113
+ }
114
+ tile.attributes.normals = (0, normalize_3d_tile_normals_1.normalize3DTileNormalAttribute)(tile, normals);
115
+ }
116
+ }
117
+ function parseBatchIds(tile, featureTable) {
118
+ let batchTable = null;
119
+ if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
120
+ tile.batchIds = featureTable.getPropertyArray('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1);
121
+ if (tile.batchIds) {
122
+ const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
123
+ if (!batchFeatureLength) {
124
+ throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
125
+ }
126
+ const { batchTableJson, batchTableBinary } = tile;
127
+ batchTable = new tile_3d_batch_table_1.default(batchTableJson, batchTableBinary, batchFeatureLength);
128
+ }
129
+ }
130
+ return batchTable;
131
+ }
132
+ // eslint-disable-next-line complexity
133
+ async function parseDraco(tile, featureTable, batchTable, options, context) {
134
+ let dracoBuffer;
135
+ let dracoFeatureTableProperties;
136
+ let dracoBatchTableProperties;
137
+ const batchTableDraco = tile.batchTableJson &&
138
+ tile.batchTableJson.extensions &&
139
+ tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
140
+ if (batchTableDraco) {
141
+ dracoBatchTableProperties = batchTableDraco.properties;
142
+ }
143
+ const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
144
+ if (featureTableDraco) {
145
+ dracoFeatureTableProperties = featureTableDraco.properties;
146
+ const dracoByteOffset = featureTableDraco.byteOffset;
147
+ const dracoByteLength = featureTableDraco.byteLength;
148
+ if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
149
+ throw new Error('Draco properties, byteOffset, and byteLength must be defined');
150
+ }
151
+ dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
152
+ tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
153
+ tile.hasColors =
154
+ Number.isFinite(dracoFeatureTableProperties.RGB) ||
155
+ Number.isFinite(dracoFeatureTableProperties.RGBA);
156
+ tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
157
+ tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
158
+ tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
159
+ }
160
+ if (!dracoBuffer) {
161
+ return true;
162
+ }
163
+ const dracoData = {
164
+ buffer: dracoBuffer,
165
+ properties: { ...dracoFeatureTableProperties, ...dracoBatchTableProperties },
166
+ featureTableProperties: dracoFeatureTableProperties,
167
+ batchTableProperties: dracoBatchTableProperties,
168
+ dequantizeInShader: false
169
+ };
170
+ return await loadDraco(tile, dracoData, options, context);
171
+ }
172
+ // eslint-disable-next-line complexity, max-statements
173
+ async function loadDraco(tile, dracoData, options, context) {
174
+ const { parse } = context;
175
+ const dracoOptions = {
176
+ ...options,
177
+ draco: {
178
+ ...options.draco,
179
+ extraAttributes: dracoData.batchTableProperties || {}
180
+ }
181
+ };
182
+ // The entire tileset might be included, too expensive to serialize
183
+ delete dracoOptions['3d-tiles'];
184
+ const data = await parse(dracoData.buffer, draco_1.DracoLoader, dracoOptions);
185
+ const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
186
+ const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
187
+ const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
188
+ const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
189
+ const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
190
+ const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
191
+ if (isQuantizedDraco) {
192
+ // Draco quantization range == quantized volume scale - size in meters of the quantized volume
193
+ // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
194
+ const quantization = data.POSITION.data.quantization;
195
+ const range = quantization.range;
196
+ tile.quantizedVolumeScale = new core_1.Vector3(range, range, range);
197
+ tile.quantizedVolumeOffset = new core_1.Vector3(quantization.minValues);
198
+ tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
199
+ tile.isQuantizedDraco = true;
200
+ }
201
+ if (isOctEncodedDraco) {
202
+ tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
203
+ tile.isOctEncodedDraco = true;
204
+ }
205
+ // Extra batch table attributes
206
+ const batchTableAttributes = {};
207
+ if (dracoData.batchTableProperties) {
208
+ for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
209
+ if (data.attributes[attributeName] && data.attributes[attributeName].value) {
210
+ batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
211
+ }
212
+ }
213
+ }
214
+ tile.attributes = {
215
+ positions: decodedPositions,
216
+ colors: (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, decodedColors, undefined),
217
+ normals: decodedNormals,
218
+ batchIds: decodedBatchIds,
219
+ ...batchTableAttributes
220
+ };
221
+ }
222
+ exports.loadDraco = loadDraco;
223
+ // TODO - this is the remaining code from Cesium's parser
224
+ /*
225
+ const batchTable = new Tile3DBatchTable(tile);
226
+
227
+ // parseDracoBuffer(tile, featureTable, batchTable);
83
228
 
84
229
  if (!tile.attributes.positions) {
85
230
  throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
86
231
  }
87
232
  }
233
+ /*
234
+
235
+ if (!tile.attributes.positions) {
236
+ if (featureTable.hasProperty('POSITION')) {
237
+ tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
238
+ } else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
239
+ tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
88
240
 
89
- function parseColors(tile, featureTable, batchTable) {
90
- if (!tile.attributes.colors) {
91
- let colors = null;
92
241
 
242
+ if (!tile.colors) {
93
243
  if (featureTable.hasProperty('RGBA')) {
94
- colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
244
+ tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
95
245
  tile.isTranslucent = true;
96
246
  } else if (featureTable.hasProperty('RGB')) {
97
- colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
98
- } else if (featureTable.hasProperty('RGB565')) {
99
- colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
247
+ tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
248
+ } else if (featureTable.hasPropertry('RGB565')) {
249
+ tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
100
250
  tile.isRGB565 = true;
101
251
  }
102
-
103
- tile.attributes.colors = normalize3DTileColorAttribute(tile, colors, batchTable);
104
252
  }
105
253
 
106
- if (featureTable.hasProperty('CONSTANT_RGBA')) {
107
- tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
108
- }
109
- }
110
-
111
- function parseNormals(tile, featureTable) {
112
254
  if (!tile.attributes.normals) {
113
- let normals = null;
114
-
115
- if (featureTable.hasProperty('NORMAL')) {
116
- normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
117
- } else if (featureTable.hasProperty('NORMAL_OCT16P')) {
118
- normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
255
+ if (featureTable.getPropertry('NORMAL')) {
256
+ tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
257
+ } else if (featureTable.getProperty('NORMAL_OCT16P')) {
258
+ tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
119
259
  tile.isOctEncoded16P = true;
120
260
  }
261
+ }
121
262
 
122
- tile.attributes.normals = normalize3DTileNormalAttribute(tile, normals);
263
+ if (!tile.batchIds) {
264
+ if (featureTable.hasProperty('BATCH_ID')) {
265
+ tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
266
+ }
123
267
  }
124
- }
125
268
 
126
- function parseBatchIds(tile, featureTable) {
127
- let batchTable = null;
269
+ if (!tile.attributes.positions) {
270
+ throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
271
+ }
128
272
 
129
- if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
130
- tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
273
+ if (featureTable.getPropertry('CONSTANT_RGBA')) {
274
+ tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
275
+ }
131
276
 
132
- if (tile.batchIds) {
133
- const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
277
+ if (tile.batchIds) {
278
+ const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');
279
+ if (!defined(batchLength)) {
280
+ throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
281
+ }
134
282
 
135
- if (!batchFeatureLength) {
136
- throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
137
- }
283
+ if (defined(batchTableBinary)) {
284
+ // Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
285
+ batchTableBinary = new Uint8Array(batchTableBinary);
286
+ }
138
287
 
139
- const {
140
- batchTableJson,
141
- batchTableBinary
142
- } = tile;
143
- batchTable = new Tile3DBatchTable(batchTableJson, batchTableBinary, batchFeatureLength);
288
+ if (defined(pointCloud._batchTableLoaded)) {
289
+ pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);
144
290
  }
145
291
  }
146
292
 
147
- return batchTable;
293
+ // If points are not batched and there are per-point properties, use these properties for styling purposes
294
+ var styleableProperties;
295
+ if (!hasBatchIds && defined(batchTableBinary)) {
296
+ tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(
297
+ pointsLength,
298
+ batchTableJson,
299
+ batchTableBinary
300
+ );
301
+ }
302
+
303
+ tile.draco = draco;
148
304
  }
149
305
 
150
- async function parseDraco(tile, featureTable, batchTable, options, context) {
306
+ // Separate parsing and decoding of Draco
307
+ export function parseDracoBuffer(tile, featureTable, batchTable) {
151
308
  let dracoBuffer;
152
309
  let dracoFeatureTableProperties;
153
310
  let dracoBatchTableProperties;
154
- const batchTableDraco = tile.batchTableJson && tile.batchTableJson.extensions && tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
155
311
 
312
+ const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');
156
313
  if (batchTableDraco) {
157
314
  dracoBatchTableProperties = batchTableDraco.properties;
158
315
  }
159
316
 
160
317
  const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
161
-
162
318
  if (featureTableDraco) {
163
319
  dracoFeatureTableProperties = featureTableDraco.properties;
164
320
  const dracoByteOffset = featureTableDraco.byteOffset;
165
321
  const dracoByteLength = featureTableDraco.byteLength;
166
-
167
- if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
322
+ if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {
168
323
  throw new Error('Draco properties, byteOffset, and byteLength must be defined');
169
324
  }
170
325
 
171
- dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
172
- tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
173
- tile.hasColors = Number.isFinite(dracoFeatureTableProperties.RGB) || Number.isFinite(dracoFeatureTableProperties.RGBA);
174
- tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
175
- tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
176
- tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
326
+ dracoBuffer = arraySlice(
327
+ featureTableBinary,
328
+ dracoByteOffset,
329
+ dracoByteOffset + dracoByteLength
330
+ );
331
+ tile.hasPositions = dracoFeatureTableProperties.POSITION;
332
+ tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;
333
+ tile.hasNormals = dracoFeatureTableProperties.NORMAL;
334
+ tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;
335
+ tile.isTranslucent = dracoFeatureTableProperties.RGBA;
177
336
  }
178
337
 
179
- if (!dracoBuffer) {
180
- return true;
181
- }
182
-
183
- const dracoData = {
184
- buffer: dracoBuffer,
185
- properties: { ...dracoFeatureTableProperties,
186
- ...dracoBatchTableProperties
187
- },
188
- featureTableProperties: dracoFeatureTableProperties,
189
- batchTableProperties: dracoBatchTableProperties,
190
- dequantizeInShader: false
191
- };
192
- return await loadDraco(tile, dracoData, options, context);
193
- }
338
+ if (dracoBuffer) {
339
+ tile.draco = {
340
+ buffer: dracoBuffer,
341
+ properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},
342
+ featureTableProperties: dracoFeatureTableProperties,
343
+ batchTableProperties: dracoBatchTableProperties,
344
+ dequantizeInShader: false
345
+ };
194
346
 
195
- export async function loadDraco(tile, dracoData, options, context) {
196
- const {
197
- parse
198
- } = context;
199
- const dracoOptions = { ...options,
200
- draco: { ...options.draco,
201
- extraAttributes: dracoData.batchTableProperties || {}
202
- }
203
- };
204
- delete dracoOptions['3d-tiles'];
205
- const data = await parse(dracoData.buffer, DracoLoader, dracoOptions);
206
- const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
207
- const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
208
- const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
209
- const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
210
- const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
211
- const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
212
-
213
- if (isQuantizedDraco) {
214
- const quantization = data.POSITION.data.quantization;
215
- const range = quantization.range;
216
- tile.quantizedVolumeScale = new Vector3(range, range, range);
217
- tile.quantizedVolumeOffset = new Vector3(quantization.minValues);
218
- tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
219
- tile.isQuantizedDraco = true;
347
+ tile.decodingState = DECODING_STATE.NEEDS_DECODE;
220
348
  }
349
+ }
221
350
 
222
- if (isOctEncodedDraco) {
223
- tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
224
- tile.isOctEncodedDraco = true;
351
+ /*
352
+ function decodeDraco(tile, context) {
353
+ if (tile.decodingState === DECODING_STATE.READY) {
354
+ return false;
225
355
  }
226
-
227
- const batchTableAttributes = {};
228
-
229
- if (dracoData.batchTableProperties) {
230
- for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
231
- if (data.attributes[attributeName] && data.attributes[attributeName].value) {
232
- batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
233
- }
356
+ if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {
357
+ var parsedContent = tile._parsedContent;
358
+ var draco = parsedContent.draco;
359
+ var decodePromise = DracoLoader.decodePointCloud(draco, context);
360
+ if (defined(decodePromise)) {
361
+ tile.decodingState = DECODING_STATE.DECODING;
362
+ decodePromise.then(function(result) {
363
+ tile.decodingState = DECODING_STATE.READY;
364
+ var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;
365
+ var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;
366
+ var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;
367
+ var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;
368
+ var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;
369
+ var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);
370
+ var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);
371
+ if (isQuantizedDraco) {
372
+ // Draco quantization range == quantized volume scale - size in meters of the quantized volume
373
+ // Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
374
+ var quantization = result.POSITION.data.quantization;
375
+ var range = quantization.range;
376
+ tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);
377
+ tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);
378
+ tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;
379
+ tile._isQuantizedDraco = true;
380
+ }
381
+ if (isOctEncodedDraco) {
382
+ tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;
383
+ tile._isOctEncodedDraco = true;
384
+ }
385
+ var styleableProperties = parsedContent.styleableProperties;
386
+ var batchTableProperties = draco.batchTableProperties;
387
+ for (var name in batchTableProperties) {
388
+ if (batchTableProperties.hasOwnProperty(name)) {
389
+ var property = result[name];
390
+ if (!defined(styleableProperties)) {
391
+ styleableProperties = {};
392
+ }
393
+ styleableProperties[name] = {
394
+ typedArray : property.array,
395
+ componentCount : property.data.componentsPerAttribute
396
+ };
397
+ }
398
+ }
399
+ parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);
400
+ parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);
401
+ parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);
402
+ parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);
403
+ parsedContent.styleableProperties = styleableProperties;
404
+ }).otherwise(function(error) {
405
+ tile.decodingState = DECODING_STATE.FAILED;
406
+ tile._readyPromise.reject(error);
407
+ });
234
408
  }
235
409
  }
236
-
237
- tile.attributes = {
238
- positions: decodedPositions,
239
- colors: normalize3DTileColorAttribute(tile, decodedColors, undefined),
240
- normals: decodedNormals,
241
- batchIds: decodedBatchIds,
242
- ...batchTableAttributes
243
- };
410
+ return true;
244
411
  }
245
- //# sourceMappingURL=parse-3d-tile-point-cloud.js.map
412
+ */