@loaders.gl/tile-converter 3.4.0-alpha.1 → 3.4.0-alpha.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 (145) hide show
  1. package/dist/3d-tiles-attributes-worker.js +2 -2
  2. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  3. package/dist/converter.min.js +2956 -178
  4. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  5. package/dist/deps-installer/deps-installer.js +4 -1
  6. package/dist/dist.min.js +30025 -27482
  7. package/dist/es5/3d-tiles-attributes-worker.js +1 -2
  8. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  9. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +264 -287
  10. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  11. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +89 -113
  12. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  13. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  14. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +0 -2
  15. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  16. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  17. package/dist/es5/constants.js.map +1 -1
  18. package/dist/es5/converter-cli.js +67 -81
  19. package/dist/es5/converter-cli.js.map +1 -1
  20. package/dist/es5/deps-installer/deps-installer.js +64 -69
  21. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  22. package/dist/es5/i3s-attributes-worker.js +1 -2
  23. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  24. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +0 -8
  25. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +0 -5
  27. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +14 -16
  29. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  30. package/dist/es5/i3s-converter/helpers/feature-attributes.js +1 -11
  31. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  32. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +3 -10
  33. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  34. package/dist/es5/i3s-converter/helpers/geometry-converter.js +397 -449
  35. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  36. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +0 -2
  37. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/node-debug.js +1 -9
  39. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/node-index-document.js +293 -318
  41. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  42. package/dist/es5/i3s-converter/helpers/node-pages.js +279 -319
  43. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  44. package/dist/es5/i3s-converter/i3s-converter.js +964 -1030
  45. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  46. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
  47. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  48. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
  49. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
  50. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
  51. package/dist/es5/i3s-converter/json-templates/shared-resources.js +1 -1
  52. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  53. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
  54. package/dist/es5/i3s-server/controllers/index-controller.js +28 -30
  55. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  56. package/dist/es5/i3s-server/routes/index.js +15 -18
  57. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  58. package/dist/es5/index.js.map +1 -1
  59. package/dist/es5/lib/utils/compress-util.js +198 -218
  60. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  61. package/dist/es5/lib/utils/file-utils.js +118 -128
  62. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  63. package/dist/es5/lib/utils/lod-conversion-utils.js +0 -1
  64. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  65. package/dist/es5/lib/utils/queue.js.map +1 -1
  66. package/dist/es5/lib/utils/statistic-utills.js +81 -85
  67. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  68. package/dist/es5/lib/utils/write-queue.js +84 -92
  69. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  70. package/dist/es5/pgm-loader.js +7 -10
  71. package/dist/es5/pgm-loader.js.map +1 -1
  72. package/dist/es5/workers/3d-tiles-attributes-worker.js +7 -9
  73. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
  74. package/dist/es5/workers/i3s-attributes-worker.js +10 -12
  75. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  76. package/dist/esm/3d-tiles-attributes-worker.js +1 -3
  77. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  78. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +1 -15
  79. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  80. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +0 -12
  81. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  82. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -1
  83. package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  84. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +0 -3
  85. package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  86. package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  87. package/dist/esm/bundle.js +0 -1
  88. package/dist/esm/bundle.js.map +1 -1
  89. package/dist/esm/converter-cli.js +0 -11
  90. package/dist/esm/converter-cli.js.map +1 -1
  91. package/dist/esm/deps-installer/deps-installer.js +2 -5
  92. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  93. package/dist/esm/i3s-attributes-worker.js +1 -3
  94. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  95. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +0 -8
  96. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  97. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +0 -5
  98. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  99. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +0 -1
  100. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  101. package/dist/esm/i3s-converter/helpers/feature-attributes.js +0 -11
  102. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  103. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +0 -7
  104. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  105. package/dist/esm/i3s-converter/helpers/geometry-converter.js +0 -48
  106. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  107. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +0 -3
  108. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  109. package/dist/esm/i3s-converter/helpers/node-debug.js +1 -9
  110. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
  111. package/dist/esm/i3s-converter/helpers/node-index-document.js +0 -14
  112. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
  113. package/dist/esm/i3s-converter/helpers/node-pages.js +0 -18
  114. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  115. package/dist/esm/i3s-converter/i3s-converter.js +4 -42
  116. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  117. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
  118. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  119. package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
  120. package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
  121. package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
  122. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  123. package/dist/esm/i3s-server/controllers/index-controller.js +0 -2
  124. package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
  125. package/dist/esm/i3s-server/routes/index.js +0 -1
  126. package/dist/esm/i3s-server/routes/index.js.map +1 -1
  127. package/dist/esm/lib/utils/compress-util.js +1 -17
  128. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  129. package/dist/esm/lib/utils/file-utils.js +0 -7
  130. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  131. package/dist/esm/lib/utils/lod-conversion-utils.js +0 -2
  132. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  133. package/dist/esm/lib/utils/queue.js.map +1 -1
  134. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  135. package/dist/esm/lib/utils/write-queue.js +0 -2
  136. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  137. package/dist/esm/pgm-loader.js +1 -3
  138. package/dist/esm/pgm-loader.js.map +1 -1
  139. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -1
  140. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
  141. package/dist/i3s-attributes-worker.js +2 -2
  142. package/dist/i3s-attributes-worker.js.map +3 -3
  143. package/dist/i3s-converter/helpers/node-pages.js +1 -1
  144. package/package.json +21 -20
  145. package/src/deps-installer/deps-installer.ts +4 -1
@@ -29,7 +29,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
29
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; }
30
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; } } }; }
31
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); }
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; }
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; }
33
33
  var DEFAULT_ROUGHNESS_FACTOR = 1;
34
34
  var DEFAULT_METALLIC_FACTOR = 1;
35
35
  var VALUES_PER_VERTEX = 3;
@@ -43,7 +43,6 @@ var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BA
43
43
  var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
44
44
  var EXT_MESH_FEATURES = 'EXT_mesh_features';
45
45
  var scratchVector = new _core.Vector3();
46
-
47
46
  function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10) {
48
47
  return _convertB3dmToI3sGeometry.apply(this, arguments);
49
48
  }
@@ -52,95 +51,92 @@ function _convertB3dmToI3sGeometry() {
52
51
  var _tileContent$gltf4;
53
52
  var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _iterator6, _step6, materialAndTexture, originarMaterialId, convertedAttributes, material, texture, nodeId;
54
53
  return _regenerator.default.wrap(function _callee$(_context) {
55
- while (1) {
56
- switch (_context.prev = _context.next) {
57
- case 0:
58
- useCartesianPositions = generateBoundingVolumes;
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;
63
- dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
64
- _context.next = 7;
65
- return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
66
- case 7:
67
- convertedAttributesMap = _context.sent;
68
-
69
- if (generateBoundingVolumes) {
70
- _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
71
- }
72
- result = [];
73
- _iterator6 = _createForOfIteratorHelper(materialAndTextureList);
74
- _context.prev = 11;
75
- _iterator6.s();
76
- case 13:
77
- if ((_step6 = _iterator6.n()).done) {
78
- _context.next = 32;
79
- break;
80
- }
81
- materialAndTexture = _step6.value;
82
- originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
83
- if (convertedAttributesMap.has(originarMaterialId)) {
84
- _context.next = 18;
85
- break;
86
- }
87
- return _context.abrupt("continue", 30);
88
- case 18:
89
- convertedAttributes = convertedAttributesMap.get(originarMaterialId);
90
- if (convertedAttributes) {
91
- _context.next = 21;
92
- break;
93
- }
94
- return _context.abrupt("continue", 30);
95
- case 21:
96
- material = materialAndTexture.material, texture = materialAndTexture.texture;
97
- _context.next = 24;
98
- return addNodeToNodePage();
99
- case 24:
100
- nodeId = _context.sent;
101
- _context.t0 = result;
102
- _context.next = 28;
103
- return _makeNodeResources({
104
- convertedAttributes: convertedAttributes,
105
- material: material,
106
- texture: texture,
107
- tileContent: tileContent,
108
- nodeId: nodeId,
109
- featuresHashArray: featuresHashArray,
110
- propertyTable: propertyTable,
111
- attributeStorageInfo: attributeStorageInfo,
112
- draco: draco,
113
- workerSource: workerSource
114
- });
115
- case 28:
116
- _context.t1 = _context.sent;
117
- _context.t0.push.call(_context.t0, _context.t1);
118
- case 30:
119
- _context.next = 13;
54
+ while (1) switch (_context.prev = _context.next) {
55
+ case 0:
56
+ useCartesianPositions = generateBoundingVolumes;
57
+ _context.next = 3;
58
+ return convertMaterials((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.materials, shouldMergeMaterials);
59
+ case 3:
60
+ materialAndTextureList = _context.sent;
61
+ dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
62
+ _context.next = 7;
63
+ return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
64
+ case 7:
65
+ convertedAttributesMap = _context.sent;
66
+ if (generateBoundingVolumes) {
67
+ _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
68
+ }
69
+ result = [];
70
+ _iterator6 = _createForOfIteratorHelper(materialAndTextureList);
71
+ _context.prev = 11;
72
+ _iterator6.s();
73
+ case 13:
74
+ if ((_step6 = _iterator6.n()).done) {
75
+ _context.next = 32;
120
76
  break;
121
- case 32:
122
- _context.next = 37;
77
+ }
78
+ materialAndTexture = _step6.value;
79
+ originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
80
+ if (convertedAttributesMap.has(originarMaterialId)) {
81
+ _context.next = 18;
123
82
  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:
133
- if (result.length) {
134
- _context.next = 42;
135
- break;
136
- }
137
- return _context.abrupt("return", null);
138
- case 42:
139
- return _context.abrupt("return", result);
140
- case 43:
141
- case "end":
142
- return _context.stop();
143
- }
83
+ }
84
+ return _context.abrupt("continue", 30);
85
+ case 18:
86
+ convertedAttributes = convertedAttributesMap.get(originarMaterialId);
87
+ if (convertedAttributes) {
88
+ _context.next = 21;
89
+ break;
90
+ }
91
+ return _context.abrupt("continue", 30);
92
+ case 21:
93
+ material = materialAndTexture.material, texture = materialAndTexture.texture;
94
+ _context.next = 24;
95
+ return addNodeToNodePage();
96
+ case 24:
97
+ nodeId = _context.sent;
98
+ _context.t0 = result;
99
+ _context.next = 28;
100
+ return _makeNodeResources({
101
+ convertedAttributes: convertedAttributes,
102
+ material: material,
103
+ texture: texture,
104
+ tileContent: tileContent,
105
+ nodeId: nodeId,
106
+ featuresHashArray: featuresHashArray,
107
+ propertyTable: propertyTable,
108
+ attributeStorageInfo: attributeStorageInfo,
109
+ draco: draco,
110
+ workerSource: workerSource
111
+ });
112
+ case 28:
113
+ _context.t1 = _context.sent;
114
+ _context.t0.push.call(_context.t0, _context.t1);
115
+ case 30:
116
+ _context.next = 13;
117
+ break;
118
+ case 32:
119
+ _context.next = 37;
120
+ break;
121
+ case 34:
122
+ _context.prev = 34;
123
+ _context.t2 = _context["catch"](11);
124
+ _iterator6.e(_context.t2);
125
+ case 37:
126
+ _context.prev = 37;
127
+ _iterator6.f();
128
+ return _context.finish(37);
129
+ case 40:
130
+ if (result.length) {
131
+ _context.next = 42;
132
+ break;
133
+ }
134
+ return _context.abrupt("return", null);
135
+ case 42:
136
+ return _context.abrupt("return", result);
137
+ case 43:
138
+ case "end":
139
+ return _context.stop();
144
140
  }
145
141
  }, _callee, null, [[11, 34, 37, 40]]);
146
142
  }));
@@ -169,7 +165,6 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
169
165
  _iterator.f();
170
166
  }
171
167
  }
172
-
173
168
  function _makeNodeResources(_x11) {
174
169
  return _makeNodeResources2.apply(this, arguments);
175
170
  }
@@ -178,50 +173,48 @@ function _makeNodeResources2() {
178
173
  var _tileContent$gltf5;
179
174
  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;
180
175
  return _regenerator.default.wrap(function _callee2$(_context2) {
181
- while (1) {
182
- switch (_context2.prev = _context2.next) {
183
- case 0:
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;
185
- boundingVolumes = convertedAttributes.boundingVolumes;
186
- vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
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;
188
- if (tileContent.batchTableJson) {
189
- makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
190
- }
191
- header = new Uint32Array(2);
192
- typedFeatureIds = generateBigUint64Array(featureIds);
193
- header.set([vertexCount, featureCount], 0);
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));
195
- compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
196
- positions: positions,
197
- normals: normals,
198
- texCoords: texture ? texCoords : new Float32Array(0),
199
- colors: colors,
200
- uvRegions: uvRegions,
201
- featureIds: featureIds,
202
- faceRange: faceRange
203
- }, workerSource.draco) : null;
204
- attributes = [];
205
- if (attributeStorageInfo && propertyTable) {
206
- attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
207
- }
208
- return _context2.abrupt("return", {
209
- nodeId: nodeId,
210
- geometry: fileBuffer,
211
- compressedGeometry: compressedGeometry,
212
- texture: texture,
213
- hasUvRegions: Boolean(uvRegions.length),
214
- sharedResources: getSharedResources(((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : _tileContent$gltf5.materials) || [], nodeId),
215
- meshMaterial: material,
216
- vertexCount: vertexCount,
217
- attributes: attributes,
218
- featureCount: featureCount,
219
- boundingVolumes: boundingVolumes
220
- });
221
- case 13:
222
- case "end":
223
- return _context2.stop();
224
- }
176
+ while (1) switch (_context2.prev = _context2.next) {
177
+ case 0:
178
+ 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;
179
+ boundingVolumes = convertedAttributes.boundingVolumes;
180
+ vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
181
+ _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;
182
+ if (tileContent.batchTableJson) {
183
+ makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
184
+ }
185
+ header = new Uint32Array(2);
186
+ typedFeatureIds = generateBigUint64Array(featureIds);
187
+ header.set([vertexCount, featureCount], 0);
188
+ 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));
189
+ compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
190
+ positions: positions,
191
+ normals: normals,
192
+ texCoords: texture ? texCoords : new Float32Array(0),
193
+ colors: colors,
194
+ uvRegions: uvRegions,
195
+ featureIds: featureIds,
196
+ faceRange: faceRange
197
+ }, workerSource.draco) : null;
198
+ attributes = [];
199
+ if (attributeStorageInfo && propertyTable) {
200
+ attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
201
+ }
202
+ return _context2.abrupt("return", {
203
+ nodeId: nodeId,
204
+ geometry: fileBuffer,
205
+ compressedGeometry: compressedGeometry,
206
+ texture: texture,
207
+ hasUvRegions: Boolean(uvRegions.length),
208
+ sharedResources: getSharedResources(((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : _tileContent$gltf5.materials) || [], nodeId),
209
+ meshMaterial: material,
210
+ vertexCount: vertexCount,
211
+ attributes: attributes,
212
+ featureCount: featureCount,
213
+ boundingVolumes: boundingVolumes
214
+ });
215
+ case 13:
216
+ case "end":
217
+ return _context2.stop();
225
218
  }
226
219
  }, _callee2);
227
220
  }));
@@ -234,93 +227,91 @@ function _convertAttributes() {
234
227
  _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, materialAndTextureList, useCartesianPositions) {
235
228
  var nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, materialAndTexture, attributes, _iterator9, _step9, mergedMaterial, _iterator8, _step8, attrKey, _attributes;
236
229
  return _regenerator.default.wrap(function _callee3$(_context3) {
237
- while (1) {
238
- switch (_context3.prev = _context3.next) {
239
- case 0:
240
- nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
241
- attributesMap = new Map();
242
- _iterator7 = _createForOfIteratorHelper(materialAndTextureList);
243
- try {
244
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
245
- materialAndTexture = _step7.value;
246
- attributes = {
247
- positions: new Float32Array(0),
248
- normals: new Float32Array(0),
249
- texCoords: new Float32Array(0),
250
- colors: new Uint8Array(0),
251
- uvRegions: new Uint16Array(0),
252
- featureIndicesGroups: [],
253
- featureIndices: [],
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();
230
+ while (1) switch (_context3.prev = _context3.next) {
231
+ case 0:
232
+ nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
233
+ attributesMap = new Map();
234
+ _iterator7 = _createForOfIteratorHelper(materialAndTextureList);
235
+ try {
236
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
237
+ materialAndTexture = _step7.value;
238
+ attributes = {
239
+ positions: new Float32Array(0),
240
+ normals: new Float32Array(0),
241
+ texCoords: new Float32Array(0),
242
+ colors: new Uint8Array(0),
243
+ uvRegions: new Uint16Array(0),
244
+ featureIndicesGroups: [],
245
+ featureIndices: [],
246
+ boundingVolumes: null,
247
+ mergedMaterials: materialAndTexture.mergedMaterials
248
+ };
249
+ _iterator9 = _createForOfIteratorHelper(materialAndTexture.mergedMaterials);
250
+ try {
251
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
252
+ mergedMaterial = _step9.value;
253
+ attributesMap.set(mergedMaterial.originalMaterialId, attributes);
267
254
  }
255
+ } catch (err) {
256
+ _iterator9.e(err);
257
+ } finally {
258
+ _iterator9.f();
268
259
  }
269
- } catch (err) {
270
- _iterator7.e(err);
271
- } finally {
272
- _iterator7.f();
273
- }
274
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
275
- _iterator8 = _createForOfIteratorHelper(attributesMap.keys());
276
- _context3.prev = 6;
277
- _iterator8.s();
278
- case 8:
279
- if ((_step8 = _iterator8.n()).done) {
280
- _context3.next = 19;
281
- break;
282
- }
283
- attrKey = _step8.value;
284
- _attributes = attributesMap.get(attrKey);
285
- if (_attributes) {
286
- _context3.next = 13;
287
- break;
288
260
  }
289
- return _context3.abrupt("continue", 17);
290
- case 13:
291
- if (!(_attributes.positions.length === 0)) {
292
- _context3.next = 16;
293
- break;
294
- }
295
- attributesMap.delete(attrKey);
296
- return _context3.abrupt("continue", 17);
297
- case 16:
298
- if (_attributes.featureIndicesGroups) {
299
- _attributes.featureIndices = _attributes.featureIndicesGroups.reduce(function (acc, value) {
300
- return acc.concat(value);
301
- });
302
- delete _attributes.featureIndicesGroups;
303
- }
304
- case 17:
305
- _context3.next = 8;
261
+ } catch (err) {
262
+ _iterator7.e(err);
263
+ } finally {
264
+ _iterator7.f();
265
+ }
266
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
267
+ _iterator8 = _createForOfIteratorHelper(attributesMap.keys());
268
+ _context3.prev = 6;
269
+ _iterator8.s();
270
+ case 8:
271
+ if ((_step8 = _iterator8.n()).done) {
272
+ _context3.next = 19;
273
+ break;
274
+ }
275
+ attrKey = _step8.value;
276
+ _attributes = attributesMap.get(attrKey);
277
+ if (_attributes) {
278
+ _context3.next = 13;
306
279
  break;
307
- case 19:
308
- _context3.next = 24;
280
+ }
281
+ return _context3.abrupt("continue", 17);
282
+ case 13:
283
+ if (!(_attributes.positions.length === 0)) {
284
+ _context3.next = 16;
309
285
  break;
310
- case 21:
311
- _context3.prev = 21;
312
- _context3.t0 = _context3["catch"](6);
313
- _iterator8.e(_context3.t0);
314
- case 24:
315
- _context3.prev = 24;
316
- _iterator8.f();
317
- return _context3.finish(24);
318
- case 27:
319
- return _context3.abrupt("return", attributesMap);
320
- case 28:
321
- case "end":
322
- return _context3.stop();
323
- }
286
+ }
287
+ attributesMap.delete(attrKey);
288
+ return _context3.abrupt("continue", 17);
289
+ case 16:
290
+ if (_attributes.featureIndicesGroups) {
291
+ _attributes.featureIndices = _attributes.featureIndicesGroups.reduce(function (acc, value) {
292
+ return acc.concat(value);
293
+ });
294
+ delete _attributes.featureIndicesGroups;
295
+ }
296
+ case 17:
297
+ _context3.next = 8;
298
+ break;
299
+ case 19:
300
+ _context3.next = 24;
301
+ break;
302
+ case 21:
303
+ _context3.prev = 21;
304
+ _context3.t0 = _context3["catch"](6);
305
+ _iterator8.e(_context3.t0);
306
+ case 24:
307
+ _context3.prev = 24;
308
+ _iterator8.f();
309
+ return _context3.finish(24);
310
+ case 27:
311
+ return _context3.abrupt("return", attributesMap);
312
+ case 28:
313
+ case "end":
314
+ return _context3.stop();
324
315
  }
325
316
  }, _callee3, null, [[6, 21, 24, 27]]);
326
317
  }));
@@ -343,7 +334,6 @@ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, a
343
334
  }
344
335
  }
345
336
  }
346
-
347
337
  function getCompositeTransformationMatrix(node, matrix) {
348
338
  var transformationMatrix = matrix;
349
339
  var nodeMatrix = node.matrix,
@@ -364,7 +354,6 @@ function getCompositeTransformationMatrix(node, matrix) {
364
354
  }
365
355
  return transformationMatrix;
366
356
  }
367
-
368
357
  function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
369
358
  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]);
370
359
  var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
@@ -374,7 +363,6 @@ function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, att
374
363
  }
375
364
  convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
376
365
  }
377
-
378
366
  function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
379
367
  var useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
380
368
  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]);
@@ -385,7 +373,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
385
373
  var _primitive$indices, _primitive$indices2, _primitive$indices3, _primitive$indices4, _primitive$indices6;
386
374
  var primitive = _step3.value;
387
375
  var outputAttributes = null;
388
- var materialUvRegion = void 0;
376
+ var materialUvRegion;
389
377
  if (primitive.material) {
390
378
  var _outputAttributes, _outputAttributes$mer;
391
379
  outputAttributes = attributesMap.get(primitive.material.uniqueId);
@@ -439,7 +427,6 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
439
427
  _iterator3.f();
440
428
  }
441
429
  }
442
-
443
430
  function transformVertexArray(args) {
444
431
  var vertices = args.vertices,
445
432
  indices = args.indices,
@@ -459,7 +446,6 @@ function transformVertexArray(args) {
459
446
  }
460
447
  return newVertices;
461
448
  }
462
-
463
449
  function transformVertexPositions(vertexVector, calleeArgs) {
464
450
  var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
465
451
  cartographicOrigin = calleeArgs.cartographicOrigin,
@@ -476,7 +462,6 @@ function transformVertexPositions(vertexVector, calleeArgs) {
476
462
  vertexVector = vertexVector.subtract(cartographicOrigin);
477
463
  return vertexVector;
478
464
  }
479
-
480
465
  function transformVertexNormals(vertexVector, calleeArgs) {
481
466
  var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
482
467
  nodeMatrix = calleeArgs.nodeMatrix;
@@ -486,7 +471,6 @@ function transformVertexNormals(vertexVector, calleeArgs) {
486
471
  vertexVector = vertexVector.transformAsVector(cartesianModelMatrix);
487
472
  return vertexVector;
488
473
  }
489
-
490
474
  function flattenTexCoords(texCoords, indices) {
491
475
  var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
492
476
  if (!texCoords) {
@@ -501,7 +485,6 @@ function flattenTexCoords(texCoords, indices) {
501
485
  }
502
486
  return newTexCoords;
503
487
  }
504
-
505
488
  function flattenColors(colorsAttribute, indices) {
506
489
  var components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
507
490
  var newColors = new Uint8Array(indices.length * components);
@@ -521,7 +504,6 @@ function flattenColors(colorsAttribute, indices) {
521
504
  }
522
505
  return newColors;
523
506
  }
524
-
525
507
  function createUvRegion(materialUvRegion, indices) {
526
508
  var result = new Uint16Array(indices.length * 4);
527
509
  for (var i = 0; i < result.length; i += 4) {
@@ -529,7 +511,6 @@ function createUvRegion(materialUvRegion, indices) {
529
511
  }
530
512
  return result;
531
513
  }
532
-
533
514
  function flattenBatchIds(batchedIds, indices) {
534
515
  if (!batchedIds.length || !indices.length) {
535
516
  return [];
@@ -541,7 +522,6 @@ function flattenBatchIds(batchedIds, indices) {
541
522
  }
542
523
  return newBatchIds;
543
524
  }
544
-
545
525
  function getBatchIds(attributes, primitive, images) {
546
526
  var batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images);
547
527
  if (batchIds.length) {
@@ -555,7 +535,6 @@ function getBatchIds(attributes, primitive, images) {
555
535
  }
556
536
  return [];
557
537
  }
558
-
559
538
  function convertMaterials() {
560
539
  return _convertMaterials.apply(this, arguments);
561
540
  }
@@ -569,37 +548,35 @@ function _convertMaterials() {
569
548
  sourceMaterial,
570
549
  _args4 = arguments;
571
550
  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();
551
+ while (1) switch (_context4.prev = _context4.next) {
552
+ case 0:
553
+ sourceMaterials = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
554
+ shouldMergeMaterials = _args4.length > 1 ? _args4[1] : undefined;
555
+ materials = [];
556
+ _iterator10 = _createForOfIteratorHelper(sourceMaterials);
557
+ try {
558
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
559
+ sourceMaterial = _step10.value;
560
+ materials.push(convertMaterial(sourceMaterial));
588
561
  }
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
- }
562
+ } catch (err) {
563
+ _iterator10.e(err);
564
+ } finally {
565
+ _iterator10.f();
566
+ }
567
+ if (!shouldMergeMaterials) {
568
+ _context4.next = 9;
569
+ break;
570
+ }
571
+ _context4.next = 8;
572
+ return mergeAllMaterials(materials);
573
+ case 8:
574
+ materials = _context4.sent;
575
+ case 9:
576
+ return _context4.abrupt("return", materials);
577
+ case 10:
578
+ case "end":
579
+ return _context4.stop();
603
580
  }
604
581
  }, _callee4);
605
582
  }));
@@ -612,94 +589,92 @@ function _mergeAllMaterials() {
612
589
  _mergeAllMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(materials) {
613
590
  var result, newMaterial, mergedIndices, i, material, _newMaterial$mergedMa, _newMaterial$mergedMa2, newWidth, newHeight, currentX, _iterator11, _step11, aTextureMetadata, newX, _iterator12, _step12, index;
614
591
  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;
592
+ while (1) switch (_context5.prev = _context5.next) {
593
+ case 0:
594
+ result = [];
595
+ case 1:
596
+ if (!(materials.length > 0)) {
597
+ _context5.next = 21;
645
598
  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());
599
+ }
600
+ newMaterial = materials.splice(0, 1)[0];
601
+ mergedIndices = [];
602
+ i = 0;
603
+ case 5:
604
+ if (!(i < materials.length)) {
605
+ _context5.next = 15;
606
+ break;
607
+ }
608
+ material = materials[i];
609
+ if (!(newMaterial.texture && material.texture || !newMaterial.texture && !material.texture)) {
610
+ _context5.next = 12;
611
+ break;
612
+ }
613
+ _context5.next = 10;
614
+ return mergeMaterials(newMaterial, material);
615
+ case 10:
616
+ newMaterial = _context5.sent;
617
+ mergedIndices.push(i);
618
+ case 12:
619
+ i++;
620
+ _context5.next = 5;
621
+ break;
622
+ case 15:
623
+ if (newMaterial.texture && mergedIndices.length) {
624
+ newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref4) {
625
+ var textureSize = _ref4.textureSize;
626
+ return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
627
+ }, 0);
628
+ newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref5) {
629
+ var textureSize = _ref5.textureSize;
630
+ return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
631
+ }, 0);
632
+ currentX = -1;
633
+ _iterator11 = _createForOfIteratorHelper(newMaterial.mergedMaterials);
676
634
  try {
677
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
678
- index = _step12.value;
679
- materials.splice(index, 1);
635
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
636
+ aTextureMetadata = _step11.value;
637
+ if (aTextureMetadata.textureSize) {
638
+ newX = currentX + 1 + aTextureMetadata.textureSize.width / newWidth * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1;
639
+ aTextureMetadata.uvRegion = new Uint16Array([currentX + 1, 0, newX, aTextureMetadata.textureSize.height / newHeight * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1]);
640
+ currentX = newX;
641
+ }
680
642
  }
681
643
  } catch (err) {
682
- _iterator12.e(err);
644
+ _iterator11.e(err);
683
645
  } finally {
684
- _iterator12.f();
646
+ _iterator11.f();
685
647
  }
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
- });
648
+ newMaterial.texture.image.width = newWidth;
649
+ newMaterial.texture.image.height = newHeight;
650
+ }
651
+ _iterator12 = _createForOfIteratorHelper(mergedIndices.reverse());
652
+ try {
653
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
654
+ index = _step12.value;
655
+ materials.splice(index, 1);
697
656
  }
698
- return _context5.abrupt("return", result);
699
- case 23:
700
- case "end":
701
- return _context5.stop();
702
- }
657
+ } catch (err) {
658
+ _iterator12.e(err);
659
+ } finally {
660
+ _iterator12.f();
661
+ }
662
+ result.push(newMaterial);
663
+ _context5.next = 1;
664
+ break;
665
+ case 21:
666
+ if (!result.length) {
667
+ result.push({
668
+ material: getDefaultMaterial(),
669
+ mergedMaterials: [{
670
+ originalMaterialId: 'default'
671
+ }]
672
+ });
673
+ }
674
+ return _context5.abrupt("return", result);
675
+ case 23:
676
+ case "end":
677
+ return _context5.stop();
703
678
  }
704
679
  }, _callee5);
705
680
  }));
@@ -713,49 +688,47 @@ function _mergeMaterials() {
713
688
  var _material1$texture, _material2$texture;
714
689
  var buffer1, buffer2, _yield$import, joinImages, sharpData;
715
690
  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 = 21;
721
- break;
722
- }
723
- buffer1 = Buffer.from(material1.texture.bufferView.data);
724
- buffer2 = Buffer.from(material2.texture.bufferView.data);
725
- _context6.prev = 3;
726
- _context6.next = 6;
727
- return Promise.resolve().then(function () {
728
- return _interopRequireWildcard(require('join-images'));
729
- });
730
- case 6:
731
- _yield$import = _context6.sent;
732
- joinImages = _yield$import.joinImages;
733
- _context6.next = 10;
734
- return joinImages([buffer1, buffer2], {
735
- direction: 'horizontal'
736
- });
737
- case 10:
738
- sharpData = _context6.sent;
739
- _context6.next = 13;
740
- return sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
741
- case 13:
742
- material1.texture.bufferView.data = _context6.sent;
743
- _context6.next = 20;
691
+ while (1) switch (_context6.prev = _context6.next) {
692
+ case 0:
693
+ 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)) {
694
+ _context6.next = 21;
744
695
  break;
745
- case 16:
746
- _context6.prev = 16;
747
- _context6.t0 = _context6["catch"](3);
748
- 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)');
749
- throw _context6.t0;
750
- case 20:
751
- material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
752
- case 21:
753
- material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
754
- return _context6.abrupt("return", material1);
755
- case 23:
756
- case "end":
757
- return _context6.stop();
758
- }
696
+ }
697
+ buffer1 = Buffer.from(material1.texture.bufferView.data);
698
+ buffer2 = Buffer.from(material2.texture.bufferView.data);
699
+ _context6.prev = 3;
700
+ _context6.next = 6;
701
+ return Promise.resolve().then(function () {
702
+ return _interopRequireWildcard(require('join-images'));
703
+ });
704
+ case 6:
705
+ _yield$import = _context6.sent;
706
+ joinImages = _yield$import.joinImages;
707
+ _context6.next = 10;
708
+ return joinImages([buffer1, buffer2], {
709
+ direction: 'horizontal'
710
+ });
711
+ case 10:
712
+ sharpData = _context6.sent;
713
+ _context6.next = 13;
714
+ return sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
715
+ case 13:
716
+ material1.texture.bufferView.data = _context6.sent;
717
+ _context6.next = 20;
718
+ break;
719
+ case 16:
720
+ _context6.prev = 16;
721
+ _context6.t0 = _context6["catch"](3);
722
+ 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)');
723
+ throw _context6.t0;
724
+ case 20:
725
+ material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
726
+ case 21:
727
+ material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
728
+ return _context6.abrupt("return", material1);
729
+ case 23:
730
+ case "end":
731
+ return _context6.stop();
759
732
  }
760
733
  }, _callee6, null, [[3, 16]]);
761
734
  }));
@@ -809,7 +782,6 @@ function convertMaterial(sourceMaterial) {
809
782
  mergedMaterials: mergedMaterials
810
783
  };
811
784
  }
812
-
813
785
  function convertAlphaMode(gltfAlphaMode) {
814
786
  switch (gltfAlphaMode) {
815
787
  case 'OPAQUE':
@@ -822,7 +794,6 @@ function convertAlphaMode(gltfAlphaMode) {
822
794
  return 'opaque';
823
795
  }
824
796
  }
825
-
826
797
  function getDefaultMaterial() {
827
798
  return {
828
799
  alphaMode: 'opaque',
@@ -832,7 +803,6 @@ function getDefaultMaterial() {
832
803
  }
833
804
  };
834
805
  }
835
-
836
806
  function getSharedResources(gltfMaterials, nodeId) {
837
807
  var i3sResources = {};
838
808
  if (!gltfMaterials || !gltfMaterials.length) {
@@ -860,7 +830,6 @@ function getSharedResources(gltfMaterials, nodeId) {
860
830
  }
861
831
  return i3sResources;
862
832
  }
863
-
864
833
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
865
834
  var _gltfMaterial$pbrMeta;
866
835
  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;
@@ -881,7 +850,6 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
881
850
  textureDefinitionInfo: textureDefinitionInfo
882
851
  };
883
852
  }
884
-
885
853
  function extractSharedResourcesMaterialInfo(baseColorFactor) {
886
854
  var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
887
855
  var matDielectricColorComponent = 0.04 / 255;
@@ -901,7 +869,6 @@ function extractSharedResourcesMaterialInfo(baseColorFactor) {
901
869
  }
902
870
  };
903
871
  }
904
-
905
872
  function extractSharedResourcesTextureInfo(texture, nodeId) {
906
873
  var _texture$source, _texture$source2, _texture$source3;
907
874
  return {
@@ -913,7 +880,6 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
913
880
  }]
914
881
  };
915
882
  }
916
-
917
883
  function generateImageId(texture, nodeId) {
918
884
  var _texture$source4;
919
885
  var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
@@ -932,13 +898,11 @@ function generateImageId(texture, nodeId) {
932
898
  var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
933
899
  return imageId.toString();
934
900
  }
935
-
936
901
  function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
937
902
  var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
938
903
  replaceIndicesByUnique(featureIndices, replaceMap);
939
904
  replaceIndicesByUnique(featureIds, replaceMap);
940
905
  }
941
-
942
906
  function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
943
907
  var featureMap = {};
944
908
  for (var index = 0; index < featureIds.length; index++) {
@@ -948,7 +912,6 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
948
912
  }
949
913
  return featureMap;
950
914
  }
951
-
952
915
  function generateStringFromBatchTableByIndex(batchTable, index) {
953
916
  var str = '';
954
917
  for (var _key in batchTable) {
@@ -956,7 +919,6 @@ function generateStringFromBatchTableByIndex(batchTable, index) {
956
919
  }
957
920
  return str;
958
921
  }
959
-
960
922
  function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
961
923
  var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
962
924
  var hash = (0, _md.default)(batchTableStr);
@@ -965,13 +927,11 @@ function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
965
927
  }
966
928
  return featuresHashArray.push(hash) - 1;
967
929
  }
968
-
969
930
  function replaceIndicesByUnique(indicesArray, featureMap) {
970
931
  for (var index = 0; index < indicesArray.length; index++) {
971
932
  indicesArray[index] = featureMap[indicesArray[index]];
972
933
  }
973
934
  }
974
-
975
935
  function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
976
936
  var attributeBuffers = [];
977
937
  var needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
@@ -987,7 +947,6 @@ function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attri
987
947
  }
988
948
  return attributeBuffers;
989
949
  }
990
-
991
950
  function generateAttributeBuffer(type, value) {
992
951
  var attributeBuffer;
993
952
  switch (type) {
@@ -1006,27 +965,23 @@ function generateAttributeBuffer(type, value) {
1006
965
  }
1007
966
  return attributeBuffer;
1008
967
  }
1009
-
1010
968
  function getAttributeType(key, attributeStorageInfo) {
1011
969
  var attribute = attributeStorageInfo.find(function (attr) {
1012
970
  return attr.name === key;
1013
971
  });
1014
972
  return attribute.attributeValues.valueType;
1015
973
  }
1016
-
1017
974
  function generateShortIntegerAttributeBuffer(featureIds) {
1018
975
  var count = new Uint32Array([featureIds.length]);
1019
976
  var valuesArray = new Uint32Array(featureIds);
1020
977
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
1021
978
  }
1022
-
1023
979
  function generateDoubleAttributeBuffer(featureIds) {
1024
980
  var count = new Uint32Array([featureIds.length]);
1025
981
  var padding = new Uint8Array(4);
1026
982
  var valuesArray = new Float64Array(featureIds);
1027
983
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
1028
984
  }
1029
-
1030
985
  function generateStringAttributeBuffer(batchAttributes) {
1031
986
  var stringCountArray = new Uint32Array([batchAttributes.length]);
1032
987
  var totalNumberOfBytes = 0;
@@ -1043,7 +998,6 @@ function generateStringAttributeBuffer(batchAttributes) {
1043
998
  var totalBytes = new Uint32Array([totalNumberOfBytes]);
1044
999
  return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
1045
1000
  }
1046
-
1047
1001
  function generateBigUint64Array(featureIds) {
1048
1002
  var typedFeatureIds = new BigUint64Array(featureIds.length);
1049
1003
  for (var index = 0; index < featureIds.length; index++) {
@@ -1051,7 +1005,6 @@ function generateBigUint64Array(featureIds) {
1051
1005
  }
1052
1006
  return typedFeatureIds;
1053
1007
  }
1054
-
1055
1008
  function generateCompressedGeometry(_x18, _x19, _x20, _x21) {
1056
1009
  return _generateCompressedGeometry.apply(this, arguments);
1057
1010
  }
@@ -1059,53 +1012,51 @@ function _generateCompressedGeometry() {
1059
1012
  _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
1060
1013
  var positions, normals, texCoords, colors, uvRegions, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
1061
1014
  return _regenerator.default.wrap(function _callee7$(_context7) {
1062
- while (1) {
1063
- switch (_context7.prev = _context7.next) {
1064
- case 0:
1065
- positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, uvRegions = attributes.uvRegions, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
1066
- indices = new Uint32Array(vertexCount);
1067
- for (index = 0; index < indices.length; index++) {
1068
- indices.set([index], index);
1015
+ while (1) switch (_context7.prev = _context7.next) {
1016
+ case 0:
1017
+ positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, uvRegions = attributes.uvRegions, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
1018
+ indices = new Uint32Array(vertexCount);
1019
+ for (index = 0; index < indices.length; index++) {
1020
+ indices.set([index], index);
1021
+ }
1022
+ featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
1023
+ featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
1024
+ compressedAttributes = {
1025
+ positions: positions,
1026
+ normals: normals,
1027
+ colors: colors,
1028
+ 'feature-index': featureIndex
1029
+ };
1030
+ if (texCoords.length) {
1031
+ compressedAttributes.texCoords = texCoords;
1032
+ }
1033
+ attributesMetadata = {
1034
+ 'feature-index': {
1035
+ 'i3s-attribute-type': 'feature-index',
1036
+ 'i3s-feature-ids': new Int32Array(featureIds)
1069
1037
  }
1070
- featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
1071
- featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
1072
- compressedAttributes = {
1073
- positions: positions,
1074
- normals: normals,
1075
- colors: colors,
1076
- 'feature-index': featureIndex
1038
+ };
1039
+ if (uvRegions.length) {
1040
+ compressedAttributes['uv-region'] = uvRegions;
1041
+ attributesMetadata['uv-region'] = {
1042
+ 'i3s-attribute-type': 'uv-region'
1077
1043
  };
1078
- if (texCoords.length) {
1079
- compressedAttributes.texCoords = texCoords;
1044
+ }
1045
+ return _context7.abrupt("return", (0, _core2.encode)({
1046
+ attributes: compressedAttributes,
1047
+ indices: indices
1048
+ }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, {
1049
+ source: dracoWorkerSoure,
1050
+ reuseWorkers: true,
1051
+ _nodeWorkers: true,
1052
+ draco: {
1053
+ method: 'MESH_SEQUENTIAL_ENCODING',
1054
+ attributesMetadata: attributesMetadata
1080
1055
  }
1081
- attributesMetadata = {
1082
- 'feature-index': {
1083
- 'i3s-attribute-type': 'feature-index',
1084
- 'i3s-feature-ids': new Int32Array(featureIds)
1085
- }
1086
- };
1087
- if (uvRegions.length) {
1088
- compressedAttributes['uv-region'] = uvRegions;
1089
- attributesMetadata['uv-region'] = {
1090
- 'i3s-attribute-type': 'uv-region'
1091
- };
1092
- }
1093
- return _context7.abrupt("return", (0, _core2.encode)({
1094
- attributes: compressedAttributes,
1095
- indices: indices
1096
- }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, {
1097
- source: dracoWorkerSoure,
1098
- reuseWorkers: true,
1099
- _nodeWorkers: true,
1100
- draco: {
1101
- method: 'MESH_SEQUENTIAL_ENCODING',
1102
- attributesMetadata: attributesMetadata
1103
- }
1104
- })));
1105
- case 10:
1106
- case "end":
1107
- return _context7.stop();
1108
- }
1056
+ })));
1057
+ case 10:
1058
+ case "end":
1059
+ return _context7.stop();
1109
1060
  }
1110
1061
  }, _callee7);
1111
1062
  }));
@@ -1123,7 +1074,6 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1123
1074
  }
1124
1075
  return orderedFeatureIndices;
1125
1076
  }
1126
-
1127
1077
  function getPropertyTable(tileContent) {
1128
1078
  var batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
1129
1079
  if (batchTableJson) {
@@ -1146,7 +1096,6 @@ function getPropertyTable(tileContent) {
1146
1096
  return null;
1147
1097
  }
1148
1098
  }
1149
-
1150
1099
  function getPropertyTableExtension(tileContent) {
1151
1100
  var _tileContent$gltf, _tileContent$gltf2, _tileContent$gltf2$ex, _tileContent$gltf3;
1152
1101
  var extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
@@ -1179,7 +1128,6 @@ function getPropertyTableExtension(tileContent) {
1179
1128
  extension: extension
1180
1129
  };
1181
1130
  }
1182
-
1183
1131
  function getPropertyTableFromExtFeatureMetadata(extension) {
1184
1132
  if (extension !== null && extension !== void 0 && extension.featureTextures) {
1185
1133
  console.warn('The I3S converter does not yet support the EXT_feature_metadata feature textures');