@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,15 +1,15 @@
1
- import type {BoundingVolumes, Extent, Mbs, Obb} from '@loaders.gl/i3s';
1
+ import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';
2
2
 
3
3
  import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
4
4
  import {Ellipsoid} from '@math.gl/geospatial';
5
5
  import {
6
6
  OrientedBoundingBox,
7
7
  makeOrientedBoundingBoxFromPoints,
8
- makeBoundingSphereFromPoints
8
+ makeBoundingSphereFromPoints,
9
+ BoundingSphere
9
10
  } from '@math.gl/culling';
10
- import TileHeader from '@loaders.gl/tiles/src/tileset/tile-3d';
11
+ import {Tile3D} from '@loaders.gl/tiles';
11
12
  import {Geoid} from '@math.gl/geoid';
12
- import {Tileset3D} from '@loaders.gl/tiles';
13
13
 
14
14
  /**
15
15
  * Create bounding volumes object from tile and geoid height model.
@@ -17,7 +17,7 @@ import {Tileset3D} from '@loaders.gl/tiles';
17
17
  * @param geoidHeightModel
18
18
  * @returns - Bounding volumes object
19
19
  */
20
- export function createBoundingVolumes(tile: TileHeader, geoidHeightModel: Geoid): BoundingVolumes {
20
+ export function createBoundingVolumes(tile: Tile3D, geoidHeightModel: Geoid): BoundingVolumes {
21
21
  let radius;
22
22
  let halfSize;
23
23
  let quaternion;
@@ -101,34 +101,41 @@ export function convertPositionsToVectors(positions: Float32Array): Vector3[] {
101
101
  }
102
102
 
103
103
  /**
104
- * Convert common coordinate to extent coordinate
105
- * @param tileset
106
- * @returns - Extent
107
- * @todo why lodMetricValue is radius? need to check this function
104
+ * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md
105
+ * @param
106
+ * @param boundingVolume
107
+ * @returns - fullExtent object
108
108
  */
109
- export function convertCommonToI3SExtentCoordinate(tileset: Tileset3D | null): Extent | null {
110
- const cartesianCenter = tileset?.cartesianCenter;
111
- if (!cartesianCenter) {
112
- return null;
109
+ export function convertBoundingVolumeToI3SFullExtent(
110
+ boundingVolume: OrientedBoundingBox | BoundingSphere
111
+ ): FullExtent {
112
+ let sphere: BoundingSphere;
113
+ if (boundingVolume instanceof BoundingSphere) {
114
+ sphere = boundingVolume;
115
+ } else {
116
+ sphere = boundingVolume.getBoundingSphere();
113
117
  }
114
- const radius = tileset?.lodMetricValue;
115
- const rightTop = Ellipsoid.WGS84.cartesianToCartographic(
116
- new Vector3(cartesianCenter[0] + radius, cartesianCenter[1] + radius, cartesianCenter[2]),
118
+ const center: Vector3 = sphere.center;
119
+ const radius: number = sphere.radius;
120
+ const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(
121
+ new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),
117
122
  new Vector3()
118
123
  );
119
- const leftBottom = Ellipsoid.WGS84.cartesianToCartographic(
120
- new Vector3(cartesianCenter[0] - radius, cartesianCenter[1] - radius, cartesianCenter[2]),
124
+ const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(
125
+ new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),
121
126
  new Vector3()
122
127
  );
123
- const isFirstRight = rightTop[0] < leftBottom[0];
124
- const isFirstTop = rightTop[1] < leftBottom[1];
125
128
 
126
- return [
127
- isFirstRight ? rightTop[0] : leftBottom[0],
128
- isFirstTop ? rightTop[1] : leftBottom[1],
129
- isFirstRight ? leftBottom[0] : rightTop[0],
130
- isFirstTop ? leftBottom[1] : rightTop[1]
131
- ];
129
+ // Converter sometimes returns min values that are bigger then max,
130
+ // so we should check and take bigger value from max and smaller for nim
131
+ return {
132
+ xmin: Math.min(vertexMin[0], vertexMax[0]),
133
+ xmax: Math.max(vertexMin[0], vertexMax[0]),
134
+ ymin: Math.min(vertexMin[1], vertexMax[1]),
135
+ ymax: Math.max(vertexMin[1], vertexMax[1]),
136
+ zmin: Math.min(vertexMin[2], vertexMax[2]),
137
+ zmax: Math.max(vertexMin[2], vertexMax[2])
138
+ };
132
139
  }
133
140
 
134
141
  /**
@@ -1,3 +1,4 @@
1
+ import type {SceneLayer3D} from '@loaders.gl/i3s';
1
2
  import {v4 as uuidv4} from 'uuid';
2
3
  import transform from 'json-map-transform';
3
4
  import {join} from 'path';
@@ -7,12 +8,15 @@ import {writeFile} from '../../lib/utils/file-utils';
7
8
 
8
9
  /**
9
10
  * Form and save sceneServer meta data into a file
10
- * @param {string} layerName - layer name to display
11
- * @param {object} layers0 - layer object embedded into sceneServer meta data
12
- * @param {string} rootPath - root path of new converted tileset
13
- * @return {promise}
11
+ * @param layerName - layer name to display
12
+ * @param layers0 - layer object embedded into sceneServer meta data
13
+ * @param rootPath - root path of new converted tileset
14
14
  */
15
- export async function createSceneServerPath(layerName, layers0, rootPath) {
15
+ export async function createSceneServerPath(
16
+ layerName: string,
17
+ layers0: SceneLayer3D,
18
+ rootPath: string
19
+ ): Promise<void> {
16
20
  const sceneServerData = {
17
21
  serviceItemId: uuidv4().replace(/-/gi, ''),
18
22
  layerName,
@@ -0,0 +1,247 @@
1
+ import type {FeatureTableJson} from '@loaders.gl/3d-tiles';
2
+ import {
3
+ Attribute,
4
+ AttributeStorageInfo,
5
+ ESRIField,
6
+ Field,
7
+ FieldInfo,
8
+ PopupInfo
9
+ } from '@loaders.gl/i3s';
10
+
11
+ /**
12
+ * Takes attributes from property table based on featureIds.
13
+ * If there is no property value for particular featureId (index) the property will be null.
14
+ * Example:
15
+ * Initial data:
16
+ * OBJECTID: [0, 1, 5]
17
+ * component: ['Windows', 'Frames', 'Wall', 'Roof', 'Skylight']
18
+ * Result:
19
+ * OBJECTID: [0, 1, 5]
20
+ * component: ['Windows', 'Frames', 'null']
21
+ * @param featureIds
22
+ * @param propertyTable
23
+ */
24
+ export function flattenPropertyTableByFeatureIds(
25
+ featureIds: number[],
26
+ propertyTable: FeatureTableJson
27
+ ): FeatureTableJson {
28
+ const resultPropertyTable: FeatureTableJson = {};
29
+ for (const propertyName in propertyTable) {
30
+ const properties = propertyTable[propertyName];
31
+ resultPropertyTable[propertyName] = getPropertiesByFeatureIds(properties, featureIds);
32
+ }
33
+
34
+ return resultPropertyTable;
35
+ }
36
+
37
+ /**
38
+ * Getting properties by featureId index
39
+ * @param properties
40
+ * @param featureIds
41
+ */
42
+ function getPropertiesByFeatureIds(properties: any[], featureIds: number[]): any[] {
43
+ const resultProperties: any = [];
44
+
45
+ for (const featureId of featureIds) {
46
+ const property = properties[featureId] || null;
47
+ resultProperties.push(property);
48
+ }
49
+
50
+ return resultProperties;
51
+ }
52
+
53
+ /**
54
+ * Check that all attributes in propertyTable have the same length as FeatureIds.
55
+ * If there are differencies between lengths we should flatten property table based on exiesting featureIds.
56
+ * @param featureIds
57
+ * @param propertyTable
58
+ * @returns
59
+ */
60
+ export function checkPropertiesLength(
61
+ featureIds: number[],
62
+ propertyTable: FeatureTableJson
63
+ ): boolean {
64
+ let needFlatten = false;
65
+
66
+ for (const attribute of Object.values(propertyTable)) {
67
+ if (featureIds.length !== attribute.length) {
68
+ needFlatten = true;
69
+ }
70
+ }
71
+
72
+ return needFlatten;
73
+ }
74
+
75
+ /** String data type name for feature attributes */
76
+ const STRING_TYPE = 'string';
77
+ /** Integer data type name for feature attributes */
78
+ const SHORT_INT_TYPE = 'Int32';
79
+ /** Double data type name for feature attributes */
80
+ const DOUBLE_TYPE = 'double';
81
+ /** Type of attribute that is linked with feature ids */
82
+ const OBJECT_ID_TYPE = 'OBJECTID';
83
+ /**
84
+ * Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
85
+ * @param key - attribute's key
86
+ * @param attribute - attribute's type in propertyTable
87
+ */
88
+ export function getAttributeType(key: string, attribute: string): string {
89
+ if (key === OBJECT_ID_TYPE) {
90
+ return OBJECT_ID_TYPE;
91
+ }
92
+ if (typeof attribute === STRING_TYPE) {
93
+ return STRING_TYPE;
94
+ } else if (typeof attribute === 'number') {
95
+ return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
96
+ }
97
+ return STRING_TYPE;
98
+ }
99
+
100
+ /**
101
+ * Generate storage attribute for map segmentation.
102
+ * @param attributeIndex - order index of attribute (f_0, f_1 ...).
103
+ * @param key - attribute key from propertyTable.
104
+ * @param attributeType - attribute type.
105
+ * @return Updated storageAttribute.
106
+ */
107
+ export function createdStorageAttribute(
108
+ attributeIndex: number,
109
+ key: string,
110
+ attributeType: Attribute
111
+ ): AttributeStorageInfo {
112
+ const storageAttribute = {
113
+ key: `f_${attributeIndex}`,
114
+ name: key,
115
+ ordering: ['attributeValues'],
116
+ header: [{property: 'count', valueType: 'UInt32'}],
117
+ attributeValues: {valueType: 'Int32', valuesPerElement: 1}
118
+ };
119
+
120
+ switch (attributeType) {
121
+ case OBJECT_ID_TYPE:
122
+ setupIdAttribute(storageAttribute);
123
+ break;
124
+ case STRING_TYPE:
125
+ setupStringAttribute(storageAttribute);
126
+ break;
127
+ case DOUBLE_TYPE:
128
+ setupDoubleAttribute(storageAttribute);
129
+ break;
130
+ case SHORT_INT_TYPE:
131
+ break;
132
+ default:
133
+ setupStringAttribute(storageAttribute);
134
+ }
135
+
136
+ return storageAttribute;
137
+ }
138
+
139
+ /**
140
+ * Find and return attribute type based on key form propertyTable.
141
+ * @param attributeType
142
+ */
143
+ export function getFieldAttributeType(attributeType: Attribute): ESRIField {
144
+ switch (attributeType) {
145
+ case OBJECT_ID_TYPE:
146
+ return 'esriFieldTypeOID';
147
+ case STRING_TYPE:
148
+ return 'esriFieldTypeString';
149
+ case SHORT_INT_TYPE:
150
+ return 'esriFieldTypeInteger';
151
+ case DOUBLE_TYPE:
152
+ return 'esriFieldTypeDouble';
153
+ default:
154
+ return 'esriFieldTypeString';
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Setup field attribute for map segmentation.
160
+ * @param key - attribute for map segmentation.
161
+ * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
162
+ */
163
+ export function createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {
164
+ return {
165
+ name: key,
166
+ type: fieldAttributeType,
167
+ alias: key
168
+ };
169
+ }
170
+
171
+ /**
172
+ * Generate popup info to show metadata on the map.
173
+ * @param propertyTable - table data with OBJECTID.
174
+ * @return data for correct rendering of popup.
175
+ */
176
+ export function createPopupInfo(propertyTable: FeatureTableJson): PopupInfo {
177
+ const title = '{OBJECTID}';
178
+ const mediaInfos = [];
179
+ const fieldInfos: FieldInfo[] = [];
180
+ const popupElements: {
181
+ fieldInfos: FieldInfo[];
182
+ type: string;
183
+ }[] = [];
184
+ const expressionInfos = [];
185
+
186
+ for (const key in propertyTable) {
187
+ fieldInfos.push({
188
+ fieldName: key,
189
+ visible: true,
190
+ isEditable: false,
191
+ label: key
192
+ });
193
+ }
194
+ popupElements.push({
195
+ fieldInfos,
196
+ type: 'fields'
197
+ });
198
+
199
+ return {
200
+ title,
201
+ mediaInfos,
202
+ popupElements,
203
+ fieldInfos,
204
+ expressionInfos
205
+ };
206
+ }
207
+
208
+ /**
209
+ * Setup storage attribute as string.
210
+ * @param storageAttribute - attribute for map segmentation.
211
+ */
212
+ function setupStringAttribute(storageAttribute: AttributeStorageInfo): void {
213
+ // @ts-expect-error
214
+ storageAttribute.ordering.unshift('attributeByteCounts');
215
+ storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});
216
+ storageAttribute.attributeValues = {
217
+ valueType: 'String',
218
+ encoding: 'UTF-8',
219
+ valuesPerElement: 1
220
+ };
221
+ storageAttribute.attributeByteCounts = {
222
+ valueType: 'UInt32',
223
+ valuesPerElement: 1
224
+ };
225
+ }
226
+
227
+ /**
228
+ * Setup Id attribute for map segmentation.
229
+ * @param storageAttribute - attribute for map segmentation .
230
+ */
231
+ function setupIdAttribute(storageAttribute: AttributeStorageInfo): void {
232
+ storageAttribute.attributeValues = {
233
+ valueType: 'Oid32',
234
+ valuesPerElement: 1
235
+ };
236
+ }
237
+
238
+ /**
239
+ * Setup double attribute for map segmentation.
240
+ * @param storageAttribute - attribute for map segmentation .
241
+ */
242
+ function setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {
243
+ storageAttribute.attributeValues = {
244
+ valueType: 'Float64',
245
+ valuesPerElement: 1
246
+ };
247
+ }
@@ -1,3 +1,4 @@
1
+ import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';
1
2
  import {concatenateTypedArrays} from '@loaders.gl/loader-utils';
2
3
 
3
4
  const VALUES_PER_VERTEX = 3;
@@ -5,11 +6,12 @@ const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
5
6
 
6
7
  /**
7
8
  * Generate geometry attributes with faceRange and featureCount
8
- * @param {Object} attributes
9
- * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.
9
+ * @param attributes
10
+ * @returns attirbutes with featureCount, featureIds and changed faceRange.
10
11
  */
11
- export function generateAttributes(attributes) {
12
- const {positions, normals, texCoords, colors, featureIndices, triangleCount} = attributes;
12
+ export function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {
13
+ const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;
14
+ const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
13
15
 
14
16
  if (!featureIndices.length) {
15
17
  return {
@@ -19,28 +21,34 @@ export function generateAttributes(attributes) {
19
21
  positions,
20
22
  normals,
21
23
  texCoords,
22
- colors
24
+ colors,
25
+ uvRegions
23
26
  };
24
27
  }
25
28
 
26
- const {faceRange, featureCount, featureIds} = calculateFaceRangesAndFeaturesCount(featureIndices);
27
- const attributeObjects = makeAttributeObjects({faceRange, featureIds, ...attributes});
29
+ const data = calculateFaceRangesAndFeaturesCount(featureIndices);
30
+ const attributeObjects = makeAttributeObjects({...data, ...attributes});
28
31
  const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
29
32
  const groupedAttributes = groupAttributesAndRangesByFeatureId(
30
- unifiedAttributeObjectsByFeatureIds
33
+ unifiedAttributeObjectsByFeatureIds,
34
+ data.featureCount
31
35
  );
32
- return {featureCount, ...groupedAttributes};
36
+ return groupedAttributes;
33
37
  }
34
38
 
35
39
  /**
36
40
  * Calculates face Ranges and feature count based on featureIndices.
37
- * @param {Object} featureIndices
38
- * @returns {Object} Object with featureCount, reordered attributes and changed faceRange.
41
+ * @param featureIndices
42
+ * @returns Object with featureCount, reordered attributes and changed faceRange.
39
43
  */
40
- function calculateFaceRangesAndFeaturesCount(featureIndices) {
44
+ function calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {
45
+ faceRange: Uint32Array;
46
+ featureCount: number;
47
+ featureIds: number[];
48
+ } {
41
49
  let rangeIndex = 1;
42
50
  let featureIndex = 1;
43
- let currentFeatureId = featureIndices[0];
51
+ let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));
44
52
  const faceRangeList: any[] = [];
45
53
  const featureIds: any[] = [];
46
54
  const uniqueFeatureIds = [currentFeatureId];
@@ -48,20 +56,21 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
48
56
  faceRangeList[0] = 0;
49
57
  featureIds[0] = currentFeatureId;
50
58
 
51
- for (let index = 1; index < featureIndices.length; index++) {
52
- if (currentFeatureId !== featureIndices[index]) {
59
+ for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {
60
+ const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));
61
+ if (currentFeatureId !== newFeatureId) {
53
62
  faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;
54
63
  faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;
55
- featureIds[featureIndex] = featureIndices[index];
64
+ featureIds[featureIndex] = newFeatureId;
56
65
 
57
- if (!uniqueFeatureIds.includes(featureIndices[index])) {
58
- uniqueFeatureIds.push(featureIndices[index]);
66
+ if (!uniqueFeatureIds.includes(newFeatureId)) {
67
+ uniqueFeatureIds.push(newFeatureId);
59
68
  }
60
69
 
61
70
  rangeIndex += 2;
62
71
  featureIndex += 1;
63
72
  }
64
- currentFeatureId = featureIndices[index];
73
+ currentFeatureId = newFeatureId;
65
74
  }
66
75
 
67
76
  faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;
@@ -72,29 +81,59 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
72
81
  return {faceRange, featureCount, featureIds};
73
82
  }
74
83
 
84
+ /**
85
+ * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).
86
+ * @param values
87
+ */
88
+ function getFrequentValue(values: number[]): number {
89
+ const map: {[key: number]: number} = {};
90
+
91
+ let mostFrequentValue = values[0];
92
+ let maxCount = 1;
93
+
94
+ for (const value of values) {
95
+ // Save item and it's frequency count to the map.
96
+ map[value] = (map[value] || 0) + 1;
97
+ // Find max count of frequency.
98
+ maxCount = maxCount > map[value] ? maxCount : map[value];
99
+ // Find the most frequent value.
100
+ mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;
101
+ }
102
+
103
+ return mostFrequentValue;
104
+ }
105
+
75
106
  /**
76
107
  * Generate list of attribute object grouped by feature ids.
77
- * @param {Object} attributes
78
- * @returns {Array} sorted list of attribute objects.
108
+ * @param attributes
109
+ * @returns sorted list of attribute objects.
79
110
  */
80
- function makeAttributeObjects(attributes) {
81
- const {featureIds, positions, normals, colors, texCoords, faceRange} = attributes;
82
- const groupedData: any[] = [];
111
+ function makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {
112
+ const {
113
+ featureIds,
114
+ positions,
115
+ normals,
116
+ colors,
117
+ uvRegions,
118
+ texCoords,
119
+ faceRange = new Uint32Array(0)
120
+ } = attributes;
121
+ const groupedData: GroupedByFeatureIdAttributes[] = [];
83
122
 
84
123
  let positionsList = new Float32Array(positions);
85
124
  let normalsList = new Float32Array(normals);
86
125
  let colorsList = new Uint8Array(colors);
87
126
  let texCoordsList = new Float32Array(texCoords);
88
-
89
- let faceRangeIndex = 0;
127
+ let uvRegionsList = new Uint16Array(uvRegions);
90
128
 
91
129
  for (let index = 0; index < featureIds.length; index++) {
92
- const startIndex = faceRange[index + faceRangeIndex];
93
- const endIndex = faceRange[index + faceRangeIndex + 1];
130
+ const startIndex = faceRange[index * 2];
131
+ const endIndex = faceRange[index * 2 + 1];
94
132
 
95
133
  const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
96
134
  const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
97
135
  const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
136
+ const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
98
137
  const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
99
138
 
100
139
  groupedData.push({
@@ -102,15 +141,15 @@ function makeAttributeObjects(attributes) {
102
141
  positions: positionsList.slice(0, positionsCount),
103
142
  normals: normalsList.slice(0, normalsCount),
104
143
  colors: colorsList.slice(0, colorsCount),
144
+ uvRegions: uvRegionsList.slice(0, uvRegionsCount),
105
145
  texCoords: texCoordsList.slice(0, texCoordsCount)
106
146
  });
107
147
 
108
148
  positionsList = positionsList.slice(positionsCount);
109
149
  normalsList = normalsList.slice(normalsCount);
110
150
  colorsList = colorsList.slice(colorsCount);
151
+ uvRegionsList = uvRegionsList.slice(uvRegionsCount);
111
152
  texCoordsList = texCoordsList.slice(texCoordsCount);
112
-
113
- faceRangeIndex += 1;
114
153
  }
115
154
 
116
155
  return groupedData.sort((first, second) => first.featureId - second.featureId);
@@ -118,13 +157,17 @@ function makeAttributeObjects(attributes) {
118
157
 
119
158
  /**
120
159
  * Generate sliced count for generating attribute objects depends on attribute name and range.
121
- * @param {String} attributeName
122
- * @param {Number} startIndex
123
- * @param {Number} endIndex
124
- * @returns {Number} - sliced count
160
+ * @param attributeName
161
+ * @param startIndex
162
+ * @param endIndex
163
+ * @returns sliced count
125
164
  */
126
- function getSliceAttributeCount(attributeName, startIndex, endIndex) {
127
- const colorsPerVertex = 4;
165
+ function getSliceAttributeCount(
166
+ attributeName: string,
167
+ startIndex: number,
168
+ endIndex: number
169
+ ): number {
170
+ const itemsPerVertex4 = 4;
128
171
  const texCoordsPerVertex = 2;
129
172
 
130
173
  const trianglesCount = endIndex - startIndex + 1;
@@ -135,7 +178,8 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
135
178
  case 'normals':
136
179
  return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
137
180
  case 'colors':
138
- return vertexCount * colorsPerVertex;
181
+ case 'uvRegions':
182
+ return vertexCount * itemsPerVertex4;
139
183
  case 'texCoords':
140
184
  return vertexCount * texCoordsPerVertex;
141
185
  default:
@@ -145,11 +189,13 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
145
189
 
146
190
  /**
147
191
  * Generates unique object list depends on feature ids and concantenate their attributes.
148
- * @param {Array} sortedData
149
- * @returns {Array} - unique list of objects
192
+ * @param sortedData
193
+ * @returns unique list of objects
150
194
  */
151
- function unifyObjectsByFeatureId(sortedData) {
152
- const uniqueObjects: any[] = [];
195
+ function unifyObjectsByFeatureId(
196
+ sortedData: GroupedByFeatureIdAttributes[]
197
+ ): GroupedByFeatureIdAttributes[] {
198
+ const uniqueObjects: GroupedByFeatureIdAttributes[] = [];
153
199
 
154
200
  for (let index = 0; index < sortedData.length; index++) {
155
201
  const currentObject = sortedData[index];
@@ -176,16 +222,20 @@ function unifyObjectsByFeatureId(sortedData) {
176
222
 
177
223
  /**
178
224
  * Generates attribute objects with new faceRange and reordered attributes.
179
- * @param {Array} unifiedObjects
180
- * @returns {Object} - ugenerated attributes with new faceRange.
225
+ * @param unifiedObjects
226
+ * @returns generated attributes with new faceRange.
181
227
  */
182
- function groupAttributesAndRangesByFeatureId(unifiedObjects) {
228
+ function groupAttributesAndRangesByFeatureId(
229
+ unifiedObjects: GroupedByFeatureIdAttributes[],
230
+ featureCount: number
231
+ ): GeometryAttributes {
183
232
  const firstAttributeObject = unifiedObjects[0];
184
- const featureIds = [firstAttributeObject.featureId];
233
+ const featureIds = [firstAttributeObject.featureId || 0];
185
234
 
186
235
  let positions = new Float32Array(firstAttributeObject.positions);
187
236
  let normals = new Float32Array(firstAttributeObject.normals);
188
237
  let colors = new Uint8Array(firstAttributeObject.colors);
238
+ let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
189
239
  let texCoords = new Float32Array(firstAttributeObject.texCoords);
190
240
  const range = [0];
191
241
 
@@ -194,11 +244,12 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
194
244
 
195
245
  for (let index = 1; index < unifiedObjects.length; index++) {
196
246
  const currentAttributesObject = unifiedObjects[index];
197
- featureIds.push(currentAttributesObject.featureId);
247
+ featureIds.push(currentAttributesObject.featureId || 0);
198
248
 
199
249
  positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
200
250
  normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
201
251
  colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
252
+ uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);
202
253
  texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);
203
254
 
204
255
  const groupedObject = unifiedObjects[objIndex];
@@ -212,5 +263,5 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
212
263
  range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
213
264
 
214
265
  const faceRange = new Uint32Array(range);
215
- return {faceRange, featureIds, positions, normals, colors, texCoords};
266
+ return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};
216
267
  }