@loaders.gl/tile-converter 4.0.0-alpha.8 → 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 +32718 -32568
  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 +115 -40
  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 +40 -13
  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 +28 -22
  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 +58 -12
  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 -62
  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,288 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = require("path");
7
- const process_1 = __importDefault(require("process"));
8
- const json_map_transform_1 = __importDefault(require("json-map-transform"));
9
- const core_1 = require("@loaders.gl/core");
10
- const i3s_1 = require("@loaders.gl/i3s");
11
- const tiles_1 = require("@loaders.gl/tiles");
12
- const pgm_loader_1 = require("../pgm-loader");
13
- const i3s_obb_to_3d_tiles_obb_1 = require("./helpers/i3s-obb-to-3d-tiles-obb");
14
- const lod_conversion_utils_1 = require("../lib/utils/lod-conversion-utils");
15
- const file_utils_1 = require("../lib/utils/file-utils");
16
- const statistic_utills_1 = require("../lib/utils/statistic-utills");
17
- const tileset_1 = require("./json-templates/tileset");
18
- const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
19
- const _3d_tiles_attributes_worker_1 = require("../3d-tiles-attributes-worker");
20
- const worker_utils_1 = require("@loaders.gl/worker-utils");
21
- const constants_1 = require("../constants");
22
- const I3S = 'I3S';
23
- /**
24
- * Converter from i3s to 3d-tiles
25
- */
26
- class Tiles3DConverter {
27
- constructor() {
28
- this.workerSource = {};
29
- this.options = {};
30
- this.tilesetPath = '';
31
- this.vertexCounter = 0;
32
- this.conversionStartTime = [0, 0];
33
- this.geoidHeightModel = null;
34
- this.sourceTileset = null;
35
- this.attributeStorageInfo = null;
36
- this.workerSource = {};
37
- }
38
- /**
39
- * Convert i3s format data to 3dTiles
40
- * @param options
41
- * @param options.inputUrl the url to read the tileset from
42
- * @param options.outputPath the output filename
43
- * @param options.tilesetName the output name of the tileset
44
- * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
45
- * @param options.maxDepth The max tree depth of conversion
46
- */
47
- async convert(options) {
48
- if (core_1.isBrowser) {
49
- console.log(constants_1.BROWSER_ERROR_MESSAGE);
50
- return constants_1.BROWSER_ERROR_MESSAGE;
51
- }
52
- const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
53
- this.conversionStartTime = process_1.default.hrtime();
54
- this.options = { maxDepth };
55
- console.log('Loading egm file...'); // eslint-disable-line
56
- this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
57
- console.log('Loading egm file completed!'); // eslint-disable-line
58
- await this.loadWorkers();
59
- const sourceTilesetJson = await (0, core_1.load)(inputUrl, i3s_1.I3SLoader, {});
60
- this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, {
61
- loadOptions: {
62
- _nodeWorkers: true,
63
- reuseWorkers: true,
64
- i3s: { coordinateSystem: i3s_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
65
- // TODO should no longer be needed with new workers
66
- // 'i3s-content-nodejs': {
67
- // workerUrl: './modules/i3s/dist/i3s-content-nodejs-worker.js'
68
- // }
69
- }
70
- });
71
- await this.sourceTileset.tilesetInitializationPromise;
72
- const rootNode = this.sourceTileset.root;
73
- if (!rootNode.header.obb) {
74
- rootNode.header.obb = (0, coordinate_converter_1.createObbFromMbs)(rootNode.header.mbs);
75
- }
76
- this.tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
77
- this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;
78
- // Removing the tilesetPath needed to exclude erroneous files after conversion
79
- try {
80
- await (0, file_utils_1.removeDir)(this.tilesetPath);
81
- }
82
- catch (e) {
83
- // do nothing
84
- }
85
- const rootTile = {
86
- boundingVolume: {
87
- box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(rootNode.header.obb, this.geoidHeightModel)
88
- },
89
- geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(rootNode),
90
- children: []
91
- };
92
- await this._addChildren(rootNode, rootTile, 1);
93
- const tileset = (0, json_map_transform_1.default)({ root: rootTile }, (0, tileset_1.TILESET)());
94
- await (0, file_utils_1.writeFile)(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
95
- this._finishConversion({ slpk: false, outputPath, tilesetName });
96
- // Clean up worker pools
97
- const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
98
- workerFarm.destroy();
99
- }
100
- /**
101
- * Convert particular I3S Node
102
- * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
103
- * @param parentNode object in resulting tileset
104
- * @param level a current level of a tree depth
105
- * @param childNodeInfo child node to convert
106
- */
107
- async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
108
- const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
109
- parentSourceNode.children.push(sourceChild);
110
- if (sourceChild.contentUrl) {
111
- await this.sourceTileset._loadTile(sourceChild);
112
- this.vertexCounter += sourceChild.content.vertexCount;
113
- let featureAttributes = null;
114
- if (this.attributeStorageInfo) {
115
- featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
116
- }
117
- if (!sourceChild.header.obb) {
118
- sourceChild.header.obb = (0, coordinate_converter_1.createObbFromMbs)(sourceChild.header.mbs);
119
- }
120
- const boundingVolume = {
121
- box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(sourceChild.header.obb, this.geoidHeightModel)
122
- };
123
- const child = {
124
- boundingVolume,
125
- geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(sourceChild),
126
- children: []
127
- };
128
- const i3sAttributesData = {
129
- tileContent: sourceChild.content,
130
- textureFormat: sourceChild?.header?.textureFormat
131
- };
132
- const b3dm = await (0, _3d_tiles_attributes_worker_1.transform3DTilesAttributesOnWorker)(i3sAttributesData, {
133
- source: this.workerSource.tile3dWorkerSource,
134
- featureAttributes
135
- });
136
- child.content = {
137
- uri: `${sourceChild.id}.b3dm`,
138
- boundingVolume
139
- };
140
- await (0, file_utils_1.writeFile)(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
141
- parentNode.children.push(child);
142
- sourceChild.unloadContent();
143
- await this._addChildren(sourceChild, child, level + 1);
144
- }
145
- else {
146
- await this._addChildren(sourceChild, parentNode, level + 1);
147
- }
148
- }
149
- /**
150
- * The recursive function of traversal of a nodes tree
151
- * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
152
- * @param parentNode object in resulting tileset
153
- * @param level a current level of a tree depth
154
- */
155
- async _addChildren(parentSourceNode, parentNode, level) {
156
- if (this.options.maxDepth && level > this.options.maxDepth) {
157
- return;
158
- }
159
- const promises = [];
160
- for (const childNodeInfo of parentSourceNode.header.children || []) {
161
- promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
162
- }
163
- await Promise.all(promises);
164
- }
165
- /**
166
- * Load a child node having information from the node header
167
- * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
168
- * @param childNodeInfo child information from 3DNodeIndexDocument
169
- * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
170
- */
171
- async _loadChildNode(parentNode, childNodeInfo) {
172
- let header;
173
- if (this.sourceTileset.tileset.nodePages) {
174
- console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
175
- header = await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(childNodeInfo.id);
176
- }
177
- else {
178
- const { loader } = this.sourceTileset;
179
- const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
180
- // load metadata
181
- const options = {
182
- i3s: {
183
- ...this.sourceTileset.loadOptions,
184
- isTileHeader: true,
185
- loadContent: false
186
- }
187
- };
188
- console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
189
- header = await (0, core_1.load)(nodeUrl, loader, options);
190
- }
191
- return new tiles_1.Tile3D(this.sourceTileset, header, parentNode);
192
- }
193
- /**
194
- * Make an url of a resource from its relative url having the base url
195
- * @param baseUrl the base url. A resulting url will be related from this url
196
- * @param relativeUrl a realtive url of a resource
197
- */
198
- _relativeUrlToFullUrl(baseUrl, relativeUrl) {
199
- let resultArray = baseUrl.split('/');
200
- const relativeUrlArray = relativeUrl.split('/');
201
- for (const folder of relativeUrlArray) {
202
- switch (folder) {
203
- case '.':
204
- continue; // eslint-disable-line no-continue
205
- case '..':
206
- resultArray = resultArray.slice(0, -1);
207
- break;
208
- default:
209
- resultArray.push(folder);
210
- }
211
- }
212
- return resultArray.join('/');
213
- }
214
- /**
215
- * Do loading all attributes related to particular node.
216
- * @param sourceChild
217
- * @param attributeStorageInfo
218
- * @returns Promise of attributes object.
219
- */
220
- async _loadChildAttributes(sourceChild, attributeStorageInfo) {
221
- const promises = [];
222
- const { attributeUrls } = sourceChild.header;
223
- for (let index = 0; index < attributeUrls.length; index++) {
224
- const inputUrl = attributeUrls[index];
225
- const attribute = attributeStorageInfo[index];
226
- const options = {
227
- attributeName: attribute.name,
228
- attributeType: this._getAttributeType(attribute)
229
- };
230
- promises.push((0, core_1.load)(inputUrl, i3s_1.I3SAttributeLoader, options));
231
- }
232
- const attributesList = await Promise.all(promises);
233
- this._replaceNestedArrays(attributesList);
234
- return Object.assign({}, ...attributesList);
235
- }
236
- /**
237
- * Returns attribute type for loading attributes
238
- * @param attribute
239
- * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
240
- * There is an 'Oid32' type if attribute has objectIds property.
241
- * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
242
- */
243
- _getAttributeType(attribute) {
244
- if (attribute.attributeValues) {
245
- return attribute.attributeValues.valueType;
246
- }
247
- else if (attribute.objectIds) {
248
- return 'Oid32';
249
- }
250
- return '';
251
- }
252
- /**
253
- * Make simple arrays from attribute typed arrays.
254
- * @param attributesList
255
- */
256
- _replaceNestedArrays(attributesList) {
257
- for (let index = 0; index < attributesList.length; index++) {
258
- const attributeObject = attributesList[index];
259
- for (const key in attributeObject) {
260
- attributeObject[key] = Array.from(attributeObject[key]);
261
- }
262
- }
263
- }
264
- /**
265
- * Print statistics in the end of conversion
266
- * @param params - output files data
267
- */
268
- async _finishConversion(params) {
269
- const filesSize = await (0, statistic_utills_1.calculateFilesSize)(params);
270
- const diff = process_1.default.hrtime(this.conversionStartTime);
271
- const conversionTime = (0, statistic_utills_1.timeConverter)(diff);
272
- console.log(`------------------------------------------------`); // eslint-disable-line
273
- console.log(`Finish conversion of ${I3S}`); // eslint-disable-line
274
- console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line
275
- console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line
276
- console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
277
- console.log(`------------------------------------------------`); // eslint-disable-line
278
- }
279
- async loadWorkers() {
280
- console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
281
- const tile3dAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(_3d_tiles_attributes_worker_1.Tile3dAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
282
- const sourceResponse = await (0, core_1.fetchFile)(tile3dAttributesWorkerUrl);
283
- const source = await sourceResponse.text();
284
- this.workerSource.tile3dWorkerSource = source;
285
- console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
286
- }
287
- }
288
- exports.default = Tiles3DConverter;
@@ -1,269 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@loaders.gl/core");
4
- const gltf_1 = require("@loaders.gl/gltf");
5
- const _3d_tiles_1 = require("@loaders.gl/3d-tiles");
6
- const core_2 = require("@math.gl/core");
7
- const geospatial_1 = require("@math.gl/geospatial");
8
- const texture_atlas_1 = require("./texture-atlas");
9
- const geometry_utils_1 = require("../../lib/utils/geometry-utils");
10
- const Z_UP_TO_Y_UP_MATRIX = new core_2.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
11
- const scratchVector = new core_2.Vector3();
12
- /**
13
- * Converts content of an I3S node to *.b3dm's file content
14
- */
15
- class B3dmConverter {
16
- /**
17
- * The starter of content conversion
18
- * @param i3sTile - Tile3D instance for I3S node
19
- * @returns - encoded content
20
- */
21
- async convert(i3sAttributesData, featureAttributes = null) {
22
- const gltf = await this.buildGltf(i3sAttributesData, featureAttributes);
23
- const b3dm = (0, core_1.encodeSync)({
24
- gltfEncoded: new Uint8Array(gltf),
25
- type: 'b3dm',
26
- featuresLength: this._getFeaturesLength(featureAttributes),
27
- batchTable: featureAttributes
28
- }, _3d_tiles_1.Tile3DWriter);
29
- return b3dm;
30
- }
31
- /**
32
- * Build and encode gltf
33
- * @param i3sTile - Tile3D instance for I3S node
34
- * @returns - encoded glb content
35
- */
36
- async buildGltf(i3sAttributesData, featureAttributes) {
37
- const { tileContent, textureFormat } = i3sAttributesData;
38
- const { material, attributes, indices: originalIndices, cartesianOrigin, cartographicOrigin, modelMatrix } = tileContent;
39
- const gltfBuilder = new gltf_1.GLTFScenegraph();
40
- const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
41
- const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
42
- const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
43
- const positions = attributes.positions;
44
- const positionsValue = positions.value;
45
- if (attributes.uvRegions && attributes.texCoords) {
46
- attributes.texCoords.value = (0, texture_atlas_1.convertTextureAtlas)(attributes.texCoords.value, attributes.uvRegions.value);
47
- }
48
- attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
49
- this._createBatchIds(tileContent, featureAttributes);
50
- if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
51
- delete attributes.normals;
52
- }
53
- const indices = originalIndices || (0, geometry_utils_1.generateSyntheticIndices)(positionsValue.length / positions.size);
54
- const meshIndex = gltfBuilder.addMesh({
55
- attributes,
56
- indices,
57
- material: materialIndex,
58
- mode: 4
59
- });
60
- const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
61
- const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
62
- const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
63
- gltfBuilder.setDefaultScene(sceneIndex);
64
- gltfBuilder.createBinaryChunk();
65
- const gltfBuffer = (0, core_1.encodeSync)(gltfBuilder.gltf, gltf_1.GLTFWriter);
66
- return gltfBuffer;
67
- }
68
- /**
69
- * Update gltfBuilder with texture from I3S tile
70
- * @param {object} i3sTile - Tile3D object
71
- * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
72
- * @returns {Promise<number | null>} - GLTF texture index
73
- */
74
- async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
75
- const { texture, material, attributes } = tileContent;
76
- let textureIndex = null;
77
- let selectedTexture = texture;
78
- if (!texture && material) {
79
- selectedTexture =
80
- material.pbrMetallicRoughness &&
81
- material.pbrMetallicRoughness.baseColorTexture &&
82
- material.pbrMetallicRoughness.baseColorTexture.texture.source.image;
83
- }
84
- if (selectedTexture) {
85
- const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
86
- const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
87
- textureIndex = gltfBuilder.addTexture({ imageIndex });
88
- delete attributes.colors;
89
- }
90
- return textureIndex;
91
- }
92
- /**
93
- * Generate a positions array which is correct for 3DTiles/GLTF format
94
- * @param {Float64Array} positionsValue - the input geometry positions array
95
- * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
96
- * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
97
- * @param {number[]} modelMatrix - the model matrix of geometry
98
- * @returns {Float32Array} - the output geometry positions array
99
- */
100
- _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
101
- const newPositionsValue = new Float32Array(positionsValue.length);
102
- for (let index = 0; index < positionsValue.length; index += 3) {
103
- const vertex = positionsValue.subarray(index, index + 3);
104
- const cartesianOriginVector = new core_2.Vector3(cartesianOrigin);
105
- let vertexVector = new core_2.Vector3(Array.from(vertex))
106
- .transform(modelMatrix)
107
- .add(cartographicOrigin);
108
- geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);
109
- vertexVector = scratchVector.subtract(cartesianOriginVector);
110
- newPositionsValue.set(vertexVector, index);
111
- }
112
- return newPositionsValue;
113
- }
114
- /**
115
- * Generate the transformation matrix for GLTF node:
116
- * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
117
- * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
118
- * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
119
- * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
120
- * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
121
- */
122
- _generateTransformMatrix(cartesianOrigin) {
123
- const translateOriginMatrix = new core_2.Matrix4().translate(cartesianOrigin);
124
- const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);
125
- return result;
126
- }
127
- /**
128
- * Create _BATCHID attribute
129
- * @param {Object} i3sContent - the source object
130
- * @returns {void}
131
- */
132
- _createBatchIds(i3sContent, featureAttributes) {
133
- const { featureIds } = i3sContent;
134
- const { OBJECTID: objectIds } = featureAttributes || {};
135
- if (!featureIds || !objectIds) {
136
- return;
137
- }
138
- for (let i = 0; i < featureIds.length; i++) {
139
- const featureId = featureIds[i];
140
- const batchId = objectIds.indexOf(featureId);
141
- featureIds[i] = batchId;
142
- }
143
- i3sContent.attributes._BATCHID = {
144
- size: 1,
145
- byteOffset: 0,
146
- value: featureIds
147
- };
148
- }
149
- /**
150
- * Deduce mime type by format from `textureSetDefinition.formats[0].format`
151
- * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
152
- * @param {string} format - format name
153
- * @returns {string} mime type.
154
- */
155
- _deduceMimeTypeFromFormat(format) {
156
- switch (format) {
157
- case 'jpg':
158
- return 'image/jpeg';
159
- case 'png':
160
- return 'image/png';
161
- case 'ktx2':
162
- return 'image/ktx2';
163
- default:
164
- console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
165
- return 'image/jpeg';
166
- }
167
- }
168
- /**
169
- * Convert i3s material to GLTF compatible material
170
- * @param {object} material - i3s material definition
171
- * @param {number | null} textureIndex - texture index in GLTF
172
- * @returns {object} GLTF material
173
- */
174
- _convertI3sMaterialToGltfMaterial(material, textureIndex) {
175
- const isTextureIndexExists = textureIndex !== null;
176
- if (!material) {
177
- material = {
178
- alphaMode: 'OPAQUE',
179
- doubleSided: false,
180
- pbrMetallicRoughness: {
181
- metallicFactor: 0,
182
- roughnessFactor: 1
183
- }
184
- };
185
- if (isTextureIndexExists) {
186
- material.pbrMetallicRoughness.baseColorTexture = {
187
- index: textureIndex,
188
- texCoord: 0
189
- };
190
- }
191
- else {
192
- material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];
193
- }
194
- return material;
195
- }
196
- if (textureIndex !== null) {
197
- material = this._setGltfTexture(material, textureIndex);
198
- }
199
- return material;
200
- }
201
- /**
202
- * Set texture properties in material with GLTF textureIndex
203
- * @param {object} materialDefinition - i3s material definition
204
- * @param {number} textureIndex - texture index in GLTF
205
- * @returns {void}
206
- */
207
- _setGltfTexture(materialDefinition, textureIndex) {
208
- const material = {
209
- ...materialDefinition,
210
- pbrMetallicRoughness: { ...materialDefinition.pbrMetallicRoughness }
211
- };
212
- // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of
213
- // properties defined in materialDefinition
214
- if (materialDefinition.pbrMetallicRoughness &&
215
- materialDefinition.pbrMetallicRoughness.baseColorTexture) {
216
- material.pbrMetallicRoughness.baseColorTexture = {
217
- index: textureIndex,
218
- texCoord: 0
219
- };
220
- }
221
- else if (materialDefinition.emissiveTexture) {
222
- material.emissiveTexture = {
223
- index: textureIndex,
224
- texCoord: 0
225
- };
226
- }
227
- else if (materialDefinition.pbrMetallicRoughness &&
228
- materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture) {
229
- material.pbrMetallicRoughness.metallicRoughnessTexture = {
230
- index: textureIndex,
231
- texCoord: 0
232
- };
233
- }
234
- else if (materialDefinition.normalTexture) {
235
- material.normalTexture = {
236
- index: textureIndex,
237
- texCoord: 0
238
- };
239
- }
240
- else if (materialDefinition.occlusionTexture) {
241
- material.occlusionTexture = {
242
- index: textureIndex,
243
- texCoord: 0
244
- };
245
- }
246
- return material;
247
- }
248
- /*
249
- * Returns Features length based on attribute array in attribute object.
250
- * @param {Object} attributes
251
- * @returns {Number} Features length .
252
- */
253
- _getFeaturesLength(attributes) {
254
- if (!attributes) {
255
- return 0;
256
- }
257
- const firstKey = Object.keys(attributes)[0];
258
- return firstKey ? attributes[firstKey].length : 0;
259
- }
260
- /* Checks that normals buffer is correct
261
- * @param {TypedArray} normals
262
- * @returns {boolean} true - normals are correct; false - normals are incorrect
263
- */
264
- _checkNormals(normals) {
265
- // If all normals === 0, the resulting tileset is all in black colors on Cesium
266
- return normals.find((value) => value);
267
- }
268
- }
269
- exports.default = B3dmConverter;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.i3sObbTo3dTilesObb = void 0;
4
- const core_1 = require("@math.gl/core");
5
- const geospatial_1 = require("@math.gl/geospatial");
6
- const culling_1 = require("@math.gl/culling");
7
- /**
8
- * Convert quaternion-based OBB to half-axes-based OBB
9
- * @param i3SObb quaternion based OBB
10
- * @param geoidHeightModel the Earth Gravity Model instance
11
- * @returns number[12] 3DTiles OBB https://github.com/CesiumGS/3d-tiles/tree/master/specification#box
12
- */
13
- function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
14
- const tiles3DCenter = [
15
- i3SObb.center[0],
16
- i3SObb.center[1],
17
- i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])
18
- ];
19
- const cartesianCenter = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new core_1.Vector3());
20
- const tiles3DObb = new culling_1.OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
21
- return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
22
- }
23
- exports.i3sObbTo3dTilesObb = i3sObbTo3dTilesObb;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertTextureAtlas = void 0;
4
- /**
5
- * Apply uvRegions to texture coordinates.
6
- * Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
7
- * Shader formula vec2 uv = fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
8
- * @param texCoords
9
- * @param uvRegions
10
- */
11
- function convertTextureAtlas(texCoords, uvRegions) {
12
- const convertedTexCoords = new Float32Array(texCoords.length);
13
- const normalisedRegions = normalizeRegions(uvRegions);
14
- for (let index = 0; index < texCoords.length; index += 2) {
15
- const uv = texCoords.subarray(index, index + 2);
16
- const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
17
- // fract(texCoords)
18
- const fractatedUV = fract([uv[0], uv[1]]);
19
- // (uvRegions.zw - uvRegions.xy)
20
- const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
21
- // fract(texCoords) * (uvRegions.zw - uvRegions.xy)
22
- const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];
23
- // fract(texCoords) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
24
- const convertedUV = [
25
- multiplicationResult[0] + regions[0],
26
- multiplicationResult[1] + regions[1]
27
- ];
28
- convertedTexCoords[index] = convertedUV[0];
29
- convertedTexCoords[index + 1] = convertedUV[1];
30
- }
31
- return convertedTexCoords;
32
- }
33
- exports.convertTextureAtlas = convertTextureAtlas;
34
- /**
35
- * Do fractation of UV array.
36
- * @param uv
37
- */
38
- function fract(uv) {
39
- return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
40
- }
41
- /**
42
- * Normalize uvRegions by dividing by the maximum Uint16 value
43
- * @param regions
44
- */
45
- function normalizeRegions(regions) {
46
- const MAX_UINT_16_VALUE = 65535;
47
- const normalizedRegions = [];
48
- for (let index = 0; index < regions.length; index++) {
49
- normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
50
- }
51
- return normalizedRegions;
52
- }
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TILESET = void 0;
7
- const json_map_transform_1 = __importDefault(require("json-map-transform"));
8
- const ASSET = () => ({
9
- version: {
10
- path: 'version',
11
- default: '1.0'
12
- }
13
- });
14
- const TILE = () => ({
15
- boundingVolume: {
16
- path: 'boundingVolume'
17
- },
18
- geometricError: {
19
- path: 'geometricError'
20
- },
21
- content: {
22
- path: 'content'
23
- },
24
- children: {
25
- path: 'children',
26
- transform: (val) => val.map((tile) => (0, json_map_transform_1.default)(tile, TILE()))
27
- }
28
- });
29
- const TILESET = () => ({
30
- asset: {
31
- path: 'asset',
32
- transform: (val) => (0, json_map_transform_1.default)(val, ASSET())
33
- },
34
- geometricError: {
35
- path: 'root',
36
- transform: (val) => val.geometricError
37
- },
38
- root: {
39
- path: 'root',
40
- transform: (val) => (0, json_map_transform_1.default)(val, TILE())
41
- }
42
- });
43
- exports.TILESET = TILESET;
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);