@loaders.gl/tile-converter 4.0.0-alpha.6 → 4.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/bin/converter.js +1 -1
  2. package/dist/3d-tiles-attributes-worker.js +2 -2
  3. package/dist/3d-tiles-attributes-worker.js.map +3 -3
  4. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  5. package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -3
  6. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -8
  7. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +2 -15
  9. package/dist/converter.min.js +75 -76
  10. package/dist/deps-installer/deps-installer.js +3 -3
  11. package/dist/dist.min.js +1870 -1581
  12. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  13. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -3
  14. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  15. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +2 -10
  16. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  17. package/dist/es5/deps-installer/deps-installer.js +4 -4
  18. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  19. package/dist/es5/i3s-attributes-worker.js +1 -1
  20. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  22. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.js +25 -17
  24. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +1 -4
  26. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  27. package/dist/es5/i3s-converter/i3s-converter.js +0 -7
  28. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  29. package/dist/es5/lib/utils/geometry-utils.js +15 -0
  30. package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
  31. package/dist/es5/pgm-loader.js +1 -1
  32. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +0 -3
  34. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  35. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +2 -8
  36. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  37. package/dist/esm/deps-installer/deps-installer.js +4 -4
  38. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  39. package/dist/esm/i3s-attributes-worker.js +1 -1
  40. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  41. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  42. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -11
  44. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  45. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +1 -4
  46. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  47. package/dist/esm/i3s-converter/i3s-converter.js +0 -7
  48. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  49. package/dist/esm/lib/utils/geometry-utils.js +8 -0
  50. package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
  51. package/dist/esm/pgm-loader.js +1 -1
  52. package/dist/i3s-attributes-worker.d.ts +10 -2
  53. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  54. package/dist/i3s-attributes-worker.js +2 -2
  55. package/dist/i3s-attributes-worker.js.map +3 -3
  56. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +4 -2
  57. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  58. package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -2
  59. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  60. package/dist/i3s-converter/helpers/geometry-converter.js +51 -43
  61. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/gltf-attributes.js +1 -4
  63. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  64. package/dist/i3s-converter/i3s-converter.js +7 -6
  65. package/dist/lib/utils/geometry-utils.d.ts +9 -0
  66. package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
  67. package/dist/lib/utils/geometry-utils.js +18 -0
  68. package/package.json +15 -16
  69. package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -3
  70. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +2 -16
  71. package/src/deps-installer/deps-installer.ts +3 -3
  72. package/src/i3s-attributes-worker.ts +11 -2
  73. package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -14
  74. package/src/i3s-converter/helpers/geometry-converter.ts +105 -78
  75. package/src/i3s-converter/helpers/gltf-attributes.ts +1 -4
  76. package/src/i3s-converter/i3s-converter.ts +8 -7
  77. package/src/lib/utils/geometry-utils.ts +14 -0
@@ -24,6 +24,7 @@ var _gltfAttributes = require("./gltf-attributes");
24
24
  var _batchIdsExtensions = require("./batch-ids-extensions");
25
25
  var _featureAttributes = require("./feature-attributes");
26
26
  var _math = require("@loaders.gl/math");
27
+ var _geometryUtils = require("../../lib/utils/geometry-utils");
27
28
  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); }
28
29
  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; }
29
30
  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; }
@@ -376,21 +377,22 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
376
377
  var materialUvRegion;
377
378
  if (primitive.material) {
378
379
  var _outputAttributes, _outputAttributes$mer;
379
- outputAttributes = attributesMap.get(primitive.material.uniqueId);
380
+ outputAttributes = attributesMap.get(primitive.material.id);
380
381
  materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(function (_ref2) {
381
382
  var _primitive$material;
382
383
  var originalMaterialId = _ref2.originalMaterialId;
383
- return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.uniqueId);
384
+ return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.id);
384
385
  })) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
385
386
  } else if (attributesMap.has('default')) {
386
387
  outputAttributes = attributesMap.get('default');
387
388
  }
388
389
  (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
390
+ (0, _core2.assert)(primitive.mode === _math.GL.TRIANGLES || primitive.mode === _math.GL.TRIANGLE_STRIP, "Primitive - unsupported mode ".concat(primitive.mode));
389
391
  var attributes = primitive.attributes;
390
392
  if (!outputAttributes) {
391
393
  return "continue";
392
394
  }
393
- var indices = getIndices(primitive);
395
+ var indices = normalizeIndices(primitive);
394
396
  outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
395
397
  vertices: attributes.POSITION.value,
396
398
  cartographicOrigin: cartographicOrigin,
@@ -427,9 +429,13 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
427
429
  _iterator3.f();
428
430
  }
429
431
  }
430
- function getIndices(primitive) {
432
+ function normalizeIndices(primitive) {
431
433
  var _primitive$indices;
432
434
  var indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
435
+ if (!indices) {
436
+ var positions = primitive.attributes.POSITION.value;
437
+ return (0, _geometryUtils.generateSyntheticIndices)(positions.length / VALUES_PER_VERTEX);
438
+ }
433
439
  if (indices && primitive.mode === _math.GL.TRIANGLE_STRIP) {
434
440
  var TypedArrayConstructor = indices.constructor;
435
441
  var newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
@@ -643,12 +649,12 @@ function _mergeAllMaterials() {
643
649
  break;
644
650
  case 15:
645
651
  if (newMaterial.texture && mergedIndices.length) {
646
- newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref4) {
647
- var textureSize = _ref4.textureSize;
652
+ newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref5) {
653
+ var textureSize = _ref5.textureSize;
648
654
  return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
649
655
  }, 0);
650
- newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref5) {
651
- var textureSize = _ref5.textureSize;
656
+ newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref6) {
657
+ var textureSize = _ref6.textureSize;
652
658
  return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
653
659
  }, 0);
654
660
  currentX = -1;
@@ -781,10 +787,9 @@ function convertMaterial(sourceMaterial) {
781
787
  textureSetDefinitionId: 0
782
788
  };
783
789
  }
784
- var uniqueId = (0, _uuid.v4)();
785
- sourceMaterial.uniqueId = uniqueId;
790
+ sourceMaterial.id = Number.isFinite(sourceMaterial.id) ? sourceMaterial.id : (0, _uuid.v4)();
786
791
  var mergedMaterials = [{
787
- originalMaterialId: uniqueId
792
+ originalMaterialId: sourceMaterial.id
788
793
  }];
789
794
  if (!texture) {
790
795
  var _sourceMaterial$pbrMe4;
@@ -892,21 +897,24 @@ function extractSharedResourcesMaterialInfo(baseColorFactor) {
892
897
  };
893
898
  }
894
899
  function extractSharedResourcesTextureInfo(texture, nodeId) {
895
- var _texture$source, _texture$source2, _texture$source3;
900
+ var _texture$source, _texture$source2, _texture$source3, _texture$source4;
896
901
  return {
897
902
  encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
898
903
  images: [{
899
904
  id: generateImageId(texture, nodeId),
900
905
  size: (_texture$source2 = texture.source) === null || _texture$source2 === void 0 ? void 0 : _texture$source2.image.width,
901
- length: [(_texture$source3 = texture.source) === null || _texture$source3 === void 0 ? void 0 : _texture$source3.image.data.length]
906
+ length: (_texture$source3 = texture.source) !== null && _texture$source3 !== void 0 && _texture$source3.image.data.length ? [(_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image.data.length] : undefined
902
907
  }]
903
908
  };
904
909
  }
905
910
  function generateImageId(texture, nodeId) {
906
- var _texture$source4;
907
- var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
908
- width = _texture$source$image.width,
909
- height = _texture$source$image.height;
911
+ var _texture$source5;
912
+ var _ref4 = ((_texture$source5 = texture.source) === null || _texture$source5 === void 0 ? void 0 : _texture$source5.image) || {},
913
+ width = _ref4.width,
914
+ height = _ref4.height;
915
+ if (!width || !height) {
916
+ return '';
917
+ }
910
918
  var levelCountOfTexture = 1;
911
919
  var indexOfLevel = 0;
912
920
  var indexOfTextureInStore = nodeId + 1;