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

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 (468) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.d.ts +28 -0
  3. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
  4. package/dist/3d-tiles-attributes-worker.js +3 -0
  5. package/dist/3d-tiles-attributes-worker.js.map +7 -0
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +90 -0
  7. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
  8. package/dist/3d-tiles-converter/3d-tiles-converter.js +275 -226
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +71 -18
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
  11. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +256 -236
  12. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
  13. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
  14. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -9
  15. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
  16. package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
  17. package/dist/3d-tiles-converter/helpers/texture-atlas.js +47 -28
  18. package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
  19. package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
  20. package/dist/3d-tiles-converter/json-templates/tileset.js +42 -36
  21. package/dist/bundle.d.ts +2 -0
  22. package/dist/bundle.d.ts.map +1 -0
  23. package/dist/bundle.js +2 -2
  24. package/dist/constants.d.ts +2 -0
  25. package/dist/constants.d.ts.map +1 -0
  26. package/dist/constants.js +4 -0
  27. package/dist/converter-cli.d.ts +2 -0
  28. package/dist/converter-cli.d.ts.map +1 -0
  29. package/dist/converter-cli.js +280 -0
  30. package/dist/converter.min.js +185 -190
  31. package/dist/deps-installer/deps-installer.d.ts +11 -3
  32. package/dist/deps-installer/deps-installer.d.ts.map +1 -0
  33. package/dist/deps-installer/deps-installer.js +61 -23
  34. package/dist/dist.min.js +64143 -0
  35. package/dist/es5/3d-tiles-attributes-worker.js +25 -0
  36. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  37. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +467 -0
  38. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  39. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +293 -0
  40. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  41. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +18 -0
  42. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  43. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +33 -0
  44. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  45. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +61 -0
  46. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  47. package/dist/es5/bundle.js +6 -0
  48. package/dist/es5/bundle.js.map +1 -0
  49. package/dist/es5/constants.js +9 -0
  50. package/dist/es5/constants.js.map +1 -0
  51. package/dist/es5/converter-cli.js +289 -0
  52. package/dist/es5/converter-cli.js.map +1 -0
  53. package/dist/es5/deps-installer/deps-installer.js +124 -0
  54. package/dist/es5/deps-installer/deps-installer.js.map +1 -0
  55. package/dist/es5/i3s-attributes-worker.js +25 -0
  56. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  57. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +116 -0
  58. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  59. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +89 -0
  60. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  61. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +41 -0
  62. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  63. package/dist/es5/i3s-converter/helpers/feature-attributes.js +174 -0
  64. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  65. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +213 -0
  66. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  67. package/dist/es5/i3s-converter/helpers/geometry-converter.js +1192 -0
  68. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
  69. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +113 -0
  70. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  71. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +82 -0
  72. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  73. package/dist/es5/i3s-converter/helpers/node-debug.js +76 -0
  74. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
  75. package/dist/es5/i3s-converter/helpers/node-index-document.js +521 -0
  76. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  77. package/dist/es5/i3s-converter/helpers/node-pages.js +519 -0
  78. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
  79. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +111 -0
  80. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  81. package/dist/es5/i3s-converter/helpers/tileset-traversal.js +82 -0
  82. package/dist/es5/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  83. package/dist/es5/i3s-converter/i3s-converter.js +1541 -0
  84. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
  85. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  86. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  87. package/dist/es5/i3s-converter/json-templates/layers.js +163 -0
  88. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
  89. package/dist/es5/i3s-converter/json-templates/metadata.js +31 -0
  90. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
  91. package/dist/es5/i3s-converter/json-templates/node.js +99 -0
  92. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
  93. package/dist/es5/i3s-converter/json-templates/scene-server.js +39 -0
  94. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
  95. package/dist/es5/i3s-converter/json-templates/shared-resources.js +173 -0
  96. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
  97. package/dist/es5/i3s-converter/json-templates/store.js +107 -0
  98. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
  99. package/dist/es5/i3s-converter/types.js +18 -0
  100. package/dist/es5/i3s-converter/types.js.map +1 -0
  101. package/dist/es5/i3s-server/README.md +19 -0
  102. package/dist/es5/i3s-server/app.js +27 -0
  103. package/dist/es5/i3s-server/app.js.map +1 -0
  104. package/dist/es5/i3s-server/controllers/index-controller.js +55 -0
  105. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
  106. package/dist/es5/i3s-server/controllers/slpk-controller.js +84 -0
  107. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -0
  108. package/dist/es5/i3s-server/routes/index.js +37 -0
  109. package/dist/es5/i3s-server/routes/index.js.map +1 -0
  110. package/dist/es5/i3s-server/routes/slpk-router.js +71 -0
  111. package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -0
  112. package/dist/es5/i3s-server/utils/create-scene-server.js +17 -0
  113. package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -0
  114. package/dist/es5/index.js +21 -0
  115. package/dist/es5/index.js.map +1 -0
  116. package/dist/es5/lib/utils/compress-util.js +346 -0
  117. package/dist/es5/lib/utils/compress-util.js.map +1 -0
  118. package/dist/es5/lib/utils/file-utils.js +208 -0
  119. package/dist/es5/lib/utils/file-utils.js.map +1 -0
  120. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  121. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  122. package/dist/es5/lib/utils/lod-conversion-utils.js +44 -0
  123. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
  124. package/dist/es5/lib/utils/queue.js +47 -0
  125. package/dist/es5/lib/utils/queue.js.map +1 -0
  126. package/dist/es5/lib/utils/statistic-utills.d.ts +25 -0
  127. package/dist/es5/lib/utils/statistic-utills.js +147 -0
  128. package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
  129. package/dist/es5/lib/utils/write-queue.js +214 -0
  130. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  131. package/dist/es5/pgm-loader.js +41 -0
  132. package/dist/es5/pgm-loader.js.map +1 -0
  133. package/dist/es5/workers/3d-tiles-attributes-worker.js +28 -0
  134. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  135. package/dist/es5/workers/i3s-attributes-worker.js +30 -0
  136. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  137. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  138. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  139. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +245 -0
  140. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  141. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +218 -0
  142. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  143. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +10 -0
  144. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  145. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +27 -0
  146. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  147. package/dist/esm/3d-tiles-converter/json-templates/tileset.js +37 -0
  148. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  149. package/dist/esm/bundle.js +4 -0
  150. package/dist/esm/bundle.js.map +1 -0
  151. package/dist/esm/constants.js +2 -0
  152. package/dist/esm/constants.js.map +1 -0
  153. package/dist/esm/converter-cli.js +232 -0
  154. package/dist/esm/converter-cli.js.map +1 -0
  155. package/dist/esm/deps-installer/deps-installer.js +45 -0
  156. package/dist/esm/deps-installer/deps-installer.js.map +1 -0
  157. package/dist/esm/i3s-attributes-worker.js +16 -0
  158. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  159. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +105 -0
  160. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  161. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +79 -0
  162. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  163. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +16 -0
  164. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  165. package/dist/esm/i3s-converter/helpers/feature-attributes.js +147 -0
  166. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  167. package/{src → dist/esm}/i3s-converter/helpers/geometry-attributes.js +80 -106
  168. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  169. package/dist/esm/i3s-converter/helpers/geometry-converter.js +906 -0
  170. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
  171. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +110 -0
  172. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  173. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +35 -0
  174. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  175. package/{src → dist/esm}/i3s-converter/helpers/node-debug.js +20 -41
  176. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
  177. package/dist/esm/i3s-converter/helpers/node-index-document.js +201 -0
  178. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  179. package/dist/esm/i3s-converter/helpers/node-pages.js +206 -0
  180. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
  181. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +48 -0
  182. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  183. package/dist/esm/i3s-converter/helpers/tileset-traversal.js +14 -0
  184. package/dist/esm/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  185. package/dist/esm/i3s-converter/i3s-converter.js +778 -0
  186. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
  187. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  188. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  189. package/dist/esm/i3s-converter/json-templates/layers.js +133 -0
  190. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
  191. package/dist/esm/i3s-converter/json-templates/metadata.js +22 -0
  192. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
  193. package/dist/esm/i3s-converter/json-templates/node.js +80 -0
  194. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
  195. package/dist/esm/i3s-converter/json-templates/scene-server.js +28 -0
  196. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
  197. package/dist/esm/i3s-converter/json-templates/shared-resources.js +123 -0
  198. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
  199. package/dist/esm/i3s-converter/json-templates/store.js +98 -0
  200. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
  201. package/dist/esm/i3s-converter/types.js +11 -0
  202. package/dist/esm/i3s-converter/types.js.map +1 -0
  203. package/dist/esm/i3s-server/README.md +19 -0
  204. package/dist/esm/i3s-server/app.js +26 -0
  205. package/dist/esm/i3s-server/app.js.map +1 -0
  206. package/dist/esm/i3s-server/bin/www +102 -0
  207. package/dist/esm/i3s-server/certs/cert.pem +19 -0
  208. package/dist/esm/i3s-server/certs/key.pem +27 -0
  209. package/dist/esm/i3s-server/controllers/index-controller.js +24 -0
  210. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
  211. package/dist/esm/i3s-server/controllers/slpk-controller.js +36 -0
  212. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -0
  213. package/dist/esm/i3s-server/routes/index.js +16 -0
  214. package/dist/esm/i3s-server/routes/index.js.map +1 -0
  215. package/dist/esm/i3s-server/routes/slpk-router.js +33 -0
  216. package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -0
  217. package/dist/esm/i3s-server/utils/create-scene-server.js +16 -0
  218. package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -0
  219. package/dist/esm/index.js +3 -0
  220. package/dist/esm/index.js.map +1 -0
  221. package/dist/esm/lib/utils/compress-util.js +168 -0
  222. package/dist/esm/lib/utils/compress-util.js.map +1 -0
  223. package/dist/esm/lib/utils/file-utils.js +87 -0
  224. package/dist/esm/lib/utils/file-utils.js.map +1 -0
  225. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  226. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  227. package/dist/esm/lib/utils/lod-conversion-utils.js +37 -0
  228. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
  229. package/dist/esm/lib/utils/queue.js +15 -0
  230. package/dist/esm/lib/utils/queue.js.map +1 -0
  231. package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
  232. package/dist/esm/lib/utils/statistic-utills.js +62 -0
  233. package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
  234. package/dist/esm/lib/utils/write-queue.js +85 -0
  235. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  236. package/dist/esm/pgm-loader.js +15 -0
  237. package/dist/esm/pgm-loader.js.map +1 -0
  238. package/dist/esm/workers/3d-tiles-attributes-worker.js +8 -0
  239. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  240. package/dist/esm/workers/i3s-attributes-worker.js +7 -0
  241. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  242. package/dist/i3s-attributes-worker.d.ts +45 -0
  243. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  244. package/dist/i3s-attributes-worker.js +9 -0
  245. package/dist/i3s-attributes-worker.js.map +7 -0
  246. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +13 -0
  247. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  248. package/dist/i3s-converter/helpers/batch-ids-extensions.js +138 -0
  249. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +40 -0
  250. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
  251. package/dist/i3s-converter/helpers/coordinate-converter.js +119 -42
  252. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
  253. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
  254. package/dist/i3s-converter/helpers/create-scene-server-path.js +27 -15
  255. package/dist/i3s-converter/helpers/feature-attributes.d.ts +56 -0
  256. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  257. package/dist/i3s-converter/helpers/feature-attributes.js +216 -0
  258. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
  259. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
  260. package/dist/i3s-converter/helpers/geometry-attributes.js +188 -185
  261. package/dist/i3s-converter/helpers/geometry-converter.d.ts +41 -35
  262. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
  263. package/dist/i3s-converter/helpers/geometry-converter.js +1179 -650
  264. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +28 -0
  265. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  266. package/dist/i3s-converter/helpers/gltf-attributes.js +128 -0
  267. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +18 -0
  268. package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -0
  269. package/dist/i3s-converter/helpers/load-3d-tiles.js +53 -0
  270. package/dist/i3s-converter/helpers/node-debug.d.ts +8 -0
  271. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
  272. package/dist/i3s-converter/helpers/node-debug.js +106 -74
  273. package/dist/i3s-converter/helpers/node-index-document.d.ts +103 -0
  274. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  275. package/dist/i3s-converter/helpers/node-index-document.js +268 -0
  276. package/dist/i3s-converter/helpers/node-pages.d.ts +125 -113
  277. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
  278. package/dist/i3s-converter/helpers/node-pages.js +313 -133
  279. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +23 -0
  280. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -0
  281. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +76 -0
  282. package/dist/i3s-converter/helpers/tileset-traversal.d.ts +25 -0
  283. package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -0
  284. package/dist/i3s-converter/helpers/tileset-traversal.js +29 -0
  285. package/dist/i3s-converter/i3s-converter.d.ts +267 -0
  286. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
  287. package/dist/i3s-converter/i3s-converter.js +891 -867
  288. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  289. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  290. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  291. package/dist/i3s-converter/json-templates/layers.d.ts +70 -0
  292. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
  293. package/dist/i3s-converter/json-templates/layers.js +138 -190
  294. package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
  295. package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
  296. package/dist/i3s-converter/json-templates/metadata.js +25 -22
  297. package/dist/i3s-converter/json-templates/node.d.ts +61 -0
  298. package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
  299. package/dist/i3s-converter/json-templates/node.js +88 -79
  300. package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
  301. package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
  302. package/dist/i3s-converter/json-templates/scene-server.js +31 -28
  303. package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
  304. package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
  305. package/dist/i3s-converter/json-templates/shared-resources.js +124 -125
  306. package/dist/i3s-converter/json-templates/store.d.ts +95 -0
  307. package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
  308. package/dist/i3s-converter/json-templates/store.js +100 -95
  309. package/dist/i3s-converter/types.d.ts +163 -0
  310. package/dist/i3s-converter/types.d.ts.map +1 -0
  311. package/dist/i3s-converter/types.js +17 -0
  312. package/dist/i3s-server/app.d.ts +3 -0
  313. package/dist/i3s-server/app.d.ts.map +1 -0
  314. package/dist/i3s-server/app.js +11 -10
  315. package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
  316. package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
  317. package/dist/i3s-server/controllers/index-controller.js +16 -24
  318. package/dist/i3s-server/controllers/slpk-controller.d.ts +3 -0
  319. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -0
  320. package/dist/i3s-server/controllers/slpk-controller.js +32 -0
  321. package/dist/i3s-server/routes/index.d.ts +3 -0
  322. package/dist/i3s-server/routes/index.d.ts.map +1 -0
  323. package/dist/i3s-server/routes/index.js +11 -15
  324. package/dist/i3s-server/routes/slpk-router.d.ts +3 -0
  325. package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -0
  326. package/dist/i3s-server/routes/slpk-router.js +33 -0
  327. package/dist/i3s-server/utils/create-scene-server.d.ts +11 -0
  328. package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -0
  329. package/dist/i3s-server/utils/create-scene-server.js +14 -0
  330. package/dist/index.d.ts +3 -0
  331. package/dist/index.d.ts.map +1 -0
  332. package/dist/index.js +10 -5
  333. package/dist/lib/utils/compress-util.d.ts +45 -0
  334. package/dist/lib/utils/compress-util.d.ts.map +1 -0
  335. package/dist/lib/utils/compress-util.js +238 -160
  336. package/dist/lib/utils/file-utils.d.ts +22 -14
  337. package/dist/lib/utils/file-utils.d.ts.map +1 -0
  338. package/dist/lib/utils/file-utils.js +134 -36
  339. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  340. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  341. package/dist/lib/utils/geometry-utils.js +18 -0
  342. package/dist/lib/utils/lod-conversion-utils.d.ts +23 -13
  343. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
  344. package/dist/lib/utils/lod-conversion-utils.js +72 -39
  345. package/dist/lib/utils/queue.d.ts +7 -0
  346. package/dist/lib/utils/queue.d.ts.map +1 -0
  347. package/dist/lib/utils/queue.js +18 -0
  348. package/dist/lib/utils/statistic-utills.d.ts +3 -25
  349. package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
  350. package/dist/lib/utils/statistic-utills.js +58 -67
  351. package/dist/lib/utils/write-queue.d.ts +39 -0
  352. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  353. package/dist/lib/utils/write-queue.js +80 -0
  354. package/dist/pgm-loader.d.ts +6 -0
  355. package/dist/pgm-loader.d.ts.map +1 -0
  356. package/dist/pgm-loader.js +23 -14
  357. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  358. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  359. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  360. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  361. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  362. package/dist/workers/i3s-attributes-worker.js +5 -0
  363. package/package.json +34 -24
  364. package/src/3d-tiles-attributes-worker.ts +43 -0
  365. package/src/3d-tiles-converter/3d-tiles-converter.ts +131 -63
  366. package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +72 -53
  367. package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
  368. package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
  369. package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
  370. package/src/constants.ts +2 -0
  371. package/src/converter-cli.ts +370 -0
  372. package/src/deps-installer/deps-installer.ts +72 -0
  373. package/src/i3s-attributes-worker.ts +59 -0
  374. package/src/i3s-converter/helpers/batch-ids-extensions.ts +202 -0
  375. package/src/i3s-converter/helpers/coordinate-converter.ts +94 -33
  376. package/src/i3s-converter/helpers/create-scene-server-path.ts +29 -0
  377. package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
  378. package/src/i3s-converter/helpers/geometry-attributes.ts +267 -0
  379. package/src/i3s-converter/helpers/geometry-converter.ts +1667 -0
  380. package/src/i3s-converter/helpers/gltf-attributes.ts +163 -0
  381. package/src/i3s-converter/helpers/load-3d-tiles.ts +68 -0
  382. package/src/i3s-converter/helpers/node-debug.ts +146 -0
  383. package/src/i3s-converter/helpers/node-index-document.ts +335 -0
  384. package/src/i3s-converter/helpers/node-pages.ts +344 -0
  385. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +81 -0
  386. package/src/i3s-converter/helpers/tileset-traversal.ts +51 -0
  387. package/src/i3s-converter/i3s-converter.ts +650 -669
  388. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  389. package/src/i3s-converter/json-templates/layers.ts +137 -0
  390. package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
  391. package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
  392. package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
  393. package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +17 -17
  394. package/src/i3s-converter/types.ts +185 -0
  395. package/src/i3s-server/README.md +19 -0
  396. package/src/i3s-server/app.js +8 -1
  397. package/src/i3s-server/controllers/slpk-controller.js +38 -0
  398. package/src/i3s-server/routes/slpk-router.js +33 -0
  399. package/src/i3s-server/utils/create-scene-server.js +15 -0
  400. package/src/index.ts +0 -4
  401. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  402. package/src/lib/utils/file-utils.ts +140 -0
  403. package/src/lib/utils/geometry-utils.ts +14 -0
  404. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +31 -5
  405. package/src/lib/utils/queue.ts +17 -0
  406. package/src/lib/utils/write-queue.ts +110 -0
  407. package/src/pgm-loader.ts +3 -3
  408. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  409. package/src/workers/i3s-attributes-worker.ts +7 -0
  410. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  411. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  412. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  413. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  414. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  415. package/dist/bundle.js.map +0 -1
  416. package/dist/deps-installer/deps-installer.js.map +0 -1
  417. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  418. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  419. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  420. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  421. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  422. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  423. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  424. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  425. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  426. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  427. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  428. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  429. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  430. package/dist/i3s-server/app.js.map +0 -1
  431. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  432. package/dist/i3s-server/routes/index.js.map +0 -1
  433. package/dist/index.js.map +0 -1
  434. package/dist/lib/geoid-height-model.d.ts +0 -41
  435. package/dist/lib/geoid-height-model.js +0 -140
  436. package/dist/lib/geoid-height-model.js.map +0 -1
  437. package/dist/lib/pgm-parser.d.ts +0 -14
  438. package/dist/lib/pgm-parser.js +0 -183
  439. package/dist/lib/pgm-parser.js.map +0 -1
  440. package/dist/lib/utils/compress-util.js.map +0 -1
  441. package/dist/lib/utils/compress-utils.d.ts +0 -53
  442. package/dist/lib/utils/file-utils.js.map +0 -1
  443. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  444. package/dist/lib/utils/statistic-utills.js.map +0 -1
  445. package/dist/pgm-loader.js.map +0 -1
  446. package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
  447. package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
  448. package/src/deps-installer/deps-installer.d.ts +0 -10
  449. package/src/deps-installer/deps-installer.js +0 -22
  450. package/src/i3s-converter/helpers/create-scene-server-path.js +0 -25
  451. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -40
  452. package/src/i3s-converter/helpers/geometry-converter.js +0 -915
  453. package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
  454. package/src/i3s-converter/helpers/node-pages.js +0 -208
  455. package/src/i3s-converter/json-templates/layers.js +0 -199
  456. package/src/lib/geoid-height-model.d.ts +0 -41
  457. package/src/lib/geoid-height-model.js +0 -239
  458. package/src/lib/pgm-parser.d.ts +0 -14
  459. package/src/lib/pgm-parser.js +0 -179
  460. package/src/lib/utils/compress-utils.d.ts +0 -53
  461. package/src/lib/utils/file-utils.d.ts +0 -43
  462. package/src/lib/utils/file-utils.js +0 -38
  463. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
  464. /package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
  465. /package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
  466. /package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
  467. /package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
  468. /package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
@@ -0,0 +1,33 @@
1
+ const express = require('express');
2
+ const {getFileByUrl} = require('../controllers/slpk-controller');
3
+ const createSceneServer = require('../utils/create-scene-server');
4
+
5
+ const sceneServerRouter = express.Router();
6
+ sceneServerRouter.get('*', async function (req, res, next) {
7
+ const file = await getFileByUrl('/');
8
+ if (file) {
9
+ const layer = JSON.parse(file.toString());
10
+ const sceneServerResponse = createSceneServer(layer.name, layer);
11
+ res.send(sceneServerResponse);
12
+ } else {
13
+ res.status(404);
14
+ res.send('File not found');
15
+ }
16
+ });
17
+
18
+ const router = express.Router();
19
+ router.get('*', async function (req, res, next) {
20
+ console.log(req.path);
21
+ const file = await getFileByUrl(req.path);
22
+ if (file) {
23
+ res.send(file);
24
+ } else {
25
+ res.status(404);
26
+ res.send('File not found');
27
+ }
28
+ });
29
+
30
+ module.exports = {
31
+ sceneServerRouter,
32
+ router
33
+ };
@@ -0,0 +1,15 @@
1
+ const {v4: uuidv4} = require('uuid');
2
+
3
+ const createSceneServer = (name, layer) => {
4
+ return {
5
+ serviceItemId: uuidv4().replace(/-/gi, ''),
6
+ serviceName: name,
7
+ name,
8
+ currentVersion: '10.7',
9
+ serviceVersion: '1.8',
10
+ supportedBindings: ['REST'],
11
+ layers: [layer]
12
+ };
13
+ };
14
+
15
+ module.exports = createSceneServer;
package/src/index.ts CHANGED
@@ -1,6 +1,2 @@
1
1
  export {default as I3SConverter} from './i3s-converter/i3s-converter';
2
- export {default as NodePages} from './i3s-converter/helpers/node-pages';
3
-
4
2
  export {default as Tiles3DConverter} from './3d-tiles-converter/3d-tiles-converter';
5
-
6
- export {DepsInstaller} from './deps-installer/deps-installer';
@@ -9,7 +9,13 @@ import {MD5Hash} from '@loaders.gl/crypto';
9
9
  import crypt from 'crypt';
10
10
  import {getAbsoluteFilePath} from './file-utils';
11
11
 
12
- export function compressFileWithGzip(pathFile) {
12
+ /**
13
+ * Compress file to gzip file
14
+ *
15
+ * @param pathFile - the path to the file
16
+ * @return the path to the gzip file
17
+ */
18
+ export function compressFileWithGzip(pathFile: string): Promise<string> {
13
19
  const compressedPathFile = `${pathFile}.gz`;
14
20
  const gzip = createGzip();
15
21
  const input = createReadStream(pathFile);
@@ -28,7 +34,18 @@ export function compressFileWithGzip(pathFile) {
28
34
  });
29
35
  }
30
36
 
31
- export async function compressFilesWithZip(fileMap, outputFile, level = 0) {
37
+ /**
38
+ * Compress files from map into slpk file
39
+ *
40
+ * @param fileMap - map with file paths (key: output path, value: input path)
41
+ * @param outputFile - output slpk file
42
+ * @param level - compression level
43
+ */
44
+ export async function compressFilesWithZip(
45
+ fileMap: {[key: string]: string},
46
+ outputFile: string,
47
+ level: number = 0
48
+ ) {
32
49
  // Before creating a new file, we need to delete the old file
33
50
  try {
34
51
  await removeFile(outputFile);
@@ -82,16 +99,44 @@ export async function compressFilesWithZip(fileMap, outputFile, level = 0) {
82
99
  });
83
100
  }
84
101
 
85
- export async function compressWithChildProcess() {
102
+ /**
103
+ * Compress files using external tool 'zip'/'7z'
104
+ *
105
+ * @param inputFolder - folder to archive - for cwd option
106
+ * @param outputFile - output slpk file
107
+ * @param level - compression level
108
+ * @param inputFiles - input files path to pass to the executable as option
109
+ * @param sevenZipExe - path to 7z.exe executable
110
+ */
111
+ export async function compressWithChildProcess(
112
+ inputFolder: string,
113
+ outputFile: string,
114
+ level: number,
115
+ inputFiles: string,
116
+ sevenZipExe: string
117
+ ) {
86
118
  // eslint-disable-next-line no-undef
87
119
  if (process.platform === 'win32') {
88
- await compressWithChildProcessWindows(...arguments);
120
+ await compressWithChildProcessWindows(inputFolder, outputFile, level, inputFiles, sevenZipExe);
89
121
  } else {
90
- await compressWithChildProcessUnix(...arguments);
122
+ await compressWithChildProcessUnix(inputFolder, outputFile, level, inputFiles);
91
123
  }
92
124
  }
93
125
 
94
- async function compressWithChildProcessUnix(inputFolder, outputFile, level = 0, inputFiles = '.') {
126
+ /**
127
+ * Compress files using external linux tool 'zip'
128
+ *
129
+ * @param inputFolder - folder to archive - for cwd option
130
+ * @param outputFile - output slpk file
131
+ * @param level - compression level
132
+ * @param inputFiles - input files path to pass to the executable as option
133
+ */
134
+ async function compressWithChildProcessUnix(
135
+ inputFolder: string,
136
+ outputFile: string,
137
+ level: number = 0,
138
+ inputFiles: string = '.'
139
+ ) {
95
140
  const fullOutputFile = getAbsoluteFilePath(outputFile);
96
141
  const args = [`-${level}`, '-r', fullOutputFile, inputFiles];
97
142
  const childProcess = new ChildProcessProxy();
@@ -105,12 +150,21 @@ async function compressWithChildProcessUnix(inputFolder, outputFile, level = 0,
105
150
  });
106
151
  }
107
152
 
153
+ /**
154
+ * Compress files using windows external tool '7z'
155
+ *
156
+ * @param inputFolder - folder to archive - for cwd option
157
+ * @param outputFile - output slpk file
158
+ * @param level - compression level
159
+ * @param inputFiles - input files path to pass to the executable as option
160
+ * @param sevenZipExe - path to 7z.exe executable
161
+ */
108
162
  async function compressWithChildProcessWindows(
109
- inputFolder,
110
- outputFile,
111
- level = 0,
112
- inputFiles = join('.', '*'),
113
- sevenZipExe
163
+ inputFolder: string,
164
+ outputFile: string,
165
+ level: number = 0,
166
+ inputFiles: string = join('.', '*'),
167
+ sevenZipExe: string
114
168
  ) {
115
169
  // Workaround for @listfile issue. In 7z.exe @-leading files are handled as listfiles
116
170
  // https://sevenzip.osdn.jp/chm/cmdline/syntax.htm
@@ -131,10 +185,17 @@ async function compressWithChildProcessWindows(
131
185
  });
132
186
  }
133
187
 
134
- export async function generateHash128FromZip(inputZipFile, outputFile) {
188
+ /**
189
+ * Generate hash file from zip archive
190
+ * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/slpk_hashtable.cmn.md
191
+ *
192
+ * @param inputZipFile
193
+ * @param outputFile
194
+ */
195
+ export async function generateHash128FromZip(inputZipFile: string, outputFile: string) {
135
196
  const input = await fs.readFile(inputZipFile);
136
197
  const zip = await JSZip.loadAsync(input);
137
- const hashTable = [];
198
+ const hashTable: {key: string; value: string}[] = [];
138
199
  const zipFiles = zip.files;
139
200
  for (const relativePath in zipFiles) {
140
201
  const zipEntry = zipFiles[relativePath];
@@ -169,7 +230,7 @@ export async function generateHash128FromZip(inputZipFile, outputFile) {
169
230
  });
170
231
  for (const key in hashTable) {
171
232
  const item = hashTable[key];
172
- const value = _longToByteArray(item.value);
233
+ const value = longToByteArray(item.value);
173
234
  // TODO: perhaps you need to wait for the 'drain' event if the write returns 'false'
174
235
  // eslint-disable-next-line no-undef
175
236
  output.write(Buffer.from(crypt.hexToBytes(item.key).concat(value)));
@@ -178,19 +239,45 @@ export async function generateHash128FromZip(inputZipFile, outputFile) {
178
239
  });
179
240
  }
180
241
 
181
- function _longToByteArray(long) {
242
+ /**
243
+ * Encode 64 bit value to byte array
244
+ *
245
+ * @param long - stringified number
246
+ * @returns
247
+ */
248
+ function longToByteArray(long: string): number[] {
182
249
  const buffer = new ArrayBuffer(8); // JS numbers are 8 bytes long, or 64 bits
183
250
  const longNum = new Float64Array(buffer); // so equivalent to Float64
184
- longNum[0] = long;
251
+ longNum[0] = parseInt(long);
185
252
  return Array.from(new Uint8Array(buffer)).reverse(); // reverse to get little endian
186
253
  }
187
254
 
188
- export async function addFileToZip(inputFolder, fileName, zipFile, sevenZipExe) {
255
+ /**
256
+ * Add file to zip archive
257
+ *
258
+ * @param inputFile
259
+ * @param fileName
260
+ * @param zipFile
261
+ * @param sevenZipExe
262
+ */
263
+ export async function addFileToZip(
264
+ inputFolder: string,
265
+ fileName: string,
266
+ zipFile: string,
267
+ sevenZipExe: string
268
+ ) {
189
269
  await compressWithChildProcess(inputFolder, zipFile, 0, fileName, sevenZipExe);
190
270
  console.log(`${fileName} added to ${zipFile}.`); // eslint-disable-line
191
271
  }
192
272
 
193
- function appendFileToArchive(archive, subFileName, subFileData) {
273
+ /**
274
+ *
275
+ * @param archive zip archive instance
276
+ * @param subFileName file path inside archive
277
+ * @param subFileData source file path
278
+ * @returns
279
+ */
280
+ function appendFileToArchive(archive: any, subFileName: string, subFileData: string) {
194
281
  return new Promise((resolve) => {
195
282
  const fileStream = createReadStream(subFileData);
196
283
  console.log(`Compression start: ${subFileName}`); // eslint-disable-line no-undef,no-console
@@ -0,0 +1,140 @@
1
+ import {load} from '@loaders.gl/core';
2
+ import {JSONLoader} from '@loaders.gl/loader-utils';
3
+ import {promises as fs} from 'fs';
4
+ import {isAbsolute, join} from 'path';
5
+ import {compressFileWithGzip} from './compress-util';
6
+
7
+ /**
8
+ * Write a file with data and name fileName to path
9
+ *
10
+ * @param path - output path
11
+ * @param data - file content
12
+ * @param fileName - name of output file (default: index.json)
13
+ */
14
+ export async function writeFile(
15
+ path: string,
16
+ data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,
17
+ fileName: string = 'index.json'
18
+ ): Promise<string> {
19
+ let toWriteData: string | Uint8Array;
20
+ if (data instanceof Promise) {
21
+ toWriteData = new Uint8Array(await data);
22
+ } else if (data instanceof ArrayBuffer) {
23
+ toWriteData = new Uint8Array(data as ArrayBuffer);
24
+ } else {
25
+ toWriteData = data;
26
+ }
27
+ await fs.mkdir(path, {recursive: true});
28
+ const pathFile = join(path, fileName);
29
+ try {
30
+ await fs.writeFile(pathFile, toWriteData);
31
+ } catch (err) {
32
+ throw err;
33
+ }
34
+ console.log(`${pathFile} saved.`); // eslint-disable-line
35
+ return pathFile;
36
+ }
37
+
38
+ /**
39
+ * Write a file with data and name fileName to path - specific one for further packaging into slpk
40
+ *
41
+ * @param path - output path
42
+ * @param data - file content
43
+ * @param fileName - name of output file (default: index.json)
44
+ * @param compress - if need to compress file with gzip (default: true)
45
+ * @param compressList - if set - the file should be added to this list and compressed in the end of conversion
46
+ */
47
+ export async function writeFileForSlpk(
48
+ path: string,
49
+ data: string | Uint8Array | ArrayBuffer | Promise<ArrayBuffer>,
50
+ fileName: string = 'index.json',
51
+ compress: boolean = true,
52
+ compressList?: string[] | null
53
+ ): Promise<string | null> {
54
+ const pathFile = await writeFile(path, data, fileName);
55
+ if (compress) {
56
+ if (compressList) {
57
+ if (!compressList.includes(pathFile)) {
58
+ compressList.push(pathFile);
59
+ return `${pathFile}.gz`;
60
+ } else {
61
+ return null;
62
+ }
63
+ } else {
64
+ const pathGzFile = await compressFileWithGzip(pathFile);
65
+ // After compression, we don't need an uncompressed file
66
+ await removeFile(pathFile);
67
+ return pathGzFile;
68
+ }
69
+ }
70
+ return pathFile;
71
+ }
72
+
73
+ /**
74
+ * Open json file
75
+ * @param path - path to the file
76
+ * @param fileName - file name
77
+ * @returns object
78
+ */
79
+ export async function openJson(path: string, fileName: string): Promise<{[key: string]: any}> {
80
+ return new Promise((resolve, reject) => {
81
+ let count = 0;
82
+ console.log(`load ${path}/${fileName}.`); // eslint-disable-line
83
+ const intervalId = setInterval(() => {
84
+ const pathFile = join(path, fileName);
85
+ load(pathFile, JSONLoader)
86
+ .then((result) => {
87
+ clearInterval(intervalId);
88
+ resolve(result);
89
+ })
90
+ .catch(() => {
91
+ count++;
92
+ if (count > 100) {
93
+ clearInterval(intervalId);
94
+ reject(new Error(`Cannon load ${path}/${fileName}.`));
95
+ }
96
+ });
97
+ }, 200);
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Check if the file exists
103
+ * @param fileName - full name of file
104
+ * @returns true if file exists, otherwise - false
105
+ */
106
+ export async function isFileExists(fileName: string): Promise<boolean> {
107
+ try {
108
+ await fs.stat(fileName);
109
+ return true;
110
+ } catch {
111
+ return false;
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Remove dir with path
117
+ *
118
+ * @param path
119
+ */
120
+ export function removeDir(path: string) {
121
+ // (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
122
+ return fs.rm(path, {recursive: true});
123
+ }
124
+
125
+ /**
126
+ * Remove file with path
127
+ *
128
+ * @param path
129
+ */
130
+ export function removeFile(path: string) {
131
+ return fs.unlink(path);
132
+ }
133
+
134
+ /**
135
+ * Generates absolute file path
136
+ * @param filePath
137
+ */
138
+ export function getAbsoluteFilePath(filePath: string) {
139
+ return isAbsolute(filePath) ? filePath : join(process.cwd(), filePath);
140
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * luma.gl can not work without indices now:
3
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
4
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
5
+ * @param {number} vertexCount - vertex count in the geometry
6
+ * @returns {Uint32Array} indices array.
7
+ */
8
+ export const generateSyntheticIndices = (vertexCount: number): Uint32Array => {
9
+ const result = new Uint32Array(vertexCount);
10
+ for (let index = 0; index < vertexCount; index++) {
11
+ result[index] = index;
12
+ }
13
+ return result;
14
+ };
@@ -1,9 +1,12 @@
1
+ import {Tiles3DTileJSONPostprocessed} from '@loaders.gl/3d-tiles';
2
+ import {BoundingVolumes} from '@loaders.gl/i3s';
3
+ import {Tile3D} from '@loaders.gl/tiles';
4
+
1
5
  // https://cesium.com/docs/cesiumjs-ref-doc/Cesium3DTileset.html
2
6
  const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
3
7
  /**
4
8
  * Do conversion from geometric error to screen threshold
5
- * @param {Object} tile
6
- * @param {Object} coordinates
9
+ *
7
10
  * In 3DTiles we have HLOD logic and parent tile also has bigger lodMetric value then its children.
8
11
  * In I3s we have reverse logic related to maxError. Parent has lower maxError than its child.
9
12
  * In nodes where are no children tile.lodMetricValue is 0. This is because of logic of HLOD in 3DTiles
@@ -13,9 +16,27 @@ const DEFAULT_MAXIMUM_SCREEN_SPACE_ERROR = 16;
13
16
  * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/lodSelection.cmn.md
14
17
  * To avoid infinity values when we do calculations of maxError we shold replace 0 with value which allows us
15
18
  * to make child maxError bigger than his parent maxError.
19
+ *
20
+ * @param tile - 3d-tiles tile JSON
21
+ * @param coordinates - node converted coordinates
22
+ * @returns An array of LOD metrics in format compatible with i3s 3DNodeIndexDocument.lodSelection
23
+ * @example
24
+ * [
25
+ {
26
+ "metricType": "maxScreenThresholdSQ",
27
+ "maxError": 870638.071285568
28
+ },
29
+ {
30
+ "metricType": "maxScreenThreshold",
31
+ "maxError": 1052.8679031638949
32
+ }
33
+ ]
16
34
  */
17
- export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
18
- const lodSelection = [];
35
+ export function convertGeometricErrorToScreenThreshold(
36
+ tile: Tiles3DTileJSONPostprocessed,
37
+ coordinates: BoundingVolumes
38
+ ) {
39
+ const lodSelection: {metricType: string; maxError: number}[] = [];
19
40
  const boundingVolume = tile.boundingVolume;
20
41
  const lodMetricValue = tile.lodMetricValue || 0.1;
21
42
  const maxScreenThreshold = {
@@ -38,7 +59,12 @@ export function convertGeometricErrorToScreenThreshold(tile, coordinates) {
38
59
  return lodSelection;
39
60
  }
40
61
 
41
- export function convertScreenThresholdToGeometricError(node) {
62
+ /**
63
+ * Convert LOD metric from "Screen Threshold" to "Screen Space Error"
64
+ * @param node - i3s node data
65
+ * @returns lod metric in 3d-tiles format
66
+ */
67
+ export function convertScreenThresholdToGeometricError(node: Tile3D): number {
42
68
  const metricData = node.header.lodSelection.maxScreenThreshold || {};
43
69
  let maxError = metricData.maxError;
44
70
  if (!maxError) {
@@ -0,0 +1,17 @@
1
+ export class Queue<T> extends Array<T> {
2
+ enqueue(val: T) {
3
+ this.push(val);
4
+ }
5
+
6
+ dequeue(): T | undefined {
7
+ return this.shift();
8
+ }
9
+
10
+ peek(): T {
11
+ return this[0];
12
+ }
13
+
14
+ isEmpty() {
15
+ return this.length === 0;
16
+ }
17
+ }
@@ -0,0 +1,110 @@
1
+ import {Queue} from './queue';
2
+ import process from 'process';
3
+
4
+ /** Memory limit size is based on testing */
5
+ const MEMORY_LIMIT = 4 * 1024 * 1024 * 1024; // 4GB
6
+
7
+ export type WriteQueueItem = {
8
+ archiveKey?: string;
9
+ /**
10
+ * writePromise() returns a Promise that will be awaited in Promise.allSettled(promises);
11
+ * Arguments for this call are specified in writeQueue.enqueue call like this:
12
+ * await writeQueue.enqueue({
13
+ * archiveKey: `nodePages/xxx.json.gz`,
14
+ * writePromise: () => writeFileForSlpk(slpkPath, data, `xxx.json`)
15
+ * });
16
+ * Note, a function like writeFileForSlpk should NOT be called when initializing the object for enqueue().
17
+ * If he function is called, the promise will be created
18
+ * and the function will allocate resources (file descriptors) for file writing.
19
+ * It will be done for ALL items in the queue, which is not supposed to happen.
20
+ * That's why the function should be passed as
21
+ * writePromise: () => writeFileForSlpk(slpkPath, content, `xxx.json`)
22
+ * instead of
23
+ * writePromise: writeFileForSlpk(slpkPath, content, `xxx.json`) // INCORRECT !
24
+ */
25
+ writePromise: () => Promise<string | null>;
26
+ };
27
+
28
+ export default class WriteQueue<T extends WriteQueueItem> extends Queue<T> {
29
+ private intervalId?: NodeJS.Timeout;
30
+ public writePromise: Promise<void> | null = null;
31
+ public fileMap: {[key: string]: string} = {};
32
+ public listeningInterval: number;
33
+ public writeConcurrency: number;
34
+
35
+ constructor(listeningInterval: number = 2000, writeConcurrency: number = 400) {
36
+ super();
37
+ this.listeningInterval = listeningInterval;
38
+ this.writeConcurrency = writeConcurrency;
39
+ }
40
+
41
+ async enqueue(val: T, writeImmediately: boolean = false) {
42
+ if (writeImmediately) {
43
+ const {archiveKey, writePromise} = val as WriteQueueItem;
44
+ const result = await writePromise();
45
+ if (archiveKey && result) {
46
+ this.fileMap[archiveKey] = result;
47
+ }
48
+ } else {
49
+ super.enqueue(val);
50
+ /** https://nodejs.org/docs/latest-v14.x/api/process.html#process_process_memoryusage */
51
+ if (process.memoryUsage().rss > MEMORY_LIMIT) {
52
+ await this.startWrite();
53
+ }
54
+ }
55
+ }
56
+
57
+ startListening() {
58
+ this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
59
+ }
60
+
61
+ stopListening() {
62
+ if (this.intervalId) {
63
+ clearInterval(this.intervalId);
64
+ }
65
+ }
66
+
67
+ async startWrite(): Promise<void> {
68
+ if (!this.writePromise) {
69
+ this.writePromise = this.doWrite();
70
+ }
71
+ await this.writePromise;
72
+ this.writePromise = null;
73
+ }
74
+
75
+ async finalize(): Promise<void> {
76
+ this.stopListening();
77
+ await this.startWrite();
78
+ }
79
+
80
+ private async doWrite(): Promise<void> {
81
+ while (this.length) {
82
+ const promises: Promise<string | null>[] = [];
83
+ const archiveKeys: (string | undefined)[] = [];
84
+ for (let i = 0; i < this.writeConcurrency; i++) {
85
+ const item = this.dequeue();
86
+ if (!item) {
87
+ break;
88
+ }
89
+ const {archiveKey, writePromise} = item as WriteQueueItem;
90
+ archiveKeys.push(archiveKey);
91
+ const promise = writePromise();
92
+ promises.push(promise);
93
+ }
94
+ const writeResults = await Promise.allSettled(promises);
95
+ this.updateFileMap(archiveKeys, writeResults);
96
+ }
97
+ }
98
+
99
+ private updateFileMap(
100
+ archiveKeys: (string | undefined)[],
101
+ writeResults: PromiseSettledResult<string | null>[]
102
+ ) {
103
+ for (let i = 0; i < archiveKeys.length; i++) {
104
+ const archiveKey = archiveKeys[i];
105
+ if (archiveKey && 'value' in writeResults[i]) {
106
+ this.fileMap[archiveKey] = (writeResults[i] as PromiseFulfilledResult<string>).value;
107
+ }
108
+ }
109
+ }
110
+ }
package/src/pgm-loader.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type {LoaderWithParser} from '@loaders.gl/loader-utils';
2
+ import {parsePGM} from '@math.gl/geoid';
2
3
 
3
4
  // __VERSION__ is injected by babel-plugin-version-inline
4
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
5
6
  const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
6
7
 
7
- import {parsePgm} from './lib/pgm-parser';
8
-
9
8
  /**
10
9
  * Loader for PGM - Netpbm grayscale image format
11
10
  */
@@ -15,7 +14,8 @@ export const PGMLoader: LoaderWithParser = {
15
14
  module: 'tile-converter',
16
15
  version: VERSION,
17
16
  mimeTypes: ['image/x-portable-graymap'],
18
- parse: (arrayBuffer, options) => parsePgm(new Uint8Array(arrayBuffer), options),
17
+ // @ts-expect-error LoaderOptions does not have cubic parameter
18
+ parse: async (arrayBuffer, options) => parsePGM(new Uint8Array(arrayBuffer), options),
19
19
  extensions: ['pgm'],
20
20
  options: {
21
21
  // TODO - use pgm namespace
@@ -0,0 +1,6 @@
1
+ import {createWorker} from '@loaders.gl/worker-utils';
2
+ import B3dmConverter from '../3d-tiles-converter/helpers/b3dm-converter';
3
+
4
+ const b3dmConverter = new B3dmConverter();
5
+
6
+ createWorker(async (data, options = {}) => b3dmConverter.convert(data, options.featureAttributes));
@@ -0,0 +1,7 @@
1
+ import {createWorker} from '@loaders.gl/worker-utils';
2
+ import {convertAttributes} from '../i3s-converter/helpers/geometry-converter';
3
+
4
+ createWorker(
5
+ async (data, options = {}) =>
6
+ await convertAttributes(data, options.materialAndTextureList, options.useCartesianPositions)
7
+ );
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":["join","process","transform","load","I3SLoader","I3SAttributeLoader","Tileset3D","Tile3D","PGMLoader","i3sObbTo3dTilesObb","convertScreenThresholdToGeometricError","writeFile","removeDir","calculateFilesSize","timeConverter","TILESET","tilesetTemplate","B3dmConverter","createObbFromMbs","I3S","Tiles3DConverter","constructor","options","tilesetPath","vertexCounter","conversionStartTime","geoidHeightModel","sourceTileset","attributeStorageInfo","convert","inputUrl","outputPath","tilesetName","maxDepth","egmFilePath","hrtime","console","log","sourceTilesetJson","root","header","obb","mbs","e","rootTile","boundingVolume","box","geometricError","children","_addChildren","tileset","JSON","stringify","_finishConversion","slpk","parentSourceNode","parentNode","level","childNodeInfo","sourceChild","_loadChildNode","push","contentUrl","_loadTile","content","vertexCount","attributes","_loadChildAttributes","child","b3dm","uri","id","Uint8Array","unloadContent","nodePages","nodePagesTile","formTileFromNodePages","loader","nodeUrl","_relativeUrlToFullUrl","url","href","i3s","loadOptions","isTileHeader","loadContent","baseUrl","relativeUrl","resultArray","split","relativeUrlArray","folder","slice","promises","attributeUrls","index","length","attribute","attributeName","name","attributeType","_getAttributeType","attributesList","Promise","all","_replaceNestedArrays","Object","assign","attributeValues","valueType","objectIds","attributeObject","key","Array","from","params","filesSize","diff","conversionTime"],"mappings":";AAGA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,OAAP,MAAoB,SAApB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,IAAR,QAAmB,kBAAnB;AACA,SAAQC,SAAR,EAAmBC,kBAAnB,QAA4C,iBAA5C;AACA,SAAQC,SAAR,EAAmBC,MAAnB,QAAgC,mBAAhC;AAEA,SAAQC,SAAR,QAAwB,eAAxB;AACA,SAAQC,kBAAR,QAAiC,mCAAjC;AACA,SAAQC,sCAAR,QAAqD,mCAArD;AACA,SAAQC,SAAR,EAAmBC,SAAnB,QAAmC,yBAAnC;AACA,SAAQC,kBAAR,EAA4BC,aAA5B,QAAgD,+BAAhD;AACA,SAAQC,OAAO,IAAIC,eAAnB,QAAyC,0BAAzC;AACA,OAAOC,aAAP,MAA0B,0BAA1B;AACA,SAAQC,gBAAR,QAA+B,+CAA/B;AAGA,MAAMC,GAAG,GAAG,KAAZ;AAKA,eAAe,MAAMC,gBAAN,CAAuB;AASpCC,EAAAA,WAAW,GAAG;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AACZ,SAAKC,OAAL,GAAe,EAAf;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,aAAL,GAAqB,CAArB;AACA,SAAKC,mBAAL,GAA2B,CAAC,CAAD,EAAI,CAAJ,CAA3B;AACA,SAAKC,gBAAL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CAACW,eAAV,CAA0BC,SAAjC;AACD,KAFD,MAEO,IAAIZ,SAAS,CAACa,SAAd,EAAyB;AAC9B,aAAO,OAAP;AACD;;AACD,WAAO,EAAP;AACD;;AAMOL,EAAAA,oBAAoB,CAACH,cAAD,EAA2C;AACrE,SAAK,IAAIP,KAAK,GAAG,CAAjB,EAAoBA,KAAK,GAAGO,cAAc,CAACN,MAA3C,EAAmDD,KAAK,EAAxD,EAA4D;AAC1D,YAAMgB,eAAe,GAAGT,cAAc,CAACP,KAAD,CAAtC;;AAEA,WAAK,MAAMiB,GAAX,IAAkBD,eAAlB,EAAmC;AACjCA,QAAAA,eAAe,CAACC,GAAD,CAAf,GAAuBC,KAAK,CAACC,IAAN,CAAWH,eAAe,CAACC,GAAD,CAA1B,CAAvB;AACD;AACF;AACF;;AAM8B,QAAjB3D,iBAAiB,CAAC8D,MAAD,EAIb;AAChB,UAAMC,SAAS,GAAG,MAAMvG,kBAAkB,CAACsG,MAAD,CAA1C;AACA,UAAME,IAAI,GAAGpH,OAAO,CAACkC,MAAR,CAAe,KAAKV,mBAApB,CAAb;AACA,UAAM6F,cAAc,GAAGxG,aAAa,CAACuG,IAAD,CAApC;AAEAjF,IAAAA,OAAO,CAACC,GAAR;AACAD,IAAAA,OAAO,CAACC,GAAR,gCAAoClB,GAApC;AACAiB,IAAAA,OAAO,CAACC,GAAR,kCAAsCiF,cAAtC;AACAlF,IAAAA,OAAO,CAACC,GAAR,mBAA8B,KAAKb,aAAnC;AACAY,IAAAA,OAAO,CAACC,GAAR,mBAA8B+E,SAA9B,EAAyC,QAAzC;AACAhF,IAAAA,OAAO,CAACC,GAAR;AACD;;AApQmC","sourcesContent":["import type {AttributeStorageInfo, FeatureAttribute, NodeReference} from '@loaders.gl/i3s';\nimport type {Node3D} from '@loaders.gl/3d-tiles';\n\nimport {join} from 'path';\nimport process from 'process';\nimport transform from 'json-map-transform';\nimport {load} from '@loaders.gl/core';\nimport {I3SLoader, I3SAttributeLoader} from '@loaders.gl/i3s';\nimport {Tileset3D, Tile3D} from '@loaders.gl/tiles';\n\nimport {PGMLoader} from '../pgm-loader';\nimport {i3sObbTo3dTilesObb} from './helpers/i3s-obb-to-3d-tiles-obb';\nimport {convertScreenThresholdToGeometricError} from '../lib/utils/lod-conversion-utils';\nimport {writeFile, removeDir} from '../lib/utils/file-utils';\nimport {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';\nimport {TILESET as tilesetTemplate} from './json-templates/tileset';\nimport B3dmConverter from './helpers/b3dm-converter';\nimport {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';\nimport {GeoidHeightModel} from '../lib/geoid-height-model';\n\nconst I3S = 'I3S';\n\n/**\n * Converter from i3s to 3d-tiles\n */\nexport default class Tiles3DConverter {\n options: any;\n tilesetPath: string;\n vertexCounter: number;\n conversionStartTime: [number, number];\n geoidHeightModel: GeoidHeightModel;\n sourceTileset: Tileset3D;\n attributeStorageInfo: AttributeStorageInfo;\n\n constructor() {\n this.options = {};\n this.tilesetPath = '';\n this.vertexCounter = 0;\n this.conversionStartTime = [0, 0];\n this.geoidHeightModel = null;\n this.sourceTileset = null;\n this.attributeStorageInfo = null;\n }\n\n /**\n * Convert i3s format data to 3dTiles\n * @param options\n * @param options.inputUrl the url to read the tileset from\n * @param options.outputPath the output filename\n * @param options.tilesetName the output name of the tileset\n * @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format\n * @param options.maxDepth The max tree depth of conversion\n */\n private async convert(options: {\n inputUrl: string;\n outputPath: string;\n tilesetName: string;\n maxDepth: number;\n egmFilePath: string;\n }): Promise<any> {\n const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;\n this.conversionStartTime = process.hrtime();\n this.options = {maxDepth};\n\n console.log('Loading egm file...'); // eslint-disable-line\n this.geoidHeightModel = await load(egmFilePath, PGMLoader);\n console.log('Loading egm file completed!'); // eslint-disable-line\n\n const sourceTilesetJson = await load(inputUrl, I3SLoader, {});\n this.sourceTileset = new Tileset3D(sourceTilesetJson, {});\n\n if (!this.sourceTileset.root.header.obb) {\n this.sourceTileset.root.header.obb = createObbFromMbs(this.sourceTileset.root.header.mbs);\n }\n\n this.tilesetPath = join(`${outputPath}`, `${tilesetName}`);\n this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;\n // Removing the tilesetPath needed to exclude erroneous files after conversion\n try {\n await removeDir(this.tilesetPath);\n } catch (e) {\n // do nothing\n }\n\n const rootTile: Node3D = {\n boundingVolume: {\n box: i3sObbTo3dTilesObb(this.sourceTileset.root.header.obb, this.geoidHeightModel)\n },\n geometricError: convertScreenThresholdToGeometricError(this.sourceTileset.root),\n children: []\n };\n\n await this._addChildren(this.sourceTileset.root, rootTile, 1);\n\n const tileset = transform({root: rootTile}, tilesetTemplate);\n await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');\n\n this._finishConversion({slpk: false, outputPath, tilesetName});\n }\n\n /**\n * The recursive function of traversal of a nodes tree\n * @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param parentNode object in resulting tileset\n * @param level a current level of a tree depth\n */\n private async _addChildren(\n parentSourceNode: Tile3D,\n parentNode: Node3D,\n level: number\n ): Promise<void> {\n if (this.options.maxDepth && level > this.options.maxDepth) {\n return;\n }\n for (const childNodeInfo of parentSourceNode.header.children || []) {\n const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);\n parentSourceNode.children.push(sourceChild);\n if (sourceChild.contentUrl) {\n await this.sourceTileset._loadTile(sourceChild);\n this.vertexCounter += sourceChild.content.vertexCount;\n\n let attributes = null;\n if (this.attributeStorageInfo) {\n attributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);\n }\n\n if (!sourceChild.header.obb) {\n sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);\n }\n\n const boundingVolume = {\n box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)\n };\n const child: Node3D = {\n boundingVolume,\n geometricError: convertScreenThresholdToGeometricError(sourceChild),\n children: []\n };\n\n const b3dm = await new B3dmConverter().convert(sourceChild, attributes);\n child.content = {\n uri: `${sourceChild.id}.b3dm`,\n boundingVolume\n };\n await writeFile(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);\n parentNode.children.push(child);\n\n sourceChild.unloadContent();\n await this._addChildren(sourceChild, child, level + 1);\n } else {\n await this._addChildren(sourceChild, parentNode, level + 1);\n }\n }\n }\n\n /**\n * Load a child node having information from the node header\n * @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)\n * @param childNodeInfo child information from 3DNodeIndexDocument\n * (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)\n */\n private async _loadChildNode(parentNode: Tile3D, childNodeInfo: NodeReference): Promise<Tile3D> {\n let header;\n if (this.sourceTileset.tileset.nodePages) {\n console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef\n header = await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(\n childNodeInfo.id\n );\n } else {\n const {loader} = this.sourceTileset;\n const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);\n // load metadata\n const options = {\n i3s: {\n ...this.sourceTileset.loadOptions,\n isTileHeader: true,\n loadContent: false\n }\n };\n\n console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef\n header = await load(nodeUrl, loader, options);\n }\n return new Tile3D(this.sourceTileset, header, parentNode);\n }\n\n /**\n * Make an url of a resource from its relative url having the base url\n * @param baseUrl the base url. A resulting url will be related from this url\n * @param relativeUrl a realtive url of a resource\n */\n private _relativeUrlToFullUrl(baseUrl: string, relativeUrl: string): string {\n let resultArray = baseUrl.split('/');\n const relativeUrlArray = relativeUrl.split('/');\n for (const folder of relativeUrlArray) {\n switch (folder) {\n case '.':\n continue; // eslint-disable-line no-continue\n case '..':\n resultArray = resultArray.slice(0, -1);\n break;\n default:\n resultArray.push(folder);\n }\n }\n return resultArray.join('/');\n }\n\n /**\n * Do loading all attributes related to particular node.\n * @param sourceChild\n * @param attributeStorageInfo\n * @returns Promise of attributes object.\n */\n private async _loadChildAttributes(\n sourceChild: Tile3D,\n attributeStorageInfo: AttributeStorageInfo\n ): Promise<FeatureAttribute> {\n const promises = [];\n const {attributeUrls} = sourceChild.header;\n\n for (let index = 0; index < attributeUrls.length; index++) {\n const inputUrl = attributeUrls[index];\n const attribute = attributeStorageInfo[index];\n const options = {\n attributeName: attribute.name,\n attributeType: this._getAttributeType(attribute)\n };\n\n promises.push(load(inputUrl, I3SAttributeLoader, options));\n }\n const attributesList = await Promise.all(promises);\n this._replaceNestedArrays(attributesList);\n return Object.assign({}, ...attributesList);\n }\n\n /**\n * Returns attribute type for loading attributes\n * @param attribute\n * Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.\n * There is an 'Oid32' type if attribute has objectIds property.\n * Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md\n */\n private _getAttributeType(attribute: AttributeStorageInfo): string {\n if (attribute.attributeValues) {\n return attribute.attributeValues.valueType;\n } else if (attribute.objectIds) {\n return 'Oid32';\n }\n return '';\n }\n\n /**\n * Make simple arrays from attribute typed arrays.\n * @param attributesList\n */\n private _replaceNestedArrays(attributesList: FeatureAttribute[]): void {\n for (let index = 0; index < attributesList.length; index++) {\n const attributeObject = attributesList[index];\n\n for (const key in attributeObject) {\n attributeObject[key] = Array.from(attributeObject[key]);\n }\n }\n }\n\n /**\n * Print statistics in the end of conversion\n * @param params - output files data\n */\n private async _finishConversion(params: {\n slpk: boolean;\n outputPath: string;\n tilesetName: string;\n }): Promise<void> {\n const filesSize = await calculateFilesSize(params);\n const diff = process.hrtime(this.conversionStartTime);\n const conversionTime = timeConverter(diff);\n\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Finish conversion of ${I3S}`); // eslint-disable-line\n console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line\n console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line\n console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n }\n}\n"],"file":"3d-tiles-converter.js"}