@loaders.gl/tile-converter 3.3.0-alpha.1 → 3.3.0-alpha.11

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