@loaders.gl/tile-converter 4.0.0-alpha.9 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (300) hide show
  1. package/bin/i3s-server.js +4 -0
  2. package/bin/slpk-extractor.js +4 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -5
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +10 -5
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts +10 -0
  8. package/dist/3d-tiles-converter/helpers/load-i3s.d.ts.map +1 -0
  9. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +2 -1
  10. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -1
  11. package/dist/converter.min.js +172 -103
  12. package/dist/deps-installer/deps-installer.d.ts +3 -2
  13. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  14. package/dist/dist.min.js +32715 -32567
  15. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +97 -117
  16. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  17. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +24 -22
  18. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  19. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +63 -0
  20. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  21. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  22. package/dist/es5/converter-cli.js +25 -65
  23. package/dist/es5/converter-cli.js.map +1 -1
  24. package/dist/es5/deps-installer/deps-installer.js +113 -39
  25. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +45 -15
  27. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  29. package/dist/es5/i3s-converter/helpers/feature-attributes.js +8 -18
  30. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  31. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +83 -43
  32. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  33. package/dist/es5/i3s-converter/helpers/geometry-converter.js +100 -102
  34. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  35. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  36. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +70 -4
  37. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/node-index-document.js +3 -2
  39. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +47 -12
  41. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  42. package/dist/es5/i3s-converter/i3s-converter.js +187 -174
  43. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  44. package/dist/es5/i3s-converter/types.js +11 -11
  45. package/dist/es5/i3s-converter/types.js.map +1 -1
  46. package/dist/es5/i3s-server/README.md +46 -2
  47. package/dist/es5/i3s-server/app.js +23 -15
  48. package/dist/es5/i3s-server/app.js.map +1 -1
  49. package/dist/es5/i3s-server/bin/www.js +33 -0
  50. package/dist/es5/i3s-server/bin/www.js.map +1 -0
  51. package/dist/es5/i3s-server/controllers/index-controller.js +23 -22
  52. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  53. package/dist/es5/i3s-server/controllers/slpk-controller.js +35 -38
  54. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  55. package/dist/es5/i3s-server/routes/index.js +2 -2
  56. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  57. package/dist/es5/i3s-server/routes/slpk-router.js +14 -13
  58. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -1
  59. package/dist/es5/i3s-server/utils/create-scene-server.js +7 -4
  60. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -1
  61. package/dist/es5/i3s-server/utils/server-utils.js +49 -0
  62. package/dist/es5/i3s-server/utils/server-utils.js.map +1 -0
  63. package/dist/es5/lib/utils/cli-utils.js +57 -0
  64. package/dist/es5/lib/utils/cli-utils.js.map +1 -0
  65. package/dist/es5/lib/utils/compress-util.js +1 -1
  66. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  67. package/dist/es5/lib/utils/lod-conversion-utils.js +10 -4
  68. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  69. package/dist/es5/pgm-loader.js +11 -3
  70. package/dist/es5/pgm-loader.js.map +1 -1
  71. package/dist/es5/slpk-extractor/slpk-extractor.js +171 -0
  72. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
  73. package/dist/es5/slpk-extractor-cli.js +117 -0
  74. package/dist/es5/slpk-extractor-cli.js.map +1 -0
  75. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +51 -58
  76. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  77. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +12 -11
  78. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  79. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js +32 -0
  80. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  81. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  82. package/dist/esm/converter-cli.js +8 -48
  83. package/dist/esm/converter-cli.js.map +1 -1
  84. package/dist/esm/deps-installer/deps-installer.js +38 -12
  85. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  86. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +28 -11
  87. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  88. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  89. package/dist/esm/i3s-converter/helpers/feature-attributes.js +10 -8
  90. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  91. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +77 -34
  92. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  93. package/dist/esm/i3s-converter/helpers/geometry-converter.js +60 -61
  94. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  95. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  96. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +33 -4
  97. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -1
  98. package/dist/esm/i3s-converter/helpers/node-index-document.js +2 -1
  99. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  100. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +37 -12
  101. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  102. package/dist/esm/i3s-converter/i3s-converter.js +101 -73
  103. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  104. package/dist/esm/i3s-converter/types.js +9 -9
  105. package/dist/esm/i3s-converter/types.js.map +1 -1
  106. package/dist/esm/i3s-server/README.md +46 -2
  107. package/dist/esm/i3s-server/app.js +13 -11
  108. package/dist/esm/i3s-server/app.js.map +1 -1
  109. package/dist/esm/i3s-server/bin/i3s-server.min.js +516 -0
  110. package/dist/esm/i3s-server/bin/www.js +30 -0
  111. package/dist/esm/i3s-server/bin/www.js.map +1 -0
  112. package/dist/esm/i3s-server/controllers/index-controller.js +4 -7
  113. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  114. package/dist/esm/i3s-server/controllers/slpk-controller.js +9 -26
  115. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  116. package/dist/esm/i3s-server/routes/index.js +1 -1
  117. package/dist/esm/i3s-server/routes/index.js.map +1 -1
  118. package/dist/esm/i3s-server/routes/slpk-router.js +5 -11
  119. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -1
  120. package/dist/esm/i3s-server/utils/create-scene-server.js +2 -5
  121. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -1
  122. package/dist/esm/i3s-server/utils/server-utils.js +40 -0
  123. package/dist/esm/i3s-server/utils/server-utils.js.map +1 -0
  124. package/dist/esm/lib/utils/cli-utils.js +47 -0
  125. package/dist/esm/lib/utils/cli-utils.js.map +1 -0
  126. package/dist/esm/lib/utils/compress-util.js +1 -1
  127. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  128. package/dist/esm/lib/utils/lod-conversion-utils.js +6 -4
  129. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  130. package/dist/esm/pgm-loader.js +7 -4
  131. package/dist/esm/pgm-loader.js.map +1 -1
  132. package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
  133. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
  134. package/dist/esm/slpk-extractor-cli.js +74 -0
  135. package/dist/esm/slpk-extractor-cli.js.map +1 -0
  136. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +15 -2
  137. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  138. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
  139. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  140. package/dist/i3s-converter/helpers/feature-attributes.d.ts +8 -8
  141. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  142. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  143. package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -9
  144. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  145. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +3 -3
  146. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  147. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +15 -0
  148. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -1
  149. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  150. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +4 -5
  151. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  152. package/dist/i3s-converter/i3s-converter.d.ts +3 -2
  153. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  154. package/dist/i3s-converter/types.d.ts +48 -7
  155. package/dist/i3s-converter/types.d.ts.map +1 -1
  156. package/dist/i3s-server/app.d.ts +1 -2
  157. package/dist/i3s-server/app.d.ts.map +1 -1
  158. package/dist/i3s-server/bin/www.d.ts +3 -0
  159. package/dist/i3s-server/bin/www.d.ts.map +1 -0
  160. package/dist/i3s-server/controllers/index-controller.d.ts +6 -1
  161. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -1
  162. package/dist/i3s-server/controllers/slpk-controller.d.ts +13 -2
  163. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  164. package/dist/i3s-server/routes/index.d.ts +1 -2
  165. package/dist/i3s-server/routes/index.d.ts.map +1 -1
  166. package/dist/i3s-server/routes/slpk-router.d.ts +2 -2
  167. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -1
  168. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -5
  169. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -1
  170. package/dist/i3s-server/utils/server-utils.d.ts +24 -0
  171. package/dist/i3s-server/utils/server-utils.d.ts.map +1 -0
  172. package/dist/lib/utils/cli-utils.d.ts +34 -0
  173. package/dist/lib/utils/cli-utils.d.ts.map +1 -0
  174. package/dist/lib/utils/lod-conversion-utils.d.ts +2 -2
  175. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  176. package/dist/pgm-loader.d.ts +9 -2
  177. package/dist/pgm-loader.d.ts.map +1 -1
  178. package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
  179. package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
  180. package/dist/slpk-extractor-cli.d.ts +17 -0
  181. package/dist/slpk-extractor-cli.d.ts.map +1 -0
  182. package/dist/slpk-extractor.min.js +189 -0
  183. package/package.json +27 -21
  184. package/src/3d-tiles-converter/3d-tiles-converter.ts +65 -69
  185. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +23 -19
  186. package/src/3d-tiles-converter/helpers/load-i3s.ts +52 -0
  187. package/src/3d-tiles-converter/helpers/texture-atlas.ts +6 -2
  188. package/src/converter-cli.ts +16 -74
  189. package/src/deps-installer/deps-installer.ts +56 -11
  190. package/src/i3s-converter/helpers/batch-ids-extensions.ts +77 -32
  191. package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
  192. package/src/i3s-converter/helpers/feature-attributes.ts +23 -18
  193. package/src/i3s-converter/helpers/geometry-attributes.ts +81 -44
  194. package/src/i3s-converter/helpers/geometry-converter.ts +149 -126
  195. package/src/i3s-converter/helpers/gltf-attributes.ts +9 -10
  196. package/src/i3s-converter/helpers/load-3d-tiles.ts +61 -5
  197. package/src/i3s-converter/helpers/node-index-document.ts +5 -1
  198. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +70 -21
  199. package/src/i3s-converter/i3s-converter.ts +145 -73
  200. package/src/i3s-converter/types.ts +49 -7
  201. package/src/i3s-server/README.md +46 -2
  202. package/src/i3s-server/{app.js → app.ts} +11 -9
  203. package/src/i3s-server/bin/www.ts +38 -0
  204. package/src/i3s-server/controllers/{index-controller.js → index-controller.ts} +10 -9
  205. package/src/i3s-server/controllers/slpk-controller.ts +32 -0
  206. package/src/i3s-server/routes/{index.js → index.ts} +2 -1
  207. package/src/i3s-server/routes/{slpk-router.js → slpk-router.ts} +5 -10
  208. package/src/i3s-server/utils/create-scene-server.ts +20 -0
  209. package/src/i3s-server/utils/server-utils.ts +70 -0
  210. package/src/lib/utils/cli-utils.ts +78 -0
  211. package/src/lib/utils/compress-util.ts +1 -1
  212. package/src/lib/utils/lod-conversion-utils.ts +10 -6
  213. package/src/pgm-loader.ts +15 -7
  214. package/src/slpk-extractor/slpk-extractor.ts +101 -0
  215. package/src/slpk-extractor-cli.ts +128 -0
  216. package/dist/3d-tiles-attributes-worker.d.ts +0 -28
  217. package/dist/3d-tiles-attributes-worker.d.ts.map +0 -1
  218. package/dist/3d-tiles-attributes-worker.js +0 -3
  219. package/dist/3d-tiles-attributes-worker.js.map +0 -7
  220. package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -288
  221. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -269
  222. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
  223. package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
  224. package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
  225. package/dist/bundle.js +0 -5
  226. package/dist/constants.js +0 -4
  227. package/dist/converter-cli.js +0 -280
  228. package/dist/deps-installer/deps-installer.js +0 -63
  229. package/dist/es5/3d-tiles-attributes-worker.js +0 -25
  230. package/dist/es5/3d-tiles-attributes-worker.js.map +0 -1
  231. package/dist/es5/i3s-attributes-worker.js +0 -25
  232. package/dist/es5/i3s-attributes-worker.js.map +0 -1
  233. package/dist/es5/i3s-server/bin/www +0 -102
  234. package/dist/es5/workers/3d-tiles-attributes-worker.js +0 -28
  235. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +0 -1
  236. package/dist/es5/workers/i3s-attributes-worker.js +0 -30
  237. package/dist/es5/workers/i3s-attributes-worker.js.map +0 -1
  238. package/dist/esm/3d-tiles-attributes-worker.js +0 -16
  239. package/dist/esm/3d-tiles-attributes-worker.js.map +0 -1
  240. package/dist/esm/i3s-attributes-worker.js +0 -16
  241. package/dist/esm/i3s-attributes-worker.js.map +0 -1
  242. package/dist/esm/i3s-server/bin/www +0 -102
  243. package/dist/esm/workers/3d-tiles-attributes-worker.js +0 -8
  244. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +0 -1
  245. package/dist/esm/workers/i3s-attributes-worker.js +0 -7
  246. package/dist/esm/workers/i3s-attributes-worker.js.map +0 -1
  247. package/dist/i3s-attributes-worker.d.ts +0 -45
  248. package/dist/i3s-attributes-worker.d.ts.map +0 -1
  249. package/dist/i3s-attributes-worker.js +0 -9
  250. package/dist/i3s-attributes-worker.js.map +0 -7
  251. package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -138
  252. package/dist/i3s-converter/helpers/coordinate-converter.js +0 -123
  253. package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
  254. package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
  255. package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
  256. package/dist/i3s-converter/helpers/geometry-converter.js +0 -1225
  257. package/dist/i3s-converter/helpers/gltf-attributes.js +0 -128
  258. package/dist/i3s-converter/helpers/load-3d-tiles.js +0 -53
  259. package/dist/i3s-converter/helpers/node-debug.js +0 -120
  260. package/dist/i3s-converter/helpers/node-index-document.js +0 -268
  261. package/dist/i3s-converter/helpers/node-pages.js +0 -316
  262. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +0 -76
  263. package/dist/i3s-converter/helpers/tileset-traversal.js +0 -29
  264. package/dist/i3s-converter/i3s-converter.js +0 -911
  265. package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
  266. package/dist/i3s-converter/json-templates/layers.js +0 -139
  267. package/dist/i3s-converter/json-templates/metadata.js +0 -25
  268. package/dist/i3s-converter/json-templates/node.js +0 -89
  269. package/dist/i3s-converter/json-templates/scene-server.js +0 -31
  270. package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
  271. package/dist/i3s-converter/json-templates/store.js +0 -103
  272. package/dist/i3s-converter/types.js +0 -17
  273. package/dist/i3s-server/app.js +0 -22
  274. package/dist/i3s-server/controllers/index-controller.js +0 -23
  275. package/dist/i3s-server/controllers/slpk-controller.js +0 -32
  276. package/dist/i3s-server/routes/index.js +0 -16
  277. package/dist/i3s-server/routes/slpk-router.js +0 -33
  278. package/dist/i3s-server/utils/create-scene-server.js +0 -14
  279. package/dist/index.js +0 -10
  280. package/dist/lib/utils/compress-util.js +0 -257
  281. package/dist/lib/utils/file-utils.js +0 -139
  282. package/dist/lib/utils/geometry-utils.js +0 -18
  283. package/dist/lib/utils/lod-conversion-utils.js +0 -76
  284. package/dist/lib/utils/queue.js +0 -18
  285. package/dist/lib/utils/statistic-utills.js +0 -64
  286. package/dist/lib/utils/write-queue.js +0 -80
  287. package/dist/pgm-loader.js +0 -24
  288. package/dist/workers/3d-tiles-attributes-worker.d.ts +0 -2
  289. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +0 -1
  290. package/dist/workers/3d-tiles-attributes-worker.js +0 -9
  291. package/dist/workers/i3s-attributes-worker.d.ts +0 -2
  292. package/dist/workers/i3s-attributes-worker.d.ts.map +0 -1
  293. package/dist/workers/i3s-attributes-worker.js +0 -5
  294. package/src/3d-tiles-attributes-worker.ts +0 -43
  295. package/src/i3s-attributes-worker.ts +0 -59
  296. package/src/i3s-server/bin/www +0 -102
  297. package/src/i3s-server/controllers/slpk-controller.js +0 -38
  298. package/src/i3s-server/utils/create-scene-server.js +0 -15
  299. package/src/workers/3d-tiles-attributes-worker.ts +0 -6
  300. package/src/workers/i3s-attributes-worker.ts +0 -7
@@ -1,13 +1,13 @@
1
1
  import type {FeatureTableJson, Tiles3DTileContent} from '@loaders.gl/3d-tiles';
2
2
  import type {
3
- GLTF_EXT_feature_metadata,
4
- GLTF_EXT_mesh_features,
5
3
  GLTFAccessorPostprocessed,
6
4
  GLTFMaterialPostprocessed,
7
5
  GLTFNodePostprocessed,
8
6
  GLTFMeshPrimitivePostprocessed,
9
7
  GLTFMeshPostprocessed,
10
- GLTFTexturePostprocessed
8
+ GLTFTexturePostprocessed,
9
+ GLTF_EXT_feature_metadata_GLTF,
10
+ GLTF_EXT_structural_metadata_GLTF
11
11
  } from '@loaders.gl/gltf';
12
12
 
13
13
  import {Vector3, Matrix4, Vector4} from '@math.gl/core';
@@ -35,13 +35,8 @@ import {
35
35
  } from '@loaders.gl/i3s';
36
36
  import {NumberArray, TypedArray} from '@loaders.gl/loader-utils';
37
37
  import {Geoid} from '@math.gl/geoid';
38
- /** Usage of worker here brings more overhead than advantage */
39
- import {
40
- B3DMAttributesData /*, transformI3SAttributesOnWorker*/,
41
- TextureImageProperties
42
- } from '../../i3s-attributes-worker';
43
38
  import {prepareDataForAttributesConversion} from './gltf-attributes';
44
- import {handleBatchIdsExtensions} from './batch-ids-extensions';
39
+ import {getTextureByMetadataClass, handleBatchIdsExtensions} from './batch-ids-extensions';
45
40
  import {checkPropertiesLength, flattenPropertyTableByFeatureIds} from './feature-attributes';
46
41
  import {GL} from '@loaders.gl/math';
47
42
 
@@ -50,10 +45,17 @@ import {GL} from '@loaders.gl/math';
50
45
  So the following import is replaced with the local import
51
46
  import type {TypedArrayConstructor} from '@math.gl/types';
52
47
  */
53
- import type {TypedArrayConstructor} from '../types';
48
+ import type {GLTFAttributesData, TextureImageProperties, TypedArrayConstructor} from '../types';
54
49
  import {generateSyntheticIndices} from '../../lib/utils/geometry-utils';
55
50
  import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
56
51
 
52
+ import {
53
+ EXT_FEATURE_METADATA,
54
+ EXT_STRUCTURAL_METADATA,
55
+ getPropertyTableFromExtFeatureMetadata,
56
+ getPropertyTableFromExtStructuralMetadata
57
+ } from '@loaders.gl/gltf';
58
+
57
59
  // Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/pbrMetallicRoughness.cmn.md
58
60
  const DEFAULT_ROUGHNESS_FACTOR = 1;
59
61
  const DEFAULT_METALLIC_FACTOR = 1;
@@ -73,9 +75,6 @@ const OBJECT_ID_TYPE = 'Oid32';
73
75
  */
74
76
  const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
75
77
 
76
- const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
77
- const EXT_MESH_FEATURES = 'EXT_mesh_features';
78
-
79
78
  let scratchVector = new Vector3();
80
79
 
81
80
  /**
@@ -93,7 +92,8 @@ let scratchVector = new Vector3();
93
92
  * @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
94
93
  * @param shouldMergeMaterials - Try to merge similar materials to be able to merge meshes into one node
95
94
  * @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
96
- * @param workerSource - source code of used workers
95
+ * @param libraries - dynamicaly loaded 3rd-party libraries
96
+ * @param metadataClass `- user selected feature metadata class name`
97
97
  * @returns Array of node resources to create one or more i3s nodes
98
98
  */
99
99
  export default async function convertB3dmToI3sGeometry(
@@ -108,7 +108,8 @@ export default async function convertB3dmToI3sGeometry(
108
108
  generateBoundingVolumes: boolean,
109
109
  shouldMergeMaterials: boolean,
110
110
  geoidHeightModel: Geoid,
111
- workerSource: {[key: string]: string}
111
+ libraries: Record<string, string>,
112
+ metadataClass?: string
112
113
  ): Promise<I3SConvertedResources[] | null> {
113
114
  const useCartesianPositions = generateBoundingVolumes;
114
115
  const materialAndTextureList: I3SMaterialWithTexture[] = await convertMaterials(
@@ -121,10 +122,12 @@ export default async function convertB3dmToI3sGeometry(
121
122
  tileTransform,
122
123
  tileBoundingVolume
123
124
  );
125
+ const featureTexture = getTextureByMetadataClass(tileContent, metadataClass);
124
126
  const convertedAttributesMap: Map<string, ConvertedAttributes> = await convertAttributes(
125
127
  dataForAttributesConversion,
126
128
  materialAndTextureList,
127
- useCartesianPositions
129
+ useCartesianPositions,
130
+ featureTexture
128
131
  );
129
132
  /** Usage of worker here brings more overhead than advantage */
130
133
  // const convertedAttributesMap: Map<string, ConvertedAttributes> =
@@ -162,7 +165,7 @@ export default async function convertB3dmToI3sGeometry(
162
165
  propertyTable,
163
166
  attributeStorageInfo,
164
167
  draco,
165
- workerSource
168
+ libraries
166
169
  })
167
170
  );
168
171
  }
@@ -214,7 +217,7 @@ function _generateBoundingVolumesFromGeometry(
214
217
  * @param params.propertyTable - batch table (corresponding to feature attributes data)
215
218
  * @param params.attributeStorageInfo - attributes metadata from 3DSceneLayer json
216
219
  * @param params.draco - is converter should create draco compressed geometry
217
- * @param params.workerSource - source code of used workers
220
+ * @param libraries - dynamicaly loaded 3rd-party libraries
218
221
  * @returns Array of I3S node resources
219
222
  */
220
223
  async function _makeNodeResources({
@@ -227,7 +230,7 @@ async function _makeNodeResources({
227
230
  propertyTable,
228
231
  attributeStorageInfo,
229
232
  draco,
230
- workerSource
233
+ libraries
231
234
  }: {
232
235
  convertedAttributes: ConvertedAttributes;
233
236
  material: I3SMaterialDefinition;
@@ -238,19 +241,25 @@ async function _makeNodeResources({
238
241
  propertyTable: FeatureTableJson | null;
239
242
  attributeStorageInfo?: AttributeStorageInfo[];
240
243
  draco: boolean;
241
- workerSource: {[key: string]: string};
244
+ libraries: Record<string, string>;
242
245
  }): Promise<I3SConvertedResources> {
243
246
  const boundingVolumes = convertedAttributes.boundingVolumes;
244
247
  const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
245
248
  const {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount} =
246
249
  generateAttributes(convertedAttributes);
247
250
 
248
- if (tileContent.batchTableJson) {
249
- makeFeatureIdsUnique(
251
+ let featureIdsMap: Record<string, number> = {};
252
+ if (propertyTable) {
253
+ /**
254
+ * 3DTiles has featureIndices unique only for one tile.
255
+ * In I3S featureIds are unique layer-wide. We create featureIds from all feature properties.
256
+ * If 3DTiles features has equal set of properties they are considered as same feature in I3S.
257
+ */
258
+ featureIdsMap = makeFeatureIdsUnique(
250
259
  featureIds,
251
260
  convertedAttributes.featureIndices,
252
261
  featuresHashArray,
253
- tileContent.batchTableJson
262
+ propertyTable
254
263
  );
255
264
  }
256
265
 
@@ -283,7 +292,7 @@ async function _makeNodeResources({
283
292
  featureIds,
284
293
  faceRange
285
294
  },
286
- workerSource.draco
295
+ libraries
287
296
  )
288
297
  : null;
289
298
 
@@ -292,6 +301,7 @@ async function _makeNodeResources({
292
301
  if (attributeStorageInfo && propertyTable) {
293
302
  attributes = convertPropertyTableToAttributeBuffers(
294
303
  featureIds,
304
+ featureIdsMap,
295
305
  propertyTable,
296
306
  attributeStorageInfo
297
307
  );
@@ -318,12 +328,14 @@ async function _makeNodeResources({
318
328
  * @param materialAndTextureList - array of data about materials and textures of the content
319
329
  * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
320
330
  * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
331
+ * @param featureTexture - feature texture key
321
332
  * @returns map of converted geometry attributes
322
333
  */
323
334
  export async function convertAttributes(
324
- attributesData: B3DMAttributesData,
335
+ attributesData: GLTFAttributesData,
325
336
  materialAndTextureList: I3SMaterialWithTexture[],
326
- useCartesianPositions: boolean
337
+ useCartesianPositions: boolean,
338
+ featureTexture: string | null
327
339
  ): Promise<Map<string, ConvertedAttributes>> {
328
340
  const {nodes, images, cartographicOrigin, cartesianModelMatrix} = attributesData;
329
341
  const attributesMap = new Map<string, ConvertedAttributes>();
@@ -351,7 +363,9 @@ export async function convertAttributes(
351
363
  cartographicOrigin,
352
364
  cartesianModelMatrix,
353
365
  attributesMap,
354
- useCartesianPositions
366
+ useCartesianPositions,
367
+ undefined,
368
+ featureTexture
355
369
  );
356
370
 
357
371
  for (const attrKey of attributesMap.keys()) {
@@ -375,7 +389,7 @@ export async function convertAttributes(
375
389
  }
376
390
 
377
391
  /**
378
- * Gltf has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.
392
+ * glTF has hierarchical structure of nodes. This function converts nodes starting from those which are in gltf scene object.
379
393
  * The goal is applying tranformation matrix for all children. Functions "convertNodes" and "convertNode" work together recursively.
380
394
  * @param nodes - gltf nodes array
381
395
  * @param images - gltf images array
@@ -385,6 +399,7 @@ export async function convertAttributes(
385
399
  * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
386
400
  * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
387
401
  * @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
402
+ * @param featureTexture - feature texture key
388
403
  * @returns {void}
389
404
  */
390
405
  function convertNodes(
@@ -394,7 +409,8 @@ function convertNodes(
394
409
  cartesianModelMatrix: Matrix4,
395
410
  attributesMap: Map<string, ConvertedAttributes>,
396
411
  useCartesianPositions: boolean,
397
- matrix: Matrix4 = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
412
+ matrix: Matrix4 = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
413
+ featureTexture: string | null
398
414
  ) {
399
415
  if (nodes) {
400
416
  for (const node of nodes) {
@@ -405,7 +421,8 @@ function convertNodes(
405
421
  cartesianModelMatrix,
406
422
  attributesMap,
407
423
  useCartesianPositions,
408
- matrix
424
+ matrix,
425
+ featureTexture
409
426
  );
410
427
  }
411
428
  }
@@ -447,11 +464,12 @@ function getCompositeTransformationMatrix(node: GLTFNodePostprocessed, matrix: M
447
464
  * @param images - gltf images array
448
465
  * @param cartographicOrigin - cartographic origin of bounding volume
449
466
  * @param cartesianModelMatrix - cartesian model matrix to convert coordinates to cartographic
450
- * @param {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
467
+ * @param attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
451
468
  * attributes
452
469
  * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
453
470
  * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
454
- * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
471
+ * @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
472
+ * @param featureTexture - feature texture key
455
473
  */
456
474
  function convertNode(
457
475
  node: GLTFNodePostprocessed,
@@ -460,7 +478,8 @@ function convertNode(
460
478
  cartesianModelMatrix: Matrix4,
461
479
  attributesMap: Map<string, ConvertedAttributes>,
462
480
  useCartesianPositions,
463
- matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
481
+ matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
482
+ featureTexture: string | null
464
483
  ) {
465
484
  const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
466
485
 
@@ -474,7 +493,8 @@ function convertNode(
474
493
  cartesianModelMatrix,
475
494
  attributesMap,
476
495
  useCartesianPositions,
477
- transformationMatrix
496
+ transformationMatrix,
497
+ featureTexture
478
498
  );
479
499
  }
480
500
 
@@ -485,7 +505,8 @@ function convertNode(
485
505
  cartesianModelMatrix,
486
506
  attributesMap,
487
507
  useCartesianPositions,
488
- transformationMatrix
508
+ transformationMatrix,
509
+ featureTexture
489
510
  );
490
511
  }
491
512
 
@@ -497,12 +518,12 @@ function convertNode(
497
518
  * @param cartesianModelMatrix - cartesian model matrix to convert coordinates to cartographic
498
519
  * @param attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
499
520
  * attributes
500
- * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
521
+ * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
501
522
  * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
502
523
  * @param attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
503
524
  * attributes
504
-
505
- * @param {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
525
+ * @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
526
+ * @param featureTexture - feature texture key
506
527
  */
507
528
  function convertMesh(
508
529
  mesh: GLTFMeshPostprocessed,
@@ -511,7 +532,8 @@ function convertMesh(
511
532
  cartesianModelMatrix: Matrix4,
512
533
  attributesMap: Map<string, ConvertedAttributes>,
513
534
  useCartesianPositions = false,
514
- matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])
535
+ matrix = new Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]),
536
+ featureTexture: string | null
515
537
  ) {
516
538
  for (const primitive of mesh.primitives) {
517
539
  let outputAttributes: ConvertedAttributes | null | undefined = null;
@@ -582,7 +604,7 @@ function convertMesh(
582
604
 
583
605
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
584
606
  outputAttributes.featureIndicesGroups.push(
585
- flattenBatchIds(getBatchIds(attributes, primitive, images), indices)
607
+ flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices)
586
608
  );
587
609
  }
588
610
  }
@@ -809,15 +831,23 @@ function flattenBatchIds(batchedIds: NumberArray, indices: TypedArray): number[]
809
831
  * @param attributes - gltf accessors
810
832
  * @param primitive - gltf primitive data
811
833
  * @param images - gltf texture images
834
+ * @param featureTexture - feature texture key
835
+ * @return batch IDs
812
836
  */
813
837
  function getBatchIds(
814
838
  attributes: {
815
839
  [key: string]: GLTFAccessorPostprocessed;
816
840
  },
817
841
  primitive: GLTFMeshPrimitivePostprocessed,
818
- images: (TextureImageProperties | null)[]
842
+ images: (TextureImageProperties | null)[],
843
+ featureTexture: string | null
819
844
  ): NumberArray {
820
- const batchIds: NumberArray = handleBatchIdsExtensions(attributes, primitive, images);
845
+ const batchIds: NumberArray = handleBatchIdsExtensions(
846
+ attributes,
847
+ primitive,
848
+ images,
849
+ featureTexture
850
+ );
821
851
 
822
852
  if (batchIds.length) {
823
853
  return batchIds;
@@ -1027,7 +1057,7 @@ function convertMaterial(sourceMaterial: GLTFMaterialPostprocessed): I3SMaterial
1027
1057
 
1028
1058
  /**
1029
1059
  * Converts from `alphaMode` material property from GLTF to I3S format
1030
- * @param gltfAlphaMode Gltf material `alphaMode` property
1060
+ * @param gltfAlphaMode glTF material `alphaMode` property
1031
1061
  * @returns I3SMaterialDefinition.alphaMode property
1032
1062
  */
1033
1063
  function convertAlphaMode(
@@ -1233,17 +1263,18 @@ function generateImageId(texture: GLTFTexturePostprocessed, nodeId: number) {
1233
1263
  * @param featureIndices
1234
1264
  * @param featuresHashArray
1235
1265
  * @param batchTable
1236
- * @returns {void}
1266
+ * @returns propertyTable indices to map featureIds
1237
1267
  */
1238
1268
  function makeFeatureIdsUnique(
1239
1269
  featureIds: number[],
1240
1270
  featureIndices: number[],
1241
1271
  featuresHashArray: string[],
1242
1272
  batchTable: {[key: string]: any}
1243
- ) {
1273
+ ): Record<string, number> {
1244
1274
  const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
1245
1275
  replaceIndicesByUnique(featureIndices, replaceMap);
1246
1276
  replaceIndicesByUnique(featureIds, replaceMap);
1277
+ return replaceMap;
1247
1278
  }
1248
1279
 
1249
1280
  /**
@@ -1257,8 +1288,8 @@ function getFeaturesReplaceMap(
1257
1288
  featureIds: any[],
1258
1289
  batchTable: object,
1259
1290
  featuresHashArray: any[]
1260
- ): Record<string, any> {
1261
- const featureMap: Record<string, any> = {};
1291
+ ): Record<string, number> {
1292
+ const featureMap: Record<string, number> = {};
1262
1293
 
1263
1294
  for (let index = 0; index < featureIds.length; index++) {
1264
1295
  const oldFeatureId = featureIds[index];
@@ -1310,7 +1341,7 @@ function getOrCreateUniqueFeatureId(
1310
1341
  * @param featureMap
1311
1342
  * @returns
1312
1343
  */
1313
- function replaceIndicesByUnique(indicesArray: any[], featureMap: Record<string, []>) {
1344
+ function replaceIndicesByUnique(indicesArray: number[], featureMap: Record<string, number>) {
1314
1345
  for (let index = 0; index < indicesArray.length; index++) {
1315
1346
  indicesArray[index] = featureMap[indicesArray[index]];
1316
1347
  }
@@ -1325,6 +1356,7 @@ function replaceIndicesByUnique(indicesArray: any[], featureMap: Record<string,
1325
1356
  */
1326
1357
  function convertPropertyTableToAttributeBuffers(
1327
1358
  featureIds: number[],
1359
+ featureIdsMap: Record<string, number>,
1328
1360
  propertyTable: FeatureTableJson,
1329
1361
  attributeStorageInfo: AttributeStorageInfo[]
1330
1362
  ): any[] {
@@ -1332,7 +1364,7 @@ function convertPropertyTableToAttributeBuffers(
1332
1364
 
1333
1365
  const needFlattenPropertyTable = checkPropertiesLength(featureIds, propertyTable);
1334
1366
  const properties = needFlattenPropertyTable
1335
- ? flattenPropertyTableByFeatureIds(featureIds, propertyTable)
1367
+ ? flattenPropertyTableByFeatureIds(featureIdsMap, propertyTable)
1336
1368
  : propertyTable;
1337
1369
 
1338
1370
  const propertyTableWithObjectIds = {
@@ -1342,10 +1374,12 @@ function convertPropertyTableToAttributeBuffers(
1342
1374
 
1343
1375
  for (const propertyName in propertyTableWithObjectIds) {
1344
1376
  const type = getAttributeType(propertyName, attributeStorageInfo);
1345
- const value = propertyTableWithObjectIds[propertyName];
1346
- const attributeBuffer = generateAttributeBuffer(type, value);
1377
+ if (type) {
1378
+ const value = propertyTableWithObjectIds[propertyName];
1379
+ const attributeBuffer = generateAttributeBuffer(type, value);
1347
1380
 
1348
- attributeBuffers.push(attributeBuffer);
1381
+ attributeBuffers.push(attributeBuffer);
1382
+ }
1349
1383
  }
1350
1384
 
1351
1385
  return attributeBuffers;
@@ -1385,6 +1419,20 @@ function generateAttributeBuffer(type: string, value: any): ArrayBuffer {
1385
1419
  */
1386
1420
  function getAttributeType(key: string, attributeStorageInfo: any[]): string {
1387
1421
  const attribute = attributeStorageInfo.find((attr) => attr.name === key);
1422
+ if (!attribute) {
1423
+ console.error(
1424
+ `attribute is null, key=${key}, attributeStorageInfo=${JSON.stringify(
1425
+ attributeStorageInfo,
1426
+ null,
1427
+ 2
1428
+ )}`
1429
+ );
1430
+ return '';
1431
+ }
1432
+ if (!attribute.attributeValues) {
1433
+ console.error(`attributeValues is null, attribute=${attribute}`);
1434
+ return '';
1435
+ }
1388
1436
  return attribute.attributeValues.valueType;
1389
1437
  }
1390
1438
 
@@ -1457,17 +1505,17 @@ function generateBigUint64Array(featureIds: any[]): BigUint64Array {
1457
1505
 
1458
1506
  /**
1459
1507
  * Generates draco compressed geometry
1460
- * @param {Number} vertexCount
1461
- * @param {Object} convertedAttributes - get rid of this argument here
1462
- * @param {Object} attributes - geometry attributes to compress
1463
- * @param {string} dracoWorkerSoure - draco worker source code
1464
- * @returns {Promise<object>} - COmpressed geometry.
1508
+ * @param vertexCount
1509
+ * @param convertedAttributes - get rid of this argument here
1510
+ * @param attributes - geometry attributes to compress
1511
+ * @param libraries - dynamicaly loaded 3rd-party libraries
1512
+ * @returns - Compressed geometry.
1465
1513
  */
1466
1514
  async function generateCompressedGeometry(
1467
1515
  vertexCount: number,
1468
1516
  convertedAttributes: Record<string, any>,
1469
1517
  attributes: Record<string, any>,
1470
- dracoWorkerSoure: string
1518
+ libraries: Record<string, string>
1471
1519
  ): Promise<ArrayBuffer> {
1472
1520
  const {positions, normals, texCoords, colors, uvRegions, featureIds, faceRange} = attributes;
1473
1521
  const indices = new Uint32Array(vertexCount);
@@ -1516,12 +1564,17 @@ async function generateCompressedGeometry(
1516
1564
 
1517
1565
  return encode({attributes: compressedAttributes, indices}, DracoWriterWorker, {
1518
1566
  ...DracoWriterWorker.options,
1519
- source: dracoWorkerSoure,
1520
1567
  reuseWorkers: true,
1521
1568
  _nodeWorkers: true,
1569
+ modules: libraries,
1570
+ useLocalLibraries: true,
1522
1571
  draco: {
1523
1572
  method: 'MESH_SEQUENTIAL_ENCODING',
1524
1573
  attributesMetadata
1574
+ },
1575
+ ['draco-writer']: {
1576
+ // We need to load local fs workers because nodejs can't load workers from the Internet
1577
+ workerUrl: './modules/draco/dist/draco-writer-worker-node.js'
1525
1578
  }
1526
1579
  });
1527
1580
  }
@@ -1556,14 +1609,18 @@ function generateFeatureIndexAttribute(
1556
1609
  * Find property table in tile
1557
1610
  * For example it can be batchTable for b3dm files or property table in gLTF extension.
1558
1611
  * @param tileContent - 3DTiles tile content
1559
- * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
1612
+ * @param metadataClass - user selected feature metadata class name
1613
+ * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA or EXT_STRUCTURAL_METADATA.
1560
1614
  */
1561
- export function getPropertyTable(tileContent: Tiles3DTileContent | null): FeatureTableJson | null {
1615
+ export function getPropertyTable(
1616
+ tileContent: Tiles3DTileContent | null,
1617
+ metadataClass?: string
1618
+ ): FeatureTableJson | null {
1562
1619
  if (!tileContent) {
1563
1620
  return null;
1564
1621
  }
1565
-
1566
- const batchTableJson = tileContent?.batchTableJson;
1622
+ let propertyTable: FeatureTableJson | null;
1623
+ const batchTableJson = tileContent.batchTableJson;
1567
1624
 
1568
1625
  if (batchTableJson) {
1569
1626
  return batchTableJson;
@@ -1572,12 +1629,19 @@ export function getPropertyTable(tileContent: Tiles3DTileContent | null): Featur
1572
1629
  const {extensionName, extension} = getPropertyTableExtension(tileContent);
1573
1630
 
1574
1631
  switch (extensionName) {
1575
- case EXT_MESH_FEATURES: {
1576
- console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
1577
- return null;
1632
+ case EXT_STRUCTURAL_METADATA: {
1633
+ propertyTable = getPropertyTableFromExtStructuralMetadata(
1634
+ extension as GLTF_EXT_structural_metadata_GLTF,
1635
+ metadataClass
1636
+ );
1637
+ return propertyTable;
1578
1638
  }
1579
1639
  case EXT_FEATURE_METADATA: {
1580
- return getPropertyTableFromExtFeatureMetadata(extension as GLTF_EXT_feature_metadata);
1640
+ propertyTable = getPropertyTableFromExtFeatureMetadata(
1641
+ extension as GLTF_EXT_feature_metadata_GLTF,
1642
+ metadataClass
1643
+ );
1644
+ return propertyTable;
1581
1645
  }
1582
1646
  default:
1583
1647
  return null;
@@ -1588,10 +1652,11 @@ export function getPropertyTable(tileContent: Tiles3DTileContent | null): Featur
1588
1652
  * Check extensions which can be with property table inside.
1589
1653
  * @param tileContent - 3DTiles tile content
1590
1654
  */
1591
- function getPropertyTableExtension(
1592
- tileContent: Tiles3DTileContent
1593
- ): GLTF_EXT_feature_metadata | GLTF_EXT_mesh_features {
1594
- const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
1655
+ function getPropertyTableExtension(tileContent: Tiles3DTileContent): {
1656
+ extensionName: null | string;
1657
+ extension: string | GLTF_EXT_feature_metadata_GLTF | GLTF_EXT_structural_metadata_GLTF | null;
1658
+ } {
1659
+ const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_STRUCTURAL_METADATA];
1595
1660
  const extensionsUsed = tileContent?.gltf?.extensionsUsed;
1596
1661
 
1597
1662
  if (!extensionsUsed) {
@@ -1599,69 +1664,27 @@ function getPropertyTableExtension(
1599
1664
  }
1600
1665
 
1601
1666
  let extensionName: string = '';
1602
-
1603
1667
  for (const extensionItem of tileContent?.gltf?.extensionsUsed || []) {
1604
1668
  if (extensionsWithPropertyTables.includes(extensionItem)) {
1605
1669
  extensionName = extensionItem;
1670
+ /*
1671
+ It returns the first extension containing the property table.
1672
+ We assume that there can be only one extension containing the property table:
1673
+ either EXT_FEATURE_METADATA, which is a depricated extension,
1674
+ or EXT_STRUCTURAL_METADATA.
1675
+ */
1606
1676
  break;
1607
1677
  }
1608
1678
  }
1609
1679
 
1610
- const extension = tileContent?.gltf?.extensions?.[extensionName];
1611
-
1612
- return {extensionName, extension};
1613
- }
1614
-
1615
- /**
1616
- * Handle EXT_feature_metadata to get property table
1617
- * @param extension
1618
- */
1619
- function getPropertyTableFromExtFeatureMetadata(
1620
- extension: GLTF_EXT_feature_metadata
1621
- ): FeatureTableJson | null {
1622
- if (extension?.featureTables) {
1623
- /**
1624
- * Take only first feature table to generate attributes storage info object.
1625
- * TODO: Think about getting data from all feature tables?
1626
- * It can be tricky just because 3dTiles is able to have multiple featureId attributes and multiple feature tables.
1627
- * In I3S we should decide which featureIds attribute will be passed to geometry data.
1628
- */
1629
- const firstFeatureTableName = Object.keys(extension.featureTables)?.[0];
1630
-
1631
- if (firstFeatureTableName) {
1632
- const featureTable = extension?.featureTables[firstFeatureTableName];
1633
- const propertyTable = {};
1634
-
1635
- for (const propertyName in featureTable.properties) {
1636
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
1637
- }
1638
-
1639
- return propertyTable;
1640
- }
1680
+ if (!extensionName) {
1681
+ return {extensionName: null, extension: null};
1641
1682
  }
1642
1683
 
1643
- if (extension?.featureTextures) {
1644
- /**
1645
- * Take only first feature texture to generate attributes storage info object.
1646
- * TODO: Think about getting data from all feature textures?
1647
- * It can be tricky just because 3dTiles is able to have multiple featureTextures.
1648
- * In I3S we should decide which featureTextures will be passed to geometry data.
1649
- */
1650
- const firstTextureName = Object.keys(extension.featureTextures)?.[0];
1651
- if (firstTextureName) {
1652
- const featureTable = extension?.featureTextures[firstTextureName];
1653
- const propertyTable = {};
1684
+ const extension = tileContent?.gltf?.extensions?.[extensionName] as
1685
+ | string // EXT_mesh_features doesn't have global metadata
1686
+ | GLTF_EXT_feature_metadata_GLTF
1687
+ | GLTF_EXT_structural_metadata_GLTF;
1654
1688
 
1655
- for (const propertyName in featureTable.properties) {
1656
- propertyTable[propertyName] = featureTable.properties[propertyName].data;
1657
- }
1658
-
1659
- return propertyTable;
1660
- }
1661
- }
1662
-
1663
- console.warn(
1664
- "The I3S converter couldn't handle EXT_feature_metadata extension: There is neither featureTables, no featureTextures in the extension."
1665
- );
1666
- return null;
1689
+ return {extensionName, extension};
1667
1690
  }
@@ -1,13 +1,9 @@
1
1
  import type {Tiles3DTileContent} from '@loaders.gl/3d-tiles';
2
2
  import type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';
3
- import type {B3DMAttributesData} from '../../i3s-attributes-worker';
4
- import {Matrix4, Vector3} from '@math.gl/core';
3
+ import {Matrix4, TypedArray, Vector3} from '@math.gl/core';
5
4
  import {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';
6
5
  import {Ellipsoid} from '@math.gl/geospatial';
7
-
8
- type AttributesObject = {
9
- [k: string]: GLTFAccessorPostprocessed;
10
- };
6
+ import {GLTFAttributesData} from '../types';
11
7
 
12
8
  /**
13
9
  * Prepare attributes for conversion to avoid binary data breaking in worker thread.
@@ -15,13 +11,13 @@ type AttributesObject = {
15
11
  * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying
16
12
  * transform of all parent tiles and transform of the current tile
17
13
  * @param boundingVolume - initialized bounding volume of the source tile
18
- * @returns
14
+ * @returns 3DTiles content data, prepared for conversion
19
15
  */
20
16
  export function prepareDataForAttributesConversion(
21
17
  tileContent: Tiles3DTileContent,
22
18
  tileTransform: Matrix4,
23
19
  boundingVolume: OrientedBoundingBox | BoundingSphere
24
- ): B3DMAttributesData {
20
+ ): GLTFAttributesData {
25
21
  let nodes =
26
22
  tileContent.gltf?.scene?.nodes ||
27
23
  tileContent.gltf?.scenes?.[0]?.nodes ||
@@ -67,9 +63,12 @@ export function prepareDataForAttributesConversion(
67
63
  /**
68
64
  * Keep only values for glTF attributes to pass data to worker thread.
69
65
  * @param attributes - geometry attributes
66
+ * @returns attributes with only `value` item
70
67
  */
71
- function getB3DMAttributesWithoutBufferView(attributes: AttributesObject): AttributesObject {
72
- const attributesWithoutBufferView = {};
68
+ function getB3DMAttributesWithoutBufferView(
69
+ attributes: Record<string, GLTFAccessorPostprocessed>
70
+ ): Record<string, {value: TypedArray}> {
71
+ const attributesWithoutBufferView: Record<string, {value: TypedArray}> = {};
73
72
 
74
73
  for (const attributeName in attributes) {
75
74
  attributesWithoutBufferView[attributeName] = {