@loaders.gl/tile-converter 3.1.5 → 3.1.6

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.
package/dist/dist.min.js CHANGED
@@ -10622,16 +10622,16 @@ var require_bounding_sphere = __commonJS({
10622
10622
  }
10623
10623
  var scratchVector7 = new _core.Vector3();
10624
10624
  var scratchVector23 = new _core.Vector3();
10625
- var BoundingSphere3 = function() {
10626
- function BoundingSphere4() {
10625
+ var BoundingSphere4 = function() {
10626
+ function BoundingSphere5() {
10627
10627
  var center = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [0, 0, 0];
10628
10628
  var radius = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
10629
- (0, _classCallCheck2.default)(this, BoundingSphere4);
10629
+ (0, _classCallCheck2.default)(this, BoundingSphere5);
10630
10630
  this.radius = -0;
10631
10631
  this.center = new _core.Vector3();
10632
10632
  this.fromCenterRadius(center, radius);
10633
10633
  }
10634
- (0, _createClass2.default)(BoundingSphere4, [{
10634
+ (0, _createClass2.default)(BoundingSphere5, [{
10635
10635
  key: "fromCenterRadius",
10636
10636
  value: function fromCenterRadius(center, radius) {
10637
10637
  this.center.from(center);
@@ -10654,7 +10654,7 @@ var require_bounding_sphere = __commonJS({
10654
10654
  }, {
10655
10655
  key: "clone",
10656
10656
  value: function clone2() {
10657
- return new BoundingSphere4(this.center, this.radius);
10657
+ return new BoundingSphere5(this.center, this.radius);
10658
10658
  }
10659
10659
  }, {
10660
10660
  key: "union",
@@ -10723,9 +10723,9 @@ var require_bounding_sphere = __commonJS({
10723
10723
  return _constants.INTERSECTION.INSIDE;
10724
10724
  }
10725
10725
  }]);
10726
- return BoundingSphere4;
10726
+ return BoundingSphere5;
10727
10727
  }();
10728
- exports.default = BoundingSphere3;
10728
+ exports.default = BoundingSphere4;
10729
10729
  }
10730
10730
  });
10731
10731
 
@@ -10762,15 +10762,15 @@ var require_oriented_bounding_box = __commonJS({
10762
10762
  COLUMN2ROW1: 7,
10763
10763
  COLUMN2ROW2: 8
10764
10764
  };
10765
- var OrientedBoundingBox6 = function() {
10766
- function OrientedBoundingBox7() {
10765
+ var OrientedBoundingBox7 = function() {
10766
+ function OrientedBoundingBox8() {
10767
10767
  var center = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [0, 0, 0];
10768
10768
  var halfAxes = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0, 0, 0, 0, 0, 0, 0, 0, 0];
10769
- (0, _classCallCheck2.default)(this, OrientedBoundingBox7);
10769
+ (0, _classCallCheck2.default)(this, OrientedBoundingBox8);
10770
10770
  this.center = new _core.Vector3().from(center);
10771
10771
  this.halfAxes = new _core.Matrix3(halfAxes);
10772
10772
  }
10773
- (0, _createClass2.default)(OrientedBoundingBox7, [{
10773
+ (0, _createClass2.default)(OrientedBoundingBox8, [{
10774
10774
  key: "halfSize",
10775
10775
  get: function get() {
10776
10776
  var xAxis = this.halfAxes.getColumn(0);
@@ -10810,7 +10810,7 @@ var require_oriented_bounding_box = __commonJS({
10810
10810
  }, {
10811
10811
  key: "clone",
10812
10812
  value: function clone2() {
10813
- return new OrientedBoundingBox7(this.center, this.halfAxes);
10813
+ return new OrientedBoundingBox8(this.center, this.halfAxes);
10814
10814
  }
10815
10815
  }, {
10816
10816
  key: "equals",
@@ -10957,9 +10957,9 @@ var require_oriented_bounding_box = __commonJS({
10957
10957
  throw new Error("not implemented");
10958
10958
  }
10959
10959
  }]);
10960
- return OrientedBoundingBox7;
10960
+ return OrientedBoundingBox8;
10961
10961
  }();
10962
- exports.default = OrientedBoundingBox6;
10962
+ exports.default = OrientedBoundingBox7;
10963
10963
  }
10964
10964
  });
10965
10965
 
@@ -74748,18 +74748,21 @@ function commonSpacePlanesToWGS84(viewport, viewportCenterCartesian) {
74748
74748
 
74749
74749
  // ../tiles/src/tileset/helpers/zoom.ts
74750
74750
  var import_core3 = __toModule(require_es54());
74751
+ var import_culling2 = __toModule(require_es57());
74751
74752
  var WGS84_RADIUS_X = 6378137;
74752
74753
  var WGS84_RADIUS_Y = 6378137;
74753
74754
  var WGS84_RADIUS_Z = 6356752314245179e-9;
74754
74755
  var scratchVector2 = new import_core3.Vector3();
74755
- function getZoomFromBoundingVolume(boundingVolume) {
74756
- const { halfAxes, radius, width, height } = boundingVolume;
74757
- if (halfAxes) {
74756
+ function getZoomFromBoundingVolume(boundingVolume, cartorgraphicCenter) {
74757
+ if (boundingVolume instanceof import_culling2.OrientedBoundingBox) {
74758
+ const { halfAxes } = boundingVolume;
74758
74759
  const obbSize = getObbSize(halfAxes);
74759
- return Math.log2(WGS84_RADIUS_Z / obbSize);
74760
- } else if (radius) {
74761
- return Math.log2(WGS84_RADIUS_Z / radius);
74762
- } else if (height && width) {
74760
+ return Math.log2(WGS84_RADIUS_Z / (obbSize + cartorgraphicCenter[2]));
74761
+ } else if (boundingVolume instanceof import_culling2.BoundingSphere) {
74762
+ const { radius } = boundingVolume;
74763
+ return Math.log2(WGS84_RADIUS_Z / (radius + cartorgraphicCenter[2]));
74764
+ } else if (boundingVolume.width && boundingVolume.height) {
74765
+ const { width, height } = boundingVolume;
74763
74766
  const zoomX = Math.log2(WGS84_RADIUS_X / width);
74764
74767
  const zoomY = Math.log2(WGS84_RADIUS_Y / height);
74765
74768
  return (zoomX + zoomY) / 2;
@@ -74777,7 +74780,7 @@ function getObbSize(halfAxes) {
74777
74780
 
74778
74781
  // ../tiles/src/tileset/tile-3d.ts
74779
74782
  var import_core7 = __toModule(require_es54());
74780
- var import_culling3 = __toModule(require_es57());
74783
+ var import_culling4 = __toModule(require_es57());
74781
74784
 
74782
74785
  // ../tiles/src/constants.ts
74783
74786
  var TILE_CONTENT_STATE = {
@@ -74814,7 +74817,7 @@ var TILE3D_OPTIMIZATION_HINT = {
74814
74817
 
74815
74818
  // ../tiles/src/tileset/helpers/bounding-volume.ts
74816
74819
  var import_core4 = __toModule(require_es54());
74817
- var import_culling2 = __toModule(require_es57());
74820
+ var import_culling3 = __toModule(require_es57());
74818
74821
  var import_geospatial3 = __toModule(require_es55());
74819
74822
  function defined2(x) {
74820
74823
  return x !== void 0 && x !== null;
@@ -74880,7 +74883,7 @@ function createBox(box, transform9, result) {
74880
74883
  result.halfAxes = halfAxes;
74881
74884
  return result;
74882
74885
  }
74883
- return new import_culling2.OrientedBoundingBox(center, halfAxes);
74886
+ return new import_culling3.OrientedBoundingBox(center, halfAxes);
74884
74887
  }
74885
74888
  function createSphere(sphere, transform9, result) {
74886
74889
  const center = new import_core4.Vector3(sphere[0], sphere[1], sphere[2]);
@@ -74893,7 +74896,7 @@ function createSphere(sphere, transform9, result) {
74893
74896
  result.radius = radius;
74894
74897
  return result;
74895
74898
  }
74896
- return new import_culling2.BoundingSphere(center, radius);
74899
+ return new import_culling3.BoundingSphere(center, radius);
74897
74900
  }
74898
74901
 
74899
74902
  // ../tiles/src/tileset/helpers/tiles-3d-lod.ts
@@ -75473,7 +75476,7 @@ var TileHeader = class {
75473
75476
  return;
75474
75477
  }
75475
75478
  const parent = this.parent;
75476
- const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : import_culling3.CullingVolume.MASK_INDETERMINATE;
75479
+ const parentVisibilityPlaneMask = parent ? parent._visibilityPlaneMask : import_culling4.CullingVolume.MASK_INDETERMINATE;
75477
75480
  if (this.tileset._traverser.options.updateTransforms) {
75478
75481
  const parentTransform = parent ? parent.computedTransform : this.tileset.modelMatrix;
75479
75482
  this._updateTransform(parentTransform);
@@ -75481,7 +75484,7 @@ var TileHeader = class {
75481
75484
  this._distanceToCamera = this.distanceToTile(frameState);
75482
75485
  this._screenSpaceError = this.getScreenSpaceError(frameState, false);
75483
75486
  this._visibilityPlaneMask = this.visibility(frameState, parentVisibilityPlaneMask);
75484
- this._visible = this._visibilityPlaneMask !== import_culling3.CullingVolume.MASK_OUTSIDE;
75487
+ this._visible = this._visibilityPlaneMask !== import_culling4.CullingVolume.MASK_OUTSIDE;
75485
75488
  this._inRequestVolume = this.insideViewerRequestVolume(frameState);
75486
75489
  this._frameNumber = frameState.frameNumber;
75487
75490
  this.viewportIds = viewportIds;
@@ -75563,7 +75566,7 @@ var TileHeader = class {
75563
75566
  this._distanceToCamera = 0;
75564
75567
  this._centerZDepth = 0;
75565
75568
  this._screenSpaceError = 0;
75566
- this._visibilityPlaneMask = import_culling3.CullingVolume.MASK_INDETERMINATE;
75569
+ this._visibilityPlaneMask = import_culling4.CullingVolume.MASK_INDETERMINATE;
75567
75570
  this._visible = void 0;
75568
75571
  this._inRequestVolume = false;
75569
75572
  this._stackLength = 0;
@@ -76022,7 +76025,7 @@ var Tileset3D = class {
76022
76025
  }
76023
76026
  this.cartographicCenter = import_geospatial5.Ellipsoid.WGS84.cartesianToCartographic(center, new import_core10.Vector3());
76024
76027
  this.cartesianCenter = center;
76025
- this.zoom = getZoomFromBoundingVolume(root.boundingVolume);
76028
+ this.zoom = getZoomFromBoundingVolume(root.boundingVolume, this.cartographicCenter);
76026
76029
  }
76027
76030
  _initializeStats() {
76028
76031
  this.stats.get(TILES_TOTAL);
@@ -83330,7 +83333,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
83330
83333
  // src/i3s-converter/helpers/coordinate-converter.ts
83331
83334
  var import_core20 = __toModule(require_es54());
83332
83335
  var import_geospatial7 = __toModule(require_es55());
83333
- var import_culling4 = __toModule(require_es57());
83336
+ var import_culling5 = __toModule(require_es57());
83334
83337
  function createBoundingVolumes(tile, geoidHeightModel) {
83335
83338
  let radius;
83336
83339
  let halfSize;
@@ -83338,7 +83341,7 @@ function createBoundingVolumes(tile, geoidHeightModel) {
83338
83341
  const boundingVolume = tile.boundingVolume;
83339
83342
  const cartographicCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new import_core20.Vector3());
83340
83343
  cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
83341
- if (boundingVolume instanceof import_culling4.OrientedBoundingBox) {
83344
+ if (boundingVolume instanceof import_culling5.OrientedBoundingBox) {
83342
83345
  halfSize = boundingVolume.halfSize;
83343
83346
  radius = new import_core20.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
83344
83347
  quaternion = boundingVolume.quaternion;
@@ -83358,8 +83361,8 @@ function createBoundingVolumes(tile, geoidHeightModel) {
83358
83361
  }
83359
83362
  function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel) {
83360
83363
  const positionVectors = convertPositionsToVectors(cartesianPositions);
83361
- const geometryObb = (0, import_culling4.makeOrientedBoundingBoxFromPoints)(positionVectors);
83362
- const geometryMbs = (0, import_culling4.makeBoundingSphereFromPoints)(positionVectors);
83364
+ const geometryObb = (0, import_culling5.makeOrientedBoundingBoxFromPoints)(positionVectors);
83365
+ const geometryMbs = (0, import_culling5.makeBoundingSphereFromPoints)(positionVectors);
83363
83366
  let mbsCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core20.Vector3());
83364
83367
  let obbCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core20.Vector3());
83365
83368
  mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
@@ -83402,10 +83405,12 @@ function createObbFromMbs(mbs) {
83402
83405
  const radius = mbs[3];
83403
83406
  const center = new import_core20.Vector3(mbs[0], mbs[1], mbs[2]);
83404
83407
  const halfAxex = new import_core20.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
83405
- return new import_culling4.OrientedBoundingBox(center, halfAxex);
83408
+ return new import_culling5.OrientedBoundingBox(center, halfAxex);
83406
83409
  }
83407
83410
 
83408
83411
  // src/i3s-converter/helpers/geometry-converter.js
83412
+ var DEFAULT_ROUGHNESS_FACTOR = 1;
83413
+ var DEFAULT_METALLIC_FACTOR = 1;
83409
83414
  var VALUES_PER_VERTEX2 = 3;
83410
83415
  var VALUES_PER_TEX_COORD = 2;
83411
83416
  var VALUES_PER_COLOR_ELEMENT = 4;
@@ -83709,12 +83714,12 @@ function convertMaterial(sourceMaterial) {
83709
83714
  emissiveFactor: sourceMaterial.emissiveFactor.map((c) => Math.round(c * 255)),
83710
83715
  alphaMode: (sourceMaterial.alphaMode || "OPAQUE").toLowerCase(),
83711
83716
  pbrMetallicRoughness: {
83712
- roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
83713
- metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
83717
+ roughnessFactor: sourceMaterial?.pbrMetallicRoughness?.roughnessFactor || DEFAULT_ROUGHNESS_FACTOR,
83718
+ metallicFactor: sourceMaterial?.pbrMetallicRoughness?.metallicFactor || DEFAULT_METALLIC_FACTOR
83714
83719
  }
83715
83720
  };
83716
83721
  let texture;
83717
- if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
83722
+ if (sourceMaterial?.pbrMetallicRoughness?.baseColorTexture) {
83718
83723
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
83719
83724
  material.pbrMetallicRoughness.baseColorTexture = {
83720
83725
  textureSetDefinitionId: 0
@@ -83726,7 +83731,7 @@ function convertMaterial(sourceMaterial) {
83726
83731
  };
83727
83732
  }
83728
83733
  if (!texture) {
83729
- const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
83734
+ const baseColorFactor = sourceMaterial?.pbrMetallicRoughness?.baseColorFactor;
83730
83735
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255)) || void 0;
83731
83736
  }
83732
83737
  return { material, texture };
@@ -83755,12 +83760,12 @@ function getSharedResources(tileContent, nodeId) {
83755
83760
  return i3sResources;
83756
83761
  }
83757
83762
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
83758
- const texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
83763
+ const texture = gltfMaterial?.pbrMetallicRoughness?.baseColorTexture || gltfMaterial.emissiveTexture;
83759
83764
  let textureDefinitionInfo = null;
83760
83765
  if (texture) {
83761
83766
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
83762
83767
  }
83763
- const { baseColorFactor, metallicFactor } = gltfMaterial.pbrMetallicRoughness;
83768
+ const { baseColorFactor, metallicFactor } = gltfMaterial?.pbrMetallicRoughness || {};
83764
83769
  let colorFactor = baseColorFactor;
83765
83770
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
83766
83771
  colorFactor = gltfMaterial.emissiveFactor;
@@ -83771,7 +83776,7 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
83771
83776
  textureDefinitionInfo
83772
83777
  };
83773
83778
  }
83774
- function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {
83779
+ function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 1) {
83775
83780
  const matDielectricColorComponent = 0.04 / 255;
83776
83781
  const black = new import_core21.Vector4(0, 0, 0, 1);
83777
83782
  const unitVector = new import_core21.Vector4(1, 1, 1, 1);
@@ -84558,7 +84563,7 @@ function transfromTextureDefinitions(textureDefinitionInfos, thisObject, origina
84558
84563
  }
84559
84564
 
84560
84565
  // src/i3s-converter/helpers/node-debug.ts
84561
- var import_culling5 = __toModule(require_es57());
84566
+ var import_culling6 = __toModule(require_es57());
84562
84567
  var import_engine = __toModule(require_es514());
84563
84568
  var import_core23 = __toModule(require_es54());
84564
84569
  var import_geospatial9 = __toModule(require_es55());
@@ -84591,11 +84596,11 @@ function validateMbs(tileWarnings, node2) {
84591
84596
  }
84592
84597
  }
84593
84598
  function createBoundingSphereFromTileMbs(mbs) {
84594
- return new import_culling5.BoundingSphere([mbs[0], mbs[1], mbs[2]], mbs[3]);
84599
+ return new import_culling6.BoundingSphere([mbs[0], mbs[1], mbs[2]], mbs[3]);
84595
84600
  }
84596
84601
  function createBoundingBoxFromTileObb(obb) {
84597
84602
  const { center, halfSize, quaternion } = obb;
84598
- return new import_culling5.OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);
84603
+ return new import_culling6.OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);
84599
84604
  }
84600
84605
  function getTileObbVertices(node2) {
84601
84606
  const geometry = new import_engine.CubeGeometry();
@@ -85823,7 +85828,7 @@ async function parse6(data, options, context) {
85823
85828
  }
85824
85829
 
85825
85830
  // ../i3s/src/lib/parsers/parse-i3s.ts
85826
- var import_culling6 = __toModule(require_es57());
85831
+ var import_culling7 = __toModule(require_es57());
85827
85832
  var import_geospatial11 = __toModule(require_es55());
85828
85833
 
85829
85834
  // ../i3s/src/i3s-node-page-loader.ts
@@ -86049,7 +86054,7 @@ function normalizeTileNonUrlData(tile) {
86049
86054
  ...tile.obb.halfSize,
86050
86055
  ...tile.obb.quaternion
86051
86056
  ];
86052
- const obb = new import_culling6.OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
86057
+ const obb = new import_culling7.OrientedBoundingBox().fromCenterHalfSizeQuaternion(boundingVolume.box.slice(0, 3), tile.obb.halfSize, tile.obb.quaternion);
86053
86058
  const boundingSphere = obb.getBoundingSphere();
86054
86059
  boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
86055
86060
  mbs = [...tile.obb.center, boundingSphere.radius];
@@ -86242,7 +86247,7 @@ async function parse8(data, options) {
86242
86247
  // src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts
86243
86248
  var import_core30 = __toModule(require_es54());
86244
86249
  var import_geospatial12 = __toModule(require_es55());
86245
- var import_culling7 = __toModule(require_es57());
86250
+ var import_culling8 = __toModule(require_es57());
86246
86251
  function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
86247
86252
  const tiles3DCenter = [
86248
86253
  i3SObb.center[0],
@@ -86250,7 +86255,7 @@ function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
86250
86255
  i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])
86251
86256
  ];
86252
86257
  const cartesianCenter = import_geospatial12.Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new import_core30.Vector3());
86253
- const tiles3DObb = new import_culling7.OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
86258
+ const tiles3DObb = new import_culling8.OrientedBoundingBox().fromCenterHalfSizeQuaternion(cartesianCenter, i3SObb.halfSize, i3SObb.quaternion);
86254
86259
  return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
86255
86260
  }
86256
86261
 
@@ -39,6 +39,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
39
39
 
40
40
  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; }
41
41
 
42
+ var DEFAULT_ROUGHNESS_FACTOR = 1;
43
+ var DEFAULT_METALLIC_FACTOR = 1;
42
44
  var VALUES_PER_VERTEX = 3;
43
45
  var VALUES_PER_TEX_COORD = 2;
44
46
  var VALUES_PER_COLOR_ELEMENT = 4;
@@ -573,6 +575,8 @@ function convertMaterials(tileContent) {
573
575
  }
574
576
 
575
577
  function convertMaterial(sourceMaterial) {
578
+ var _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
579
+
576
580
  var material = {
577
581
  doubleSided: sourceMaterial.doubleSided,
578
582
  emissiveFactor: sourceMaterial.emissiveFactor.map(function (c) {
@@ -580,13 +584,13 @@ function convertMaterial(sourceMaterial) {
580
584
  }),
581
585
  alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
582
586
  pbrMetallicRoughness: {
583
- roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
584
- metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
587
+ roughnessFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe === void 0 ? void 0 : _sourceMaterial$pbrMe.roughnessFactor) || DEFAULT_ROUGHNESS_FACTOR,
588
+ metallicFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe2 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe2 === void 0 ? void 0 : _sourceMaterial$pbrMe2.metallicFactor) || DEFAULT_METALLIC_FACTOR
585
589
  }
586
590
  };
587
591
  var texture;
588
592
 
589
- if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
593
+ if (sourceMaterial !== null && sourceMaterial !== void 0 && (_sourceMaterial$pbrMe3 = sourceMaterial.pbrMetallicRoughness) !== null && _sourceMaterial$pbrMe3 !== void 0 && _sourceMaterial$pbrMe3.baseColorTexture) {
590
594
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
591
595
  material.pbrMetallicRoughness.baseColorTexture = {
592
596
  textureSetDefinitionId: 0
@@ -599,7 +603,9 @@ function convertMaterial(sourceMaterial) {
599
603
  }
600
604
 
601
605
  if (!texture) {
602
- var baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
606
+ var _sourceMaterial$pbrMe4;
607
+
608
+ var baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
603
609
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
604
610
  return Math.round(c * 255);
605
611
  }) || undefined;
@@ -656,16 +662,19 @@ function getSharedResources(tileContent, nodeId) {
656
662
  }
657
663
 
658
664
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
659
- var texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
665
+ var _gltfMaterial$pbrMeta;
666
+
667
+ 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;
660
668
  var textureDefinitionInfo = null;
661
669
 
662
670
  if (texture) {
663
671
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
664
672
  }
665
673
 
666
- var _gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness,
667
- baseColorFactor = _gltfMaterial$pbrMeta.baseColorFactor,
668
- metallicFactor = _gltfMaterial$pbrMeta.metallicFactor;
674
+ var _ref2 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
675
+ baseColorFactor = _ref2.baseColorFactor,
676
+ metallicFactor = _ref2.metallicFactor;
677
+
669
678
  var colorFactor = baseColorFactor;
670
679
 
671
680
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
@@ -680,7 +689,7 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
680
689
  }
681
690
 
682
691
  function extractSharedResourcesMaterialInfo(baseColorFactor) {
683
- var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
692
+ var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
684
693
  var matDielectricColorComponent = 0.04 / 255;
685
694
  var black = new _core.Vector4(0, 0, 0, 1);
686
695
  var unitVector = new _core.Vector4(1, 1, 1, 1);