@loaders.gl/tile-converter 3.1.2 → 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.
Files changed (29) hide show
  1. package/dist/converter.min.js +1 -1
  2. package/dist/dist.min.js +140 -71
  3. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  4. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +11 -18
  5. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  6. package/dist/es5/i3s-converter/helpers/geometry-converter.js +47 -13
  7. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  8. package/dist/es5/i3s-converter/helpers/node-debug.js +9 -3
  9. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  10. package/dist/es5/i3s-converter/i3s-converter.js +12 -10
  11. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  12. package/dist/es5/pgm-loader.js +1 -1
  13. package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  14. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +10 -18
  15. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  16. package/dist/esm/i3s-converter/helpers/geometry-converter.js +46 -11
  17. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  18. package/dist/esm/i3s-converter/helpers/node-debug.js +9 -3
  19. package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
  20. package/dist/esm/i3s-converter/i3s-converter.js +3 -3
  21. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  22. package/dist/esm/pgm-loader.js +1 -1
  23. package/package.json +14 -14
  24. package/src/i3s-converter/helpers/create-scene-server-path.ts +9 -5
  25. package/src/i3s-converter/helpers/geometry-attributes.ts +52 -30
  26. package/src/i3s-converter/helpers/geometry-converter.js +52 -11
  27. package/src/i3s-converter/helpers/node-debug.ts +58 -12
  28. package/src/i3s-converter/i3s-converter.ts +4 -4
  29. package/src/i3s-converter/types.ts +28 -0
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);
@@ -82359,7 +82362,8 @@ async function parseImplicitTiles(subtree, options, parentData = {
82359
82362
  const currentTile = await parseImplicitTiles(subtree, options, pData, index, childTileLevel, globalData);
82360
82363
  if (currentTile.contentUrl || currentTile.children.length) {
82361
82364
  const globalLevel = lev + 1;
82362
- const formattedTile = formatTileData(currentTile, globalLevel, options);
82365
+ const childCoordinates = { childTileX, childTileY, childTileZ };
82366
+ const formattedTile = formatTileData(currentTile, globalLevel, childCoordinates, options);
82363
82367
  tile.children.push(formattedTile);
82364
82368
  }
82365
82369
  }
@@ -82374,10 +82378,19 @@ function getAvailabilityResult(availabilityData, index) {
82374
82378
  }
82375
82379
  return false;
82376
82380
  }
82377
- function formatTileData(tile, level, options) {
82378
- const { basePath, refine, getRefine: getRefine2, lodMetricType, getTileType: getTileType2, rootLodMetricValue } = options;
82381
+ function formatTileData(tile, level, childCoordinates, options) {
82382
+ const {
82383
+ basePath,
82384
+ refine,
82385
+ getRefine: getRefine2,
82386
+ lodMetricType,
82387
+ getTileType: getTileType2,
82388
+ rootLodMetricValue,
82389
+ rootBoundingVolume
82390
+ } = options;
82379
82391
  const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, "");
82380
82392
  const lodMetricValue = rootLodMetricValue / 2 ** level;
82393
+ const boundingVolume = calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates);
82381
82394
  return {
82382
82395
  children: tile.children,
82383
82396
  contentUrl: tile.contentUrl,
@@ -82386,9 +82399,31 @@ function formatTileData(tile, level, options) {
82386
82399
  refine: getRefine2(refine),
82387
82400
  type: getTileType2(tile),
82388
82401
  lodMetricType,
82389
- lodMetricValue
82402
+ lodMetricValue,
82403
+ boundingVolume
82390
82404
  };
82391
82405
  }
82406
+ function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates) {
82407
+ if (rootBoundingVolume.region) {
82408
+ const { childTileX, childTileY, childTileZ } = childCoordinates;
82409
+ const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
82410
+ const boundingVolumesCount = 2 ** level;
82411
+ const sizeX = (east - west) / boundingVolumesCount;
82412
+ const sizeY = (north - south) / boundingVolumesCount;
82413
+ const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
82414
+ const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];
82415
+ const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];
82416
+ const [childMinimumHeight, childMaximumHeight] = [
82417
+ minimumHeight + sizeZ * childTileZ,
82418
+ minimumHeight + sizeZ * (childTileZ + 1)
82419
+ ];
82420
+ return {
82421
+ region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
82422
+ };
82423
+ }
82424
+ console.warn("Unsupported bounding volume type: ", rootBoundingVolume);
82425
+ return null;
82426
+ }
82392
82427
  function concatBits(first, second) {
82393
82428
  return parseInt(first.toString(2) + second.toString(2), 2);
82394
82429
  }
@@ -82490,6 +82525,7 @@ async function normalizeImplicitTileHeaders(tileset) {
82490
82525
  const contentUrlTemplate = `${basePath}/${tileset.root.content.uri}`;
82491
82526
  const refine = tileset.root.refine;
82492
82527
  const rootLodMetricValue = tileset.root.geometricError;
82528
+ const rootBoundingVolume = tileset.root.boundingVolume;
82493
82529
  const options = {
82494
82530
  contentUrlTemplate,
82495
82531
  subtreesUriTemplate,
@@ -82500,6 +82536,7 @@ async function normalizeImplicitTileHeaders(tileset) {
82500
82536
  basePath,
82501
82537
  lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
82502
82538
  rootLodMetricValue,
82539
+ rootBoundingVolume,
82503
82540
  getTileType,
82504
82541
  getRefine
82505
82542
  };
@@ -83162,11 +83199,11 @@ function generateAttributes(attributes) {
83162
83199
  colors
83163
83200
  };
83164
83201
  }
83165
- const { faceRange, featureCount, featureIds } = calculateFaceRangesAndFeaturesCount(featureIndices);
83166
- const attributeObjects = makeAttributeObjects({ faceRange, featureIds, ...attributes });
83202
+ const data = calculateFaceRangesAndFeaturesCount(featureIndices);
83203
+ const attributeObjects = makeAttributeObjects({ ...data, ...attributes });
83167
83204
  const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
83168
- const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds);
83169
- return { featureCount, ...groupedAttributes };
83205
+ const groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
83206
+ return groupedAttributes;
83170
83207
  }
83171
83208
  function calculateFaceRangesAndFeaturesCount(featureIndices) {
83172
83209
  let rangeIndex = 1;
@@ -83196,7 +83233,14 @@ function calculateFaceRangesAndFeaturesCount(featureIndices) {
83196
83233
  return { faceRange, featureCount, featureIds };
83197
83234
  }
83198
83235
  function makeAttributeObjects(attributes) {
83199
- const { featureIds, positions, normals, colors, texCoords, faceRange } = attributes;
83236
+ const {
83237
+ featureIds,
83238
+ positions,
83239
+ normals,
83240
+ colors,
83241
+ texCoords,
83242
+ faceRange = new Uint32Array(0)
83243
+ } = attributes;
83200
83244
  const groupedData = [];
83201
83245
  let positionsList = new Float32Array(positions);
83202
83246
  let normalsList = new Float32Array(normals);
@@ -83258,9 +83302,9 @@ function unifyObjectsByFeatureId(sortedData) {
83258
83302
  }
83259
83303
  return uniqueObjects;
83260
83304
  }
83261
- function groupAttributesAndRangesByFeatureId(unifiedObjects) {
83305
+ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
83262
83306
  const firstAttributeObject = unifiedObjects[0];
83263
- const featureIds = [firstAttributeObject.featureId];
83307
+ const featureIds = [firstAttributeObject.featureId || 0];
83264
83308
  let positions = new Float32Array(firstAttributeObject.positions);
83265
83309
  let normals = new Float32Array(firstAttributeObject.normals);
83266
83310
  let colors = new Uint8Array(firstAttributeObject.colors);
@@ -83270,7 +83314,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
83270
83314
  let sum = 0;
83271
83315
  for (let index = 1; index < unifiedObjects.length; index++) {
83272
83316
  const currentAttributesObject = unifiedObjects[index];
83273
- featureIds.push(currentAttributesObject.featureId);
83317
+ featureIds.push(currentAttributesObject.featureId || 0);
83274
83318
  positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
83275
83319
  normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
83276
83320
  colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
@@ -83283,13 +83327,13 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
83283
83327
  }
83284
83328
  range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);
83285
83329
  const faceRange = new Uint32Array(range);
83286
- return { faceRange, featureIds, positions, normals, colors, texCoords };
83330
+ return { faceRange, featureIds, positions, normals, colors, texCoords, featureCount };
83287
83331
  }
83288
83332
 
83289
83333
  // src/i3s-converter/helpers/coordinate-converter.ts
83290
83334
  var import_core20 = __toModule(require_es54());
83291
83335
  var import_geospatial7 = __toModule(require_es55());
83292
- var import_culling4 = __toModule(require_es57());
83336
+ var import_culling5 = __toModule(require_es57());
83293
83337
  function createBoundingVolumes(tile, geoidHeightModel) {
83294
83338
  let radius;
83295
83339
  let halfSize;
@@ -83297,7 +83341,7 @@ function createBoundingVolumes(tile, geoidHeightModel) {
83297
83341
  const boundingVolume = tile.boundingVolume;
83298
83342
  const cartographicCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new import_core20.Vector3());
83299
83343
  cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
83300
- if (boundingVolume instanceof import_culling4.OrientedBoundingBox) {
83344
+ if (boundingVolume instanceof import_culling5.OrientedBoundingBox) {
83301
83345
  halfSize = boundingVolume.halfSize;
83302
83346
  radius = new import_core20.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
83303
83347
  quaternion = boundingVolume.quaternion;
@@ -83317,8 +83361,8 @@ function createBoundingVolumes(tile, geoidHeightModel) {
83317
83361
  }
83318
83362
  function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel) {
83319
83363
  const positionVectors = convertPositionsToVectors(cartesianPositions);
83320
- const geometryObb = (0, import_culling4.makeOrientedBoundingBoxFromPoints)(positionVectors);
83321
- const geometryMbs = (0, import_culling4.makeBoundingSphereFromPoints)(positionVectors);
83364
+ const geometryObb = (0, import_culling5.makeOrientedBoundingBoxFromPoints)(positionVectors);
83365
+ const geometryMbs = (0, import_culling5.makeBoundingSphereFromPoints)(positionVectors);
83322
83366
  let mbsCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core20.Vector3());
83323
83367
  let obbCenter = import_geospatial7.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core20.Vector3());
83324
83368
  mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
@@ -83361,10 +83405,12 @@ function createObbFromMbs(mbs) {
83361
83405
  const radius = mbs[3];
83362
83406
  const center = new import_core20.Vector3(mbs[0], mbs[1], mbs[2]);
83363
83407
  const halfAxex = new import_core20.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
83364
- return new import_culling4.OrientedBoundingBox(center, halfAxex);
83408
+ return new import_culling5.OrientedBoundingBox(center, halfAxex);
83365
83409
  }
83366
83410
 
83367
83411
  // src/i3s-converter/helpers/geometry-converter.js
83412
+ var DEFAULT_ROUGHNESS_FACTOR = 1;
83413
+ var DEFAULT_METALLIC_FACTOR = 1;
83368
83414
  var VALUES_PER_VERTEX2 = 3;
83369
83415
  var VALUES_PER_TEX_COORD = 2;
83370
83416
  var VALUES_PER_COLOR_ELEMENT = 4;
@@ -83503,14 +83549,30 @@ function convertNodes(nodes, tileContent, attributesMap, useCartesianPositions,
83503
83549
  }
83504
83550
  }
83505
83551
  }
83552
+ function getCompositeTransformationMatrix(node2, matrix) {
83553
+ let transformationMatrix = matrix;
83554
+ const { matrix: nodeMatrix, rotation, scale, translation } = node2;
83555
+ if (nodeMatrix) {
83556
+ transformationMatrix = matrix.multiplyRight(nodeMatrix);
83557
+ }
83558
+ if (rotation) {
83559
+ transformationMatrix = transformationMatrix.rotateXYZ(rotation);
83560
+ }
83561
+ if (scale) {
83562
+ transformationMatrix = transformationMatrix.scale(scale);
83563
+ }
83564
+ if (translation) {
83565
+ transformationMatrix = transformationMatrix.translate(translation);
83566
+ }
83567
+ return transformationMatrix;
83568
+ }
83506
83569
  function convertNode(node2, tileContent, attributesMap, useCartesianPositions, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
83507
- const nodeMatrix = node2.matrix;
83508
- const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
83570
+ const transformationMatrix = getCompositeTransformationMatrix(node2, matrix);
83509
83571
  const mesh = node2.mesh;
83510
83572
  if (mesh) {
83511
- convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, compositeMatrix);
83573
+ convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
83512
83574
  }
83513
- convertNodes(node2.children, tileContent, attributesMap, useCartesianPositions, compositeMatrix);
83575
+ convertNodes(node2.children, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
83514
83576
  }
83515
83577
  function convertMesh(mesh, content, attributesMap, useCartesianPositions = false, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
83516
83578
  for (const primitive of mesh.primitives) {
@@ -83652,12 +83714,12 @@ function convertMaterial(sourceMaterial) {
83652
83714
  emissiveFactor: sourceMaterial.emissiveFactor.map((c) => Math.round(c * 255)),
83653
83715
  alphaMode: (sourceMaterial.alphaMode || "OPAQUE").toLowerCase(),
83654
83716
  pbrMetallicRoughness: {
83655
- roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
83656
- metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
83717
+ roughnessFactor: sourceMaterial?.pbrMetallicRoughness?.roughnessFactor || DEFAULT_ROUGHNESS_FACTOR,
83718
+ metallicFactor: sourceMaterial?.pbrMetallicRoughness?.metallicFactor || DEFAULT_METALLIC_FACTOR
83657
83719
  }
83658
83720
  };
83659
83721
  let texture;
83660
- if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
83722
+ if (sourceMaterial?.pbrMetallicRoughness?.baseColorTexture) {
83661
83723
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
83662
83724
  material.pbrMetallicRoughness.baseColorTexture = {
83663
83725
  textureSetDefinitionId: 0
@@ -83669,7 +83731,7 @@ function convertMaterial(sourceMaterial) {
83669
83731
  };
83670
83732
  }
83671
83733
  if (!texture) {
83672
- const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
83734
+ const baseColorFactor = sourceMaterial?.pbrMetallicRoughness?.baseColorFactor;
83673
83735
  material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map((c) => Math.round(c * 255)) || void 0;
83674
83736
  }
83675
83737
  return { material, texture };
@@ -83698,12 +83760,12 @@ function getSharedResources(tileContent, nodeId) {
83698
83760
  return i3sResources;
83699
83761
  }
83700
83762
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
83701
- const texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
83763
+ const texture = gltfMaterial?.pbrMetallicRoughness?.baseColorTexture || gltfMaterial.emissiveTexture;
83702
83764
  let textureDefinitionInfo = null;
83703
83765
  if (texture) {
83704
83766
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
83705
83767
  }
83706
- const { baseColorFactor, metallicFactor } = gltfMaterial.pbrMetallicRoughness;
83768
+ const { baseColorFactor, metallicFactor } = gltfMaterial?.pbrMetallicRoughness || {};
83707
83769
  let colorFactor = baseColorFactor;
83708
83770
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
83709
83771
  colorFactor = gltfMaterial.emissiveFactor;
@@ -83714,7 +83776,7 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
83714
83776
  textureDefinitionInfo
83715
83777
  };
83716
83778
  }
83717
- function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {
83779
+ function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 1) {
83718
83780
  const matDielectricColorComponent = 0.04 / 255;
83719
83781
  const black = new import_core21.Vector4(0, 0, 0, 1);
83720
83782
  const unitVector = new import_core21.Vector4(1, 1, 1, 1);
@@ -84501,12 +84563,12 @@ function transfromTextureDefinitions(textureDefinitionInfos, thisObject, origina
84501
84563
  }
84502
84564
 
84503
84565
  // src/i3s-converter/helpers/node-debug.ts
84504
- var import_culling5 = __toModule(require_es57());
84566
+ var import_culling6 = __toModule(require_es57());
84505
84567
  var import_engine = __toModule(require_es514());
84506
84568
  var import_core23 = __toModule(require_es54());
84507
84569
  var import_geospatial9 = __toModule(require_es55());
84508
84570
  function validateNodeBoundingVolumes(node2) {
84509
- if (!node2.parentNode.obb || !node2.parentNode.mbs) {
84571
+ if (!node2?.parentNode?.obb || !node2?.parentNode?.mbs) {
84510
84572
  return [];
84511
84573
  }
84512
84574
  const tileWarnings = [];
@@ -84521,7 +84583,7 @@ function validateObb(tileWarnings, node2) {
84521
84583
  if (isTileObbInsideParentObb) {
84522
84584
  return;
84523
84585
  }
84524
- const title = `OBB of Tile (${node2.id}) doesn't fit into Parent (${node2.parentNode.id}) tile OBB`;
84586
+ const title = `OBB of Tile (${node2.id}) doesn't fit into Parent (${node2.parentNode?.id}) tile OBB`;
84525
84587
  tileWarnings.push(title);
84526
84588
  }
84527
84589
  function validateMbs(tileWarnings, node2) {
@@ -84529,16 +84591,16 @@ function validateMbs(tileWarnings, node2) {
84529
84591
  const parentMbs = createBoundingSphereFromTileMbs(node2.parentNode.mbs);
84530
84592
  const distanceBetweenCenters = tileMbs.center.distanceTo(parentMbs.center);
84531
84593
  if (distanceBetweenCenters + tileMbs.radius > parentMbs.radius) {
84532
- const title = `MBS of Tile (${node2.id}) doesn't fit into Parent (${node2.parentNode.id}) tile MBS`;
84594
+ const title = `MBS of Tile (${node2.id}) doesn't fit into Parent (${node2.parentNode?.id}) tile MBS`;
84533
84595
  tileWarnings.push(title);
84534
84596
  }
84535
84597
  }
84536
84598
  function createBoundingSphereFromTileMbs(mbs) {
84537
- 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]);
84538
84600
  }
84539
84601
  function createBoundingBoxFromTileObb(obb) {
84540
84602
  const { center, halfSize, quaternion } = obb;
84541
- return new import_culling5.OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);
84603
+ return new import_culling6.OrientedBoundingBox().fromCenterHalfSizeQuaternion(center, halfSize, quaternion);
84542
84604
  }
84543
84605
  function getTileObbVertices(node2) {
84544
84606
  const geometry = new import_engine.CubeGeometry();
@@ -85042,12 +85104,13 @@ var I3SConverter = class {
85042
85104
  }
85043
85105
  }
85044
85106
  async writeTextureFile(textureData, name8, format, childPath, slpkChildPath) {
85045
- const texturePath = (0, import_path7.join)(childPath, `textures/${name8}/`);
85046
- await writeFile3(texturePath, textureData, `index.${format}`);
85047
85107
  if (this.options.slpk) {
85048
85108
  const slpkTexturePath = (0, import_path7.join)(childPath, "textures");
85049
85109
  const compress = false;
85050
85110
  this.fileMap[`${slpkChildPath}/textures/${name8}.${format}`] = await writeFileForSlpk(slpkTexturePath, textureData, `${name8}.${format}`, compress);
85111
+ } else {
85112
+ const texturePath = (0, import_path7.join)(childPath, `textures/${name8}/`);
85113
+ await writeFile3(texturePath, textureData, `index.${format}`);
85051
85114
  }
85052
85115
  }
85053
85116
  async _writeAttributes(attributes, childPath, slpkChildPath) {
@@ -85765,7 +85828,7 @@ async function parse6(data, options, context) {
85765
85828
  }
85766
85829
 
85767
85830
  // ../i3s/src/lib/parsers/parse-i3s.ts
85768
- var import_culling6 = __toModule(require_es57());
85831
+ var import_culling7 = __toModule(require_es57());
85769
85832
  var import_geospatial11 = __toModule(require_es55());
85770
85833
 
85771
85834
  // ../i3s/src/i3s-node-page-loader.ts
@@ -85991,7 +86054,7 @@ function normalizeTileNonUrlData(tile) {
85991
86054
  ...tile.obb.halfSize,
85992
86055
  ...tile.obb.quaternion
85993
86056
  ];
85994
- 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);
85995
86058
  const boundingSphere = obb.getBoundingSphere();
85996
86059
  boundingVolume.sphere = [...boundingSphere.center, boundingSphere.radius];
85997
86060
  mbs = [...tile.obb.center, boundingSphere.radius];
@@ -86011,7 +86074,13 @@ async function normalizeTilesetData(tileset, options, context) {
86011
86074
  } else {
86012
86075
  const rootNodeUrl = getUrlWithToken(`${tileset.url}/nodes/root`, options.i3s?.token);
86013
86076
  tileset.root = await load(rootNodeUrl, tileset.loader, {
86014
- i3s: { loadContent: false, isTileHeader: true, isTileset: false }
86077
+ ...options,
86078
+ i3s: {
86079
+ ...options.i3s,
86080
+ loadContent: false,
86081
+ isTileHeader: true,
86082
+ isTileset: false
86083
+ }
86015
86084
  });
86016
86085
  }
86017
86086
  tileset.basePath = tileset.url;
@@ -86178,7 +86247,7 @@ async function parse8(data, options) {
86178
86247
  // src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts
86179
86248
  var import_core30 = __toModule(require_es54());
86180
86249
  var import_geospatial12 = __toModule(require_es55());
86181
- var import_culling7 = __toModule(require_es57());
86250
+ var import_culling8 = __toModule(require_es57());
86182
86251
  function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
86183
86252
  const tiles3DCenter = [
86184
86253
  i3SObb.center[0],
@@ -86186,7 +86255,7 @@ function i3sObbTo3dTilesObb(i3SObb, geoidHeightModel) {
86186
86255
  i3SObb.center[2] + geoidHeightModel.getHeight(i3SObb.center[1], i3SObb.center[0])
86187
86256
  ];
86188
86257
  const cartesianCenter = import_geospatial12.Ellipsoid.WGS84.cartographicToCartesian(tiles3DCenter, new import_core30.Vector3());
86189
- 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);
86190
86259
  return [...tiles3DObb.center, ...tiles3DObb.halfAxes.toArray()];
86191
86260
  }
86192
86261
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"names":["createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;SASsBA,qB;;;;;qFAAf,iBAAqCC,SAArC,EAAgDC,OAAhD,EAAyDC,QAAzD;AAAA;AAAA;AAAA;AAAA;AAAA;AACCC,YAAAA,eADD,GACmB;AACtBC,cAAAA,aAAa,EAAE,gBAASC,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,cAAAA,SAAS,EAATA,SAFsB;AAGtBC,cAAAA,OAAO,EAAPA;AAHsB,aADnB;AAOCK,YAAAA,WAPD,GAOe,+BAAUH,eAAV,EAA2B,gCAA3B,CAPf;AAQCI,YAAAA,YARD,GAQgB,gBAAKL,QAAL,EAAe,aAAf,CARhB;AAAA;AAAA,mBASC,0BAAUK,YAAV,EAAwBC,IAAI,CAACC,SAAL,CAAeH,WAAf,CAAxB,CATD;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param {string} layerName - layer name to display\n * @param {object} layers0 - layer object embedded into sceneServer meta data\n * @param {string} rootPath - root path of new converted tileset\n * @return {promise}\n */\nexport async function createSceneServerPath(layerName, layers0, rootPath) {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
1
+ {"version":3,"sources":["../../../../src/i3s-converter/helpers/create-scene-server-path.ts"],"names":["createSceneServerPath","layerName","layers0","rootPath","sceneServerData","serviceItemId","replace","sceneServer","nodePagePath","JSON","stringify"],"mappings":";;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;;AACA;;SAQsBA,qB;;;;;qFAAf,iBACLC,SADK,EAELC,OAFK,EAGLC,QAHK;AAAA;AAAA;AAAA;AAAA;AAAA;AAKCC,YAAAA,eALD,GAKmB;AACtBC,cAAAA,aAAa,EAAE,gBAASC,OAAT,CAAiB,KAAjB,EAAwB,EAAxB,CADO;AAEtBL,cAAAA,SAAS,EAATA,SAFsB;AAGtBC,cAAAA,OAAO,EAAPA;AAHsB,aALnB;AAWCK,YAAAA,WAXD,GAWe,+BAAUH,eAAV,EAA2B,gCAA3B,CAXf;AAYCI,YAAAA,YAZD,GAYgB,gBAAKL,QAAL,EAAe,aAAf,CAZhB;AAAA;AAAA,mBAaC,0BAAUK,YAAV,EAAwBC,IAAI,CAACC,SAAL,CAAeH,WAAf,CAAxB,CAbD;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {SceneLayer3D} from '@loaders.gl/i3s';\nimport {v4 as uuidv4} from 'uuid';\nimport transform from 'json-map-transform';\nimport {join} from 'path';\n\nimport {SCENE_SERVER as sceneServerTemplate} from '../json-templates/scene-server';\nimport {writeFile} from '../../lib/utils/file-utils';\n\n/**\n * Form and save sceneServer meta data into a file\n * @param layerName - layer name to display\n * @param layers0 - layer object embedded into sceneServer meta data\n * @param rootPath - root path of new converted tileset\n */\nexport async function createSceneServerPath(\n layerName: string,\n layers0: SceneLayer3D,\n rootPath: string\n): Promise<void> {\n const sceneServerData = {\n serviceItemId: uuidv4().replace(/-/gi, ''),\n layerName,\n layers0\n };\n\n const sceneServer = transform(sceneServerData, sceneServerTemplate());\n const nodePagePath = join(rootPath, 'SceneServer');\n await writeFile(nodePagePath, JSON.stringify(sceneServer));\n}\n"],"file":"create-scene-server-path.js"}
@@ -38,20 +38,11 @@ function generateAttributes(attributes) {
38
38
  };
39
39
  }
40
40
 
41
- var _calculateFaceRangesA = calculateFaceRangesAndFeaturesCount(featureIndices),
42
- faceRange = _calculateFaceRangesA.faceRange,
43
- featureCount = _calculateFaceRangesA.featureCount,
44
- featureIds = _calculateFaceRangesA.featureIds;
45
-
46
- var attributeObjects = makeAttributeObjects(_objectSpread({
47
- faceRange: faceRange,
48
- featureIds: featureIds
49
- }, attributes));
41
+ var data = calculateFaceRangesAndFeaturesCount(featureIndices);
42
+ var attributeObjects = makeAttributeObjects(_objectSpread(_objectSpread({}, data), attributes));
50
43
  var unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);
51
- var groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds);
52
- return _objectSpread({
53
- featureCount: featureCount
54
- }, groupedAttributes);
44
+ var groupedAttributes = groupAttributesAndRangesByFeatureId(unifiedAttributeObjectsByFeatureIds, data.featureCount);
45
+ return groupedAttributes;
55
46
  }
56
47
 
57
48
  function calculateFaceRangesAndFeaturesCount(featureIndices) {
@@ -97,7 +88,8 @@ function makeAttributeObjects(attributes) {
97
88
  normals = attributes.normals,
98
89
  colors = attributes.colors,
99
90
  texCoords = attributes.texCoords,
100
- faceRange = attributes.faceRange;
91
+ _attributes$faceRange = attributes.faceRange,
92
+ faceRange = _attributes$faceRange === void 0 ? new Uint32Array(0) : _attributes$faceRange;
101
93
  var groupedData = [];
102
94
  var positionsList = new Float32Array(positions);
103
95
  var normalsList = new Float32Array(normals);
@@ -179,9 +171,9 @@ function unifyObjectsByFeatureId(sortedData) {
179
171
  return uniqueObjects;
180
172
  }
181
173
 
182
- function groupAttributesAndRangesByFeatureId(unifiedObjects) {
174
+ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
183
175
  var firstAttributeObject = unifiedObjects[0];
184
- var featureIds = [firstAttributeObject.featureId];
176
+ var featureIds = [firstAttributeObject.featureId || 0];
185
177
  var positions = new Float32Array(firstAttributeObject.positions);
186
178
  var normals = new Float32Array(firstAttributeObject.normals);
187
179
  var colors = new Uint8Array(firstAttributeObject.colors);
@@ -192,7 +184,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
192
184
 
193
185
  for (var index = 1; index < unifiedObjects.length; index++) {
194
186
  var currentAttributesObject = unifiedObjects[index];
195
- featureIds.push(currentAttributesObject.featureId);
187
+ featureIds.push(currentAttributesObject.featureId || 0);
196
188
  positions = (0, _loaderUtils.concatenateTypedArrays)(positions, currentAttributesObject.positions);
197
189
  normals = (0, _loaderUtils.concatenateTypedArrays)(normals, currentAttributesObject.normals);
198
190
  colors = (0, _loaderUtils.concatenateTypedArrays)(colors, currentAttributesObject.colors);
@@ -212,7 +204,8 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects) {
212
204
  positions: positions,
213
205
  normals: normals,
214
206
  colors: colors,
215
- texCoords: texCoords
207
+ texCoords: texCoords,
208
+ featureCount: featureCount
216
209
  };
217
210
  }
218
211
  //# sourceMappingURL=geometry-attributes.js.map