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

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 (359) hide show
  1. package/dist/3d-tiles-attributes-worker.d.ts +28 -0
  2. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
  3. package/dist/3d-tiles-attributes-worker.js +3 -0
  4. package/dist/3d-tiles-attributes-worker.js.map +7 -0
  5. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +13 -1
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +273 -233
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +9 -8
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +268 -245
  11. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +22 -9
  12. package/dist/3d-tiles-converter/helpers/texture-atlas.js +47 -28
  13. package/dist/3d-tiles-converter/json-templates/tileset.js +38 -35
  14. package/dist/bundle.js +2 -2
  15. package/dist/constants.d.ts +2 -0
  16. package/dist/constants.d.ts.map +1 -0
  17. package/dist/constants.js +4 -0
  18. package/dist/converter-cli.d.ts +2 -0
  19. package/dist/converter-cli.d.ts.map +1 -0
  20. package/dist/converter-cli.js +280 -0
  21. package/dist/converter.min.js +186 -190
  22. package/dist/deps-installer/deps-installer.d.ts +11 -3
  23. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  24. package/dist/deps-installer/deps-installer.js +59 -18
  25. package/dist/dist.min.js +12412 -35443
  26. package/dist/es5/3d-tiles-attributes-worker.js +25 -0
  27. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  28. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +470 -0
  29. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  30. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +301 -0
  31. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  32. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +18 -0
  33. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  34. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +33 -0
  35. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  36. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +61 -0
  37. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  38. package/dist/es5/bundle.js +6 -0
  39. package/dist/es5/bundle.js.map +1 -0
  40. package/dist/es5/constants.js +9 -0
  41. package/dist/es5/constants.js.map +1 -0
  42. package/dist/es5/converter-cli.js +289 -0
  43. package/dist/es5/converter-cli.js.map +1 -0
  44. package/dist/es5/deps-installer/deps-installer.js +123 -0
  45. package/dist/es5/deps-installer/deps-installer.js.map +1 -0
  46. package/dist/es5/i3s-attributes-worker.js +25 -0
  47. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  48. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +116 -0
  49. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  50. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +90 -0
  51. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  52. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +41 -0
  53. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  54. package/dist/es5/i3s-converter/helpers/feature-attributes.js +174 -0
  55. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -0
  56. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +213 -0
  57. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  58. package/dist/es5/i3s-converter/helpers/geometry-converter.js +1173 -0
  59. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -0
  60. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +83 -0
  61. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  62. package/dist/es5/i3s-converter/helpers/node-debug.js +76 -0
  63. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -0
  64. package/dist/es5/i3s-converter/helpers/node-index-document.js +492 -0
  65. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  66. package/dist/es5/i3s-converter/helpers/node-pages.js +519 -0
  67. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -0
  68. package/dist/es5/i3s-converter/i3s-converter.js +1519 -0
  69. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -0
  70. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  71. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  72. package/dist/es5/i3s-converter/json-templates/layers.js +163 -0
  73. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -0
  74. package/dist/es5/i3s-converter/json-templates/metadata.js +31 -0
  75. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -0
  76. package/dist/es5/i3s-converter/json-templates/node.js +99 -0
  77. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -0
  78. package/dist/es5/i3s-converter/json-templates/scene-server.js +39 -0
  79. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -0
  80. package/dist/es5/i3s-converter/json-templates/shared-resources.js +173 -0
  81. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -0
  82. package/dist/es5/i3s-converter/json-templates/store.js +107 -0
  83. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -0
  84. package/dist/es5/i3s-converter/types.js +2 -0
  85. package/dist/es5/i3s-converter/types.js.map +1 -0
  86. package/dist/es5/i3s-server/app.js +18 -0
  87. package/dist/es5/i3s-server/app.js.map +1 -0
  88. package/dist/es5/i3s-server/controllers/index-controller.js +55 -0
  89. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -0
  90. package/dist/es5/i3s-server/routes/index.js +37 -0
  91. package/dist/es5/i3s-server/routes/index.js.map +1 -0
  92. package/dist/es5/index.js +21 -0
  93. package/dist/es5/index.js.map +1 -0
  94. package/dist/es5/lib/utils/compress-util.js +346 -0
  95. package/dist/es5/lib/utils/compress-util.js.map +1 -0
  96. package/dist/es5/lib/utils/file-utils.js +208 -0
  97. package/dist/es5/lib/utils/file-utils.js.map +1 -0
  98. package/dist/es5/lib/utils/lod-conversion-utils.js +44 -0
  99. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -0
  100. package/dist/es5/lib/utils/queue.js +47 -0
  101. package/dist/es5/lib/utils/queue.js.map +1 -0
  102. package/dist/es5/lib/utils/statistic-utills.d.ts +25 -0
  103. package/dist/es5/lib/utils/statistic-utills.js +147 -0
  104. package/dist/es5/lib/utils/statistic-utills.js.map +1 -0
  105. package/dist/es5/lib/utils/write-queue.js +214 -0
  106. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  107. package/dist/es5/pgm-loader.js +41 -0
  108. package/dist/es5/pgm-loader.js.map +1 -0
  109. package/dist/es5/workers/3d-tiles-attributes-worker.js +28 -0
  110. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  111. package/dist/es5/workers/i3s-attributes-worker.js +30 -0
  112. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  113. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  114. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  115. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +248 -0
  116. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  117. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +224 -0
  118. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  119. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +10 -0
  120. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  121. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +27 -0
  122. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  123. package/dist/esm/3d-tiles-converter/json-templates/tileset.js +37 -0
  124. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  125. package/dist/esm/bundle.js +4 -0
  126. package/dist/esm/bundle.js.map +1 -0
  127. package/dist/esm/constants.js +2 -0
  128. package/dist/esm/constants.js.map +1 -0
  129. package/dist/esm/converter-cli.js +232 -0
  130. package/dist/esm/converter-cli.js.map +1 -0
  131. package/dist/esm/deps-installer/deps-installer.js +44 -0
  132. package/dist/esm/deps-installer/deps-installer.js.map +1 -0
  133. package/dist/esm/i3s-attributes-worker.js +16 -0
  134. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  135. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +105 -0
  136. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  137. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +80 -0
  138. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  139. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +16 -0
  140. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  141. package/dist/esm/i3s-converter/helpers/feature-attributes.js +147 -0
  142. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -0
  143. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +190 -0
  144. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  145. package/dist/esm/i3s-converter/helpers/geometry-converter.js +887 -0
  146. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -0
  147. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +76 -0
  148. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  149. package/dist/esm/i3s-converter/helpers/node-debug.js +72 -0
  150. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -0
  151. package/dist/esm/i3s-converter/helpers/node-index-document.js +188 -0
  152. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  153. package/dist/esm/i3s-converter/helpers/node-pages.js +206 -0
  154. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -0
  155. package/dist/esm/i3s-converter/i3s-converter.js +771 -0
  156. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -0
  157. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  158. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  159. package/dist/esm/i3s-converter/json-templates/layers.js +133 -0
  160. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -0
  161. package/dist/esm/i3s-converter/json-templates/metadata.js +22 -0
  162. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -0
  163. package/dist/esm/i3s-converter/json-templates/node.js +80 -0
  164. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -0
  165. package/dist/esm/i3s-converter/json-templates/scene-server.js +28 -0
  166. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -0
  167. package/dist/esm/i3s-converter/json-templates/shared-resources.js +123 -0
  168. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -0
  169. package/dist/esm/i3s-converter/json-templates/store.js +98 -0
  170. package/dist/esm/i3s-converter/json-templates/store.js.map +1 -0
  171. package/dist/esm/i3s-converter/types.js +2 -0
  172. package/dist/esm/i3s-converter/types.js.map +1 -0
  173. package/dist/esm/i3s-server/app.js +16 -0
  174. package/dist/esm/i3s-server/app.js.map +1 -0
  175. package/dist/esm/i3s-server/bin/www +102 -0
  176. package/dist/esm/i3s-server/certs/cert.pem +19 -0
  177. package/dist/esm/i3s-server/certs/key.pem +27 -0
  178. package/dist/esm/i3s-server/controllers/index-controller.js +24 -0
  179. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -0
  180. package/dist/esm/i3s-server/routes/index.js +16 -0
  181. package/dist/esm/i3s-server/routes/index.js.map +1 -0
  182. package/dist/esm/index.js +3 -0
  183. package/dist/esm/index.js.map +1 -0
  184. package/dist/esm/lib/utils/compress-util.js +168 -0
  185. package/dist/esm/lib/utils/compress-util.js.map +1 -0
  186. package/dist/esm/lib/utils/file-utils.js +87 -0
  187. package/dist/esm/lib/utils/file-utils.js.map +1 -0
  188. package/dist/esm/lib/utils/lod-conversion-utils.js +37 -0
  189. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -0
  190. package/dist/esm/lib/utils/queue.js +15 -0
  191. package/dist/esm/lib/utils/queue.js.map +1 -0
  192. package/dist/esm/lib/utils/statistic-utills.d.ts +25 -0
  193. package/dist/esm/lib/utils/statistic-utills.js +62 -0
  194. package/dist/esm/lib/utils/statistic-utills.js.map +1 -0
  195. package/dist/esm/lib/utils/write-queue.js +85 -0
  196. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  197. package/dist/esm/pgm-loader.js +15 -0
  198. package/dist/esm/pgm-loader.js.map +1 -0
  199. package/dist/esm/workers/3d-tiles-attributes-worker.js +8 -0
  200. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  201. package/dist/esm/workers/i3s-attributes-worker.js +7 -0
  202. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  203. package/dist/i3s-attributes-worker.d.ts +37 -0
  204. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  205. package/dist/i3s-attributes-worker.js +9 -0
  206. package/dist/i3s-attributes-worker.js.map +7 -0
  207. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -0
  208. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -0
  209. package/dist/i3s-converter/helpers/batch-ids-extensions.js +141 -0
  210. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +9 -9
  211. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  212. package/dist/i3s-converter/helpers/coordinate-converter.js +118 -72
  213. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +5 -5
  214. package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -1
  215. package/dist/i3s-converter/helpers/create-scene-server-path.js +27 -15
  216. package/dist/i3s-converter/helpers/feature-attributes.d.ts +56 -0
  217. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -0
  218. package/dist/i3s-converter/helpers/feature-attributes.js +216 -0
  219. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +4 -19
  220. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  221. package/dist/i3s-converter/helpers/geometry-attributes.js +188 -185
  222. package/dist/i3s-converter/helpers/geometry-converter.d.ts +36 -39
  223. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  224. package/dist/i3s-converter/helpers/geometry-converter.js +1142 -689
  225. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  226. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  227. package/dist/i3s-converter/helpers/gltf-attributes.js +88 -0
  228. package/dist/i3s-converter/helpers/node-debug.d.ts +7 -1
  229. package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -1
  230. package/dist/i3s-converter/helpers/node-debug.js +106 -72
  231. package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
  232. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  233. package/dist/i3s-converter/helpers/node-index-document.js +250 -0
  234. package/dist/i3s-converter/helpers/node-pages.d.ts +81 -41
  235. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  236. package/dist/i3s-converter/helpers/node-pages.js +313 -144
  237. package/dist/i3s-converter/i3s-converter.d.ts +60 -113
  238. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  239. package/dist/i3s-converter/i3s-converter.js +857 -951
  240. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  241. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  242. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  243. package/dist/i3s-converter/json-templates/layers.d.ts +5 -30
  244. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  245. package/dist/i3s-converter/json-templates/layers.js +132 -194
  246. package/dist/i3s-converter/json-templates/metadata.js +24 -21
  247. package/dist/i3s-converter/json-templates/node.js +82 -77
  248. package/dist/i3s-converter/json-templates/scene-server.js +30 -27
  249. package/dist/i3s-converter/json-templates/shared-resources.js +116 -122
  250. package/dist/i3s-converter/json-templates/store.js +100 -95
  251. package/dist/i3s-converter/types.d.ts +137 -6
  252. package/dist/i3s-converter/types.d.ts.map +1 -1
  253. package/dist/i3s-converter/types.js +2 -2
  254. package/dist/i3s-server/app.js +2 -9
  255. package/dist/i3s-server/controllers/index-controller.js +16 -24
  256. package/dist/i3s-server/routes/index.js +11 -15
  257. package/dist/index.d.ts +0 -2
  258. package/dist/index.d.ts.map +1 -1
  259. package/dist/index.js +10 -5
  260. package/dist/lib/utils/compress-util.d.ts +12 -20
  261. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  262. package/dist/lib/utils/compress-util.js +238 -160
  263. package/dist/lib/utils/file-utils.d.ts +22 -14
  264. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  265. package/dist/lib/utils/file-utils.js +133 -36
  266. package/dist/lib/utils/lod-conversion-utils.d.ts +21 -12
  267. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  268. package/dist/lib/utils/lod-conversion-utils.js +72 -39
  269. package/dist/lib/utils/queue.d.ts +7 -0
  270. package/dist/lib/utils/queue.d.ts.map +1 -0
  271. package/dist/lib/utils/queue.js +18 -0
  272. package/dist/lib/utils/statistic-utills.d.ts +3 -25
  273. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  274. package/dist/lib/utils/statistic-utills.js +58 -67
  275. package/dist/lib/utils/write-queue.d.ts +39 -0
  276. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  277. package/dist/lib/utils/write-queue.js +80 -0
  278. package/dist/pgm-loader.d.ts.map +1 -1
  279. package/dist/pgm-loader.js +23 -14
  280. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  281. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  282. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  283. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  284. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  285. package/dist/workers/i3s-attributes-worker.js +5 -0
  286. package/package.json +33 -24
  287. package/src/3d-tiles-attributes-worker.ts +43 -0
  288. package/src/3d-tiles-converter/3d-tiles-converter.ts +101 -40
  289. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +38 -29
  290. package/src/constants.ts +2 -0
  291. package/src/converter-cli.ts +370 -0
  292. package/src/deps-installer/deps-installer.ts +71 -0
  293. package/src/i3s-attributes-worker.ts +50 -0
  294. package/src/i3s-converter/helpers/batch-ids-extensions.ts +206 -0
  295. package/src/i3s-converter/helpers/coordinate-converter.ts +33 -26
  296. package/src/i3s-converter/helpers/create-scene-server-path.ts +9 -5
  297. package/src/i3s-converter/helpers/feature-attributes.ts +247 -0
  298. package/src/i3s-converter/helpers/geometry-attributes.ts +98 -47
  299. package/src/i3s-converter/helpers/geometry-converter.ts +1608 -0
  300. package/src/i3s-converter/helpers/gltf-attributes.ts +103 -0
  301. package/src/i3s-converter/helpers/node-debug.ts +68 -16
  302. package/src/i3s-converter/helpers/node-index-document.ts +315 -0
  303. package/src/i3s-converter/helpers/node-pages.ts +222 -101
  304. package/src/i3s-converter/i3s-converter.ts +407 -555
  305. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  306. package/src/i3s-converter/json-templates/layers.ts +27 -91
  307. package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
  308. package/src/i3s-converter/types.ts +156 -5
  309. package/src/index.ts +0 -4
  310. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  311. package/src/lib/utils/file-utils.ts +139 -0
  312. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  313. package/src/lib/utils/queue.ts +17 -0
  314. package/src/lib/utils/write-queue.ts +110 -0
  315. package/src/pgm-loader.ts +2 -2
  316. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  317. package/src/workers/i3s-attributes-worker.ts +7 -0
  318. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  319. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  320. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  321. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  322. package/dist/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  323. package/dist/bundle.js.map +0 -1
  324. package/dist/deps-installer/deps-installer.js.map +0 -1
  325. package/dist/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  326. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  327. package/dist/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  328. package/dist/i3s-converter/helpers/geometry-converter.js.map +0 -1
  329. package/dist/i3s-converter/helpers/node-debug.js.map +0 -1
  330. package/dist/i3s-converter/helpers/node-pages.js.map +0 -1
  331. package/dist/i3s-converter/i3s-converter.js.map +0 -1
  332. package/dist/i3s-converter/json-templates/layers.js.map +0 -1
  333. package/dist/i3s-converter/json-templates/metadata.js.map +0 -1
  334. package/dist/i3s-converter/json-templates/node.js.map +0 -1
  335. package/dist/i3s-converter/json-templates/scene-server.js.map +0 -1
  336. package/dist/i3s-converter/json-templates/shared-resources.js.map +0 -1
  337. package/dist/i3s-converter/json-templates/store.js.map +0 -1
  338. package/dist/i3s-converter/types.js.map +0 -1
  339. package/dist/i3s-server/app.js.map +0 -1
  340. package/dist/i3s-server/controllers/index-controller.js.map +0 -1
  341. package/dist/i3s-server/routes/index.js.map +0 -1
  342. package/dist/index.js.map +0 -1
  343. package/dist/lib/utils/compress-util.js.map +0 -1
  344. package/dist/lib/utils/file-utils.js.map +0 -1
  345. package/dist/lib/utils/lod-conversion-utils.js.map +0 -1
  346. package/dist/lib/utils/statistic-utills.js.map +0 -1
  347. package/dist/pgm-loader.js.map +0 -1
  348. package/src/deps-installer/deps-installer.d.ts +0 -10
  349. package/src/deps-installer/deps-installer.js +0 -22
  350. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  351. package/src/i3s-converter/helpers/geometry-converter.js +0 -992
  352. package/src/lib/utils/compress-util.d.ts +0 -53
  353. package/src/lib/utils/file-utils.d.ts +0 -43
  354. package/src/lib/utils/file-utils.js +0 -38
  355. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
  356. /package/dist/{i3s-server → es5/i3s-server}/bin/www +0 -0
  357. /package/dist/{i3s-server → es5/i3s-server}/certs/cert.pem +0 -0
  358. /package/dist/{i3s-server → es5/i3s-server}/certs/key.pem +0 -0
  359. /package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
@@ -1,259 +1,282 @@
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 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]);
10
+ const scratchVector = new core_2.Vector3();
11
+ /**
12
+ * Converts content of an I3S node to *.b3dm's file content
13
+ */
14
+ class B3dmConverter {
15
+ /**
16
+ * The starter of content conversion
17
+ * @param i3sTile - Tile3D instance for I3S node
18
+ * @returns - encoded content
19
+ */
20
+ async convert(i3sAttributesData, featureAttributes = null) {
21
+ const gltf = await this.buildGltf(i3sAttributesData, featureAttributes);
22
+ const b3dm = (0, core_1.encodeSync)({
23
+ gltfEncoded: new Uint8Array(gltf),
24
+ type: 'b3dm',
25
+ featuresLength: this._getFeaturesLength(featureAttributes),
26
+ batchTable: featureAttributes
27
+ }, _3d_tiles_1.Tile3DWriter);
28
+ return b3dm;
49
29
  }
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;
30
+ /**
31
+ * Build and encode gltf
32
+ * @param i3sTile - Tile3D instance for I3S node
33
+ * @returns - encoded glb content
34
+ */
35
+ async buildGltf(i3sAttributesData, featureAttributes) {
36
+ const { tileContent, textureFormat } = i3sAttributesData;
37
+ const { material, attributes, indices: originalIndices, cartesianOrigin, cartographicOrigin, modelMatrix } = tileContent;
38
+ const gltfBuilder = new gltf_1.GLTFScenegraph();
39
+ const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
40
+ const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
41
+ const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
42
+ const positions = attributes.positions;
43
+ const positionsValue = positions.value;
44
+ if (attributes.uvRegions && attributes.texCoords) {
45
+ attributes.texCoords.value = (0, texture_atlas_1.convertTextureAtlas)(attributes.texCoords.value, attributes.uvRegions.value);
46
+ }
47
+ attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
48
+ this._createBatchIds(tileContent, featureAttributes);
49
+ if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
50
+ delete attributes.normals;
51
+ }
52
+ const indices = originalIndices || this._generateSynteticIndices(positionsValue.length / positions.size);
53
+ const meshIndex = gltfBuilder.addMesh({
54
+ attributes,
55
+ indices,
56
+ material: materialIndex,
57
+ mode: 4
58
+ });
59
+ const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
60
+ const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
61
+ const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
62
+ gltfBuilder.setDefaultScene(sceneIndex);
63
+ gltfBuilder.createBinaryChunk();
64
+ const gltfBuffer = (0, core_1.encodeSync)(gltfBuilder.gltf, gltf_1.GLTFWriter);
65
+ return gltfBuffer;
55
66
  }
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;
67
+ /**
68
+ * Update gltfBuilder with texture from I3S tile
69
+ * @param {object} i3sTile - Tile3D object
70
+ * @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
71
+ * @returns {Promise<number | null>} - GLTF texture index
72
+ */
73
+ async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
74
+ const { texture, material, attributes } = tileContent;
75
+ let textureIndex = null;
76
+ let selectedTexture = texture;
77
+ if (!texture && material) {
78
+ selectedTexture =
79
+ material.pbrMetallicRoughness &&
80
+ material.pbrMetallicRoughness.baseColorTexture &&
81
+ material.pbrMetallicRoughness.baseColorTexture.texture.source.image;
82
+ }
83
+ if (selectedTexture) {
84
+ const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
85
+ const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
86
+ textureIndex = gltfBuilder.addTexture({ imageIndex });
87
+ delete attributes.colors;
88
+ }
89
+ return textureIndex;
97
90
  }
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;
91
+ /**
92
+ * Generate a positions array which is correct for 3DTiles/GLTF format
93
+ * @param {Float64Array} positionsValue - the input geometry positions array
94
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
95
+ * @param {number[]} cartographicOrigin - the tile center in the cartographic coordinate system
96
+ * @param {number[]} modelMatrix - the model matrix of geometry
97
+ * @returns {Float32Array} - the output geometry positions array
98
+ */
99
+ _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
100
+ const newPositionsValue = new Float32Array(positionsValue.length);
101
+ for (let index = 0; index < positionsValue.length; index += 3) {
102
+ const vertex = positionsValue.subarray(index, index + 3);
103
+ const cartesianOriginVector = new core_2.Vector3(cartesianOrigin);
104
+ let vertexVector = new core_2.Vector3(Array.from(vertex))
105
+ .transform(modelMatrix)
106
+ .add(cartographicOrigin);
107
+ geospatial_1.Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector);
108
+ vertexVector = scratchVector.subtract(cartesianOriginVector);
109
+ newPositionsValue.set(vertexVector, index);
110
+ }
111
+ return newPositionsValue;
107
112
  }
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);
113
+ /**
114
+ * Generate the transformation matrix for GLTF node:
115
+ * https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-node
116
+ * 1. Create the translate transformation from cartesianOrigin (the positions array stores offsets from this cartesianOrigin)
117
+ * 2. Create the rotation transformation to rotate model from z-up coordinates (I3S specific) to y-up coordinates (GLTF specific)
118
+ * @param {number[]} cartesianOrigin - the tile center in the cartesian coordinate system
119
+ * @returns {Matrix4} - an array of 16 numbers (4x4 matrix)
120
+ */
121
+ _generateTransformMatrix(cartesianOrigin) {
122
+ const translateOriginMatrix = new core_2.Matrix4().translate(cartesianOrigin);
123
+ const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);
124
+ return result;
122
125
  }
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;
126
+ /**
127
+ * Create _BATCHID attribute
128
+ * @param {Object} i3sContent - the source object
129
+ * @returns {void}
130
+ */
131
+ _createBatchIds(i3sContent, featureAttributes) {
132
+ const { featureIds } = i3sContent;
133
+ const { OBJECTID: objectIds } = featureAttributes || {};
134
+ if (!featureIds || !objectIds) {
135
+ return;
136
+ }
137
+ for (let i = 0; i < featureIds.length; i++) {
138
+ const featureId = featureIds[i];
139
+ const batchId = objectIds.indexOf(featureId);
140
+ featureIds[i] = batchId;
141
+ }
142
+ i3sContent.attributes._BATCHID = {
143
+ size: 1,
144
+ byteOffset: 0,
145
+ value: featureIds
146
+ };
145
147
  }
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);
148
+ /**
149
+ * luma.gl can not work without indices now:
150
+ * https://github.com/visgl/luma.gl/blob/d8cad75b9f8ca3e578cf078ed9d19e619c2ddbc9/modules/experimental/src/gltf/gltf-instantiator.js#L115
151
+ * This method generates syntetic indices array: [0, 1, 2, 3, .... , vertexCount-1]
152
+ * @param {number} vertexCount - vertex count in the geometry
153
+ * @returns {Uint32Array} indices array.
154
+ */
155
+ _generateSynteticIndices(vertexCount) {
156
+ const result = new Uint32Array(vertexCount);
157
+ for (let index = 0; index < vertexCount; index++) {
158
+ result.set([index], index);
159
+ }
160
+ return result;
155
161
  }
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';
162
+ /**
163
+ * Deduce mime type by format from `textureSetDefinition.formats[0].format`
164
+ * https://github.com/Esri/i3s-spec/blob/master/docs/1.7/textureSetDefinitionFormat.cmn.md
165
+ * @param {string} format - format name
166
+ * @returns {string} mime type.
167
+ */
168
+ _deduceMimeTypeFromFormat(format) {
169
+ switch (format) {
170
+ case 'jpg':
171
+ return 'image/jpeg';
172
+ case 'png':
173
+ return 'image/png';
174
+ case 'ktx2':
175
+ return 'image/ktx2';
176
+ default:
177
+ console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
178
+ return 'image/jpeg';
179
+ }
174
180
  }
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
181
+ /**
182
+ * Convert i3s material to GLTF compatible material
183
+ * @param {object} material - i3s material definition
184
+ * @param {number | null} textureIndex - texture index in GLTF
185
+ * @returns {object} GLTF material
186
+ */
187
+ _convertI3sMaterialToGltfMaterial(material, textureIndex) {
188
+ const isTextureIndexExists = textureIndex !== null;
189
+ if (!material) {
190
+ material = {
191
+ alphaMode: 'OPAQUE',
192
+ doubleSided: false,
193
+ pbrMetallicRoughness: {
194
+ metallicFactor: 0,
195
+ roughnessFactor: 1
196
+ }
197
+ };
198
+ if (isTextureIndexExists) {
199
+ material.pbrMetallicRoughness.baseColorTexture = {
200
+ index: textureIndex,
201
+ texCoord: 0
202
+ };
203
+ }
204
+ else {
205
+ material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];
206
+ }
207
+ return material;
187
208
  }
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;
209
+ if (textureIndex !== null) {
210
+ material = this._setGltfTexture(material, textureIndex);
211
+ }
212
+ return material;
200
213
  }
201
-
202
- if (textureIndex !== null) {
203
- material = this._setGltfTexture(material, textureIndex);
214
+ /**
215
+ * Set texture properties in material with GLTF textureIndex
216
+ * @param {object} materialDefinition - i3s material definition
217
+ * @param {number} textureIndex - texture index in GLTF
218
+ * @returns {void}
219
+ */
220
+ _setGltfTexture(materialDefinition, textureIndex) {
221
+ const material = {
222
+ ...materialDefinition,
223
+ pbrMetallicRoughness: { ...materialDefinition.pbrMetallicRoughness }
224
+ };
225
+ // I3SLoader now support loading only one texture. This elseif sequence will assign this texture to one of
226
+ // properties defined in materialDefinition
227
+ if (materialDefinition.pbrMetallicRoughness &&
228
+ materialDefinition.pbrMetallicRoughness.baseColorTexture) {
229
+ material.pbrMetallicRoughness.baseColorTexture = {
230
+ index: textureIndex,
231
+ texCoord: 0
232
+ };
233
+ }
234
+ else if (materialDefinition.emissiveTexture) {
235
+ material.emissiveTexture = {
236
+ index: textureIndex,
237
+ texCoord: 0
238
+ };
239
+ }
240
+ else if (materialDefinition.pbrMetallicRoughness &&
241
+ materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture) {
242
+ material.pbrMetallicRoughness.metallicRoughnessTexture = {
243
+ index: textureIndex,
244
+ texCoord: 0
245
+ };
246
+ }
247
+ else if (materialDefinition.normalTexture) {
248
+ material.normalTexture = {
249
+ index: textureIndex,
250
+ texCoord: 0
251
+ };
252
+ }
253
+ else if (materialDefinition.occlusionTexture) {
254
+ material.occlusionTexture = {
255
+ index: textureIndex,
256
+ texCoord: 0
257
+ };
258
+ }
259
+ return material;
204
260
  }
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
- };
261
+ /*
262
+ * Returns Features length based on attribute array in attribute object.
263
+ * @param {Object} attributes
264
+ * @returns {Number} Features length .
265
+ */
266
+ _getFeaturesLength(attributes) {
267
+ if (!attributes) {
268
+ return 0;
269
+ }
270
+ const firstKey = Object.keys(attributes)[0];
271
+ return firstKey ? attributes[firstKey].length : 0;
240
272
  }
241
-
242
- return material;
243
- }
244
-
245
- _getFeaturesLength(attributes) {
246
- if (!attributes) {
247
- return 0;
273
+ /* Checks that normals buffer is correct
274
+ * @param {TypedArray} normals
275
+ * @returns {boolean} true - normals are correct; false - normals are incorrect
276
+ */
277
+ _checkNormals(normals) {
278
+ // If all normals === 0, the resulting tileset is all in black colors on Cesium
279
+ return normals.find((value) => value);
248
280
  }
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
281
  }
259
- //# sourceMappingURL=b3dm-converter.js.map
282
+ 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