@loaders.gl/tile-converter 4.0.0-alpha.5 → 4.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (368) 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 +13 -1
  7. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/3d-tiles-converter.js +274 -233
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +9 -16
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  11. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +256 -246
  12. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -9
  13. package/dist/3d-tiles-converter/helpers/texture-atlas.js +47 -28
  14. package/dist/3d-tiles-converter/json-templates/tileset.js +38 -35
  15. package/dist/bundle.js +2 -2
  16. package/dist/constants.d.ts +2 -0
  17. package/dist/constants.d.ts.map +1 -0
  18. package/dist/constants.js +4 -0
  19. package/dist/converter-cli.d.ts +2 -0
  20. package/dist/converter-cli.d.ts.map +1 -0
  21. package/dist/converter-cli.js +280 -0
  22. package/dist/converter.min.js +185 -190
  23. package/dist/deps-installer/deps-installer.d.ts +11 -3
  24. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  25. package/dist/deps-installer/deps-installer.js +59 -18
  26. package/dist/dist.min.js +15153 -37895
  27. package/dist/es5/3d-tiles-attributes-worker.js +25 -0
  28. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  29. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +467 -0
  30. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  31. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +293 -0
  32. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  33. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +18 -0
  34. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  35. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +33 -0
  36. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  37. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +61 -0
  38. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  39. package/dist/es5/bundle.js +6 -0
  40. package/dist/es5/bundle.js.map +1 -0
  41. package/dist/es5/constants.js +9 -0
  42. package/dist/es5/constants.js.map +1 -0
  43. package/dist/es5/converter-cli.js +289 -0
  44. package/dist/es5/converter-cli.js.map +1 -0
  45. package/dist/es5/deps-installer/deps-installer.js +123 -0
  46. package/dist/es5/deps-installer/deps-installer.js.map +1 -0
  47. package/dist/es5/i3s-attributes-worker.js +25 -0
  48. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  49. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +116 -0
  50. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  51. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +90 -0
  52. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  53. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +41 -0
  54. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  55. package/dist/es5/i3s-converter/helpers/feature-attributes.js +174 -0
  56. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  57. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +213 -0
  58. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  59. package/dist/es5/i3s-converter/helpers/geometry-converter.js +1181 -0
  60. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
  61. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +80 -0
  62. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  63. package/dist/es5/i3s-converter/helpers/node-debug.js +76 -0
  64. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
  65. package/dist/es5/i3s-converter/helpers/node-index-document.js +492 -0
  66. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  67. package/dist/es5/i3s-converter/helpers/node-pages.js +519 -0
  68. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
  69. package/dist/es5/i3s-converter/i3s-converter.js +1512 -0
  70. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
  71. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  72. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  73. package/dist/es5/i3s-converter/json-templates/layers.js +163 -0
  74. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
  75. package/dist/es5/i3s-converter/json-templates/metadata.js +31 -0
  76. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
  77. package/dist/es5/i3s-converter/json-templates/node.js +99 -0
  78. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
  79. package/dist/es5/i3s-converter/json-templates/scene-server.js +39 -0
  80. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
  81. package/dist/es5/i3s-converter/json-templates/shared-resources.js +173 -0
  82. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
  83. package/dist/es5/i3s-converter/json-templates/store.js +107 -0
  84. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
  85. package/dist/es5/i3s-converter/types.js +2 -0
  86. package/dist/es5/i3s-converter/types.js.map +1 -0
  87. package/dist/es5/i3s-server/app.js +18 -0
  88. package/dist/es5/i3s-server/app.js.map +1 -0
  89. package/dist/es5/i3s-server/controllers/index-controller.js +55 -0
  90. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
  91. package/dist/es5/i3s-server/routes/index.js +37 -0
  92. package/dist/es5/i3s-server/routes/index.js.map +1 -0
  93. package/dist/es5/index.js +21 -0
  94. package/dist/es5/index.js.map +1 -0
  95. package/dist/es5/lib/utils/compress-util.js +346 -0
  96. package/dist/es5/lib/utils/compress-util.js.map +1 -0
  97. package/dist/es5/lib/utils/file-utils.js +208 -0
  98. package/dist/es5/lib/utils/file-utils.js.map +1 -0
  99. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  100. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  101. package/dist/es5/lib/utils/lod-conversion-utils.js +44 -0
  102. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
  103. package/dist/es5/lib/utils/queue.js +47 -0
  104. package/dist/es5/lib/utils/queue.js.map +1 -0
  105. package/dist/es5/lib/utils/statistic-utills.d.ts +25 -0
  106. package/dist/es5/lib/utils/statistic-utills.js +147 -0
  107. package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
  108. package/dist/es5/lib/utils/write-queue.js +214 -0
  109. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  110. package/dist/es5/pgm-loader.js +41 -0
  111. package/dist/es5/pgm-loader.js.map +1 -0
  112. package/dist/es5/workers/3d-tiles-attributes-worker.js +28 -0
  113. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  114. package/dist/es5/workers/i3s-attributes-worker.js +30 -0
  115. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  116. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  117. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  118. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +245 -0
  119. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  120. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +218 -0
  121. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  122. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +10 -0
  123. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  124. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +27 -0
  125. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  126. package/dist/esm/3d-tiles-converter/json-templates/tileset.js +37 -0
  127. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  128. package/dist/esm/bundle.js +4 -0
  129. package/dist/esm/bundle.js.map +1 -0
  130. package/dist/esm/constants.js +2 -0
  131. package/dist/esm/constants.js.map +1 -0
  132. package/dist/esm/converter-cli.js +232 -0
  133. package/dist/esm/converter-cli.js.map +1 -0
  134. package/dist/esm/deps-installer/deps-installer.js +44 -0
  135. package/dist/esm/deps-installer/deps-installer.js.map +1 -0
  136. package/dist/esm/i3s-attributes-worker.js +16 -0
  137. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  138. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +105 -0
  139. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  140. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +80 -0
  141. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  142. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +16 -0
  143. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  144. package/dist/esm/i3s-converter/helpers/feature-attributes.js +147 -0
  145. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  146. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +190 -0
  147. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  148. package/dist/esm/i3s-converter/helpers/geometry-converter.js +895 -0
  149. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
  150. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +73 -0
  151. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  152. package/dist/esm/i3s-converter/helpers/node-debug.js +72 -0
  153. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
  154. package/dist/esm/i3s-converter/helpers/node-index-document.js +188 -0
  155. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  156. package/dist/esm/i3s-converter/helpers/node-pages.js +206 -0
  157. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
  158. package/dist/esm/i3s-converter/i3s-converter.js +764 -0
  159. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
  160. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  161. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  162. package/dist/esm/i3s-converter/json-templates/layers.js +133 -0
  163. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
  164. package/dist/esm/i3s-converter/json-templates/metadata.js +22 -0
  165. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
  166. package/dist/esm/i3s-converter/json-templates/node.js +80 -0
  167. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
  168. package/dist/esm/i3s-converter/json-templates/scene-server.js +28 -0
  169. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
  170. package/dist/esm/i3s-converter/json-templates/shared-resources.js +123 -0
  171. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
  172. package/dist/esm/i3s-converter/json-templates/store.js +98 -0
  173. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
  174. package/dist/esm/i3s-converter/types.js +2 -0
  175. package/dist/esm/i3s-converter/types.js.map +1 -0
  176. package/dist/esm/i3s-server/app.js +16 -0
  177. package/dist/esm/i3s-server/app.js.map +1 -0
  178. package/dist/esm/i3s-server/bin/www +102 -0
  179. package/dist/esm/i3s-server/certs/cert.pem +19 -0
  180. package/dist/esm/i3s-server/certs/key.pem +27 -0
  181. package/dist/esm/i3s-server/controllers/index-controller.js +24 -0
  182. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
  183. package/dist/esm/i3s-server/routes/index.js +16 -0
  184. package/dist/esm/i3s-server/routes/index.js.map +1 -0
  185. package/dist/esm/index.js +3 -0
  186. package/dist/esm/index.js.map +1 -0
  187. package/dist/esm/lib/utils/compress-util.js +168 -0
  188. package/dist/esm/lib/utils/compress-util.js.map +1 -0
  189. package/dist/esm/lib/utils/file-utils.js +87 -0
  190. package/dist/esm/lib/utils/file-utils.js.map +1 -0
  191. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  192. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  193. package/dist/esm/lib/utils/lod-conversion-utils.js +37 -0
  194. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
  195. package/dist/esm/lib/utils/queue.js +15 -0
  196. package/dist/esm/lib/utils/queue.js.map +1 -0
  197. package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
  198. package/dist/esm/lib/utils/statistic-utills.js +62 -0
  199. package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
  200. package/dist/esm/lib/utils/write-queue.js +85 -0
  201. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  202. package/dist/esm/pgm-loader.js +15 -0
  203. package/dist/esm/pgm-loader.js.map +1 -0
  204. package/dist/esm/workers/3d-tiles-attributes-worker.js +8 -0
  205. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  206. package/dist/esm/workers/i3s-attributes-worker.js +7 -0
  207. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  208. package/dist/i3s-attributes-worker.d.ts +45 -0
  209. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  210. package/dist/i3s-attributes-worker.js +9 -0
  211. package/dist/i3s-attributes-worker.js.map +7 -0
  212. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +13 -0
  213. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  214. package/dist/i3s-converter/helpers/batch-ids-extensions.js +141 -0
  215. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +9 -9
  216. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  217. package/dist/i3s-converter/helpers/coordinate-converter.js +118 -72
  218. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +5 -5
  219. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -1
  220. package/dist/i3s-converter/helpers/create-scene-server-path.js +27 -15
  221. package/dist/i3s-converter/helpers/feature-attributes.d.ts +56 -0
  222. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  223. package/dist/i3s-converter/helpers/feature-attributes.js +216 -0
  224. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +4 -19
  225. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  226. package/dist/i3s-converter/helpers/geometry-attributes.js +188 -185
  227. package/dist/i3s-converter/helpers/geometry-converter.d.ts +36 -39
  228. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  229. package/dist/i3s-converter/helpers/geometry-converter.js +1150 -689
  230. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  231. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  232. package/dist/i3s-converter/helpers/gltf-attributes.js +85 -0
  233. package/dist/i3s-converter/helpers/node-debug.d.ts +7 -1
  234. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -1
  235. package/dist/i3s-converter/helpers/node-debug.js +106 -72
  236. package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
  237. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  238. package/dist/i3s-converter/helpers/node-index-document.js +250 -0
  239. package/dist/i3s-converter/helpers/node-pages.d.ts +81 -41
  240. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  241. package/dist/i3s-converter/helpers/node-pages.js +313 -144
  242. package/dist/i3s-converter/i3s-converter.d.ts +60 -113
  243. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  244. package/dist/i3s-converter/i3s-converter.js +858 -951
  245. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  246. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  247. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  248. package/dist/i3s-converter/json-templates/layers.d.ts +5 -30
  249. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  250. package/dist/i3s-converter/json-templates/layers.js +132 -194
  251. package/dist/i3s-converter/json-templates/metadata.js +24 -21
  252. package/dist/i3s-converter/json-templates/node.js +82 -77
  253. package/dist/i3s-converter/json-templates/scene-server.js +30 -27
  254. package/dist/i3s-converter/json-templates/shared-resources.js +116 -122
  255. package/dist/i3s-converter/json-templates/store.js +100 -95
  256. package/dist/i3s-converter/types.d.ts +137 -6
  257. package/dist/i3s-converter/types.d.ts.map +1 -1
  258. package/dist/i3s-converter/types.js +2 -2
  259. package/dist/i3s-server/app.js +2 -9
  260. package/dist/i3s-server/controllers/index-controller.js +16 -24
  261. package/dist/i3s-server/routes/index.js +11 -15
  262. package/dist/index.d.ts +0 -2
  263. package/dist/index.d.ts.map +1 -1
  264. package/dist/index.js +10 -5
  265. package/dist/lib/utils/compress-util.d.ts +12 -20
  266. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  267. package/dist/lib/utils/compress-util.js +238 -160
  268. package/dist/lib/utils/file-utils.d.ts +22 -14
  269. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  270. package/dist/lib/utils/file-utils.js +133 -36
  271. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  272. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  273. package/dist/lib/utils/geometry-utils.js +18 -0
  274. package/dist/lib/utils/lod-conversion-utils.d.ts +21 -12
  275. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  276. package/dist/lib/utils/lod-conversion-utils.js +72 -39
  277. package/dist/lib/utils/queue.d.ts +7 -0
  278. package/dist/lib/utils/queue.d.ts.map +1 -0
  279. package/dist/lib/utils/queue.js +18 -0
  280. package/dist/lib/utils/statistic-utills.d.ts +3 -25
  281. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  282. package/dist/lib/utils/statistic-utills.js +58 -67
  283. package/dist/lib/utils/write-queue.d.ts +39 -0
  284. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  285. package/dist/lib/utils/write-queue.js +80 -0
  286. package/dist/pgm-loader.d.ts.map +1 -1
  287. package/dist/pgm-loader.js +23 -14
  288. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  289. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  290. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  291. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  292. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  293. package/dist/workers/i3s-attributes-worker.js +5 -0
  294. package/package.json +32 -24
  295. package/src/3d-tiles-attributes-worker.ts +43 -0
  296. package/src/3d-tiles-converter/3d-tiles-converter.ts +102 -40
  297. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +39 -44
  298. package/src/constants.ts +2 -0
  299. package/src/converter-cli.ts +370 -0
  300. package/src/deps-installer/deps-installer.ts +71 -0
  301. package/src/i3s-attributes-worker.ts +59 -0
  302. package/src/i3s-converter/helpers/batch-ids-extensions.ts +205 -0
  303. package/src/i3s-converter/helpers/coordinate-converter.ts +33 -26
  304. package/src/i3s-converter/helpers/create-scene-server-path.ts +9 -5
  305. package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
  306. package/src/i3s-converter/helpers/geometry-attributes.ts +98 -47
  307. package/src/i3s-converter/helpers/geometry-converter.ts +1635 -0
  308. package/src/i3s-converter/helpers/gltf-attributes.ts +100 -0
  309. package/src/i3s-converter/helpers/node-debug.ts +68 -16
  310. package/src/i3s-converter/helpers/node-index-document.ts +315 -0
  311. package/src/i3s-converter/helpers/node-pages.ts +222 -101
  312. package/src/i3s-converter/i3s-converter.ts +408 -555
  313. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  314. package/src/i3s-converter/json-templates/layers.ts +27 -91
  315. package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
  316. package/src/i3s-converter/types.ts +156 -5
  317. package/src/index.ts +0 -4
  318. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  319. package/src/lib/utils/file-utils.ts +139 -0
  320. package/src/lib/utils/geometry-utils.ts +14 -0
  321. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  322. package/src/lib/utils/queue.ts +17 -0
  323. package/src/lib/utils/write-queue.ts +110 -0
  324. package/src/pgm-loader.ts +2 -2
  325. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  326. package/src/workers/i3s-attributes-worker.ts +7 -0
  327. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  328. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  329. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  330. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  331. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  332. package/dist/bundle.js.map +0 -1
  333. package/dist/deps-installer/deps-installer.js.map +0 -1
  334. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  335. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  336. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  337. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  338. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  339. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  340. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  341. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  342. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  343. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  344. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  345. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  346. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  347. package/dist/i3s-converter/types.js.map +0 -1
  348. package/dist/i3s-server/app.js.map +0 -1
  349. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  350. package/dist/i3s-server/routes/index.js.map +0 -1
  351. package/dist/index.js.map +0 -1
  352. package/dist/lib/utils/compress-util.js.map +0 -1
  353. package/dist/lib/utils/file-utils.js.map +0 -1
  354. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  355. package/dist/lib/utils/statistic-utills.js.map +0 -1
  356. package/dist/pgm-loader.js.map +0 -1
  357. package/src/deps-installer/deps-installer.d.ts +0 -10
  358. package/src/deps-installer/deps-installer.js +0 -22
  359. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  360. package/src/i3s-converter/helpers/geometry-converter.js +0 -992
  361. package/src/lib/utils/compress-util.d.ts +0 -53
  362. package/src/lib/utils/file-utils.d.ts +0 -43
  363. package/src/lib/utils/file-utils.js +0 -38
  364. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
  365. /package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
  366. /package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
  367. /package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
  368. /package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
@@ -1,259 +1,269 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { encodeSync } from '@loaders.gl/core';
3
- import { GLTFScenegraph, GLTFWriter } from '@loaders.gl/gltf';
4
- import { Tile3DWriter } from '@loaders.gl/3d-tiles';
5
- import { Matrix4, Vector3 } from '@math.gl/core';
6
- import { Ellipsoid } from '@math.gl/geospatial';
7
- import { convertTextureAtlas } from './texture-atlas';
8
- const Z_UP_TO_Y_UP_MATRIX = new Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
9
- const scratchVector = new Vector3();
10
- export default class B3dmConverter {
11
- constructor() {
12
- _defineProperty(this, "rtcCenter", void 0);
13
-
14
- _defineProperty(this, "i3sTile", void 0);
15
- }
16
-
17
- async convert(i3sTile, attributes = null) {
18
- this.i3sTile = i3sTile;
19
- const gltf = await this.buildGltf(i3sTile);
20
- const b3dm = encodeSync({
21
- gltfEncoded: new Uint8Array(gltf),
22
- type: 'b3dm',
23
- featuresLength: this._getFeaturesLength(attributes),
24
- batchTable: attributes
25
- }, Tile3DWriter);
26
- return b3dm;
27
- }
28
-
29
- async buildGltf(i3sTile) {
30
- const {
31
- material,
32
- attributes,
33
- indices: originalIndices,
34
- cartesianOrigin,
35
- cartographicOrigin,
36
- modelMatrix
37
- } = i3sTile.content;
38
- const gltfBuilder = new GLTFScenegraph();
39
- const textureIndex = await this._addI3sTextureToGltf(i3sTile, gltfBuilder);
40
-
41
- const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
42
-
43
- const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
44
- const positions = attributes.positions;
45
- const positionsValue = positions.value;
46
-
47
- if (attributes.uvRegions && attributes.texCoords) {
48
- attributes.texCoords.value = convertTextureAtlas(attributes.texCoords.value, attributes.uvRegions.value);
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;
49
30
  }
50
-
51
- attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
52
-
53
- if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
54
- delete attributes.normals;
55
- }
56
-
57
- const indices = originalIndices || this._generateSynteticIndices(positionsValue.length / positions.size);
58
-
59
- const meshIndex = gltfBuilder.addMesh({
60
- attributes,
61
- indices,
62
- material: materialIndex,
63
- mode: 4
64
- });
65
-
66
- const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
67
-
68
- const nodeIndex = gltfBuilder.addNode({
69
- meshIndex,
70
- matrix: transformMatrix
71
- });
72
- const sceneIndex = gltfBuilder.addScene({
73
- nodeIndices: [nodeIndex]
74
- });
75
- gltfBuilder.setDefaultScene(sceneIndex);
76
- gltfBuilder.createBinaryChunk();
77
- const gltfBuffer = encodeSync(gltfBuilder.gltf, GLTFWriter);
78
- return gltfBuffer;
79
- }
80
-
81
- async _addI3sTextureToGltf(i3sTile, gltfBuilder) {
82
- const {
83
- content: {
84
- texture,
85
- material,
86
- attributes
87
- },
88
- header: {
89
- textureFormat
90
- }
91
- } = i3sTile;
92
- let textureIndex = null;
93
- let selectedTexture = texture;
94
-
95
- if (!texture && material) {
96
- selectedTexture = material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture && material.pbrMetallicRoughness.baseColorTexture.texture.source.image;
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;
97
67
  }
98
-
99
- if (selectedTexture) {
100
- const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
101
-
102
- const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
103
- textureIndex = gltfBuilder.addTexture({
104
- imageIndex
105
- });
106
- delete attributes.colors;
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;
107
91
  }
108
-
109
- return textureIndex;
110
- }
111
-
112
- _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
113
- const newPositionsValue = new Float32Array(positionsValue.length);
114
-
115
- for (let index = 0; index < positionsValue.length; index += 3) {
116
- const vertex = positionsValue.subarray(index, index + 3);
117
- const cartesianOriginVector = new Vector3(cartesianOrigin);
118
- let vertexVector = new Vector3(Array.from(vertex)).transform(modelMatrix).add(cartographicOrigin);
119
- Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);
120
- vertexVector = scratchVector.subtract(cartesianOriginVector);
121
- newPositionsValue.set(vertexVector, index);
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;
122
113
  }
123
-
124
- return newPositionsValue;
125
- }
126
-
127
- _generateTransformMatrix(cartesianOrigin) {
128
- const translateOriginMatrix = new Matrix4().translate(cartesianOrigin);
129
- const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);
130
- return result;
131
- }
132
-
133
- _generateBatchId(faceRanges) {
134
- const batchIdArraySize = (faceRanges[faceRanges.length - 1] + 1) * 3;
135
- const batchId = new Float32Array(batchIdArraySize);
136
- let rangeIndex = 0;
137
- let currentBatchId = 0;
138
-
139
- for (let index = 0; index < faceRanges.length / 2; index++) {
140
- const fromIndex = faceRanges[rangeIndex] * 3;
141
- const untilPosition = (faceRanges[rangeIndex + 1] + 1) * 3;
142
- batchId.fill(currentBatchId, fromIndex, untilPosition);
143
- rangeIndex += 2;
144
- currentBatchId += 1;
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;
145
126
  }
146
-
147
- return batchId;
148
- }
149
-
150
- _generateSynteticIndices(vertexCount) {
151
- const result = new Uint32Array(vertexCount);
152
-
153
- for (let index = 0; index < vertexCount; index++) {
154
- result.set([index], index);
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
+ };
155
148
  }
156
-
157
- return result;
158
- }
159
-
160
- _deduceMimeTypeFromFormat(format) {
161
- switch (format) {
162
- case 'jpg':
163
- return 'image/jpeg';
164
-
165
- case 'png':
166
- return 'image/png';
167
-
168
- case 'ktx2':
169
- return 'image/ktx2';
170
-
171
- default:
172
- console.warn("Unexpected texture format in I3S: ".concat(format));
173
- return 'image/jpeg';
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
+ }
174
167
  }
175
- }
176
-
177
- _convertI3sMaterialToGltfMaterial(material, textureIndex) {
178
- const isTextureIndexExists = textureIndex !== null;
179
-
180
- if (!material) {
181
- material = {
182
- alphaMode: 'OPAQUE',
183
- doubleSided: false,
184
- pbrMetallicRoughness: {
185
- metallicFactor: 0,
186
- roughnessFactor: 1
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;
187
195
  }
188
- };
189
-
190
- if (isTextureIndexExists) {
191
- material.pbrMetallicRoughness.baseColorTexture = {
192
- index: textureIndex,
193
- texCoord: 0
194
- };
195
- } else {
196
- material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];
197
- }
198
-
199
- return material;
196
+ if (textureIndex !== null) {
197
+ material = this._setGltfTexture(material, textureIndex);
198
+ }
199
+ return material;
200
200
  }
201
-
202
- if (textureIndex !== null) {
203
- material = this._setGltfTexture(material, textureIndex);
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;
204
247
  }
205
-
206
- return material;
207
- }
208
-
209
- _setGltfTexture(materialDefinition, textureIndex) {
210
- const material = { ...materialDefinition,
211
- pbrMetallicRoughness: { ...materialDefinition.pbrMetallicRoughness
212
- }
213
- };
214
-
215
- if (materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.baseColorTexture) {
216
- material.pbrMetallicRoughness.baseColorTexture = {
217
- index: textureIndex,
218
- texCoord: 0
219
- };
220
- } else if (materialDefinition.emissiveTexture) {
221
- material.emissiveTexture = {
222
- index: textureIndex,
223
- texCoord: 0
224
- };
225
- } else if (materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture) {
226
- material.pbrMetallicRoughness.metallicRoughnessTexture = {
227
- index: textureIndex,
228
- texCoord: 0
229
- };
230
- } else if (materialDefinition.normalTexture) {
231
- material.normalTexture = {
232
- index: textureIndex,
233
- texCoord: 0
234
- };
235
- } else if (materialDefinition.occlusionTexture) {
236
- material.occlusionTexture = {
237
- index: textureIndex,
238
- texCoord: 0
239
- };
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;
240
259
  }
241
-
242
- return material;
243
- }
244
-
245
- _getFeaturesLength(attributes) {
246
- if (!attributes) {
247
- return 0;
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);
248
267
  }
249
-
250
- const firstKey = Object.keys(attributes)[0];
251
- return firstKey ? attributes[firstKey].length : 0;
252
- }
253
-
254
- _checkNormals(normals) {
255
- return normals.find(value => value);
256
- }
257
-
258
268
  }
259
- //# sourceMappingURL=b3dm-converter.js.map
269
+ exports.default = B3dmConverter;
@@ -1,10 +1,23 @@
1
- import { Vector3 } from '@math.gl/core';
2
- import { Ellipsoid } from '@math.gl/geospatial';
3
- import { OrientedBoundingBox } from '@math.gl/culling';
4
- export function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
5
- const tiles3DCenter = [i3SObb.center[0], i3SObb.center[1], i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])];
6
- const cartesianCenter = Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new Vector3());
7
- const tiles3DObb = new OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
8
- return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
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()];
9
22
  }
10
- //# sourceMappingURL=i3s-obb-to-3d-tiles-obb.js.map
23
+ exports.i3sObbTo3dTilesObb = i3sObbTo3dTilesObb;
@@ -1,33 +1,52 @@
1
- export function convertTextureAtlas(texCoords, uvRegions) {
2
- const convertedTexCoords = new Float32Array(texCoords.length);
3
- const normalisedRegions = normalizeRegions(uvRegions);
4
-
5
- for (let index = 0; index < texCoords.length; index += 2) {
6
- const uv = texCoords.subarray(index, index + 2);
7
- const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
8
- const fractatedUV = fract([uv[0], uv[1]]);
9
- const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
10
- const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];
11
- const convertedUV = [multiplicationResult[0] + regions[0], multiplicationResult[1] + regions[1]];
12
- convertedTexCoords[index] = convertedUV[0];
13
- convertedTexCoords[index + 1] = convertedUV[1];
14
- }
15
-
16
- return convertedTexCoords;
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;
17
32
  }
18
-
33
+ exports.convertTextureAtlas = convertTextureAtlas;
34
+ /**
35
+ * Do fractation of UV array.
36
+ * @param uv
37
+ */
19
38
  function fract(uv) {
20
- return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
39
+ return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
21
40
  }
22
-
41
+ /**
42
+ * Normalize uvRegions by dividing by the maximum Uint16 value
43
+ * @param regions
44
+ */
23
45
  function normalizeRegions(regions) {
24
- const MAX_UINT_16_VALUE = 65535;
25
- const normalizedRegions = [];
26
-
27
- for (let index = 0; index < regions.length; index++) {
28
- normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
29
- }
30
-
31
- return normalizedRegions;
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;
32
52
  }
33
- //# sourceMappingURL=texture-atlas.js.map