@loaders.gl/tile-converter 3.3.0-alpha.8 → 3.3.1

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 (132) 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-cli.js +14 -2
  4. package/dist/converter.min.js +22 -22
  5. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  6. package/dist/deps-installer/deps-installer.js +8 -0
  7. package/dist/dist.min.js +1167 -848
  8. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  9. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  10. package/dist/es5/converter-cli.js +14 -2
  11. package/dist/es5/converter-cli.js.map +1 -1
  12. package/dist/es5/deps-installer/deps-installer.js +13 -2
  13. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  14. package/dist/es5/i3s-attributes-worker.js +1 -1
  15. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  16. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +16 -7
  18. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/geometry-converter.js +363 -113
  20. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +6 -11
  22. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/node-index-document.js +517 -0
  24. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
  25. package/dist/es5/i3s-converter/helpers/node-pages.js +455 -173
  26. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  27. package/dist/es5/i3s-converter/i3s-converter.js +549 -618
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
  30. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  31. package/dist/es5/i3s-converter/json-templates/layers.js +2 -93
  32. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  33. package/dist/es5/i3s-converter/json-templates/shared-resources.js +3 -3
  34. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  35. package/dist/es5/i3s-converter/types.js.map +1 -1
  36. package/dist/es5/lib/utils/file-utils.js +93 -9
  37. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  38. package/dist/es5/lib/utils/write-queue.js +38 -25
  39. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  40. package/dist/es5/pgm-loader.js +1 -1
  41. package/dist/es5/pgm-loader.js.map +1 -1
  42. package/dist/es5/workers/i3s-attributes-worker.js +1 -1
  43. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  44. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  45. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -1
  46. package/dist/esm/converter-cli.js +14 -2
  47. package/dist/esm/converter-cli.js.map +1 -1
  48. package/dist/esm/deps-installer/deps-installer.js +9 -1
  49. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  50. package/dist/esm/i3s-attributes-worker.js +1 -1
  51. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  52. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  53. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +16 -7
  54. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  55. package/dist/esm/i3s-converter/helpers/geometry-converter.js +150 -40
  56. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  57. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +6 -9
  58. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  59. package/dist/esm/i3s-converter/helpers/node-index-document.js +202 -0
  60. package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
  61. package/dist/esm/i3s-converter/helpers/node-pages.js +162 -76
  62. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  63. package/dist/esm/i3s-converter/i3s-converter.js +115 -220
  64. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  65. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
  66. package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
  67. package/dist/esm/i3s-converter/json-templates/layers.js +2 -85
  68. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  69. package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -3
  70. package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
  71. package/dist/esm/i3s-converter/types.js.map +1 -1
  72. package/dist/esm/lib/utils/file-utils.js +44 -3
  73. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  74. package/dist/esm/lib/utils/write-queue.js +19 -10
  75. package/dist/esm/lib/utils/write-queue.js.map +1 -1
  76. package/dist/esm/pgm-loader.js +1 -1
  77. package/dist/esm/pgm-loader.js.map +1 -1
  78. package/dist/esm/workers/i3s-attributes-worker.js +1 -1
  79. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
  80. package/dist/i3s-attributes-worker.js +2 -2
  81. package/dist/i3s-attributes-worker.js.map +2 -2
  82. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +3 -3
  83. package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -3
  84. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  85. package/dist/i3s-converter/helpers/geometry-attributes.js +16 -10
  86. package/dist/i3s-converter/helpers/geometry-converter.d.ts +8 -4
  87. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  88. package/dist/i3s-converter/helpers/geometry-converter.js +200 -44
  89. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  90. package/dist/i3s-converter/helpers/gltf-attributes.js +2 -3
  91. package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
  92. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
  93. package/dist/i3s-converter/helpers/node-index-document.js +250 -0
  94. package/dist/i3s-converter/helpers/node-pages.d.ts +78 -43
  95. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  96. package/dist/i3s-converter/helpers/node-pages.js +194 -93
  97. package/dist/i3s-converter/i3s-converter.d.ts +33 -58
  98. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  99. package/dist/i3s-converter/i3s-converter.js +122 -233
  100. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
  101. package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
  102. package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
  103. package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
  104. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  105. package/dist/i3s-converter/json-templates/layers.js +2 -86
  106. package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
  107. package/dist/i3s-converter/types.d.ts +28 -2
  108. package/dist/i3s-converter/types.d.ts.map +1 -1
  109. package/dist/lib/utils/file-utils.d.ts +17 -1
  110. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  111. package/dist/lib/utils/file-utils.js +64 -7
  112. package/dist/lib/utils/write-queue.d.ts +18 -2
  113. package/dist/lib/utils/write-queue.d.ts.map +1 -1
  114. package/dist/lib/utils/write-queue.js +18 -12
  115. package/dist/workers/i3s-attributes-worker.js +1 -1
  116. package/package.json +25 -20
  117. package/src/converter-cli.ts +22 -2
  118. package/src/deps-installer/deps-installer.ts +9 -0
  119. package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -3
  120. package/src/i3s-converter/helpers/geometry-attributes.ts +16 -11
  121. package/src/i3s-converter/helpers/geometry-converter.ts +217 -48
  122. package/src/i3s-converter/helpers/gltf-attributes.ts +2 -3
  123. package/src/i3s-converter/helpers/node-index-document.ts +315 -0
  124. package/src/i3s-converter/helpers/node-pages.ts +215 -110
  125. package/src/i3s-converter/i3s-converter.ts +170 -312
  126. package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
  127. package/src/i3s-converter/json-templates/layers.ts +2 -91
  128. package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
  129. package/src/i3s-converter/types.ts +29 -2
  130. package/src/lib/utils/file-utils.ts +62 -7
  131. package/src/lib/utils/write-queue.ts +36 -15
  132. package/src/workers/i3s-attributes-worker.ts +2 -1
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
@@ -16,11 +17,14 @@ var _draco = require("@loaders.gl/draco");
16
17
  var _core2 = require("@loaders.gl/core");
17
18
  var _loaderUtils = require("@loaders.gl/loader-utils");
18
19
  var _md = _interopRequireDefault(require("md5"));
20
+ var _uuid = require("uuid");
19
21
  var _geometryAttributes = require("./geometry-attributes");
20
22
  var _coordinateConverter = require("./coordinate-converter");
21
23
  var _gltfAttributes = require("./gltf-attributes");
22
24
  var _batchIdsExtensions = require("./batch-ids-extensions");
23
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; }
24
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; }
25
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; }
26
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; } } }; }
@@ -40,66 +44,62 @@ var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
40
44
  var EXT_MESH_FEATURES = 'EXT_mesh_features';
41
45
  var scratchVector = new _core.Vector3();
42
46
 
43
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
47
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10) {
44
48
  return _convertB3dmToI3sGeometry.apply(this, arguments);
45
49
  }
46
50
  function _convertB3dmToI3sGeometry() {
47
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
51
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
48
52
  var _tileContent$gltf4;
49
- var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _ref3, _ref3$materials, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture, nodeId;
53
+ var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _iterator6, _step6, materialAndTexture, originarMaterialId, convertedAttributes, material, texture, nodeId;
50
54
  return _regenerator.default.wrap(function _callee$(_context) {
51
55
  while (1) {
52
56
  switch (_context.prev = _context.next) {
53
57
  case 0:
54
58
  useCartesianPositions = generateBoundingVolumes;
55
- materialAndTextureList = convertMaterials((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.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;
56
63
  dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
57
- _context.next = 5;
58
- return convertAttributes(dataForAttributesConversion, useCartesianPositions);
59
- case 5:
64
+ _context.next = 7;
65
+ return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
66
+ case 7:
60
67
  convertedAttributesMap = _context.sent;
61
68
 
62
69
  if (generateBoundingVolumes) {
63
70
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
64
71
  }
65
- if (convertedAttributesMap.has('default')) {
66
- materialAndTextureList.push({
67
- material: getDefaultMaterial()
68
- });
69
- }
70
72
  result = [];
71
- _ref3 = tileContent.gltf || {
72
- materials: []
73
- }, _ref3$materials = _ref3.materials, materials = _ref3$materials === void 0 ? [] : _ref3$materials;
74
- if (!(materials !== null && materials !== void 0 && materials.length)) {
75
- materials.push({
76
- id: 'default'
77
- });
78
- }
79
- i = 0;
80
- case 12:
81
- if (!(i < materials.length)) {
82
- _context.next = 29;
73
+ _iterator6 = _createForOfIteratorHelper(materialAndTextureList);
74
+ _context.prev = 11;
75
+ _iterator6.s();
76
+ case 13:
77
+ if ((_step6 = _iterator6.n()).done) {
78
+ _context.next = 32;
83
79
  break;
84
80
  }
85
- sourceMaterial = materials[i];
86
- if (convertedAttributesMap.has(sourceMaterial.id)) {
87
- _context.next = 16;
81
+ materialAndTexture = _step6.value;
82
+ originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
83
+ if (convertedAttributesMap.has(originarMaterialId)) {
84
+ _context.next = 18;
88
85
  break;
89
86
  }
90
- return _context.abrupt("continue", 26);
91
- case 16:
92
- convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
87
+ return _context.abrupt("continue", 30);
88
+ case 18:
89
+ convertedAttributes = convertedAttributesMap.get(originarMaterialId);
93
90
  if (convertedAttributes) {
94
- _context.next = 19;
91
+ _context.next = 21;
95
92
  break;
96
93
  }
97
- return _context.abrupt("continue", 26);
98
- case 19:
99
- _materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
100
- nodeId = addNodeToNodePage();
101
- _context.t0 = result;
94
+ return _context.abrupt("continue", 30);
95
+ case 21:
96
+ material = materialAndTexture.material, texture = materialAndTexture.texture;
102
97
  _context.next = 24;
98
+ return addNodeToNodePage();
99
+ case 24:
100
+ nodeId = _context.sent;
101
+ _context.t0 = result;
102
+ _context.next = 28;
103
103
  return _makeNodeResources({
104
104
  convertedAttributes: convertedAttributes,
105
105
  material: material,
@@ -112,27 +112,37 @@ function _convertB3dmToI3sGeometry() {
112
112
  draco: draco,
113
113
  workerSource: workerSource
114
114
  });
115
- case 24:
115
+ case 28:
116
116
  _context.t1 = _context.sent;
117
117
  _context.t0.push.call(_context.t0, _context.t1);
118
- case 26:
119
- i++;
120
- _context.next = 12;
118
+ case 30:
119
+ _context.next = 13;
120
+ break;
121
+ case 32:
122
+ _context.next = 37;
121
123
  break;
122
- case 29:
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:
123
133
  if (result.length) {
124
- _context.next = 31;
134
+ _context.next = 42;
125
135
  break;
126
136
  }
127
137
  return _context.abrupt("return", null);
128
- case 31:
138
+ case 42:
129
139
  return _context.abrupt("return", result);
130
- case 32:
140
+ case 43:
131
141
  case "end":
132
142
  return _context.stop();
133
143
  }
134
144
  }
135
- }, _callee);
145
+ }, _callee, null, [[11, 34, 37, 40]]);
136
146
  }));
137
147
  return _convertB3dmToI3sGeometry.apply(this, arguments);
138
148
  }
@@ -160,13 +170,13 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
160
170
  }
161
171
  }
162
172
 
163
- function _makeNodeResources(_x10) {
173
+ function _makeNodeResources(_x11) {
164
174
  return _makeNodeResources2.apply(this, arguments);
165
175
  }
166
176
  function _makeNodeResources2() {
167
177
  _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
168
178
  var _tileContent$gltf5;
169
- var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
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;
170
180
  return _regenerator.default.wrap(function _callee2$(_context2) {
171
181
  while (1) {
172
182
  switch (_context2.prev = _context2.next) {
@@ -174,19 +184,20 @@ function _makeNodeResources2() {
174
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;
175
185
  boundingVolumes = convertedAttributes.boundingVolumes;
176
186
  vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
177
- _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;
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;
178
188
  if (tileContent.batchTableJson) {
179
189
  makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
180
190
  }
181
191
  header = new Uint32Array(2);
182
192
  typedFeatureIds = generateBigUint64Array(featureIds);
183
193
  header.set([vertexCount, featureCount], 0);
184
- 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));
185
195
  compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
186
196
  positions: positions,
187
197
  normals: normals,
188
198
  texCoords: texture ? texCoords : new Float32Array(0),
189
199
  colors: colors,
200
+ uvRegions: uvRegions,
190
201
  featureIds: featureIds,
191
202
  faceRange: faceRange
192
203
  }, workerSource.draco) : null;
@@ -199,6 +210,7 @@ function _makeNodeResources2() {
199
210
  geometry: fileBuffer,
200
211
  compressedGeometry: compressedGeometry,
201
212
  texture: texture,
213
+ hasUvRegions: Boolean(uvRegions.length),
202
214
  sharedResources: getSharedResources(((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : _tileContent$gltf5.materials) || [], nodeId),
203
215
  meshMaterial: material,
204
216
  vertexCount: vertexCount,
@@ -215,33 +227,44 @@ function _makeNodeResources2() {
215
227
  }));
216
228
  return _makeNodeResources2.apply(this, arguments);
217
229
  }
218
- function convertAttributes(_x11, _x12) {
230
+ function convertAttributes(_x12, _x13, _x14) {
219
231
  return _convertAttributes.apply(this, arguments);
220
232
  }
221
233
  function _convertAttributes() {
222
- _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, useCartesianPositions) {
223
- var gltfMaterials, nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, material, _iterator8, _step8, attrKey, attributes;
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;
224
236
  return _regenerator.default.wrap(function _callee3$(_context3) {
225
237
  while (1) {
226
238
  switch (_context3.prev = _context3.next) {
227
239
  case 0:
228
- gltfMaterials = attributesData.gltfMaterials, nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
240
+ nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
229
241
  attributesMap = new Map();
230
- _iterator7 = _createForOfIteratorHelper(gltfMaterials || [{
231
- id: 'default'
232
- }]);
242
+ _iterator7 = _createForOfIteratorHelper(materialAndTextureList);
233
243
  try {
234
244
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
235
- material = _step7.value;
236
- attributesMap.set(material.id, {
245
+ materialAndTexture = _step7.value;
246
+ attributes = {
237
247
  positions: new Float32Array(0),
238
248
  normals: new Float32Array(0),
239
249
  texCoords: new Float32Array(0),
240
250
  colors: new Uint8Array(0),
251
+ uvRegions: new Uint16Array(0),
241
252
  featureIndicesGroups: [],
242
253
  featureIndices: [],
243
- boundingVolumes: null
244
- });
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
+ }
245
268
  }
246
269
  } catch (err) {
247
270
  _iterator7.e(err);
@@ -258,25 +281,25 @@ function _convertAttributes() {
258
281
  break;
259
282
  }
260
283
  attrKey = _step8.value;
261
- attributes = attributesMap.get(attrKey);
262
- if (attributes) {
284
+ _attributes = attributesMap.get(attrKey);
285
+ if (_attributes) {
263
286
  _context3.next = 13;
264
287
  break;
265
288
  }
266
289
  return _context3.abrupt("continue", 17);
267
290
  case 13:
268
- if (!(attributes.positions.length === 0)) {
291
+ if (!(_attributes.positions.length === 0)) {
269
292
  _context3.next = 16;
270
293
  break;
271
294
  }
272
295
  attributesMap.delete(attrKey);
273
296
  return _context3.abrupt("continue", 17);
274
297
  case 16:
275
- if (attributes.featureIndicesGroups) {
276
- attributes.featureIndices = attributes.featureIndicesGroups.reduce(function (acc, value) {
298
+ if (_attributes.featureIndicesGroups) {
299
+ _attributes.featureIndices = _attributes.featureIndicesGroups.reduce(function (acc, value) {
277
300
  return acc.concat(value);
278
301
  });
279
- delete attributes.featureIndicesGroups;
302
+ delete _attributes.featureIndicesGroups;
280
303
  }
281
304
  case 17:
282
305
  _context3.next = 8;
@@ -358,19 +381,26 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
358
381
  var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
359
382
  _step3;
360
383
  try {
361
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
362
- var _primitive$indices, _primitive$indices2, _primitive$indices3, _primitive$indices4, _primitive$indices5;
384
+ var _loop = function _loop() {
385
+ var _primitive$indices, _primitive$indices2, _primitive$indices3, _primitive$indices4, _primitive$indices6;
363
386
  var primitive = _step3.value;
364
387
  var outputAttributes = null;
388
+ var materialUvRegion = void 0;
365
389
  if (primitive.material) {
366
- 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;
367
397
  } else if (attributesMap.has('default')) {
368
398
  outputAttributes = attributesMap.get('default');
369
399
  }
370
400
  (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
371
401
  var attributes = primitive.attributes;
372
402
  if (!outputAttributes) {
373
- continue;
403
+ return "continue";
374
404
  }
375
405
  outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
376
406
  vertices: attributes.POSITION.value,
@@ -392,8 +422,16 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
392
422
  }));
393
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));
394
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
+ }
395
429
  outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
396
- 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;
397
435
  }
398
436
  } catch (err) {
399
437
  _iterator3.e(err);
@@ -484,6 +522,14 @@ function flattenColors(colorsAttribute, indices) {
484
522
  return newColors;
485
523
  }
486
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
+
487
533
  function flattenBatchIds(batchedIds, indices) {
488
534
  if (!batchedIds.length || !indices.length) {
489
535
  return [];
@@ -511,23 +557,210 @@ function getBatchIds(attributes, primitive, images) {
511
557
  }
512
558
 
513
559
  function convertMaterials() {
514
- var sourceMaterials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
515
- var result = [];
516
- var _iterator4 = _createForOfIteratorHelper(sourceMaterials),
517
- _step4;
518
- try {
519
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
520
- var sourceMaterial = _step4.value;
521
- result.push(convertMaterial(sourceMaterial));
522
- }
523
- } catch (err) {
524
- _iterator4.e(err);
525
- } finally {
526
- _iterator4.f();
527
- }
528
- 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 = 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;
744
+ 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
+ }
759
+ }
760
+ }, _callee6, null, [[3, 16]]);
761
+ }));
762
+ return _mergeMaterials.apply(this, arguments);
529
763
  }
530
-
531
764
  function convertMaterial(sourceMaterial) {
532
765
  var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
533
766
  var material = {
@@ -553,16 +786,27 @@ function convertMaterial(sourceMaterial) {
553
786
  textureSetDefinitionId: 0
554
787
  };
555
788
  }
789
+ var uniqueId = (0, _uuid.v4)();
790
+ sourceMaterial.uniqueId = uniqueId;
791
+ var mergedMaterials = [{
792
+ originalMaterialId: uniqueId
793
+ }];
556
794
  if (!texture) {
557
795
  var _sourceMaterial$pbrMe4;
558
796
  var baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
559
797
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
560
798
  return Math.round(c * 255);
561
799
  }) || undefined;
800
+ } else {
801
+ mergedMaterials[0].textureSize = {
802
+ width: texture.image.width,
803
+ height: texture.image.height
804
+ };
562
805
  }
563
806
  return {
564
807
  material: material,
565
- texture: texture
808
+ texture: texture,
809
+ mergedMaterials: mergedMaterials
566
810
  };
567
811
  }
568
812
 
@@ -595,11 +839,11 @@ function getSharedResources(gltfMaterials, nodeId) {
595
839
  return i3sResources;
596
840
  }
597
841
  i3sResources.materialDefinitionInfos = [];
598
- var _iterator5 = _createForOfIteratorHelper(gltfMaterials),
599
- _step5;
842
+ var _iterator4 = _createForOfIteratorHelper(gltfMaterials),
843
+ _step4;
600
844
  try {
601
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
602
- var gltfMaterial = _step5.value;
845
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
846
+ var gltfMaterial = _step4.value;
603
847
  var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
604
848
  materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
605
849
  textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
@@ -610,9 +854,9 @@ function getSharedResources(gltfMaterials, nodeId) {
610
854
  }
611
855
  }
612
856
  } catch (err) {
613
- _iterator5.e(err);
857
+ _iterator4.e(err);
614
858
  } finally {
615
- _iterator5.f();
859
+ _iterator4.f();
616
860
  }
617
861
  return i3sResources;
618
862
  }
@@ -624,9 +868,9 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
624
868
  if (texture) {
625
869
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
626
870
  }
627
- var _ref2 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
628
- baseColorFactor = _ref2.baseColorFactor,
629
- metallicFactor = _ref2.metallicFactor;
871
+ var _ref3 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
872
+ baseColorFactor = _ref3.baseColorFactor,
873
+ metallicFactor = _ref3.metallicFactor;
630
874
  var colorFactor = baseColorFactor;
631
875
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
632
876
  colorFactor = gltfMaterial.emissiveFactor;
@@ -808,17 +1052,17 @@ function generateBigUint64Array(featureIds) {
808
1052
  return typedFeatureIds;
809
1053
  }
810
1054
 
811
- function generateCompressedGeometry(_x13, _x14, _x15, _x16) {
1055
+ function generateCompressedGeometry(_x18, _x19, _x20, _x21) {
812
1056
  return _generateCompressedGeometry.apply(this, arguments);
813
1057
  }
814
1058
  function _generateCompressedGeometry() {
815
- _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
816
- var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
817
- return _regenerator.default.wrap(function _callee4$(_context4) {
1059
+ _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
1060
+ var positions, normals, texCoords, colors, uvRegions, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
1061
+ return _regenerator.default.wrap(function _callee7$(_context7) {
818
1062
  while (1) {
819
- switch (_context4.prev = _context4.next) {
1063
+ switch (_context7.prev = _context7.next) {
820
1064
  case 0:
821
- positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
1065
+ positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, uvRegions = attributes.uvRegions, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
822
1066
  indices = new Uint32Array(vertexCount);
823
1067
  for (index = 0; index < indices.length; index++) {
824
1068
  indices.set([index], index);
@@ -840,7 +1084,13 @@ function _generateCompressedGeometry() {
840
1084
  'i3s-feature-ids': new Int32Array(featureIds)
841
1085
  }
842
1086
  };
843
- return _context4.abrupt("return", (0, _core2.encode)({
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)({
844
1094
  attributes: compressedAttributes,
845
1095
  indices: indices
846
1096
  }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, {
@@ -852,12 +1102,12 @@ function _generateCompressedGeometry() {
852
1102
  attributesMetadata: attributesMetadata
853
1103
  }
854
1104
  })));
855
- case 9:
1105
+ case 10:
856
1106
  case "end":
857
- return _context4.stop();
1107
+ return _context7.stop();
858
1108
  }
859
1109
  }
860
- }, _callee4);
1110
+ }, _callee7);
861
1111
  }));
862
1112
  return _generateCompressedGeometry.apply(this, arguments);
863
1113
  }
@@ -908,20 +1158,20 @@ function getPropertyTableExtension(tileContent) {
908
1158
  };
909
1159
  }
910
1160
  var extensionName = '';
911
- var _iterator6 = _createForOfIteratorHelper((tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed) || []),
912
- _step6;
1161
+ var _iterator5 = _createForOfIteratorHelper((tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed) || []),
1162
+ _step5;
913
1163
  try {
914
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
915
- var extensionItem = _step6.value;
1164
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1165
+ var extensionItem = _step5.value;
916
1166
  if (extensionsWithPropertyTables.includes(extensionItem)) {
917
1167
  extensionName = extensionItem;
918
1168
  break;
919
1169
  }
920
1170
  }
921
1171
  } catch (err) {
922
- _iterator6.e(err);
1172
+ _iterator5.e(err);
923
1173
  } finally {
924
- _iterator6.f();
1174
+ _iterator5.f();
925
1175
  }
926
1176
  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];
927
1177
  return {