@loaders.gl/tile-converter 4.0.0-beta.2 → 4.0.0-beta.3

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 (288) hide show
  1. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/3d-tiles-converter.js +31 -32
  2. package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -0
  3. package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/b3dm-converter.js +5 -6
  4. package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -0
  5. package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -0
  6. package/dist/3d-tiles-converter/helpers/load-i3s.js.map +1 -0
  7. package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
  8. package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -0
  9. package/dist/constants.js.map +1 -0
  10. package/dist/{esm/converter-cli.js → converter-cli.js} +37 -15
  11. package/dist/converter-cli.js.map +1 -0
  12. package/dist/converter.min.js +496 -328
  13. package/dist/{esm/deps-installer → deps-installer}/deps-installer.js +3 -3
  14. package/dist/deps-installer/deps-installer.js.map +1 -0
  15. package/dist/esm/i3s-server/bin/i3s-server.min.js +786 -428
  16. package/dist/{esm/i3s-converter → i3s-converter}/helpers/batch-ids-extensions.js +2 -2
  17. package/dist/i3s-converter/helpers/batch-ids-extensions.js.map +1 -0
  18. package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -0
  19. package/dist/{esm/i3s-converter → i3s-converter}/helpers/create-scene-server-path.js +2 -2
  20. package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -0
  21. package/dist/{esm/i3s-converter → i3s-converter}/helpers/feature-attributes.js +1 -1
  22. package/dist/i3s-converter/helpers/feature-attributes.js.map +1 -0
  23. package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -0
  24. package/dist/{esm/i3s-converter → i3s-converter}/helpers/geometry-converter.js +11 -11
  25. package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -0
  26. package/dist/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  27. package/dist/{esm/i3s-converter → i3s-converter}/helpers/load-3d-tiles.js +1 -1
  28. package/dist/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
  29. package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-debug.js +2 -2
  30. package/dist/i3s-converter/helpers/node-debug.js.map +1 -0
  31. package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-index-document.js +14 -15
  32. package/dist/i3s-converter/helpers/node-index-document.js.map +1 -0
  33. package/dist/{esm/i3s-converter → i3s-converter}/helpers/node-pages.js +13 -14
  34. package/dist/i3s-converter/helpers/node-pages.js.map +1 -0
  35. package/dist/{esm/i3s-converter → i3s-converter}/helpers/preprocess-3d-tiles.js +1 -1
  36. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
  37. package/dist/i3s-converter/helpers/tileset-traversal.js.map +1 -0
  38. package/dist/i3s-converter/i3s-converter.d.ts +6 -0
  39. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  40. package/dist/{esm/i3s-converter → i3s-converter}/i3s-converter.js +120 -111
  41. package/dist/i3s-converter/i3s-converter.js.map +1 -0
  42. package/dist/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  43. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/layers.js +1 -1
  44. package/dist/i3s-converter/json-templates/layers.js.map +1 -0
  45. package/dist/i3s-converter/json-templates/metadata.js.map +1 -0
  46. package/dist/i3s-converter/json-templates/node.js.map +1 -0
  47. package/dist/i3s-converter/json-templates/scene-server.js.map +1 -0
  48. package/dist/{esm/i3s-converter → i3s-converter}/json-templates/shared-resources.js +2 -2
  49. package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -0
  50. package/dist/i3s-converter/json-templates/store.js.map +1 -0
  51. package/dist/i3s-converter/types.js.map +1 -0
  52. package/dist/{esm/i3s-server → i3s-server}/app.js +1 -1
  53. package/dist/i3s-server/app.js.map +1 -0
  54. package/dist/{esm/i3s-server → i3s-server}/bin/www.js +4 -4
  55. package/dist/i3s-server/bin/www.js.map +1 -0
  56. package/dist/{esm/i3s-server → i3s-server}/controllers/index-controller.js +1 -1
  57. package/dist/i3s-server/controllers/index-controller.js.map +1 -0
  58. package/dist/i3s-server/controllers/slpk-controller.d.ts +2 -3
  59. package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -1
  60. package/dist/i3s-server/controllers/slpk-controller.js +19 -0
  61. package/dist/i3s-server/controllers/slpk-controller.js.map +1 -0
  62. package/dist/i3s-server/routes/index.js.map +1 -0
  63. package/dist/{esm/i3s-server → i3s-server}/routes/slpk-router.js +2 -2
  64. package/dist/i3s-server/routes/slpk-router.js.map +1 -0
  65. package/dist/i3s-server/utils/create-scene-server.js.map +1 -0
  66. package/dist/{esm/i3s-server → i3s-server}/utils/server-utils.js +5 -5
  67. package/dist/i3s-server/utils/server-utils.js.map +1 -0
  68. package/dist/index.cjs +5129 -0
  69. package/dist/index.js +3 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/{esm/lib → lib}/utils/cli-utils.js +2 -2
  72. package/dist/lib/utils/cli-utils.js.map +1 -0
  73. package/dist/{esm/lib → lib}/utils/compress-util.js +15 -15
  74. package/dist/lib/utils/compress-util.js.map +1 -0
  75. package/dist/{esm/lib → lib}/utils/file-utils.js +5 -5
  76. package/dist/lib/utils/file-utils.js.map +1 -0
  77. package/dist/lib/utils/geometry-utils.js.map +1 -0
  78. package/dist/lib/utils/lod-conversion-utils.js.map +1 -0
  79. package/dist/lib/utils/queue.js.map +1 -0
  80. package/dist/lib/utils/statistic-utills.d.js +2 -0
  81. package/dist/lib/utils/statistic-utills.d.js.map +1 -0
  82. package/dist/{esm/lib → lib}/utils/statistic-utills.js +6 -6
  83. package/dist/lib/utils/statistic-utills.js.map +1 -0
  84. package/dist/{esm/lib → lib}/utils/write-queue.js +6 -7
  85. package/dist/lib/utils/write-queue.js.map +1 -0
  86. package/dist/{esm/pgm-loader.js → pgm-loader.js} +1 -1
  87. package/dist/pgm-loader.js.map +1 -0
  88. package/dist/{esm/slpk-extractor → slpk-extractor}/slpk-extractor.js +4 -4
  89. package/dist/slpk-extractor/slpk-extractor.js.map +1 -0
  90. package/dist/{esm/slpk-extractor-cli.js → slpk-extractor-cli.js} +6 -6
  91. package/dist/slpk-extractor-cli.js.map +1 -0
  92. package/dist/slpk-extractor.min.js +279 -133
  93. package/package.json +29 -22
  94. package/src/converter-cli.ts +32 -14
  95. package/src/i3s-converter/i3s-converter.ts +44 -30
  96. package/src/i3s-server/controllers/slpk-controller.ts +12 -10
  97. package/src/slpk-extractor/slpk-extractor.ts +1 -1
  98. package/dist/bundle.d.ts +0 -2
  99. package/dist/bundle.d.ts.map +0 -1
  100. package/dist/dist.min.js +0 -64291
  101. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -447
  102. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  103. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +0 -295
  104. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  105. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -18
  106. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  107. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js +0 -63
  108. package/dist/es5/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  109. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -33
  110. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  111. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +0 -61
  112. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  113. package/dist/es5/bundle.js +0 -6
  114. package/dist/es5/bundle.js.map +0 -1
  115. package/dist/es5/constants.js +0 -9
  116. package/dist/es5/constants.js.map +0 -1
  117. package/dist/es5/converter-cli.js +0 -249
  118. package/dist/es5/converter-cli.js.map +0 -1
  119. package/dist/es5/deps-installer/deps-installer.js +0 -198
  120. package/dist/es5/deps-installer/deps-installer.js.map +0 -1
  121. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +0 -146
  122. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  123. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -89
  124. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  125. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +0 -41
  126. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  127. package/dist/es5/i3s-converter/helpers/feature-attributes.js +0 -164
  128. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +0 -1
  129. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +0 -253
  130. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  131. package/dist/es5/i3s-converter/helpers/geometry-converter.js +0 -1190
  132. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +0 -1
  133. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +0 -113
  134. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  135. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +0 -148
  136. package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  137. package/dist/es5/i3s-converter/helpers/node-debug.js +0 -76
  138. package/dist/es5/i3s-converter/helpers/node-debug.js.map +0 -1
  139. package/dist/es5/i3s-converter/helpers/node-index-document.js +0 -522
  140. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +0 -1
  141. package/dist/es5/i3s-converter/helpers/node-pages.js +0 -519
  142. package/dist/es5/i3s-converter/helpers/node-pages.js.map +0 -1
  143. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +0 -146
  144. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  145. package/dist/es5/i3s-converter/helpers/tileset-traversal.js +0 -82
  146. package/dist/es5/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  147. package/dist/es5/i3s-converter/i3s-converter.js +0 -1554
  148. package/dist/es5/i3s-converter/i3s-converter.js.map +0 -1
  149. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +0 -107
  150. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  151. package/dist/es5/i3s-converter/json-templates/layers.js +0 -163
  152. package/dist/es5/i3s-converter/json-templates/layers.js.map +0 -1
  153. package/dist/es5/i3s-converter/json-templates/metadata.js +0 -31
  154. package/dist/es5/i3s-converter/json-templates/metadata.js.map +0 -1
  155. package/dist/es5/i3s-converter/json-templates/node.js +0 -99
  156. package/dist/es5/i3s-converter/json-templates/node.js.map +0 -1
  157. package/dist/es5/i3s-converter/json-templates/scene-server.js +0 -39
  158. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +0 -1
  159. package/dist/es5/i3s-converter/json-templates/shared-resources.js +0 -173
  160. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +0 -1
  161. package/dist/es5/i3s-converter/json-templates/store.js +0 -107
  162. package/dist/es5/i3s-converter/json-templates/store.js.map +0 -1
  163. package/dist/es5/i3s-converter/types.js +0 -18
  164. package/dist/es5/i3s-converter/types.js.map +0 -1
  165. package/dist/es5/i3s-server/app.js +0 -35
  166. package/dist/es5/i3s-server/app.js.map +0 -1
  167. package/dist/es5/i3s-server/bin/www.js +0 -33
  168. package/dist/es5/i3s-server/bin/www.js.map +0 -1
  169. package/dist/es5/i3s-server/controllers/index-controller.js +0 -56
  170. package/dist/es5/i3s-server/controllers/index-controller.js.map +0 -1
  171. package/dist/es5/i3s-server/controllers/slpk-controller.js +0 -81
  172. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +0 -1
  173. package/dist/es5/i3s-server/routes/index.js +0 -37
  174. package/dist/es5/i3s-server/routes/index.js.map +0 -1
  175. package/dist/es5/i3s-server/routes/slpk-router.js +0 -72
  176. package/dist/es5/i3s-server/routes/slpk-router.js.map +0 -1
  177. package/dist/es5/i3s-server/utils/create-scene-server.js +0 -20
  178. package/dist/es5/i3s-server/utils/create-scene-server.js.map +0 -1
  179. package/dist/es5/i3s-server/utils/server-utils.js +0 -49
  180. package/dist/es5/i3s-server/utils/server-utils.js.map +0 -1
  181. package/dist/es5/index.js +0 -21
  182. package/dist/es5/index.js.map +0 -1
  183. package/dist/es5/lib/utils/cli-utils.js +0 -57
  184. package/dist/es5/lib/utils/cli-utils.js.map +0 -1
  185. package/dist/es5/lib/utils/compress-util.js +0 -346
  186. package/dist/es5/lib/utils/compress-util.js.map +0 -1
  187. package/dist/es5/lib/utils/file-utils.js +0 -208
  188. package/dist/es5/lib/utils/file-utils.js.map +0 -1
  189. package/dist/es5/lib/utils/geometry-utils.js +0 -15
  190. package/dist/es5/lib/utils/geometry-utils.js.map +0 -1
  191. package/dist/es5/lib/utils/lod-conversion-utils.js +0 -50
  192. package/dist/es5/lib/utils/lod-conversion-utils.js.map +0 -1
  193. package/dist/es5/lib/utils/queue.js +0 -47
  194. package/dist/es5/lib/utils/queue.js.map +0 -1
  195. package/dist/es5/lib/utils/statistic-utills.d.ts +0 -25
  196. package/dist/es5/lib/utils/statistic-utills.js +0 -147
  197. package/dist/es5/lib/utils/statistic-utills.js.map +0 -1
  198. package/dist/es5/lib/utils/write-queue.js +0 -214
  199. package/dist/es5/lib/utils/write-queue.js.map +0 -1
  200. package/dist/es5/pgm-loader.js +0 -49
  201. package/dist/es5/pgm-loader.js.map +0 -1
  202. package/dist/es5/slpk-extractor/slpk-extractor.js +0 -171
  203. package/dist/es5/slpk-extractor/slpk-extractor.js.map +0 -1
  204. package/dist/es5/slpk-extractor-cli.js +0 -117
  205. package/dist/es5/slpk-extractor-cli.js.map +0 -1
  206. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +0 -1
  207. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +0 -1
  208. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +0 -1
  209. package/dist/esm/3d-tiles-converter/helpers/load-i3s.js.map +0 -1
  210. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +0 -1
  211. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +0 -1
  212. package/dist/esm/bundle.js +0 -4
  213. package/dist/esm/bundle.js.map +0 -1
  214. package/dist/esm/constants.js.map +0 -1
  215. package/dist/esm/converter-cli.js.map +0 -1
  216. package/dist/esm/deps-installer/deps-installer.js.map +0 -1
  217. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +0 -1
  218. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +0 -1
  219. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +0 -1
  220. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +0 -1
  221. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +0 -1
  222. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +0 -1
  223. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +0 -1
  224. package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +0 -1
  225. package/dist/esm/i3s-converter/helpers/node-debug.js.map +0 -1
  226. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +0 -1
  227. package/dist/esm/i3s-converter/helpers/node-pages.js.map +0 -1
  228. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +0 -1
  229. package/dist/esm/i3s-converter/helpers/tileset-traversal.js.map +0 -1
  230. package/dist/esm/i3s-converter/i3s-converter.js.map +0 -1
  231. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +0 -1
  232. package/dist/esm/i3s-converter/json-templates/layers.js.map +0 -1
  233. package/dist/esm/i3s-converter/json-templates/metadata.js.map +0 -1
  234. package/dist/esm/i3s-converter/json-templates/node.js.map +0 -1
  235. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +0 -1
  236. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +0 -1
  237. package/dist/esm/i3s-converter/json-templates/store.js.map +0 -1
  238. package/dist/esm/i3s-converter/types.js.map +0 -1
  239. package/dist/esm/i3s-server/README.md +0 -63
  240. package/dist/esm/i3s-server/app.js.map +0 -1
  241. package/dist/esm/i3s-server/bin/www.js.map +0 -1
  242. package/dist/esm/i3s-server/certs/cert.pem +0 -19
  243. package/dist/esm/i3s-server/certs/key.pem +0 -27
  244. package/dist/esm/i3s-server/controllers/index-controller.js.map +0 -1
  245. package/dist/esm/i3s-server/controllers/slpk-controller.js +0 -19
  246. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +0 -1
  247. package/dist/esm/i3s-server/routes/index.js.map +0 -1
  248. package/dist/esm/i3s-server/routes/slpk-router.js.map +0 -1
  249. package/dist/esm/i3s-server/utils/create-scene-server.js.map +0 -1
  250. package/dist/esm/i3s-server/utils/server-utils.js.map +0 -1
  251. package/dist/esm/index.js +0 -3
  252. package/dist/esm/index.js.map +0 -1
  253. package/dist/esm/lib/utils/cli-utils.js.map +0 -1
  254. package/dist/esm/lib/utils/compress-util.js.map +0 -1
  255. package/dist/esm/lib/utils/file-utils.js.map +0 -1
  256. package/dist/esm/lib/utils/geometry-utils.js.map +0 -1
  257. package/dist/esm/lib/utils/lod-conversion-utils.js.map +0 -1
  258. package/dist/esm/lib/utils/queue.js.map +0 -1
  259. package/dist/esm/lib/utils/statistic-utills.d.ts +0 -25
  260. package/dist/esm/lib/utils/statistic-utills.js.map +0 -1
  261. package/dist/esm/lib/utils/write-queue.js.map +0 -1
  262. package/dist/esm/pgm-loader.js.map +0 -1
  263. package/dist/esm/slpk-extractor/slpk-extractor.js.map +0 -1
  264. package/dist/esm/slpk-extractor-cli.js.map +0 -1
  265. package/src/bundle.ts +0 -4
  266. /package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/i3s-obb-to-3d-tiles-obb.js +0 -0
  267. /package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/load-i3s.js +0 -0
  268. /package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/helpers/texture-atlas.js +0 -0
  269. /package/dist/{esm/3d-tiles-converter → 3d-tiles-converter}/json-templates/tileset.js +0 -0
  270. /package/dist/{esm/constants.js → constants.js} +0 -0
  271. /package/dist/{esm/i3s-converter → i3s-converter}/helpers/coordinate-converter.js +0 -0
  272. /package/dist/{esm/i3s-converter → i3s-converter}/helpers/geometry-attributes.js +0 -0
  273. /package/dist/{esm/i3s-converter → i3s-converter}/helpers/gltf-attributes.js +0 -0
  274. /package/dist/{esm/i3s-converter → i3s-converter}/helpers/tileset-traversal.js +0 -0
  275. /package/dist/{esm/i3s-converter → i3s-converter}/json-templates/geometry-definitions.js +0 -0
  276. /package/dist/{esm/i3s-converter → i3s-converter}/json-templates/metadata.js +0 -0
  277. /package/dist/{esm/i3s-converter → i3s-converter}/json-templates/node.js +0 -0
  278. /package/dist/{esm/i3s-converter → i3s-converter}/json-templates/scene-server.js +0 -0
  279. /package/dist/{esm/i3s-converter → i3s-converter}/json-templates/store.js +0 -0
  280. /package/dist/{esm/i3s-converter → i3s-converter}/types.js +0 -0
  281. /package/dist/{es5/i3s-server → i3s-server}/README.md +0 -0
  282. /package/dist/{es5/i3s-server → i3s-server}/certs/cert.pem +0 -0
  283. /package/dist/{es5/i3s-server → i3s-server}/certs/key.pem +0 -0
  284. /package/dist/{esm/i3s-server → i3s-server}/routes/index.js +0 -0
  285. /package/dist/{esm/i3s-server → i3s-server}/utils/create-scene-server.js +0 -0
  286. /package/dist/{esm/lib → lib}/utils/geometry-utils.js +0 -0
  287. /package/dist/{esm/lib → lib}/utils/lod-conversion-utils.js +0 -0
  288. /package/dist/{esm/lib → lib}/utils/queue.js +0 -0
@@ -1,1190 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.convertAttributes = convertAttributes;
9
- exports.default = convertB3dmToI3sGeometry;
10
- exports.getPropertyTable = getPropertyTable;
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
- var _core = require("@math.gl/core");
15
- var _geospatial = require("@math.gl/geospatial");
16
- var _draco = require("@loaders.gl/draco");
17
- var _core2 = require("@loaders.gl/core");
18
- var _loaderUtils = require("@loaders.gl/loader-utils");
19
- var _md = _interopRequireDefault(require("md5"));
20
- var _uuid = require("uuid");
21
- var _geometryAttributes = require("./geometry-attributes");
22
- var _coordinateConverter = require("./coordinate-converter");
23
- var _gltfAttributes = require("./gltf-attributes");
24
- var _batchIdsExtensions = require("./batch-ids-extensions");
25
- var _featureAttributes = require("./feature-attributes");
26
- var _math = require("@loaders.gl/math");
27
- var _geometryUtils = require("../../lib/utils/geometry-utils");
28
- var _gltf = require("@loaders.gl/gltf");
29
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
30
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
31
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
33
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
36
- var DEFAULT_ROUGHNESS_FACTOR = 1;
37
- var DEFAULT_METALLIC_FACTOR = 1;
38
- var VALUES_PER_VERTEX = 3;
39
- var VALUES_PER_TEX_COORD = 2;
40
- var VALUES_PER_COLOR_ELEMENT = 4;
41
- var STRING_TYPE = 'string';
42
- var SHORT_INT_TYPE = 'Int32';
43
- var DOUBLE_TYPE = 'Float64';
44
- var OBJECT_ID_TYPE = 'Oid32';
45
- var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
46
- var scratchVector = new _core.Vector3();
47
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10, _x11, _x12, _x13) {
48
- return _convertB3dmToI3sGeometry.apply(this, arguments);
49
- }
50
- function _convertB3dmToI3sGeometry() {
51
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
52
- var _tileContent$gltf4;
53
- var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, featureTexture, convertedAttributesMap, result, _iterator6, _step6, materialAndTexture, originarMaterialId, convertedAttributes, material, texture, nodeId;
54
- return _regenerator.default.wrap(function _callee$(_context) {
55
- while (1) switch (_context.prev = _context.next) {
56
- case 0:
57
- useCartesianPositions = generateBoundingVolumes;
58
- _context.next = 3;
59
- return convertMaterials((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.materials, shouldMergeMaterials);
60
- case 3:
61
- materialAndTextureList = _context.sent;
62
- dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent, tileTransform, tileBoundingVolume);
63
- featureTexture = (0, _batchIdsExtensions.getTextureByMetadataClass)(tileContent, metadataClass);
64
- _context.next = 8;
65
- return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
66
- case 8:
67
- convertedAttributesMap = _context.sent;
68
- if (generateBoundingVolumes) {
69
- _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
70
- }
71
- result = [];
72
- _iterator6 = _createForOfIteratorHelper(materialAndTextureList);
73
- _context.prev = 12;
74
- _iterator6.s();
75
- case 14:
76
- if ((_step6 = _iterator6.n()).done) {
77
- _context.next = 33;
78
- break;
79
- }
80
- materialAndTexture = _step6.value;
81
- originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
82
- if (convertedAttributesMap.has(originarMaterialId)) {
83
- _context.next = 19;
84
- break;
85
- }
86
- return _context.abrupt("continue", 31);
87
- case 19:
88
- convertedAttributes = convertedAttributesMap.get(originarMaterialId);
89
- if (convertedAttributes) {
90
- _context.next = 22;
91
- break;
92
- }
93
- return _context.abrupt("continue", 31);
94
- case 22:
95
- material = materialAndTexture.material, texture = materialAndTexture.texture;
96
- _context.next = 25;
97
- return addNodeToNodePage();
98
- case 25:
99
- nodeId = _context.sent;
100
- _context.t0 = result;
101
- _context.next = 29;
102
- return _makeNodeResources({
103
- convertedAttributes: convertedAttributes,
104
- material: material,
105
- texture: texture,
106
- tileContent: tileContent,
107
- nodeId: nodeId,
108
- featuresHashArray: featuresHashArray,
109
- propertyTable: propertyTable,
110
- attributeStorageInfo: attributeStorageInfo,
111
- draco: draco,
112
- libraries: libraries
113
- });
114
- case 29:
115
- _context.t1 = _context.sent;
116
- _context.t0.push.call(_context.t0, _context.t1);
117
- case 31:
118
- _context.next = 14;
119
- break;
120
- case 33:
121
- _context.next = 38;
122
- break;
123
- case 35:
124
- _context.prev = 35;
125
- _context.t2 = _context["catch"](12);
126
- _iterator6.e(_context.t2);
127
- case 38:
128
- _context.prev = 38;
129
- _iterator6.f();
130
- return _context.finish(38);
131
- case 41:
132
- if (result.length) {
133
- _context.next = 43;
134
- break;
135
- }
136
- return _context.abrupt("return", null);
137
- case 43:
138
- return _context.abrupt("return", result);
139
- case 44:
140
- case "end":
141
- return _context.stop();
142
- }
143
- }, _callee, null, [[12, 35, 38, 41]]);
144
- }));
145
- return _convertB3dmToI3sGeometry.apply(this, arguments);
146
- }
147
- function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
148
- var _iterator = _createForOfIteratorHelper(convertedAttributesMap.values()),
149
- _step;
150
- try {
151
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
152
- var attributes = _step.value;
153
- var boundingVolumes = (0, _coordinateConverter.createBoundingVolumesFromGeometry)(attributes.positions, geoidHeightModel);
154
- attributes.boundingVolumes = boundingVolumes;
155
- var cartographicOrigin = boundingVolumes.obb.center;
156
- for (var index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
157
- var vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
158
- _geospatial.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
159
- scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
160
- scratchVector = scratchVector.subtract(cartographicOrigin);
161
- attributes.positions.set(scratchVector, index);
162
- }
163
- }
164
- } catch (err) {
165
- _iterator.e(err);
166
- } finally {
167
- _iterator.f();
168
- }
169
- }
170
- function _makeNodeResources(_x14) {
171
- return _makeNodeResources2.apply(this, arguments);
172
- }
173
- function _makeNodeResources2() {
174
- _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
175
- var _tileContent$gltf5;
176
- var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, libraries, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount, featureIdsMap, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
177
- return _regenerator.default.wrap(function _callee2$(_context2) {
178
- while (1) switch (_context2.prev = _context2.next) {
179
- case 0:
180
- convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, propertyTable = _ref.propertyTable, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco, libraries = _ref.libraries;
181
- boundingVolumes = convertedAttributes.boundingVolumes;
182
- vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
183
- _generateAttributes = (0, _geometryAttributes.generateAttributes)(convertedAttributes), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, uvRegions = _generateAttributes.uvRegions, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
184
- featureIdsMap = {};
185
- if (propertyTable) {
186
- featureIdsMap = makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, propertyTable);
187
- }
188
- header = new Uint32Array(2);
189
- typedFeatureIds = generateBigUint64Array(featureIds);
190
- header.set([vertexCount, featureCount], 0);
191
- fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, uvRegions, typedFeatureIds.buffer, faceRange.buffer));
192
- compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
193
- positions: positions,
194
- normals: normals,
195
- texCoords: texture ? texCoords : new Float32Array(0),
196
- colors: colors,
197
- uvRegions: uvRegions,
198
- featureIds: featureIds,
199
- faceRange: faceRange
200
- }, libraries) : null;
201
- attributes = [];
202
- if (attributeStorageInfo && propertyTable) {
203
- attributes = convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo);
204
- }
205
- return _context2.abrupt("return", {
206
- nodeId: nodeId,
207
- geometry: fileBuffer,
208
- compressedGeometry: compressedGeometry,
209
- texture: texture,
210
- hasUvRegions: Boolean(uvRegions.length),
211
- sharedResources: getSharedResources(((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : _tileContent$gltf5.materials) || [], nodeId),
212
- meshMaterial: material,
213
- vertexCount: vertexCount,
214
- attributes: attributes,
215
- featureCount: featureCount,
216
- boundingVolumes: boundingVolumes
217
- });
218
- case 14:
219
- case "end":
220
- return _context2.stop();
221
- }
222
- }, _callee2);
223
- }));
224
- return _makeNodeResources2.apply(this, arguments);
225
- }
226
- function convertAttributes(_x15, _x16, _x17, _x18) {
227
- return _convertAttributes.apply(this, arguments);
228
- }
229
- function _convertAttributes() {
230
- _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
231
- var nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, materialAndTexture, attributes, _iterator9, _step9, mergedMaterial, _iterator8, _step8, attrKey, _attributes;
232
- return _regenerator.default.wrap(function _callee3$(_context3) {
233
- while (1) switch (_context3.prev = _context3.next) {
234
- case 0:
235
- nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
236
- attributesMap = new Map();
237
- _iterator7 = _createForOfIteratorHelper(materialAndTextureList);
238
- try {
239
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
240
- materialAndTexture = _step7.value;
241
- attributes = {
242
- positions: new Float32Array(0),
243
- normals: new Float32Array(0),
244
- texCoords: new Float32Array(0),
245
- colors: new Uint8Array(0),
246
- uvRegions: new Uint16Array(0),
247
- featureIndicesGroups: [],
248
- featureIndices: [],
249
- boundingVolumes: null,
250
- mergedMaterials: materialAndTexture.mergedMaterials
251
- };
252
- _iterator9 = _createForOfIteratorHelper(materialAndTexture.mergedMaterials);
253
- try {
254
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
255
- mergedMaterial = _step9.value;
256
- attributesMap.set(mergedMaterial.originalMaterialId, attributes);
257
- }
258
- } catch (err) {
259
- _iterator9.e(err);
260
- } finally {
261
- _iterator9.f();
262
- }
263
- }
264
- } catch (err) {
265
- _iterator7.e(err);
266
- } finally {
267
- _iterator7.f();
268
- }
269
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, undefined, featureTexture);
270
- _iterator8 = _createForOfIteratorHelper(attributesMap.keys());
271
- _context3.prev = 6;
272
- _iterator8.s();
273
- case 8:
274
- if ((_step8 = _iterator8.n()).done) {
275
- _context3.next = 19;
276
- break;
277
- }
278
- attrKey = _step8.value;
279
- _attributes = attributesMap.get(attrKey);
280
- if (_attributes) {
281
- _context3.next = 13;
282
- break;
283
- }
284
- return _context3.abrupt("continue", 17);
285
- case 13:
286
- if (!(_attributes.positions.length === 0)) {
287
- _context3.next = 16;
288
- break;
289
- }
290
- attributesMap.delete(attrKey);
291
- return _context3.abrupt("continue", 17);
292
- case 16:
293
- if (_attributes.featureIndicesGroups) {
294
- _attributes.featureIndices = _attributes.featureIndicesGroups.reduce(function (acc, value) {
295
- return acc.concat(value);
296
- });
297
- delete _attributes.featureIndicesGroups;
298
- }
299
- case 17:
300
- _context3.next = 8;
301
- break;
302
- case 19:
303
- _context3.next = 24;
304
- break;
305
- case 21:
306
- _context3.prev = 21;
307
- _context3.t0 = _context3["catch"](6);
308
- _iterator8.e(_context3.t0);
309
- case 24:
310
- _context3.prev = 24;
311
- _iterator8.f();
312
- return _context3.finish(24);
313
- case 27:
314
- return _context3.abrupt("return", attributesMap);
315
- case 28:
316
- case "end":
317
- return _context3.stop();
318
- }
319
- }, _callee3, null, [[6, 21, 24, 27]]);
320
- }));
321
- return _convertAttributes.apply(this, arguments);
322
- }
323
- function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
324
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
325
- var featureTexture = arguments.length > 7 ? arguments[7] : undefined;
326
- if (nodes) {
327
- var _iterator2 = _createForOfIteratorHelper(nodes),
328
- _step2;
329
- try {
330
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
331
- var node = _step2.value;
332
- convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
333
- }
334
- } catch (err) {
335
- _iterator2.e(err);
336
- } finally {
337
- _iterator2.f();
338
- }
339
- }
340
- }
341
- function getCompositeTransformationMatrix(node, matrix) {
342
- var transformationMatrix = matrix;
343
- var nodeMatrix = node.matrix,
344
- rotation = node.rotation,
345
- scale = node.scale,
346
- translation = node.translation;
347
- if (nodeMatrix) {
348
- transformationMatrix = matrix.multiplyRight(nodeMatrix);
349
- }
350
- if (translation) {
351
- transformationMatrix = transformationMatrix.translate(translation);
352
- }
353
- if (rotation) {
354
- transformationMatrix = transformationMatrix.rotateXYZ(rotation);
355
- }
356
- if (scale) {
357
- transformationMatrix = transformationMatrix.scale(scale);
358
- }
359
- return transformationMatrix;
360
- }
361
- function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
362
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
363
- var featureTexture = arguments.length > 7 ? arguments[7] : undefined;
364
- var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
365
- var mesh = node.mesh;
366
- if (mesh) {
367
- convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
368
- }
369
- convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
370
- }
371
- function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
372
- var useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
373
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
374
- var featureTexture = arguments.length > 7 ? arguments[7] : undefined;
375
- var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
376
- _step3;
377
- try {
378
- var _loop = function _loop() {
379
- var primitive = _step3.value;
380
- var outputAttributes = null;
381
- var materialUvRegion;
382
- if (primitive.material) {
383
- var _outputAttributes, _outputAttributes$mer;
384
- outputAttributes = attributesMap.get(primitive.material.id);
385
- materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(function (_ref2) {
386
- var _primitive$material;
387
- var originalMaterialId = _ref2.originalMaterialId;
388
- return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.id);
389
- })) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
390
- } else if (attributesMap.has('default')) {
391
- outputAttributes = attributesMap.get('default');
392
- }
393
- (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
394
- (0, _core2.assert)(primitive.mode === undefined || primitive.mode === _math.GL.TRIANGLES || primitive.mode === _math.GL.TRIANGLE_STRIP, "Primitive - unsupported mode ".concat(primitive.mode));
395
- var attributes = primitive.attributes;
396
- if (!outputAttributes) {
397
- return "continue";
398
- }
399
- var indices = normalizeIndices(primitive);
400
- outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
401
- vertices: attributes.POSITION.value,
402
- cartographicOrigin: cartographicOrigin,
403
- cartesianModelMatrix: cartesianModelMatrix,
404
- nodeMatrix: matrix,
405
- indices: indices,
406
- attributeSpecificTransformation: transformVertexPositions,
407
- useCartesianPositions: useCartesianPositions
408
- }));
409
- outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
410
- vertices: attributes.NORMAL && attributes.NORMAL.value,
411
- cartographicOrigin: cartographicOrigin,
412
- cartesianModelMatrix: cartesianModelMatrix,
413
- nodeMatrix: matrix,
414
- indices: indices,
415
- attributeSpecificTransformation: transformVertexNormals,
416
- useCartesianPositions: false
417
- }));
418
- outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
419
- outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
420
- if (materialUvRegion) {
421
- outputAttributes.uvRegions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
422
- }
423
- outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
424
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
425
- };
426
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
427
- var _ret = _loop();
428
- if (_ret === "continue") continue;
429
- }
430
- } catch (err) {
431
- _iterator3.e(err);
432
- } finally {
433
- _iterator3.f();
434
- }
435
- }
436
- function normalizeIndices(primitive) {
437
- var _primitive$indices;
438
- var indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
439
- if (!indices) {
440
- var positions = primitive.attributes.POSITION.value;
441
- return (0, _geometryUtils.generateSyntheticIndices)(positions.length / VALUES_PER_VERTEX);
442
- }
443
- if (indices && primitive.mode === _math.GL.TRIANGLE_STRIP) {
444
- var TypedArrayConstructor = indices.constructor;
445
- var newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
446
- var triangleIndex = 0;
447
- var currentTriangle = indices.slice(0, 3);
448
- newIndices.set(currentTriangle, 0);
449
- for (var i = 1; i + 2 < indices.length; i++) {
450
- triangleIndex += 3;
451
- currentTriangle = indices.slice(i, i + 3);
452
- if (i % 2 === 0) {
453
- newIndices.set(currentTriangle, triangleIndex);
454
- } else {
455
- newIndices.set(currentTriangle.reverse(), triangleIndex);
456
- }
457
- }
458
- indices = newIndices;
459
- }
460
- return indices;
461
- }
462
- function transformVertexArray(args) {
463
- var vertices = args.vertices,
464
- indices = args.indices,
465
- attributeSpecificTransformation = args.attributeSpecificTransformation;
466
- var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
467
- if (!vertices) {
468
- return newVertices;
469
- }
470
- for (var i = 0; i < indices.length; i++) {
471
- var coordIndex = indices[i] * VALUES_PER_VERTEX;
472
- var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
473
- var vertexVector = new _core.Vector3(Array.from(vertex));
474
- vertexVector = attributeSpecificTransformation(vertexVector, args);
475
- newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
476
- newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
477
- newVertices[i * VALUES_PER_VERTEX + 2] = vertexVector.z;
478
- }
479
- return newVertices;
480
- }
481
- function transformVertexPositions(vertexVector, calleeArgs) {
482
- var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
483
- cartographicOrigin = calleeArgs.cartographicOrigin,
484
- nodeMatrix = calleeArgs.nodeMatrix,
485
- useCartesianPositions = calleeArgs.useCartesianPositions;
486
- if (nodeMatrix) {
487
- vertexVector = vertexVector.transform(nodeMatrix);
488
- }
489
- vertexVector = vertexVector.transform(cartesianModelMatrix);
490
- if (useCartesianPositions) {
491
- return vertexVector;
492
- }
493
- _geospatial.Ellipsoid.WGS84.cartesianToCartographic([vertexVector[0], vertexVector[1], vertexVector[2]], vertexVector);
494
- vertexVector = vertexVector.subtract(cartographicOrigin);
495
- return vertexVector;
496
- }
497
- function transformVertexNormals(vertexVector, calleeArgs) {
498
- var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
499
- nodeMatrix = calleeArgs.nodeMatrix;
500
- if (nodeMatrix) {
501
- vertexVector = vertexVector.transformAsVector(nodeMatrix);
502
- }
503
- vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);
504
- return vertexVector;
505
- }
506
- function flattenTexCoords(texCoords, indices) {
507
- var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
508
- if (!texCoords) {
509
- newTexCoords.fill(1);
510
- return newTexCoords;
511
- }
512
- for (var i = 0; i < indices.length; i++) {
513
- var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
514
- var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
515
- newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
516
- newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
517
- }
518
- return newTexCoords;
519
- }
520
- function flattenColors(colorsAttribute, indices) {
521
- var components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
522
- var newColors = new Uint8Array(indices.length * components);
523
- if (!colorsAttribute) {
524
- newColors.fill(255);
525
- return newColors;
526
- }
527
- var colors = colorsAttribute.value;
528
- for (var i = 0; i < indices.length; i++) {
529
- var colorIndex = indices[i] * components;
530
- var color = colors.subarray(colorIndex, colorIndex + components);
531
- var colorUint8 = new Uint8Array(components);
532
- for (var j = 0; j < color.length; j++) {
533
- colorUint8[j] = color[j] * 255;
534
- }
535
- newColors.set(colorUint8, i * components);
536
- }
537
- return newColors;
538
- }
539
- function createUvRegion(materialUvRegion, indices) {
540
- var result = new Uint16Array(indices.length * 4);
541
- for (var i = 0; i < result.length; i += 4) {
542
- result.set(materialUvRegion, i);
543
- }
544
- return result;
545
- }
546
- function flattenBatchIds(batchedIds, indices) {
547
- if (!batchedIds.length || !indices.length) {
548
- return [];
549
- }
550
- var newBatchIds = [];
551
- for (var i = 0; i < indices.length; i++) {
552
- var coordIndex = indices[i];
553
- newBatchIds.push(batchedIds[coordIndex]);
554
- }
555
- return newBatchIds;
556
- }
557
- function getBatchIds(attributes, primitive, images, featureTexture) {
558
- var batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images, featureTexture);
559
- if (batchIds.length) {
560
- return batchIds;
561
- }
562
- for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
563
- var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
564
- if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
565
- return attributes[possibleBatchIdAttributeName].value;
566
- }
567
- }
568
- return [];
569
- }
570
- function convertMaterials() {
571
- return _convertMaterials.apply(this, arguments);
572
- }
573
- function _convertMaterials() {
574
- _convertMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4() {
575
- var sourceMaterials,
576
- shouldMergeMaterials,
577
- materials,
578
- _iterator10,
579
- _step10,
580
- sourceMaterial,
581
- _args4 = arguments;
582
- return _regenerator.default.wrap(function _callee4$(_context4) {
583
- while (1) switch (_context4.prev = _context4.next) {
584
- case 0:
585
- sourceMaterials = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
586
- shouldMergeMaterials = _args4.length > 1 ? _args4[1] : undefined;
587
- materials = [];
588
- _iterator10 = _createForOfIteratorHelper(sourceMaterials);
589
- try {
590
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
591
- sourceMaterial = _step10.value;
592
- materials.push(convertMaterial(sourceMaterial));
593
- }
594
- } catch (err) {
595
- _iterator10.e(err);
596
- } finally {
597
- _iterator10.f();
598
- }
599
- if (!shouldMergeMaterials) {
600
- _context4.next = 9;
601
- break;
602
- }
603
- _context4.next = 8;
604
- return mergeAllMaterials(materials);
605
- case 8:
606
- materials = _context4.sent;
607
- case 9:
608
- return _context4.abrupt("return", materials);
609
- case 10:
610
- case "end":
611
- return _context4.stop();
612
- }
613
- }, _callee4);
614
- }));
615
- return _convertMaterials.apply(this, arguments);
616
- }
617
- function mergeAllMaterials(_x19) {
618
- return _mergeAllMaterials.apply(this, arguments);
619
- }
620
- function _mergeAllMaterials() {
621
- _mergeAllMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(materials) {
622
- var result, newMaterial, mergedIndices, i, material, _newMaterial$mergedMa, _newMaterial$mergedMa2, newWidth, newHeight, currentX, _iterator11, _step11, aTextureMetadata, newX, _iterator12, _step12, index;
623
- return _regenerator.default.wrap(function _callee5$(_context5) {
624
- while (1) switch (_context5.prev = _context5.next) {
625
- case 0:
626
- result = [];
627
- case 1:
628
- if (!(materials.length > 0)) {
629
- _context5.next = 21;
630
- break;
631
- }
632
- newMaterial = materials.splice(0, 1)[0];
633
- mergedIndices = [];
634
- i = 0;
635
- case 5:
636
- if (!(i < materials.length)) {
637
- _context5.next = 15;
638
- break;
639
- }
640
- material = materials[i];
641
- if (!(newMaterial.texture && material.texture || !newMaterial.texture && !material.texture)) {
642
- _context5.next = 12;
643
- break;
644
- }
645
- _context5.next = 10;
646
- return mergeMaterials(newMaterial, material);
647
- case 10:
648
- newMaterial = _context5.sent;
649
- mergedIndices.push(i);
650
- case 12:
651
- i++;
652
- _context5.next = 5;
653
- break;
654
- case 15:
655
- if (newMaterial.texture && mergedIndices.length) {
656
- newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref5) {
657
- var textureSize = _ref5.textureSize;
658
- return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
659
- }, 0);
660
- newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref6) {
661
- var textureSize = _ref6.textureSize;
662
- return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
663
- }, 0);
664
- currentX = -1;
665
- _iterator11 = _createForOfIteratorHelper(newMaterial.mergedMaterials);
666
- try {
667
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
668
- aTextureMetadata = _step11.value;
669
- if (aTextureMetadata.textureSize) {
670
- newX = currentX + 1 + aTextureMetadata.textureSize.width / newWidth * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1;
671
- aTextureMetadata.uvRegion = new Uint16Array([currentX + 1, 0, newX, aTextureMetadata.textureSize.height / newHeight * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1]);
672
- currentX = newX;
673
- }
674
- }
675
- } catch (err) {
676
- _iterator11.e(err);
677
- } finally {
678
- _iterator11.f();
679
- }
680
- newMaterial.texture.image.width = newWidth;
681
- newMaterial.texture.image.height = newHeight;
682
- }
683
- _iterator12 = _createForOfIteratorHelper(mergedIndices.reverse());
684
- try {
685
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
686
- index = _step12.value;
687
- materials.splice(index, 1);
688
- }
689
- } catch (err) {
690
- _iterator12.e(err);
691
- } finally {
692
- _iterator12.f();
693
- }
694
- result.push(newMaterial);
695
- _context5.next = 1;
696
- break;
697
- case 21:
698
- if (!result.length) {
699
- result.push({
700
- material: getDefaultMaterial(),
701
- mergedMaterials: [{
702
- originalMaterialId: 'default'
703
- }]
704
- });
705
- }
706
- return _context5.abrupt("return", result);
707
- case 23:
708
- case "end":
709
- return _context5.stop();
710
- }
711
- }, _callee5);
712
- }));
713
- return _mergeAllMaterials.apply(this, arguments);
714
- }
715
- function mergeMaterials(_x20, _x21) {
716
- return _mergeMaterials.apply(this, arguments);
717
- }
718
- function _mergeMaterials() {
719
- _mergeMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(material1, material2) {
720
- var _material1$texture, _material2$texture;
721
- var buffer1, buffer2, _yield$import, joinImages, sharpData;
722
- return _regenerator.default.wrap(function _callee6$(_context6) {
723
- while (1) switch (_context6.prev = _context6.next) {
724
- case 0:
725
- if (!((_material1$texture = material1.texture) !== null && _material1$texture !== void 0 && _material1$texture.bufferView && (_material2$texture = material2.texture) !== null && _material2$texture !== void 0 && _material2$texture.bufferView && material1.mergedMaterials && material2.mergedMaterials)) {
726
- _context6.next = 21;
727
- break;
728
- }
729
- buffer1 = Buffer.from(material1.texture.bufferView.data);
730
- buffer2 = Buffer.from(material2.texture.bufferView.data);
731
- _context6.prev = 3;
732
- _context6.next = 6;
733
- return Promise.resolve().then(function () {
734
- return _interopRequireWildcard(require('join-images'));
735
- });
736
- case 6:
737
- _yield$import = _context6.sent;
738
- joinImages = _yield$import.joinImages;
739
- _context6.next = 10;
740
- return joinImages([buffer1, buffer2], {
741
- direction: 'horizontal'
742
- });
743
- case 10:
744
- sharpData = _context6.sent;
745
- _context6.next = 13;
746
- return sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
747
- case 13:
748
- material1.texture.bufferView.data = _context6.sent;
749
- _context6.next = 20;
750
- break;
751
- case 16:
752
- _context6.prev = 16;
753
- _context6.t0 = _context6["catch"](3);
754
- console.log('Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)');
755
- throw _context6.t0;
756
- case 20:
757
- material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
758
- case 21:
759
- material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
760
- return _context6.abrupt("return", material1);
761
- case 23:
762
- case "end":
763
- return _context6.stop();
764
- }
765
- }, _callee6, null, [[3, 16]]);
766
- }));
767
- return _mergeMaterials.apply(this, arguments);
768
- }
769
- function convertMaterial(sourceMaterial) {
770
- var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
771
- var material = {
772
- doubleSided: sourceMaterial.doubleSided,
773
- emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(function (c) {
774
- return Math.round(c * 255);
775
- }),
776
- alphaMode: convertAlphaMode(sourceMaterial.alphaMode),
777
- pbrMetallicRoughness: {
778
- roughnessFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe === void 0 ? void 0 : _sourceMaterial$pbrMe.roughnessFactor) || DEFAULT_ROUGHNESS_FACTOR,
779
- metallicFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe2 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe2 === void 0 ? void 0 : _sourceMaterial$pbrMe2.metallicFactor) || DEFAULT_METALLIC_FACTOR
780
- }
781
- };
782
- var texture;
783
- if (sourceMaterial !== null && sourceMaterial !== void 0 && (_sourceMaterial$pbrMe3 = sourceMaterial.pbrMetallicRoughness) !== null && _sourceMaterial$pbrMe3 !== void 0 && _sourceMaterial$pbrMe3.baseColorTexture) {
784
- texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
785
- material.pbrMetallicRoughness.baseColorTexture = {
786
- textureSetDefinitionId: 0
787
- };
788
- } else if (sourceMaterial.emissiveTexture) {
789
- texture = sourceMaterial.emissiveTexture.texture.source;
790
- material.pbrMetallicRoughness.baseColorTexture = {
791
- textureSetDefinitionId: 0
792
- };
793
- }
794
- sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, _uuid.v4)();
795
- var mergedMaterials = [{
796
- originalMaterialId: sourceMaterial.id
797
- }];
798
- if (!texture) {
799
- var _sourceMaterial$pbrMe4;
800
- var baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
801
- material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
802
- return Math.round(c * 255);
803
- }) || undefined;
804
- } else {
805
- mergedMaterials[0].textureSize = {
806
- width: texture.image.width,
807
- height: texture.image.height
808
- };
809
- }
810
- return {
811
- material: material,
812
- texture: texture,
813
- mergedMaterials: mergedMaterials
814
- };
815
- }
816
- function convertAlphaMode(gltfAlphaMode) {
817
- switch (gltfAlphaMode) {
818
- case 'OPAQUE':
819
- return 'opaque';
820
- case 'MASK':
821
- return 'mask';
822
- case 'BLEND':
823
- return 'blend';
824
- default:
825
- return 'opaque';
826
- }
827
- }
828
- function getDefaultMaterial() {
829
- return {
830
- alphaMode: 'opaque',
831
- pbrMetallicRoughness: {
832
- metallicFactor: 1,
833
- roughnessFactor: 1
834
- }
835
- };
836
- }
837
- function getSharedResources(gltfMaterials, nodeId) {
838
- var i3sResources = {};
839
- if (!gltfMaterials || !gltfMaterials.length) {
840
- return i3sResources;
841
- }
842
- i3sResources.materialDefinitionInfos = [];
843
- var _iterator4 = _createForOfIteratorHelper(gltfMaterials),
844
- _step4;
845
- try {
846
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
847
- var gltfMaterial = _step4.value;
848
- var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
849
- materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
850
- textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
851
- i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
852
- if (textureDefinitionInfo) {
853
- i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
854
- i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
855
- }
856
- }
857
- } catch (err) {
858
- _iterator4.e(err);
859
- } finally {
860
- _iterator4.f();
861
- }
862
- return i3sResources;
863
- }
864
- function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
865
- var _gltfMaterial$pbrMeta;
866
- var texture = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : (_gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness) === null || _gltfMaterial$pbrMeta === void 0 ? void 0 : _gltfMaterial$pbrMeta.baseColorTexture) || gltfMaterial.emissiveTexture;
867
- var textureDefinitionInfo = null;
868
- if (texture) {
869
- textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
870
- }
871
- var _ref3 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
872
- baseColorFactor = _ref3.baseColorFactor,
873
- metallicFactor = _ref3.metallicFactor;
874
- var colorFactor = baseColorFactor;
875
- if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
876
- colorFactor = gltfMaterial.emissiveFactor;
877
- colorFactor[3] = colorFactor[3] || 1;
878
- }
879
- return {
880
- materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
881
- textureDefinitionInfo: textureDefinitionInfo
882
- };
883
- }
884
- function extractSharedResourcesMaterialInfo(baseColorFactor) {
885
- var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
886
- var matDielectricColorComponent = 0.04 / 255;
887
- var black = new _core.Vector4(0, 0, 0, 1);
888
- var unitVector = new _core.Vector4(1, 1, 1, 1);
889
- var dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
890
- var baseColorVector = new _core.Vector4(baseColorFactor);
891
- var firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
892
- var diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
893
- dielectricSpecular[3] = 1;
894
- var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
895
- return {
896
- params: {
897
- diffuse: diffuse.toArray(),
898
- specular: specular.toArray(),
899
- renderMode: 'solid'
900
- }
901
- };
902
- }
903
- function extractSharedResourcesTextureInfo(texture, nodeId) {
904
- var _texture$source, _texture$source2, _texture$source3, _texture$source4;
905
- return {
906
- encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
907
- images: [{
908
- id: generateImageId(texture, nodeId),
909
- size: (_texture$source2 = texture.source) === null || _texture$source2 === void 0 ? void 0 : _texture$source2.image.width,
910
- length: (_texture$source3 = texture.source) !== null && _texture$source3 !== void 0 && _texture$source3.image.data.length ? [(_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image.data.length] : undefined
911
- }]
912
- };
913
- }
914
- function generateImageId(texture, nodeId) {
915
- var _texture$source5;
916
- var _ref4 = ((_texture$source5 = texture.source) === null || _texture$source5 === void 0 ? void 0 : _texture$source5.image) || {},
917
- width = _ref4.width,
918
- height = _ref4.height;
919
- if (!width || !height) {
920
- return '';
921
- }
922
- var levelCountOfTexture = 1;
923
- var indexOfLevel = 0;
924
- var indexOfTextureInStore = nodeId + 1;
925
- var zerosCount = 32 - indexOfTextureInStore.toString(2).length;
926
- var rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
927
- var shiftedLevelCountOfTexture = levelCountOfTexture << 28;
928
- var shiftedIndexOfLevel = indexOfLevel << 24;
929
- var shiftedWidth = width - 1 << 12;
930
- var shiftedHeight = height - 1 << 0;
931
- var leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
932
- var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
933
- return imageId.toString();
934
- }
935
- function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
936
- var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
937
- replaceIndicesByUnique(featureIndices, replaceMap);
938
- replaceIndicesByUnique(featureIds, replaceMap);
939
- return replaceMap;
940
- }
941
- function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
942
- var featureMap = {};
943
- for (var index = 0; index < featureIds.length; index++) {
944
- var oldFeatureId = featureIds[index];
945
- var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
946
- featureMap[oldFeatureId.toString()] = uniqueFeatureId;
947
- }
948
- return featureMap;
949
- }
950
- function generateStringFromBatchTableByIndex(batchTable, index) {
951
- var str = '';
952
- for (var _key in batchTable) {
953
- str += batchTable[_key][index];
954
- }
955
- return str;
956
- }
957
- function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
958
- var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
959
- var hash = (0, _md.default)(batchTableStr);
960
- if (featuresHashArray.includes(hash)) {
961
- return featuresHashArray.indexOf(hash);
962
- }
963
- return featuresHashArray.push(hash) - 1;
964
- }
965
- function replaceIndicesByUnique(indicesArray, featureMap) {
966
- for (var index = 0; index < indicesArray.length; index++) {
967
- indicesArray[index] = featureMap[indicesArray[index]];
968
- }
969
- }
970
- function convertPropertyTableToAttributeBuffers(featureIds, featureIdsMap, propertyTable, attributeStorageInfo) {
971
- var attributeBuffers = [];
972
- var needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
973
- var properties = needFlattenPropertyTable ? (0, _featureAttributes.flattenPropertyTableByFeatureIds)(featureIdsMap, propertyTable) : propertyTable;
974
- var propertyTableWithObjectIds = _objectSpread({
975
- OBJECTID: featureIds
976
- }, properties);
977
- for (var propertyName in propertyTableWithObjectIds) {
978
- var type = getAttributeType(propertyName, attributeStorageInfo);
979
- if (type) {
980
- var value = propertyTableWithObjectIds[propertyName];
981
- var attributeBuffer = generateAttributeBuffer(type, value);
982
- attributeBuffers.push(attributeBuffer);
983
- }
984
- }
985
- return attributeBuffers;
986
- }
987
- function generateAttributeBuffer(type, value) {
988
- var attributeBuffer;
989
- switch (type) {
990
- case OBJECT_ID_TYPE:
991
- case SHORT_INT_TYPE:
992
- attributeBuffer = generateShortIntegerAttributeBuffer(value);
993
- break;
994
- case DOUBLE_TYPE:
995
- attributeBuffer = generateDoubleAttributeBuffer(value);
996
- break;
997
- case STRING_TYPE:
998
- attributeBuffer = generateStringAttributeBuffer(value);
999
- break;
1000
- default:
1001
- attributeBuffer = generateStringAttributeBuffer(value);
1002
- }
1003
- return attributeBuffer;
1004
- }
1005
- function getAttributeType(key, attributeStorageInfo) {
1006
- var attribute = attributeStorageInfo.find(function (attr) {
1007
- return attr.name === key;
1008
- });
1009
- if (!attribute) {
1010
- console.error("attribute is null, key=".concat(key, ", attributeStorageInfo=").concat(JSON.stringify(attributeStorageInfo, null, 2)));
1011
- return '';
1012
- }
1013
- if (!attribute.attributeValues) {
1014
- console.error("attributeValues is null, attribute=".concat(attribute));
1015
- return '';
1016
- }
1017
- return attribute.attributeValues.valueType;
1018
- }
1019
- function generateShortIntegerAttributeBuffer(featureIds) {
1020
- var count = new Uint32Array([featureIds.length]);
1021
- var valuesArray = new Uint32Array(featureIds);
1022
- return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
1023
- }
1024
- function generateDoubleAttributeBuffer(featureIds) {
1025
- var count = new Uint32Array([featureIds.length]);
1026
- var padding = new Uint8Array(4);
1027
- var valuesArray = new Float64Array(featureIds);
1028
- return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
1029
- }
1030
- function generateStringAttributeBuffer(batchAttributes) {
1031
- var stringCountArray = new Uint32Array([batchAttributes.length]);
1032
- var totalNumberOfBytes = 0;
1033
- var stringSizesArray = new Uint32Array(batchAttributes.length);
1034
- var stringBufferArray = [];
1035
- for (var index = 0; index < batchAttributes.length; index++) {
1036
- var currentString = "".concat(String(batchAttributes[index]), "\0");
1037
- var currentStringBuffer = Buffer.from(currentString);
1038
- var currentStringSize = currentStringBuffer.length;
1039
- totalNumberOfBytes += currentStringSize;
1040
- stringSizesArray[index] = currentStringSize;
1041
- stringBufferArray.push(currentStringBuffer);
1042
- }
1043
- var totalBytes = new Uint32Array([totalNumberOfBytes]);
1044
- return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
1045
- }
1046
- function generateBigUint64Array(featureIds) {
1047
- var typedFeatureIds = new BigUint64Array(featureIds.length);
1048
- for (var index = 0; index < featureIds.length; index++) {
1049
- typedFeatureIds[index] = BigInt(featureIds[index]);
1050
- }
1051
- return typedFeatureIds;
1052
- }
1053
- function generateCompressedGeometry(_x22, _x23, _x24, _x25) {
1054
- return _generateCompressedGeometry.apply(this, arguments);
1055
- }
1056
- function _generateCompressedGeometry() {
1057
- _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(vertexCount, convertedAttributes, attributes, libraries) {
1058
- var positions, normals, texCoords, colors, uvRegions, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
1059
- return _regenerator.default.wrap(function _callee7$(_context7) {
1060
- while (1) switch (_context7.prev = _context7.next) {
1061
- case 0:
1062
- positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, uvRegions = attributes.uvRegions, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
1063
- indices = new Uint32Array(vertexCount);
1064
- for (index = 0; index < indices.length; index++) {
1065
- indices.set([index], index);
1066
- }
1067
- featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
1068
- featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
1069
- compressedAttributes = {
1070
- positions: positions,
1071
- normals: normals,
1072
- colors: colors,
1073
- 'feature-index': featureIndex
1074
- };
1075
- if (texCoords.length) {
1076
- compressedAttributes.texCoords = texCoords;
1077
- }
1078
- attributesMetadata = {
1079
- 'feature-index': {
1080
- 'i3s-attribute-type': 'feature-index',
1081
- 'i3s-feature-ids': new Int32Array(featureIds)
1082
- }
1083
- };
1084
- if (uvRegions.length) {
1085
- compressedAttributes['uv-region'] = uvRegions;
1086
- attributesMetadata['uv-region'] = {
1087
- 'i3s-attribute-type': 'uv-region'
1088
- };
1089
- }
1090
- return _context7.abrupt("return", (0, _core2.encode)({
1091
- attributes: compressedAttributes,
1092
- indices: indices
1093
- }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, (0, _defineProperty2.default)({
1094
- reuseWorkers: true,
1095
- _nodeWorkers: true,
1096
- modules: libraries,
1097
- useLocalLibraries: true,
1098
- draco: {
1099
- method: 'MESH_SEQUENTIAL_ENCODING',
1100
- attributesMetadata: attributesMetadata
1101
- }
1102
- }, 'draco-writer', {
1103
- workerUrl: './modules/draco/dist/draco-writer-worker-node.js'
1104
- }))));
1105
- case 10:
1106
- case "end":
1107
- return _context7.stop();
1108
- }
1109
- }, _callee7);
1110
- }));
1111
- return _generateCompressedGeometry.apply(this, arguments);
1112
- }
1113
- function generateFeatureIndexAttribute(featureIndex, faceRange) {
1114
- var orderedFeatureIndices = new Uint32Array(featureIndex.length);
1115
- var fillIndex = 0;
1116
- var startIndex = 0;
1117
- for (var index = 1; index < faceRange.length; index += 2) {
1118
- var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
1119
- orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
1120
- fillIndex++;
1121
- startIndex = endIndex + 1;
1122
- }
1123
- return orderedFeatureIndices;
1124
- }
1125
- function getPropertyTable(tileContent, metadataClass) {
1126
- if (!tileContent) {
1127
- return null;
1128
- }
1129
- var propertyTable;
1130
- var batchTableJson = tileContent.batchTableJson;
1131
- if (batchTableJson) {
1132
- return batchTableJson;
1133
- }
1134
- var _getPropertyTableExte = getPropertyTableExtension(tileContent),
1135
- extensionName = _getPropertyTableExte.extensionName,
1136
- extension = _getPropertyTableExte.extension;
1137
- switch (extensionName) {
1138
- case _gltf.EXT_STRUCTURAL_METADATA:
1139
- {
1140
- propertyTable = (0, _gltf.getPropertyTableFromExtStructuralMetadata)(extension, metadataClass);
1141
- return propertyTable;
1142
- }
1143
- case _gltf.EXT_FEATURE_METADATA:
1144
- {
1145
- propertyTable = (0, _gltf.getPropertyTableFromExtFeatureMetadata)(extension, metadataClass);
1146
- return propertyTable;
1147
- }
1148
- default:
1149
- return null;
1150
- }
1151
- }
1152
- function getPropertyTableExtension(tileContent) {
1153
- var _tileContent$gltf, _tileContent$gltf2, _tileContent$gltf2$ex, _tileContent$gltf3;
1154
- var extensionsWithPropertyTables = [_gltf.EXT_FEATURE_METADATA, _gltf.EXT_STRUCTURAL_METADATA];
1155
- var extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.extensionsUsed;
1156
- if (!extensionsUsed) {
1157
- return {
1158
- extensionName: null,
1159
- extension: null
1160
- };
1161
- }
1162
- var extensionName = '';
1163
- var _iterator5 = _createForOfIteratorHelper((tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed) || []),
1164
- _step5;
1165
- try {
1166
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1167
- var extensionItem = _step5.value;
1168
- if (extensionsWithPropertyTables.includes(extensionItem)) {
1169
- extensionName = extensionItem;
1170
- break;
1171
- }
1172
- }
1173
- } catch (err) {
1174
- _iterator5.e(err);
1175
- } finally {
1176
- _iterator5.f();
1177
- }
1178
- if (!extensionName) {
1179
- return {
1180
- extensionName: null,
1181
- extension: null
1182
- };
1183
- }
1184
- var extension = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : (_tileContent$gltf2$ex = _tileContent$gltf2.extensions) === null || _tileContent$gltf2$ex === void 0 ? void 0 : _tileContent$gltf2$ex[extensionName];
1185
- return {
1186
- extensionName: extensionName,
1187
- extension: extension
1188
- };
1189
- }
1190
- //# sourceMappingURL=geometry-converter.js.map