@loaders.gl/tile-converter 3.3.0-alpha.2 → 3.3.0-alpha.4

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 (88) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
  3. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  4. package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
  5. package/dist/converter.min.js +21 -21
  6. package/dist/deps-installer/deps-installer.d.ts +5 -1
  7. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  8. package/dist/deps-installer/deps-installer.js +21 -1
  9. package/dist/dist.min.js +671 -1028
  10. package/dist/es5/3d-tiles-attributes-worker.js +1 -1
  11. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +115 -101
  12. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  13. package/dist/es5/deps-installer/deps-installer.js +70 -6
  14. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  15. package/dist/es5/i3s-attributes-worker.js +1 -1
  16. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -0
  18. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  20. package/dist/es5/i3s-converter/helpers/feature-attributes.js +153 -0
  21. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  22. package/dist/es5/i3s-converter/helpers/geometry-converter.js +40 -44
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  24. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +55 -36
  25. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/node-pages.js +10 -2
  27. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  28. package/dist/es5/i3s-converter/i3s-converter.js +364 -435
  29. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  30. package/dist/es5/pgm-loader.js +1 -1
  31. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  32. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +59 -44
  33. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  34. package/dist/esm/deps-installer/deps-installer.js +21 -2
  35. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  36. package/dist/esm/i3s-attributes-worker.js +1 -1
  37. package/dist/esm/i3s-attributes-worker.js.map +1 -1
  38. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -0
  39. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  41. package/dist/esm/i3s-converter/helpers/feature-attributes.js +138 -0
  42. package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -21
  44. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  45. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +55 -36
  46. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  47. package/dist/esm/i3s-converter/helpers/node-pages.js +9 -2
  48. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  49. package/dist/esm/i3s-converter/i3s-converter.js +93 -183
  50. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  51. package/dist/esm/pgm-loader.js +1 -1
  52. package/dist/i3s-attributes-worker.d.ts +5 -1
  53. package/dist/i3s-attributes-worker.d.ts.map +1 -1
  54. package/dist/i3s-attributes-worker.js +3 -3
  55. package/dist/i3s-attributes-worker.js.map +2 -2
  56. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +2 -3
  57. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  58. package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -0
  59. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
  60. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  61. package/dist/i3s-converter/helpers/feature-attributes.d.ts +32 -0
  62. package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
  63. package/dist/i3s-converter/helpers/feature-attributes.js +162 -1
  64. package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -4
  65. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/helpers/geometry-converter.js +29 -27
  67. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
  68. package/dist/i3s-converter/helpers/gltf-attributes.js +50 -30
  69. package/dist/i3s-converter/helpers/node-pages.d.ts +4 -0
  70. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  71. package/dist/i3s-converter/helpers/node-pages.js +9 -2
  72. package/dist/i3s-converter/i3s-converter.d.ts +24 -48
  73. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  74. package/dist/i3s-converter/i3s-converter.js +88 -186
  75. package/dist/i3s-converter/types.d.ts +4 -0
  76. package/dist/i3s-converter/types.d.ts.map +1 -1
  77. package/package.json +15 -15
  78. package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
  79. package/src/deps-installer/deps-installer.ts +29 -2
  80. package/src/i3s-attributes-worker.ts +5 -1
  81. package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -6
  82. package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
  83. package/src/i3s-converter/helpers/feature-attributes.ts +182 -0
  84. package/src/i3s-converter/helpers/geometry-converter.ts +45 -36
  85. package/src/i3s-converter/helpers/gltf-attributes.ts +54 -33
  86. package/src/i3s-converter/helpers/node-pages.ts +10 -2
  87. package/src/i3s-converter/i3s-converter.ts +125 -210
  88. package/src/i3s-converter/types.ts +4 -0
package/dist/dist.min.js CHANGED
@@ -5259,15 +5259,15 @@ var require_vector3 = __commonJS({
5259
5259
  }
5260
5260
  var ORIGIN = [0, 0, 0];
5261
5261
  var constants = {};
5262
- var Vector321 = function(_Vector) {
5263
- (0, _inherits2.default)(Vector322, _Vector);
5264
- var _super = _createSuper(Vector322);
5265
- function Vector322() {
5262
+ var Vector320 = function(_Vector) {
5263
+ (0, _inherits2.default)(Vector321, _Vector);
5264
+ var _super = _createSuper(Vector321);
5265
+ function Vector321() {
5266
5266
  var _this;
5267
5267
  var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
5268
5268
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
5269
5269
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
5270
- (0, _classCallCheck2.default)(this, Vector322);
5270
+ (0, _classCallCheck2.default)(this, Vector321);
5271
5271
  _this = _super.call(this, -0, -0, -0);
5272
5272
  if (arguments.length === 1 && (0, _common.isArray)(x)) {
5273
5273
  _this.copy(x);
@@ -5283,7 +5283,7 @@ var require_vector3 = __commonJS({
5283
5283
  }
5284
5284
  return _this;
5285
5285
  }
5286
- (0, _createClass2.default)(Vector322, [{
5286
+ (0, _createClass2.default)(Vector321, [{
5287
5287
  key: "set",
5288
5288
  value: function set(x, y, z) {
5289
5289
  this[0] = x;
@@ -5403,12 +5403,12 @@ var require_vector3 = __commonJS({
5403
5403
  }], [{
5404
5404
  key: "ZERO",
5405
5405
  get: function get() {
5406
- return constants.ZERO = constants.ZERO || Object.freeze(new Vector322(0, 0, 0, 0));
5406
+ return constants.ZERO = constants.ZERO || Object.freeze(new Vector321(0, 0, 0, 0));
5407
5407
  }
5408
5408
  }]);
5409
- return Vector322;
5409
+ return Vector321;
5410
5410
  }(_vector.default);
5411
- exports.default = Vector321;
5411
+ exports.default = Vector320;
5412
5412
  }
5413
5413
  });
5414
5414
 
@@ -8373,12 +8373,12 @@ var require_matrix4 = __commonJS({
8373
8373
  COL3ROW3: 15
8374
8374
  });
8375
8375
  var constants = {};
8376
- var Matrix411 = function(_Matrix) {
8377
- (0, _inherits2.default)(Matrix412, _Matrix);
8378
- var _super = _createSuper(Matrix412);
8379
- function Matrix412(array) {
8376
+ var Matrix410 = function(_Matrix) {
8377
+ (0, _inherits2.default)(Matrix411, _Matrix);
8378
+ var _super = _createSuper(Matrix411);
8379
+ function Matrix411(array) {
8380
8380
  var _this;
8381
- (0, _classCallCheck2.default)(this, Matrix412);
8381
+ (0, _classCallCheck2.default)(this, Matrix411);
8382
8382
  _this = _super.call(this, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
8383
8383
  if (arguments.length === 1 && Array.isArray(array)) {
8384
8384
  _this.copy(array);
@@ -8387,7 +8387,7 @@ var require_matrix4 = __commonJS({
8387
8387
  }
8388
8388
  return _this;
8389
8389
  }
8390
- (0, _createClass2.default)(Matrix412, [{
8390
+ (0, _createClass2.default)(Matrix411, [{
8391
8391
  key: "INDICES",
8392
8392
  get: function get() {
8393
8393
  return INDICES;
@@ -8502,7 +8502,7 @@ var require_matrix4 = __commonJS({
8502
8502
  value: function frustum(_ref) {
8503
8503
  var left = _ref.left, right = _ref.right, bottom = _ref.bottom, top = _ref.top, near = _ref.near, far = _ref.far;
8504
8504
  if (far === Infinity) {
8505
- Matrix412._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
8505
+ Matrix411._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
8506
8506
  } else {
8507
8507
  mat4.frustum(this, left, right, bottom, top, near, far);
8508
8508
  }
@@ -8539,7 +8539,7 @@ var require_matrix4 = __commonJS({
8539
8539
  var halfY = fovy / 2;
8540
8540
  var top = focalDistance * Math.tan(halfY);
8541
8541
  var right = top * aspect;
8542
- return new Matrix412().ortho({
8542
+ return new Matrix411().ortho({
8543
8543
  left: -right,
8544
8544
  right,
8545
8545
  bottom: -top,
@@ -8773,13 +8773,13 @@ var require_matrix4 = __commonJS({
8773
8773
  }], [{
8774
8774
  key: "IDENTITY",
8775
8775
  get: function get() {
8776
- constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix412(IDENTITY));
8776
+ constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix411(IDENTITY));
8777
8777
  return constants.IDENTITY;
8778
8778
  }
8779
8779
  }, {
8780
8780
  key: "ZERO",
8781
8781
  get: function get() {
8782
- constants.ZERO = constants.ZERO || Object.freeze(new Matrix412(ZERO));
8782
+ constants.ZERO = constants.ZERO || Object.freeze(new Matrix411(ZERO));
8783
8783
  return constants.ZERO;
8784
8784
  }
8785
8785
  }, {
@@ -8811,9 +8811,9 @@ var require_matrix4 = __commonJS({
8811
8811
  return result;
8812
8812
  }
8813
8813
  }]);
8814
- return Matrix412;
8814
+ return Matrix411;
8815
8815
  }(_matrix.default);
8816
- exports.default = Matrix411;
8816
+ exports.default = Matrix410;
8817
8817
  }
8818
8818
  });
8819
8819
 
@@ -10788,7 +10788,7 @@ var require_type_utils = __commonJS({
10788
10788
  var noop = function noop2(x) {
10789
10789
  return x;
10790
10790
  };
10791
- var scratchVector8 = new _core.Vector3();
10791
+ var scratchVector7 = new _core.Vector3();
10792
10792
  function fromCartographic(cartographic, result) {
10793
10793
  var map = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : noop;
10794
10794
  if ((0, _core.isArray)(cartographic)) {
@@ -10807,11 +10807,11 @@ var require_type_utils = __commonJS({
10807
10807
  return result;
10808
10808
  }
10809
10809
  function fromCartographicToRadians(cartographic) {
10810
- var vector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scratchVector8;
10810
+ var vector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scratchVector7;
10811
10811
  return fromCartographic(cartographic, vector, _core.config._cartographicRadians ? noop : _core.toRadians);
10812
10812
  }
10813
10813
  function fromCartographicToDegrees(cartographic) {
10814
- var vector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scratchVector8;
10814
+ var vector = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : scratchVector7;
10815
10815
  return fromCartographic(cartographic, vector, _core.config._cartographicRadians ? _core.toDegrees : noop);
10816
10816
  }
10817
10817
  function toCartographic(vector, cartographic) {
@@ -10841,7 +10841,7 @@ var require_type_utils = __commonJS({
10841
10841
  if (!vector) {
10842
10842
  return false;
10843
10843
  }
10844
- scratchVector8.from(vector);
10844
+ scratchVector7.from(vector);
10845
10845
  var oneOverRadiiSquared = _constants.WGS84_CONSTANTS.oneOverRadiiSquared, centerToleranceSquared = _constants.WGS84_CONSTANTS.centerToleranceSquared;
10846
10846
  var x2 = vector[0] * vector[0] * oneOverRadiiSquared[0];
10847
10847
  var y2 = vector[1] * vector[1] * oneOverRadiiSquared[1];
@@ -10900,13 +10900,13 @@ var require_scale_to_geodetic_surface = __commonJS({
10900
10900
  }
10901
10901
  return newObj;
10902
10902
  }
10903
- var scratchVector8 = new _core.Vector3();
10903
+ var scratchVector7 = new _core.Vector3();
10904
10904
  var scaleToGeodeticSurfaceIntersection = new _core.Vector3();
10905
10905
  var scaleToGeodeticSurfaceGradient = new _core.Vector3();
10906
10906
  function scaleToGeodeticSurface(cartesian, ellipsoid) {
10907
10907
  var result = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : new _core.Vector3();
10908
10908
  var oneOverRadii = ellipsoid.oneOverRadii, oneOverRadiiSquared = ellipsoid.oneOverRadiiSquared, centerToleranceSquared = ellipsoid.centerToleranceSquared;
10909
- scratchVector8.from(cartesian);
10909
+ scratchVector7.from(cartesian);
10910
10910
  var positionX = cartesian.x;
10911
10911
  var positionY = cartesian.y;
10912
10912
  var positionZ = cartesian.z;
@@ -10953,7 +10953,7 @@ var require_scale_to_geodetic_surface = __commonJS({
10953
10953
  var derivative = -2 * denominator;
10954
10954
  correction = func / derivative;
10955
10955
  } while (Math.abs(func) > _core._MathUtils.EPSILON12);
10956
- return scratchVector8.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
10956
+ return scratchVector7.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
10957
10957
  }
10958
10958
  }
10959
10959
  });
@@ -11139,19 +11139,19 @@ var require_ellipsoid = __commonJS({
11139
11139
  }
11140
11140
  return newObj;
11141
11141
  }
11142
- var scratchVector8 = new _core.Vector3();
11142
+ var scratchVector7 = new _core.Vector3();
11143
11143
  var scratchNormal2 = new _core.Vector3();
11144
11144
  var scratchK = new _core.Vector3();
11145
11145
  var scratchPosition3 = new _core.Vector3();
11146
11146
  var scratchHeight = new _core.Vector3();
11147
11147
  var scratchCartesian = new _core.Vector3();
11148
11148
  var wgs84;
11149
- var Ellipsoid15 = function() {
11150
- function Ellipsoid16() {
11149
+ var Ellipsoid14 = function() {
11150
+ function Ellipsoid15() {
11151
11151
  var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
11152
11152
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
11153
11153
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
11154
- (0, _classCallCheck2.default)(this, Ellipsoid16);
11154
+ (0, _classCallCheck2.default)(this, Ellipsoid15);
11155
11155
  (0, _core.assert)(x >= 0);
11156
11156
  (0, _core.assert)(y >= 0);
11157
11157
  (0, _core.assert)(z >= 0);
@@ -11168,7 +11168,7 @@ var require_ellipsoid = __commonJS({
11168
11168
  }
11169
11169
  Object.freeze(this);
11170
11170
  }
11171
- (0, _createClass2.default)(Ellipsoid16, [{
11171
+ (0, _createClass2.default)(Ellipsoid15, [{
11172
11172
  key: "equals",
11173
11173
  value: function equals(right) {
11174
11174
  return this === right || Boolean(right && this.radii.equals(right.radii));
@@ -11226,7 +11226,7 @@ var require_ellipsoid = __commonJS({
11226
11226
  key: "geocentricSurfaceNormal",
11227
11227
  value: function geocentricSurfaceNormal(cartesian) {
11228
11228
  var result = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0, 0, 0];
11229
- return scratchVector8.from(cartesian).normalize().to(result);
11229
+ return scratchVector7.from(cartesian).normalize().to(result);
11230
11230
  }
11231
11231
  }, {
11232
11232
  key: "geodeticSurfaceNormalCartographic",
@@ -11236,14 +11236,14 @@ var require_ellipsoid = __commonJS({
11236
11236
  var longitude = cartographicVectorRadians[0];
11237
11237
  var latitude = cartographicVectorRadians[1];
11238
11238
  var cosLatitude = Math.cos(latitude);
11239
- scratchVector8.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
11240
- return scratchVector8.to(result);
11239
+ scratchVector7.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
11240
+ return scratchVector7.to(result);
11241
11241
  }
11242
11242
  }, {
11243
11243
  key: "geodeticSurfaceNormal",
11244
11244
  value: function geodeticSurfaceNormal(cartesian) {
11245
11245
  var result = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0, 0, 0];
11246
- return scratchVector8.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
11246
+ return scratchVector7.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
11247
11247
  }
11248
11248
  }, {
11249
11249
  key: "scaleToGeodeticSurface",
@@ -11291,13 +11291,13 @@ var require_ellipsoid = __commonJS({
11291
11291
  }], [{
11292
11292
  key: "WGS84",
11293
11293
  get: function get() {
11294
- wgs84 = wgs84 || new Ellipsoid16(_constants.WGS84_RADIUS_X, _constants.WGS84_RADIUS_Y, _constants.WGS84_RADIUS_Z);
11294
+ wgs84 = wgs84 || new Ellipsoid15(_constants.WGS84_RADIUS_X, _constants.WGS84_RADIUS_Y, _constants.WGS84_RADIUS_Z);
11295
11295
  return wgs84;
11296
11296
  }
11297
11297
  }]);
11298
- return Ellipsoid16;
11298
+ return Ellipsoid15;
11299
11299
  }();
11300
- exports.default = Ellipsoid15;
11300
+ exports.default = Ellipsoid14;
11301
11301
  }
11302
11302
  });
11303
11303
 
@@ -11356,7 +11356,7 @@ var require_axis_aligned_bounding_box = __commonJS({
11356
11356
  var _createClass2 = _interopRequireDefault(require_createClass());
11357
11357
  var _core = require_es56();
11358
11358
  var _constants = require_constants2();
11359
- var scratchVector8 = new _core.Vector3();
11359
+ var scratchVector7 = new _core.Vector3();
11360
11360
  var scratchNormal2 = new _core.Vector3();
11361
11361
  var AxisAlignedBoundingBox = function() {
11362
11362
  function AxisAlignedBoundingBox2() {
@@ -11364,7 +11364,7 @@ var require_axis_aligned_bounding_box = __commonJS({
11364
11364
  var maximum = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [0, 0, 0];
11365
11365
  var center = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
11366
11366
  (0, _classCallCheck2.default)(this, AxisAlignedBoundingBox2);
11367
- center = center || scratchVector8.copy(minimum).add(maximum).scale(0.5);
11367
+ center = center || scratchVector7.copy(minimum).add(maximum).scale(0.5);
11368
11368
  this.center = new _core.Vector3(center);
11369
11369
  this.halfDiagonal = new _core.Vector3(maximum).subtract(this.center);
11370
11370
  this.minimum = new _core.Vector3(minimum);
@@ -11412,7 +11412,7 @@ var require_axis_aligned_bounding_box = __commonJS({
11412
11412
  }, {
11413
11413
  key: "distanceSquaredTo",
11414
11414
  value: function distanceSquaredTo(point) {
11415
- var offset = scratchVector8.from(point).subtract(this.center);
11415
+ var offset = scratchVector7.from(point).subtract(this.center);
11416
11416
  var halfDiagonal = this.halfDiagonal;
11417
11417
  var distanceSquared = 0;
11418
11418
  var d;
@@ -11490,7 +11490,7 @@ var require_bounding_sphere = __commonJS({
11490
11490
  }
11491
11491
  return newObj;
11492
11492
  }
11493
- var scratchVector8 = new _core.Vector3();
11493
+ var scratchVector7 = new _core.Vector3();
11494
11494
  var scratchVector23 = new _core.Vector3();
11495
11495
  var BoundingSphere5 = function() {
11496
11496
  function BoundingSphere6() {
@@ -11511,7 +11511,7 @@ var require_bounding_sphere = __commonJS({
11511
11511
  }, {
11512
11512
  key: "fromCornerPoints",
11513
11513
  value: function fromCornerPoints(corner, oppositeCorner) {
11514
- oppositeCorner = scratchVector8.from(oppositeCorner);
11514
+ oppositeCorner = scratchVector7.from(oppositeCorner);
11515
11515
  this.center = new _core.Vector3().from(corner).add(oppositeCorner).scale(0.5);
11516
11516
  this.radius = this.center.distance(oppositeCorner);
11517
11517
  return this;
@@ -11533,7 +11533,7 @@ var require_bounding_sphere = __commonJS({
11533
11533
  var leftRadius = this.radius;
11534
11534
  var rightCenter = boundingSphere.center;
11535
11535
  var rightRadius = boundingSphere.radius;
11536
- var toRightCenter = scratchVector8.copy(rightCenter).subtract(leftCenter);
11536
+ var toRightCenter = scratchVector7.copy(rightCenter).subtract(leftCenter);
11537
11537
  var centerSeparation = toRightCenter.magnitude();
11538
11538
  if (leftRadius >= centerSeparation + rightRadius) {
11539
11539
  return this.clone();
@@ -11550,7 +11550,7 @@ var require_bounding_sphere = __commonJS({
11550
11550
  }, {
11551
11551
  key: "expand",
11552
11552
  value: function expand(point) {
11553
- point = scratchVector8.from(point);
11553
+ point = scratchVector7.from(point);
11554
11554
  var radius = point.subtract(this.center).magnitude();
11555
11555
  if (radius > this.radius) {
11556
11556
  this.radius = radius;
@@ -11561,14 +11561,14 @@ var require_bounding_sphere = __commonJS({
11561
11561
  key: "transform",
11562
11562
  value: function transform9(_transform) {
11563
11563
  this.center.transform(_transform);
11564
- var scale = mat4.getScaling(scratchVector8, _transform);
11564
+ var scale = mat4.getScaling(scratchVector7, _transform);
11565
11565
  this.radius = Math.max(scale[0], Math.max(scale[1], scale[2])) * this.radius;
11566
11566
  return this;
11567
11567
  }
11568
11568
  }, {
11569
11569
  key: "distanceSquaredTo",
11570
11570
  value: function distanceSquaredTo(point) {
11571
- point = scratchVector8.from(point);
11571
+ point = scratchVector7.from(point);
11572
11572
  var delta = point.subtract(this.center);
11573
11573
  return delta.lengthSquared() - this.radius * this.radius;
11574
11574
  }
@@ -60808,15 +60808,15 @@ var require_vector32 = __commonJS({
60808
60808
  }
60809
60809
  var ORIGIN = [0, 0, 0];
60810
60810
  var constants = {};
60811
- var Vector321 = function(_Vector) {
60812
- (0, _inherits2.default)(Vector322, _Vector);
60813
- var _super = _createSuper(Vector322);
60814
- function Vector322() {
60811
+ var Vector320 = function(_Vector) {
60812
+ (0, _inherits2.default)(Vector321, _Vector);
60813
+ var _super = _createSuper(Vector321);
60814
+ function Vector321() {
60815
60815
  var _this;
60816
60816
  var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
60817
60817
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
60818
60818
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
60819
- (0, _classCallCheck2.default)(this, Vector322);
60819
+ (0, _classCallCheck2.default)(this, Vector321);
60820
60820
  _this = _super.call(this, -0, -0, -0);
60821
60821
  if (arguments.length === 1 && (0, _common.isArray)(x)) {
60822
60822
  _this.copy(x);
@@ -60832,7 +60832,7 @@ var require_vector32 = __commonJS({
60832
60832
  }
60833
60833
  return _this;
60834
60834
  }
60835
- (0, _createClass2.default)(Vector322, [{
60835
+ (0, _createClass2.default)(Vector321, [{
60836
60836
  key: "set",
60837
60837
  value: function set(x, y, z) {
60838
60838
  this[0] = x;
@@ -60952,12 +60952,12 @@ var require_vector32 = __commonJS({
60952
60952
  }], [{
60953
60953
  key: "ZERO",
60954
60954
  get: function get() {
60955
- return constants.ZERO = constants.ZERO || Object.freeze(new Vector322(0, 0, 0, 0));
60955
+ return constants.ZERO = constants.ZERO || Object.freeze(new Vector321(0, 0, 0, 0));
60956
60956
  }
60957
60957
  }]);
60958
- return Vector322;
60958
+ return Vector321;
60959
60959
  }(_vector.default);
60960
- exports.default = Vector321;
60960
+ exports.default = Vector320;
60961
60961
  }
60962
60962
  });
60963
60963
 
@@ -61707,12 +61707,12 @@ var require_matrix42 = __commonJS({
61707
61707
  COL3ROW3: 15
61708
61708
  });
61709
61709
  var constants = {};
61710
- var Matrix411 = function(_Matrix) {
61711
- (0, _inherits2.default)(Matrix412, _Matrix);
61712
- var _super = _createSuper(Matrix412);
61713
- function Matrix412(array) {
61710
+ var Matrix410 = function(_Matrix) {
61711
+ (0, _inherits2.default)(Matrix411, _Matrix);
61712
+ var _super = _createSuper(Matrix411);
61713
+ function Matrix411(array) {
61714
61714
  var _this;
61715
- (0, _classCallCheck2.default)(this, Matrix412);
61715
+ (0, _classCallCheck2.default)(this, Matrix411);
61716
61716
  _this = _super.call(this, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
61717
61717
  if (arguments.length === 1 && Array.isArray(array)) {
61718
61718
  _this.copy(array);
@@ -61721,7 +61721,7 @@ var require_matrix42 = __commonJS({
61721
61721
  }
61722
61722
  return _this;
61723
61723
  }
61724
- (0, _createClass2.default)(Matrix412, [{
61724
+ (0, _createClass2.default)(Matrix411, [{
61725
61725
  key: "INDICES",
61726
61726
  get: function get() {
61727
61727
  return INDICES;
@@ -61836,7 +61836,7 @@ var require_matrix42 = __commonJS({
61836
61836
  value: function frustum(_ref) {
61837
61837
  var left = _ref.left, right = _ref.right, bottom = _ref.bottom, top = _ref.top, near = _ref.near, far = _ref.far;
61838
61838
  if (far === Infinity) {
61839
- Matrix412._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
61839
+ Matrix411._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
61840
61840
  } else {
61841
61841
  mat4.frustum(this, left, right, bottom, top, near, far);
61842
61842
  }
@@ -61873,7 +61873,7 @@ var require_matrix42 = __commonJS({
61873
61873
  var halfY = fovy / 2;
61874
61874
  var top = focalDistance * Math.tan(halfY);
61875
61875
  var right = top * aspect;
61876
- return new Matrix412().ortho({
61876
+ return new Matrix411().ortho({
61877
61877
  left: -right,
61878
61878
  right,
61879
61879
  bottom: -top,
@@ -62107,13 +62107,13 @@ var require_matrix42 = __commonJS({
62107
62107
  }], [{
62108
62108
  key: "IDENTITY",
62109
62109
  get: function get() {
62110
- constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix412(IDENTITY));
62110
+ constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix411(IDENTITY));
62111
62111
  return constants.IDENTITY;
62112
62112
  }
62113
62113
  }, {
62114
62114
  key: "ZERO",
62115
62115
  get: function get() {
62116
- constants.ZERO = constants.ZERO || Object.freeze(new Matrix412(ZERO));
62116
+ constants.ZERO = constants.ZERO || Object.freeze(new Matrix411(ZERO));
62117
62117
  return constants.ZERO;
62118
62118
  }
62119
62119
  }, {
@@ -62145,9 +62145,9 @@ var require_matrix42 = __commonJS({
62145
62145
  return result;
62146
62146
  }
62147
62147
  }]);
62148
- return Matrix412;
62148
+ return Matrix411;
62149
62149
  }(_matrix.default);
62150
- exports.default = Matrix411;
62150
+ exports.default = Matrix410;
62151
62151
  }
62152
62152
  });
62153
62153
 
@@ -68750,15 +68750,15 @@ var require_vector33 = __commonJS({
68750
68750
  }
68751
68751
  var ORIGIN = [0, 0, 0];
68752
68752
  var constants = {};
68753
- var Vector321 = function(_Vector) {
68754
- (0, _inherits2.default)(Vector322, _Vector);
68755
- var _super = _createSuper(Vector322);
68756
- function Vector322() {
68753
+ var Vector320 = function(_Vector) {
68754
+ (0, _inherits2.default)(Vector321, _Vector);
68755
+ var _super = _createSuper(Vector321);
68756
+ function Vector321() {
68757
68757
  var _this;
68758
68758
  var x = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
68759
68759
  var y = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
68760
68760
  var z = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
68761
- (0, _classCallCheck2.default)(this, Vector322);
68761
+ (0, _classCallCheck2.default)(this, Vector321);
68762
68762
  _this = _super.call(this, -0, -0, -0);
68763
68763
  if (arguments.length === 1 && (0, _common.isArray)(x)) {
68764
68764
  _this.copy(x);
@@ -68774,7 +68774,7 @@ var require_vector33 = __commonJS({
68774
68774
  }
68775
68775
  return _this;
68776
68776
  }
68777
- (0, _createClass2.default)(Vector322, [{
68777
+ (0, _createClass2.default)(Vector321, [{
68778
68778
  key: "set",
68779
68779
  value: function set(x, y, z) {
68780
68780
  this[0] = x;
@@ -68894,12 +68894,12 @@ var require_vector33 = __commonJS({
68894
68894
  }], [{
68895
68895
  key: "ZERO",
68896
68896
  get: function get() {
68897
- return constants.ZERO = constants.ZERO || Object.freeze(new Vector322(0, 0, 0, 0));
68897
+ return constants.ZERO = constants.ZERO || Object.freeze(new Vector321(0, 0, 0, 0));
68898
68898
  }
68899
68899
  }]);
68900
- return Vector322;
68900
+ return Vector321;
68901
68901
  }(_vector.default);
68902
- exports.default = Vector321;
68902
+ exports.default = Vector320;
68903
68903
  }
68904
68904
  });
68905
68905
 
@@ -69649,12 +69649,12 @@ var require_matrix43 = __commonJS({
69649
69649
  COL3ROW3: 15
69650
69650
  });
69651
69651
  var constants = {};
69652
- var Matrix411 = function(_Matrix) {
69653
- (0, _inherits2.default)(Matrix412, _Matrix);
69654
- var _super = _createSuper(Matrix412);
69655
- function Matrix412(array) {
69652
+ var Matrix410 = function(_Matrix) {
69653
+ (0, _inherits2.default)(Matrix411, _Matrix);
69654
+ var _super = _createSuper(Matrix411);
69655
+ function Matrix411(array) {
69656
69656
  var _this;
69657
- (0, _classCallCheck2.default)(this, Matrix412);
69657
+ (0, _classCallCheck2.default)(this, Matrix411);
69658
69658
  _this = _super.call(this, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
69659
69659
  if (arguments.length === 1 && Array.isArray(array)) {
69660
69660
  _this.copy(array);
@@ -69663,7 +69663,7 @@ var require_matrix43 = __commonJS({
69663
69663
  }
69664
69664
  return _this;
69665
69665
  }
69666
- (0, _createClass2.default)(Matrix412, [{
69666
+ (0, _createClass2.default)(Matrix411, [{
69667
69667
  key: "INDICES",
69668
69668
  get: function get() {
69669
69669
  return INDICES;
@@ -69778,7 +69778,7 @@ var require_matrix43 = __commonJS({
69778
69778
  value: function frustum(_ref) {
69779
69779
  var left = _ref.left, right = _ref.right, bottom = _ref.bottom, top = _ref.top, near = _ref.near, far = _ref.far;
69780
69780
  if (far === Infinity) {
69781
- Matrix412._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
69781
+ Matrix411._computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
69782
69782
  } else {
69783
69783
  mat4.frustum(this, left, right, bottom, top, near, far);
69784
69784
  }
@@ -69815,7 +69815,7 @@ var require_matrix43 = __commonJS({
69815
69815
  var halfY = fovy / 2;
69816
69816
  var top = focalDistance * Math.tan(halfY);
69817
69817
  var right = top * aspect;
69818
- return new Matrix412().ortho({
69818
+ return new Matrix411().ortho({
69819
69819
  left: -right,
69820
69820
  right,
69821
69821
  bottom: -top,
@@ -70049,13 +70049,13 @@ var require_matrix43 = __commonJS({
70049
70049
  }], [{
70050
70050
  key: "IDENTITY",
70051
70051
  get: function get() {
70052
- constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix412(IDENTITY));
70052
+ constants.IDENTITY = constants.IDENTITY || Object.freeze(new Matrix411(IDENTITY));
70053
70053
  return constants.IDENTITY;
70054
70054
  }
70055
70055
  }, {
70056
70056
  key: "ZERO",
70057
70057
  get: function get() {
70058
- constants.ZERO = constants.ZERO || Object.freeze(new Matrix412(ZERO));
70058
+ constants.ZERO = constants.ZERO || Object.freeze(new Matrix411(ZERO));
70059
70059
  return constants.ZERO;
70060
70060
  }
70061
70061
  }, {
@@ -70087,9 +70087,9 @@ var require_matrix43 = __commonJS({
70087
70087
  return result;
70088
70088
  }
70089
70089
  }]);
70090
- return Matrix412;
70090
+ return Matrix411;
70091
70091
  }(_matrix.default);
70092
- exports.default = Matrix411;
70092
+ exports.default = Matrix410;
70093
70093
  }
70094
70094
  });
70095
70095
 
@@ -74368,56 +74368,6 @@ function copyToArray(source, target, targetOffset) {
74368
74368
  return targetOffset + padToNBytes(sourceArray.byteLength, 4);
74369
74369
  }
74370
74370
 
74371
- // ../loader-utils/src/lib/binary-utils/binary-copy-utils.ts
74372
- function copyPaddedArrayBufferToDataView(dataView, byteOffset, sourceBuffer, padding) {
74373
- const paddedLength = padToNBytes(sourceBuffer.byteLength, padding);
74374
- const padLength = paddedLength - sourceBuffer.byteLength;
74375
- if (dataView) {
74376
- const targetArray = new Uint8Array(dataView.buffer, dataView.byteOffset + byteOffset, sourceBuffer.byteLength);
74377
- const sourceArray = new Uint8Array(sourceBuffer);
74378
- targetArray.set(sourceArray);
74379
- for (let i = 0; i < padLength; ++i) {
74380
- dataView.setUint8(byteOffset + sourceBuffer.byteLength + i, 32);
74381
- }
74382
- }
74383
- byteOffset += paddedLength;
74384
- return byteOffset;
74385
- }
74386
- function copyPaddedStringToDataView(dataView, byteOffset, string, padding) {
74387
- const textEncoder = new TextEncoder();
74388
- const stringBuffer = textEncoder.encode(string);
74389
- byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, stringBuffer, padding);
74390
- return byteOffset;
74391
- }
74392
-
74393
- // ../loader-utils/src/lib/binary-utils/encode-utils.ts
74394
- function padStringToByteAlignment(string, byteAlignment) {
74395
- const length = string.length;
74396
- const paddedLength = Math.ceil(length / byteAlignment) * byteAlignment;
74397
- const padding = paddedLength - length;
74398
- let whitespace = "";
74399
- for (let i = 0; i < padding; ++i) {
74400
- whitespace += " ";
74401
- }
74402
- return string + whitespace;
74403
- }
74404
- function copyStringToDataView(dataView, byteOffset, string, byteLength) {
74405
- if (dataView) {
74406
- for (let i = 0; i < byteLength; i++) {
74407
- dataView.setUint8(byteOffset + i, string.charCodeAt(i));
74408
- }
74409
- }
74410
- return byteOffset + byteLength;
74411
- }
74412
- function copyBinaryToDataView(dataView, byteOffset, binary, byteLength) {
74413
- if (dataView) {
74414
- for (let i = 0; i < byteLength; i++) {
74415
- dataView.setUint8(byteOffset + i, binary[i]);
74416
- }
74417
- }
74418
- return byteOffset + byteLength;
74419
- }
74420
-
74421
74371
  // ../loader-utils/src/lib/iterators/async-iteration.ts
74422
74372
  async function concatenateArrayBuffersAsync(asyncIterator) {
74423
74373
  const arrayBuffers = [];
@@ -75490,12 +75440,6 @@ async function encode(data, writer, options) {
75490
75440
  }
75491
75441
  throw new Error("Writer could not encode data");
75492
75442
  }
75493
- function encodeSync(data, writer, options) {
75494
- if (writer.encodeSync) {
75495
- return writer.encodeSync(data, options);
75496
- }
75497
- throw new Error("Writer could not synchronously encode data");
75498
- }
75499
75443
  function encodeInBatches(data, writer, options) {
75500
75444
  if (writer.encodeInBatches) {
75501
75445
  const dataIterator = getIterator(data);
@@ -76419,6 +76363,7 @@ var TileHeader = class {
76419
76363
  this._lodJudge = null;
76420
76364
  this._expireDate = null;
76421
76365
  this._expiredContent = null;
76366
+ this.implicitTiling = null;
76422
76367
  Object.seal(this);
76423
76368
  }
76424
76369
  destroy() {
@@ -76708,6 +76653,7 @@ var TileHeader = class {
76708
76653
  return {
76709
76654
  ...this.tileset.options.i3s,
76710
76655
  _tileOptions: {
76656
+ attributeUrls: this.header.attributeUrls,
76711
76657
  textureUrl: this.header.textureUrl,
76712
76658
  textureFormat: this.header.textureFormat,
76713
76659
  textureLoaderOptions: this.header.textureLoaderOptions,
@@ -76716,7 +76662,9 @@ var TileHeader = class {
76716
76662
  mbs: this.header.mbs
76717
76663
  },
76718
76664
  _tilesetOptions: {
76719
- store: this.tileset.tileset.store
76665
+ store: this.tileset.tileset.store,
76666
+ attributeStorageInfo: this.tileset.tileset.attributeStorageInfo,
76667
+ fields: this.tileset.tileset.fields
76720
76668
  },
76721
76669
  isTileHeader: false
76722
76670
  };
@@ -77442,12 +77390,6 @@ var TILE3D_TYPE = {
77442
77390
  GLTF: "glTF"
77443
77391
  };
77444
77392
  var TILE3D_TYPES = Object.keys(TILE3D_TYPE);
77445
- var MAGIC_ARRAY = {
77446
- BATCHED_MODEL: [98, 51, 100, 109],
77447
- INSTANCED_MODEL: [105, 51, 100, 109],
77448
- POINT_CLOUD: [112, 110, 116, 115],
77449
- COMPOSITE: [99, 109, 112, 116]
77450
- };
77451
77393
 
77452
77394
  // ../3d-tiles/src/lib/parsers/helpers/parse-utils.ts
77453
77395
  function getStringFromArrayBuffer(arrayBuffer, byteOffset, byteLength) {
@@ -82430,7 +82372,7 @@ var GLTFV1Normalizer = class {
82430
82372
  metallicFactor: 1,
82431
82373
  roughnessFactor: 1
82432
82374
  };
82433
- const textureId = material.values?.tex || material.values?.texture2d_0;
82375
+ const textureId = material.values?.tex || material.values?.texture2d_0 || material.values?.diffuseTex;
82434
82376
  const textureIndex = json.textures.findIndex((texture) => texture.id === textureId);
82435
82377
  if (textureIndex !== -1) {
82436
82378
  material.pbrMetallicRoughness.baseColorTexture = { index: textureIndex };
@@ -82961,10 +82903,13 @@ function getReferencesImageIndices(gltf) {
82961
82903
  async function loadImage(gltf, image, index, options, context) {
82962
82904
  const { fetch: fetch2, parse: parse9 } = context;
82963
82905
  let arrayBuffer;
82964
- if (image.uri) {
82906
+ if (image.uri && !image.hasOwnProperty("bufferView")) {
82965
82907
  const uri = resolveUrl(image.uri, options);
82966
82908
  const response = await fetch2(uri);
82967
82909
  arrayBuffer = await response.arrayBuffer();
82910
+ image.bufferView = {
82911
+ data: arrayBuffer
82912
+ };
82968
82913
  }
82969
82914
  if (Number.isFinite(image.bufferView)) {
82970
82915
  const array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView);
@@ -83025,87 +82970,6 @@ async function parse3(arrayBuffer, options = {}, context) {
83025
82970
  return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
83026
82971
  }
83027
82972
 
83028
- // ../gltf/src/lib/encoders/encode-glb.ts
83029
- var MAGIC_glTF2 = 1179937895;
83030
- var MAGIC_JSON = 1313821514;
83031
- var MAGIC_BIN = 5130562;
83032
- var LE2 = true;
83033
- function encodeGLBSync(glb, dataView, byteOffset = 0, options = {}) {
83034
- const { magic = MAGIC_glTF2, version: version2 = 2, json = {}, binary } = glb;
83035
- const byteOffsetStart = byteOffset;
83036
- if (dataView) {
83037
- dataView.setUint32(byteOffset + 0, magic, LE2);
83038
- dataView.setUint32(byteOffset + 4, version2, LE2);
83039
- dataView.setUint32(byteOffset + 8, 0, LE2);
83040
- }
83041
- const byteOffsetFileLength = byteOffset + 8;
83042
- byteOffset += 12;
83043
- const byteOffsetJsonHeader = byteOffset;
83044
- if (dataView) {
83045
- dataView.setUint32(byteOffset + 0, 0, LE2);
83046
- dataView.setUint32(byteOffset + 4, MAGIC_JSON, LE2);
83047
- }
83048
- byteOffset += 8;
83049
- const jsonString = JSON.stringify(json);
83050
- byteOffset = copyPaddedStringToDataView(dataView, byteOffset, jsonString, 4);
83051
- if (dataView) {
83052
- const jsonByteLength = byteOffset - byteOffsetJsonHeader - 8;
83053
- dataView.setUint32(byteOffsetJsonHeader + 0, jsonByteLength, LE2);
83054
- }
83055
- if (binary) {
83056
- const byteOffsetBinHeader = byteOffset;
83057
- if (dataView) {
83058
- dataView.setUint32(byteOffset + 0, 0, LE2);
83059
- dataView.setUint32(byteOffset + 4, MAGIC_BIN, LE2);
83060
- }
83061
- byteOffset += 8;
83062
- byteOffset = copyPaddedArrayBufferToDataView(dataView, byteOffset, binary, 4);
83063
- if (dataView) {
83064
- const binByteLength = byteOffset - byteOffsetBinHeader - 8;
83065
- dataView.setUint32(byteOffsetBinHeader + 0, binByteLength, LE2);
83066
- }
83067
- }
83068
- if (dataView) {
83069
- const fileByteLength = byteOffset - byteOffsetStart;
83070
- dataView.setUint32(byteOffsetFileLength, fileByteLength, LE2);
83071
- }
83072
- return byteOffset;
83073
- }
83074
-
83075
- // ../gltf/src/lib/encoders/encode-gltf.ts
83076
- function encodeGLTFSync(gltf, arrayBuffer, byteOffset, options) {
83077
- convertBuffersToBase64(gltf);
83078
- return encodeGLBSync(gltf, arrayBuffer, byteOffset, options);
83079
- }
83080
- function convertBuffersToBase64(gltf, { firstBuffer = 0 } = {}) {
83081
- if (gltf.buffers && gltf.buffers.length > firstBuffer) {
83082
- throw new Error("encodeGLTF: multiple buffers not yet implemented");
83083
- }
83084
- }
83085
-
83086
- // ../gltf/src/gltf-writer.ts
83087
- var GLTFWriter = {
83088
- name: "glTF",
83089
- id: "gltf",
83090
- module: "gltf",
83091
- version: VERSION6,
83092
- extensions: ["glb"],
83093
- mimeTypes: ["model/gltf-binary"],
83094
- binary: true,
83095
- encodeSync: encodeSync2,
83096
- options: {
83097
- gltf: {}
83098
- }
83099
- };
83100
- function encodeSync2(gltf, options = {}) {
83101
- const { byteOffset = 0 } = options;
83102
- const byteLength = encodeGLTFSync(gltf, null, byteOffset, options);
83103
- const arrayBuffer = new ArrayBuffer(byteLength);
83104
- const dataView = new DataView(arrayBuffer);
83105
- encodeGLTFSync(gltf, dataView, byteOffset, options);
83106
- return arrayBuffer;
83107
- }
83108
-
83109
82973
  // ../3d-tiles/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts
83110
82974
  var GLTF_FORMAT = {
83111
82975
  URI: 0,
@@ -83370,7 +83234,7 @@ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile =
83370
83234
  // ../3d-tiles/src/lib/parsers/helpers/parse-3d-tile-subtree.ts
83371
83235
  var SUBTREE_FILE_MAGIC = 1952609651;
83372
83236
  var SUBTREE_FILE_VERSION = 1;
83373
- async function parse3DTilesSubtree(data) {
83237
+ async function parse3DTilesSubtree(data, options, context) {
83374
83238
  const magic = new Uint32Array(data.slice(0, 4));
83375
83239
  if (magic[0] !== SUBTREE_FILE_MAGIC) {
83376
83240
  throw new Error("Wrong subtree file magic number");
@@ -83390,22 +83254,39 @@ async function parse3DTilesSubtree(data) {
83390
83254
  internalBinaryBuffer = data.slice(24 + jsonByteLength);
83391
83255
  }
83392
83256
  if ("bufferView" in subtree.tileAvailability) {
83393
- subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, "tileAvailability", internalBinaryBuffer);
83257
+ subtree.tileAvailability.explicitBitstream = await getExplicitBitstream(subtree, "tileAvailability", internalBinaryBuffer, context);
83394
83258
  }
83395
83259
  if ("bufferView" in subtree.contentAvailability) {
83396
- subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, "contentAvailability", internalBinaryBuffer);
83260
+ subtree.contentAvailability.explicitBitstream = await getExplicitBitstream(subtree, "contentAvailability", internalBinaryBuffer, context);
83397
83261
  }
83398
83262
  if ("bufferView" in subtree.childSubtreeAvailability) {
83399
- subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, "childSubtreeAvailability", internalBinaryBuffer);
83263
+ subtree.childSubtreeAvailability.explicitBitstream = await getExplicitBitstream(subtree, "childSubtreeAvailability", internalBinaryBuffer, context);
83400
83264
  }
83401
83265
  return subtree;
83402
83266
  }
83403
- async function getExplicitBitstream(subtree, name10, internalBinaryBuffer) {
83267
+ function resolveBufferUri(bitstreamRelativeUri, basePath) {
83268
+ const hasProtocol = basePath.startsWith("http");
83269
+ if (hasProtocol) {
83270
+ const resolvedUri2 = new URL(bitstreamRelativeUri, basePath);
83271
+ return decodeURI(resolvedUri2.toString());
83272
+ }
83273
+ const basePathWithProtocol = `http://${basePath}`;
83274
+ const resolvedUri = new URL(bitstreamRelativeUri, basePathWithProtocol);
83275
+ return `/${resolvedUri.host}${resolvedUri.pathname}`;
83276
+ }
83277
+ async function getExplicitBitstream(subtree, name10, internalBinaryBuffer, context) {
83404
83278
  const bufferViewIndex = subtree[name10].bufferView;
83405
83279
  const bufferView = subtree.bufferViews[bufferViewIndex];
83406
83280
  const buffer = subtree.buffers[bufferView.buffer];
83281
+ if (!context?.url || !context.fetch) {
83282
+ throw new Error("Url is not provided");
83283
+ }
83284
+ if (!context.fetch) {
83285
+ throw new Error("fetch is not provided");
83286
+ }
83407
83287
  if (buffer.uri) {
83408
- const response = await fetchFile(buffer.uri);
83288
+ const bufferUri = resolveBufferUri(buffer.uri, context?.url);
83289
+ const response = await context.fetch(bufferUri);
83409
83290
  const data = await response.arrayBuffer();
83410
83291
  return new Uint8Array(data, bufferView.byteOffset, bufferView.byteLength);
83411
83292
  }
@@ -83560,6 +83441,8 @@ function formatTileData(tile, level, childCoordinates, options) {
83560
83441
  type: getTileType2(tile),
83561
83442
  lodMetricType,
83562
83443
  lodMetricValue,
83444
+ geometricError: lodMetricValue,
83445
+ transform: tile.transform,
83563
83446
  boundingVolume
83564
83447
  };
83565
83448
  }
@@ -83662,41 +83545,48 @@ function normalizeTileData(tile, options) {
83662
83545
  tile.refine = getRefine(tile.refine);
83663
83546
  return tile;
83664
83547
  }
83665
- function normalizeTileHeaders(tileset) {
83548
+ async function normalizeTileHeaders(tileset, options) {
83666
83549
  const basePath = tileset.basePath;
83667
- const root = normalizeTileData(tileset.root, tileset);
83550
+ let root;
83551
+ const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset?.root);
83552
+ if (rootImplicitTilingExtension && tileset.root) {
83553
+ root = await normalizeImplicitTileHeaders(tileset.root, tileset, rootImplicitTilingExtension, options);
83554
+ } else {
83555
+ root = normalizeTileData(tileset.root, tileset);
83556
+ }
83668
83557
  const stack2 = [];
83669
83558
  stack2.push(root);
83670
83559
  while (stack2.length > 0) {
83671
83560
  const tile = stack2.pop() || {};
83672
83561
  const children = tile.children || [];
83673
- for (const childHeader of children) {
83674
- normalizeTileData(childHeader, { basePath });
83562
+ for (let childHeader of children) {
83563
+ const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);
83564
+ if (childImplicitTilingExtension) {
83565
+ childHeader = await normalizeImplicitTileHeaders(childHeader, tileset, childImplicitTilingExtension, options);
83566
+ } else {
83567
+ normalizeTileData(childHeader, { basePath });
83568
+ }
83675
83569
  stack2.push(childHeader);
83676
83570
  }
83677
83571
  }
83678
83572
  return root;
83679
83573
  }
83680
- async function normalizeImplicitTileHeaders(tileset) {
83681
- if (!tileset.root) {
83682
- return null;
83683
- }
83574
+ async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtension, options) {
83684
83575
  const basePath = tileset.basePath;
83685
- const implicitTilingExtension = tileset.root.extensions["3DTILES_implicit_tiling"];
83686
83576
  const {
83687
83577
  subdivisionScheme,
83688
83578
  maximumLevel,
83689
83579
  subtreeLevels,
83690
83580
  subtrees: { uri: subtreesUriTemplate }
83691
83581
  } = implicitTilingExtension;
83692
- const subtreeUrl = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
83693
- const rootSubtreeUrl = resolveUri(subtreeUrl, basePath);
83694
- const rootSubtree = await load(rootSubtreeUrl, Tile3DSubtreeLoader);
83695
- const contentUrlTemplate = resolveUri(tileset.root.content.uri, basePath);
83696
- const refine = tileset.root.refine;
83697
- const rootLodMetricValue = tileset.root.geometricError;
83698
- const rootBoundingVolume = tileset.root.boundingVolume;
83699
- const options = {
83582
+ const replacedUrlTemplate = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
83583
+ const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);
83584
+ const subtree = await load(subtreeUrl, Tile3DSubtreeLoader, options);
83585
+ const contentUrlTemplate = resolveUri(tile.content.uri, basePath);
83586
+ const refine = tileset?.root?.refine;
83587
+ const rootLodMetricValue = tile.geometricError;
83588
+ const rootBoundingVolume = tile.boundingVolume;
83589
+ const implicitOptions = {
83700
83590
  contentUrlTemplate,
83701
83591
  subtreesUriTemplate,
83702
83592
  subdivisionScheme,
@@ -83710,7 +83600,7 @@ async function normalizeImplicitTileHeaders(tileset) {
83710
83600
  getTileType,
83711
83601
  getRefine
83712
83602
  };
83713
- return await normalizeImplicitTileData(tileset.root, rootSubtree, options);
83603
+ return await normalizeImplicitTileData(tile, subtree, implicitOptions);
83714
83604
  }
83715
83605
  async function normalizeImplicitTileData(tile, rootSubtree, options) {
83716
83606
  if (!tile) {
@@ -83730,9 +83620,11 @@ async function normalizeImplicitTileData(tile, rootSubtree, options) {
83730
83620
  tile.id = tile.contentUrl;
83731
83621
  return tile;
83732
83622
  }
83623
+ function getImplicitTilingExtensionData(tile) {
83624
+ return tile?.extensions?.["3DTILES_implicit_tiling"] || tile?.implicitTiling;
83625
+ }
83733
83626
 
83734
83627
  // ../3d-tiles/src/tiles-3d-loader.ts
83735
- var IMPLICIT_TILING_EXTENSION_NAME = "3DTILES_implicit_tiling";
83736
83628
  var Tiles3DLoader = {
83737
83629
  id: "3d-tiles",
83738
83630
  name: "3D Tiles",
@@ -83769,7 +83661,7 @@ async function parseTileset(data, options, context) {
83769
83661
  tilesetJson.loader = options.loader || Tiles3DLoader;
83770
83662
  tilesetJson.url = context.url;
83771
83663
  tilesetJson.basePath = getBaseUri(tilesetJson);
83772
- tilesetJson.root = hasImplicitTilingExtension(tilesetJson) ? await normalizeImplicitTileHeaders(tilesetJson) : normalizeTileHeaders(tilesetJson);
83664
+ tilesetJson.root = await normalizeTileHeaders(tilesetJson, options);
83773
83665
  tilesetJson.type = TILESET_TYPE.TILES3D;
83774
83666
  tilesetJson.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
83775
83667
  tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
@@ -83790,9 +83682,6 @@ async function parse4(data, options, context) {
83790
83682
  }
83791
83683
  return data;
83792
83684
  }
83793
- function hasImplicitTilingExtension(tilesetJson) {
83794
- return tilesetJson?.extensionsRequired?.includes(IMPLICIT_TILING_EXTENSION_NAME) && tilesetJson?.extensionsUsed?.includes(IMPLICIT_TILING_EXTENSION_NAME);
83795
- }
83796
83685
 
83797
83686
  // ../3d-tiles/src/lib/ion/ion.ts
83798
83687
  var CESIUM_ION_URL = "https://api.cesium.com/v1/assets";
@@ -83874,177 +83763,6 @@ var CesiumIonLoader = {
83874
83763
  }
83875
83764
  };
83876
83765
 
83877
- // ../3d-tiles/src/lib/encoders/helpers/encode-3d-tile-header.ts
83878
- function encode3DTileHeader(tile, dataView, byteOffset) {
83879
- const HEADER_SIZE = 12;
83880
- if (!dataView) {
83881
- return byteOffset + HEADER_SIZE;
83882
- }
83883
- const { magic, version: version2 = 1, byteLength = 12 } = tile;
83884
- assert2(Array.isArray(magic) && Number.isFinite(version2) && Number.isFinite(byteLength));
83885
- dataView.setUint8(byteOffset + 0, magic[0]);
83886
- dataView.setUint8(byteOffset + 1, magic[1]);
83887
- dataView.setUint8(byteOffset + 2, magic[2]);
83888
- dataView.setUint8(byteOffset + 3, magic[3]);
83889
- dataView.setUint32(byteOffset + 4, version2, true);
83890
- dataView.setUint32(byteOffset + 8, byteLength, true);
83891
- byteOffset += HEADER_SIZE;
83892
- return byteOffset;
83893
- }
83894
- function encode3DTileByteLength(dataView, byteOffsetTileStart, byteLength) {
83895
- if (!dataView) {
83896
- return;
83897
- }
83898
- dataView.setUint32(byteOffsetTileStart + 8, byteLength, true);
83899
- }
83900
-
83901
- // ../3d-tiles/src/lib/encoders/encode-3d-tile-composite.ts
83902
- function encodeComposite3DTile(tile, dataView, byteOffset, options, encode3DTile2) {
83903
- tile = { magic: MAGIC_ARRAY.COMPOSITE, tiles: [], ...tile };
83904
- const byteOffsetStart = byteOffset;
83905
- byteOffset += encode3DTileHeader(tile, dataView, byteOffset);
83906
- if (dataView) {
83907
- dataView.setUint32(byteOffset, tile.tiles.length, true);
83908
- }
83909
- byteOffset += 4;
83910
- for (let i = 0; i < tile.tiles.length; ++i) {
83911
- byteOffset += encode3DTile2(tile.tiles[i], dataView, byteOffset, options);
83912
- }
83913
- encode3DTileByteLength(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
83914
- return byteOffset;
83915
- }
83916
-
83917
- // ../3d-tiles/src/lib/encoders/encode-3d-tile-batched-model.ts
83918
- function encodeBatchedModel3DTile(tile, dataView, byteOffset, options) {
83919
- const { featuresLength = 0, batchTable } = tile;
83920
- const featureTableJson = {
83921
- BATCH_LENGTH: featuresLength
83922
- };
83923
- const featureTableJsonString = JSON.stringify(featureTableJson);
83924
- const batchTableJsonString = batchTable ? JSON.stringify(batchTable) : "";
83925
- const featureTableJsonByteLength = padToNBytes(featureTableJsonString.length, 8);
83926
- const batchTableJsonByteLength = batchTableJsonString ? padToNBytes(batchTableJsonString.length, 8) : 0;
83927
- tile = { magic: MAGIC_ARRAY.BATCHED_MODEL, ...tile };
83928
- const byteOffsetStart = byteOffset;
83929
- byteOffset = encode3DTileHeader(tile, dataView, byteOffset);
83930
- if (dataView) {
83931
- dataView.setUint32(12, featureTableJsonByteLength, true);
83932
- dataView.setUint32(16, 0, true);
83933
- dataView.setUint32(20, batchTableJsonByteLength, true);
83934
- dataView.setUint32(24, 0, true);
83935
- }
83936
- byteOffset += 16;
83937
- byteOffset = copyPaddedStringToDataView(dataView, byteOffset, featureTableJsonString, 8);
83938
- if (batchTable) {
83939
- byteOffset = copyPaddedStringToDataView(dataView, byteOffset, batchTableJsonString, 8);
83940
- }
83941
- const gltfEncoded = tile.gltfEncoded;
83942
- if (gltfEncoded) {
83943
- byteOffset = copyBinaryToDataView(dataView, byteOffset, gltfEncoded, gltfEncoded.byteLength);
83944
- }
83945
- encode3DTileByteLength(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
83946
- return byteOffset;
83947
- }
83948
-
83949
- // ../3d-tiles/src/lib/encoders/encode-3d-tile-instanced-model.ts
83950
- function encodeInstancedModel3DTile(tile, dataView, byteOffset, options) {
83951
- const { featuresLength = 1, gltfFormat = 1, gltfUri = "" } = tile;
83952
- const gltfUriByteLength = gltfUri.length;
83953
- const featureTableJson = {
83954
- INSTANCES_LENGTH: featuresLength,
83955
- POSITION: new Array(featuresLength * 3).fill(0)
83956
- };
83957
- const featureTableJsonString = JSON.stringify(featureTableJson);
83958
- const featureTableJsonByteLength = featureTableJsonString.length;
83959
- tile = { magic: MAGIC_ARRAY.INSTANCED_MODEL, ...tile };
83960
- const byteOffsetStart = byteOffset;
83961
- byteOffset = encode3DTileHeader(tile, dataView, 0);
83962
- if (dataView) {
83963
- dataView.setUint32(12, featureTableJsonByteLength, true);
83964
- dataView.setUint32(16, 0, true);
83965
- dataView.setUint32(20, 0, true);
83966
- dataView.setUint32(24, 0, true);
83967
- dataView.setUint32(28, gltfFormat, true);
83968
- }
83969
- byteOffset += 20;
83970
- byteOffset += copyStringToDataView(dataView, byteOffset, featureTableJsonString, featureTableJsonByteLength);
83971
- byteOffset += copyStringToDataView(dataView, byteOffset, gltfUri, gltfUriByteLength);
83972
- encode3DTileByteLength(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
83973
- return byteOffset;
83974
- }
83975
-
83976
- // ../3d-tiles/src/lib/encoders/encode-3d-tile-point-cloud.ts
83977
- var DEFAULT_FEATURE_TABLE_JSON = {
83978
- POINTS_LENGTH: 1,
83979
- POSITIONS: {
83980
- byteOffset: 0
83981
- }
83982
- };
83983
- function encodePointCloud3DTile(tile, dataView, byteOffset, options) {
83984
- const { featureTableJson = DEFAULT_FEATURE_TABLE_JSON } = tile;
83985
- let featureTableJsonString = JSON.stringify(featureTableJson);
83986
- featureTableJsonString = padStringToByteAlignment(featureTableJsonString, 4);
83987
- const { featureTableJsonByteLength = featureTableJsonString.length } = tile;
83988
- const featureTableBinary = new ArrayBuffer(12);
83989
- const featureTableBinaryByteLength = featureTableBinary.byteLength;
83990
- tile = { magic: MAGIC_ARRAY.POINT_CLOUD, ...tile };
83991
- const byteOffsetStart = byteOffset;
83992
- byteOffset += encode3DTileHeader(tile, dataView, 0);
83993
- if (dataView) {
83994
- dataView.setUint32(byteOffset + 0, featureTableJsonByteLength, true);
83995
- dataView.setUint32(byteOffset + 4, featureTableBinaryByteLength, true);
83996
- dataView.setUint32(byteOffset + 8, 0, true);
83997
- dataView.setUint32(byteOffset + 12, 0, true);
83998
- }
83999
- byteOffset += 16;
84000
- byteOffset += copyStringToDataView(dataView, byteOffset, featureTableJsonString, featureTableJsonByteLength);
84001
- byteOffset += copyBinaryToDataView(dataView, byteOffset, featureTableBinary, featureTableBinaryByteLength);
84002
- encode3DTileByteLength(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
84003
- return byteOffset;
84004
- }
84005
-
84006
- // ../3d-tiles/src/lib/encoders/encode-3d-tile.ts
84007
- function encode3DTile(tile, options) {
84008
- const byteLength = encode3DTileToDataView(tile, null, 0, options);
84009
- const arrayBuffer = new ArrayBuffer(byteLength);
84010
- const dataView = new DataView(arrayBuffer);
84011
- encode3DTileToDataView(tile, dataView, 0, options);
84012
- return arrayBuffer;
84013
- }
84014
- function encode3DTileToDataView(tile, dataView, byteOffset, options) {
84015
- assert2(typeof tile.type === "string");
84016
- switch (tile.type) {
84017
- case TILE3D_TYPE.COMPOSITE:
84018
- return encodeComposite3DTile(tile, dataView, byteOffset, options, encode3DTileToDataView);
84019
- case TILE3D_TYPE.POINT_CLOUD:
84020
- return encodePointCloud3DTile(tile, dataView, byteOffset, options);
84021
- case TILE3D_TYPE.BATCHED_3D_MODEL:
84022
- return encodeBatchedModel3DTile(tile, dataView, byteOffset, options);
84023
- case TILE3D_TYPE.INSTANCED_3D_MODEL:
84024
- return encodeInstancedModel3DTile(tile, dataView, byteOffset, options);
84025
- default:
84026
- throw new Error("3D Tiles: unknown tile type");
84027
- }
84028
- }
84029
-
84030
- // ../3d-tiles/src/tile-3d-writer.ts
84031
- var Tile3DWriter = {
84032
- name: "3D Tile",
84033
- id: "3d-tiles",
84034
- module: "3d-tiles",
84035
- version: VERSION4,
84036
- extensions: ["cmpt", "pnts", "b3dm", "i3dm"],
84037
- mimeTypes: ["application/octet-stream"],
84038
- encodeSync: encodeSync3,
84039
- binary: true,
84040
- options: {
84041
- ["3d-tiles"]: {}
84042
- }
84043
- };
84044
- function encodeSync3(tile, options) {
84045
- return encode3DTile(tile, options);
84046
- }
84047
-
84048
83766
  // src/i3s-converter/i3s-converter.ts
84049
83767
  var import_path7 = __toModule(require("path"));
84050
83768
 
@@ -84109,6 +83827,10 @@ var NodePages = class {
84109
83827
  const nodeIndex = id % this.nodesPerPage;
84110
83828
  return this.nodePages[pageIndex].nodes[nodeIndex];
84111
83829
  }
83830
+ updateAll(id, data) {
83831
+ const node2 = this.getNodeById(id);
83832
+ Object.assign(node2, data, { index: node2.index });
83833
+ }
84112
83834
  updateMaterialByNodeId(id, materialId) {
84113
83835
  const node2 = this.getNodeById(id);
84114
83836
  if (!node2.mesh) {
@@ -84128,7 +83850,7 @@ var NodePages = class {
84128
83850
  }
84129
83851
  updateNodeAttributeByNodeId(id) {
84130
83852
  const node2 = this.getNodeById(id);
84131
- if (!node2.mesh) {
83853
+ if (!node2.mesh || !node2.index) {
84132
83854
  return;
84133
83855
  }
84134
83856
  node2.mesh.attribute.resource = node2.index;
@@ -84155,7 +83877,7 @@ var NodePages = class {
84155
83877
  parentNode.children?.push(childId);
84156
83878
  }
84157
83879
  updateResourceInMesh(node2) {
84158
- if (node2.mesh) {
83880
+ if (node2.mesh && isFinite(node2.index)) {
84159
83881
  node2.mesh.geometry.resource = node2.index;
84160
83882
  }
84161
83883
  }
@@ -84360,7 +84082,7 @@ async function getTotalFilesSize(dirPath) {
84360
84082
  }
84361
84083
 
84362
84084
  // src/i3s-converter/helpers/geometry-converter.ts
84363
- var import_core22 = __toModule(require_es56());
84085
+ var import_core21 = __toModule(require_es56());
84364
84086
  var import_geospatial9 = __toModule(require_es57());
84365
84087
  var import_md5 = __toModule(require_md52());
84366
84088
 
@@ -84525,7 +84247,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
84525
84247
  }
84526
84248
 
84527
84249
  // src/i3s-converter/helpers/coordinate-converter.ts
84528
- var import_core21 = __toModule(require_es56());
84250
+ var import_core20 = __toModule(require_es56());
84529
84251
  var import_geospatial8 = __toModule(require_es57());
84530
84252
  var import_culling5 = __toModule(require_es58());
84531
84253
  function createBoundingVolumes(tile, geoidHeightModel) {
@@ -84533,16 +84255,16 @@ function createBoundingVolumes(tile, geoidHeightModel) {
84533
84255
  let halfSize;
84534
84256
  let quaternion;
84535
84257
  const boundingVolume = tile.boundingVolume;
84536
- const cartographicCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new import_core21.Vector3());
84258
+ const cartographicCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(boundingVolume.center, new import_core20.Vector3());
84537
84259
  cartographicCenter[2] = cartographicCenter[2] - geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);
84538
84260
  if (boundingVolume instanceof import_culling5.OrientedBoundingBox) {
84539
84261
  halfSize = boundingVolume.halfSize;
84540
- radius = new import_core21.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
84262
+ radius = new import_core20.Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
84541
84263
  quaternion = boundingVolume.quaternion;
84542
84264
  } else {
84543
84265
  radius = tile.boundingVolume.radius;
84544
84266
  halfSize = [radius, radius, radius];
84545
- quaternion = new import_core21.Quaternion().fromMatrix3(new import_core21.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]])).normalize();
84267
+ quaternion = new import_core20.Quaternion().fromMatrix3(new import_core20.Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]])).normalize();
84546
84268
  }
84547
84269
  return {
84548
84270
  mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],
@@ -84557,8 +84279,8 @@ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel)
84557
84279
  const positionVectors = convertPositionsToVectors(cartesianPositions);
84558
84280
  const geometryObb = (0, import_culling5.makeOrientedBoundingBoxFromPoints)(positionVectors);
84559
84281
  const geometryMbs = (0, import_culling5.makeBoundingSphereFromPoints)(positionVectors);
84560
- let mbsCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core21.Vector3());
84561
- let obbCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core21.Vector3());
84282
+ let mbsCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new import_core20.Vector3());
84283
+ let obbCenter = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new import_core20.Vector3());
84562
84284
  mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);
84563
84285
  obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);
84564
84286
  return {
@@ -84573,7 +84295,7 @@ function createBoundingVolumesFromGeometry(cartesianPositions, geoidHeightModel)
84573
84295
  function convertPositionsToVectors(positions) {
84574
84296
  const result = [];
84575
84297
  for (let i = 0; i < positions.length; i += 3) {
84576
- const positionVector = new import_core21.Vector3([positions[i], positions[i + 1], positions[i + 2]]);
84298
+ const positionVector = new import_core20.Vector3([positions[i], positions[i + 1], positions[i + 2]]);
84577
84299
  result.push(positionVector);
84578
84300
  }
84579
84301
  return result;
@@ -84587,8 +84309,8 @@ function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
84587
84309
  }
84588
84310
  const center = sphere.center;
84589
84311
  const radius = sphere.radius;
84590
- const vertexMax = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(new import_core21.Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new import_core21.Vector3());
84591
- const vertexMin = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(new import_core21.Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new import_core21.Vector3());
84312
+ const vertexMax = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(new import_core20.Vector3(center[0] + radius, center[1] + radius, center[2] + radius), new import_core20.Vector3());
84313
+ const vertexMin = import_geospatial8.Ellipsoid.WGS84.cartesianToCartographic(new import_core20.Vector3(center[0] - radius, center[1] - radius, center[2] - radius), new import_core20.Vector3());
84592
84314
  return {
84593
84315
  xmin: vertexMin[0],
84594
84316
  xmax: vertexMax[0],
@@ -84600,8 +84322,8 @@ function convertBoundingVolumeToI3SFullExtent(boundingVolume) {
84600
84322
  }
84601
84323
  function createObbFromMbs(mbs) {
84602
84324
  const radius = mbs[3];
84603
- const center = new import_core21.Vector3(mbs[0], mbs[1], mbs[2]);
84604
- const halfAxex = new import_core21.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
84325
+ const center = new import_core20.Vector3(mbs[0], mbs[1], mbs[2]);
84326
+ const halfAxex = new import_core20.Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);
84605
84327
  return new import_culling5.OrientedBoundingBox(center, halfAxex);
84606
84328
  }
84607
84329
 
@@ -84619,45 +84341,60 @@ function prepareDataForAttributesConversion(tileContent) {
84619
84341
  const gltfMaterials = tileContent.gltf?.materials?.map((material) => ({ id: material.id }));
84620
84342
  let nodes = tileContent.gltf?.scene?.nodes || tileContent.gltf?.scenes?.[0]?.nodes || tileContent.gltf?.nodes || [];
84621
84343
  const images = tileContent.gltf?.images?.map((imageObject) => {
84622
- const data = imageObject?.image?.compressed ? null : imageObject?.image?.data.subarray();
84623
- return {
84624
- data,
84625
- compressed: Boolean(imageObject?.image?.compressed),
84626
- height: imageObject.image.height,
84627
- width: imageObject.image.width,
84628
- components: imageObject.image.components,
84629
- mimeType: imageObject.mimeType
84630
- };
84631
- }) || [];
84632
- const prepearedNodes = nodes.map((node2) => {
84633
- if (!node2.mesh) {
84634
- return node2;
84344
+ if (imageObject?.image?.compressed) {
84345
+ return {
84346
+ data: null,
84347
+ compressed: true
84348
+ };
84349
+ } else {
84350
+ const data = imageObject?.image?.data;
84351
+ const dataCopy = new Uint8Array(data.length);
84352
+ dataCopy.set(data);
84353
+ return {
84354
+ data: dataCopy,
84355
+ compressed: false,
84356
+ height: imageObject.image.height,
84357
+ width: imageObject.image.width,
84358
+ components: imageObject.image.components,
84359
+ mimeType: imageObject.mimeType
84360
+ };
84635
84361
  }
84636
- return {
84637
- ...node2,
84638
- images,
84639
- mesh: {
84640
- ...node2.mesh,
84641
- primitives: node2.mesh?.primitives.map((primitive) => ({
84642
- ...primitive,
84643
- indices: { value: primitive?.indices?.value },
84644
- attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
84645
- material: {
84646
- id: primitive?.material?.id
84647
- }
84648
- }))
84649
- }
84650
- };
84651
- });
84362
+ }) || [];
84363
+ prepareNodes(nodes);
84652
84364
  const cartographicOrigin = tileContent.cartographicOrigin;
84653
84365
  const cartesianModelMatrix = tileContent.cartesianModelMatrix;
84654
84366
  return {
84655
84367
  gltfMaterials,
84656
- nodes: prepearedNodes,
84368
+ nodes,
84369
+ images,
84657
84370
  cartographicOrigin,
84658
84371
  cartesianModelMatrix
84659
84372
  };
84660
84373
  }
84374
+ function prepareNodes(nodes) {
84375
+ for (let index = 0; index < nodes.length; index++) {
84376
+ const node2 = nodes[index];
84377
+ if (node2.mesh) {
84378
+ nodes[index] = {
84379
+ ...node2,
84380
+ mesh: {
84381
+ ...node2.mesh,
84382
+ primitives: node2.mesh?.primitives.map((primitive) => ({
84383
+ ...primitive,
84384
+ indices: { value: primitive?.indices?.value },
84385
+ attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
84386
+ material: {
84387
+ id: primitive?.material?.id
84388
+ }
84389
+ }))
84390
+ }
84391
+ };
84392
+ }
84393
+ if (node2.children) {
84394
+ prepareNodes(node2.children);
84395
+ }
84396
+ }
84397
+ }
84661
84398
 
84662
84399
  // src/i3s-converter/helpers/batch-ids-extensions.ts
84663
84400
  var EXT_MESH_FEATURES = "EXT_mesh_features";
@@ -84723,6 +84460,9 @@ function generateImplicitFeatureIds(featuresCount, constant = 0, divisor = 0) {
84723
84460
  return featureIds;
84724
84461
  }
84725
84462
  function generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images) {
84463
+ if (!images?.length) {
84464
+ return [];
84465
+ }
84726
84466
  const CHANNELS_MAP = {
84727
84467
  r: 0,
84728
84468
  g: 1,
@@ -84782,6 +84522,118 @@ function checkPropertiesLength(featureIds, propertyTable) {
84782
84522
  }
84783
84523
  return needFlatten;
84784
84524
  }
84525
+ var STRING_TYPE = "string";
84526
+ var SHORT_INT_TYPE = "Int32";
84527
+ var DOUBLE_TYPE = "double";
84528
+ var OBJECT_ID_TYPE = "OBJECTID";
84529
+ function getAttributeType(key, attribute) {
84530
+ if (key === OBJECT_ID_TYPE) {
84531
+ return OBJECT_ID_TYPE;
84532
+ }
84533
+ if (typeof attribute === STRING_TYPE) {
84534
+ return STRING_TYPE;
84535
+ } else if (typeof attribute === "number") {
84536
+ return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
84537
+ }
84538
+ return STRING_TYPE;
84539
+ }
84540
+ function createdStorageAttribute(attributeIndex, key, attributeType) {
84541
+ const storageAttribute = {
84542
+ key: `f_${attributeIndex}`,
84543
+ name: key,
84544
+ ordering: ["attributeValues"],
84545
+ header: [{ property: "count", valueType: "UInt32" }],
84546
+ attributeValues: { valueType: "Int32", valuesPerElement: 1 }
84547
+ };
84548
+ switch (attributeType) {
84549
+ case OBJECT_ID_TYPE:
84550
+ setupIdAttribute(storageAttribute);
84551
+ break;
84552
+ case STRING_TYPE:
84553
+ setupStringAttribute(storageAttribute);
84554
+ break;
84555
+ case DOUBLE_TYPE:
84556
+ setupDoubleAttribute(storageAttribute);
84557
+ break;
84558
+ case SHORT_INT_TYPE:
84559
+ break;
84560
+ default:
84561
+ setupStringAttribute(storageAttribute);
84562
+ }
84563
+ return storageAttribute;
84564
+ }
84565
+ function getFieldAttributeType(attributeType) {
84566
+ switch (attributeType) {
84567
+ case OBJECT_ID_TYPE:
84568
+ return "esriFieldTypeOID";
84569
+ case STRING_TYPE:
84570
+ return "esriFieldTypeString";
84571
+ case SHORT_INT_TYPE:
84572
+ return "esriFieldTypeInteger";
84573
+ case DOUBLE_TYPE:
84574
+ return "esriFieldTypeDouble";
84575
+ default:
84576
+ return "esriFieldTypeString";
84577
+ }
84578
+ }
84579
+ function createFieldAttribute(key, fieldAttributeType) {
84580
+ return {
84581
+ name: key,
84582
+ type: fieldAttributeType,
84583
+ alias: key
84584
+ };
84585
+ }
84586
+ function createPopupInfo(propertyTable) {
84587
+ const title = "{OBJECTID}";
84588
+ const mediaInfos = [];
84589
+ const fieldInfos = [];
84590
+ const popupElements = [];
84591
+ const expressionInfos = [];
84592
+ for (const key in propertyTable) {
84593
+ fieldInfos.push({
84594
+ fieldName: key,
84595
+ visible: true,
84596
+ isEditable: false,
84597
+ label: key
84598
+ });
84599
+ }
84600
+ popupElements.push({
84601
+ fieldInfos,
84602
+ type: "fields"
84603
+ });
84604
+ return {
84605
+ title,
84606
+ mediaInfos,
84607
+ popupElements,
84608
+ fieldInfos,
84609
+ expressionInfos
84610
+ };
84611
+ }
84612
+ function setupStringAttribute(storageAttribute) {
84613
+ storageAttribute.ordering.unshift("attributeByteCounts");
84614
+ storageAttribute.header.push({ property: "attributeValuesByteCount", valueType: "UInt32" });
84615
+ storageAttribute.attributeValues = {
84616
+ valueType: "String",
84617
+ encoding: "UTF-8",
84618
+ valuesPerElement: 1
84619
+ };
84620
+ storageAttribute.attributeByteCounts = {
84621
+ valueType: "UInt32",
84622
+ valuesPerElement: 1
84623
+ };
84624
+ }
84625
+ function setupIdAttribute(storageAttribute) {
84626
+ storageAttribute.attributeValues = {
84627
+ valueType: "Oid32",
84628
+ valuesPerElement: 1
84629
+ };
84630
+ }
84631
+ function setupDoubleAttribute(storageAttribute) {
84632
+ storageAttribute.attributeValues = {
84633
+ valueType: "Float64",
84634
+ valuesPerElement: 1
84635
+ };
84636
+ }
84785
84637
 
84786
84638
  // src/i3s-converter/helpers/geometry-converter.ts
84787
84639
  var DEFAULT_ROUGHNESS_FACTOR = 1;
@@ -84789,15 +84641,15 @@ var DEFAULT_METALLIC_FACTOR = 1;
84789
84641
  var VALUES_PER_VERTEX2 = 3;
84790
84642
  var VALUES_PER_TEX_COORD = 2;
84791
84643
  var VALUES_PER_COLOR_ELEMENT = 4;
84792
- var STRING_TYPE = "string";
84793
- var SHORT_INT_TYPE = "Int32";
84794
- var DOUBLE_TYPE = "Float64";
84795
- var OBJECT_ID_TYPE = "Oid32";
84644
+ var STRING_TYPE2 = "string";
84645
+ var SHORT_INT_TYPE2 = "Int32";
84646
+ var DOUBLE_TYPE2 = "Float64";
84647
+ var OBJECT_ID_TYPE2 = "Oid32";
84796
84648
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ["CUSTOM_ATTRIBUTE_2", "_BATCHID", "BATCHID"];
84797
84649
  var EXT_FEATURE_METADATA3 = "EXT_feature_metadata";
84798
84650
  var EXT_MESH_FEATURES2 = "EXT_mesh_features";
84799
- var scratchVector5 = new import_core22.Vector3();
84800
- async function convertB3dmToI3sGeometry(tileContent, nodeId, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
84651
+ var scratchVector5 = new import_core21.Vector3();
84652
+ async function convertB3dmToI3sGeometry(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
84801
84653
  const useCartesianPositions = generateBoundingVolumes;
84802
84654
  const materialAndTextureList = convertMaterials(tileContent.gltf?.materials);
84803
84655
  const dataForAttributesConversion = prepareDataForAttributesConversion(tileContent);
@@ -84811,7 +84663,6 @@ async function convertB3dmToI3sGeometry(tileContent, nodeId, propertyTable, feat
84811
84663
  });
84812
84664
  }
84813
84665
  const result = [];
84814
- let nodesCounter = nodeId;
84815
84666
  let { materials = [] } = tileContent.gltf || { materials: [] };
84816
84667
  if (!materials?.length) {
84817
84668
  materials.push({ id: "default" });
@@ -84826,19 +84677,19 @@ async function convertB3dmToI3sGeometry(tileContent, nodeId, propertyTable, feat
84826
84677
  continue;
84827
84678
  }
84828
84679
  const { material, texture } = materialAndTextureList[i];
84680
+ const nodeId = addNodeToNodePage();
84829
84681
  result.push(await _makeNodeResources({
84830
84682
  convertedAttributes,
84831
84683
  material,
84832
84684
  texture,
84833
84685
  tileContent,
84834
- nodeId: nodesCounter,
84686
+ nodeId,
84835
84687
  featuresHashArray,
84836
84688
  propertyTable,
84837
84689
  attributeStorageInfo,
84838
84690
  draco,
84839
84691
  workerSource
84840
84692
  }));
84841
- nodesCounter++;
84842
84693
  }
84843
84694
  if (!result.length) {
84844
84695
  return null;
@@ -84894,6 +84745,7 @@ async function _makeNodeResources({
84894
84745
  attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
84895
84746
  }
84896
84747
  return {
84748
+ nodeId,
84897
84749
  geometry: fileBuffer,
84898
84750
  compressedGeometry,
84899
84751
  texture,
@@ -84906,7 +84758,7 @@ async function _makeNodeResources({
84906
84758
  };
84907
84759
  }
84908
84760
  async function convertAttributes(attributesData, useCartesianPositions) {
84909
- const { gltfMaterials, nodes, cartographicOrigin, cartesianModelMatrix } = attributesData;
84761
+ const { gltfMaterials, nodes, images, cartographicOrigin, cartesianModelMatrix } = attributesData;
84910
84762
  const attributesMap = new Map();
84911
84763
  for (const material of gltfMaterials || [{ id: "default" }]) {
84912
84764
  attributesMap.set(material.id, {
@@ -84919,7 +84771,7 @@ async function convertAttributes(attributesData, useCartesianPositions) {
84919
84771
  boundingVolumes: null
84920
84772
  });
84921
84773
  }
84922
- convertNodes(nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
84774
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
84923
84775
  for (const attrKey of attributesMap.keys()) {
84924
84776
  const attributes = attributesMap.get(attrKey);
84925
84777
  if (!attributes) {
@@ -84936,10 +84788,10 @@ async function convertAttributes(attributesData, useCartesianPositions) {
84936
84788
  }
84937
84789
  return attributesMap;
84938
84790
  }
84939
- function convertNodes(nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core22.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84791
+ function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84940
84792
  if (nodes) {
84941
84793
  for (const node2 of nodes) {
84942
- convertNode(node2, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
84794
+ convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
84943
84795
  }
84944
84796
  }
84945
84797
  }
@@ -84960,16 +84812,15 @@ function getCompositeTransformationMatrix(node2, matrix) {
84960
84812
  }
84961
84813
  return transformationMatrix;
84962
84814
  }
84963
- function convertNode(node2, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core22.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84815
+ function convertNode(node2, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84964
84816
  const transformationMatrix = getCompositeTransformationMatrix(node2, matrix);
84965
84817
  const mesh = node2.mesh;
84966
- const images = node2.images;
84967
84818
  if (mesh) {
84968
84819
  convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
84969
84820
  }
84970
- convertNodes(node2.children || [], cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
84821
+ convertNodes(node2.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
84971
84822
  }
84972
- function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core22.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84823
+ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new import_core21.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
84973
84824
  for (const primitive of mesh.primitives) {
84974
84825
  let outputAttributes = null;
84975
84826
  if (primitive.material) {
@@ -85015,7 +84866,7 @@ function transformVertexArray(args) {
85015
84866
  for (let i = 0; i < indices.length; i++) {
85016
84867
  const coordIndex = indices[i] * VALUES_PER_VERTEX2;
85017
84868
  const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX2);
85018
- let vertexVector = new import_core22.Vector3(Array.from(vertex));
84869
+ let vertexVector = new import_core21.Vector3(Array.from(vertex));
85019
84870
  vertexVector = attributeSpecificTransformation(vertexVector, args);
85020
84871
  newVertices[i * VALUES_PER_VERTEX2] = vertexVector.x;
85021
84872
  newVertices[i * VALUES_PER_VERTEX2 + 1] = vertexVector.y;
@@ -85192,10 +85043,10 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
85192
85043
  }
85193
85044
  function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 1) {
85194
85045
  const matDielectricColorComponent = 0.04 / 255;
85195
- const black = new import_core22.Vector4(0, 0, 0, 1);
85196
- const unitVector = new import_core22.Vector4(1, 1, 1, 1);
85197
- const dielectricSpecular = new import_core22.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
85198
- const baseColorVector = new import_core22.Vector4(baseColorFactor);
85046
+ const black = new import_core21.Vector4(0, 0, 0, 1);
85047
+ const unitVector = new import_core21.Vector4(1, 1, 1, 1);
85048
+ const dielectricSpecular = new import_core21.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
85049
+ const baseColorVector = new import_core21.Vector4(baseColorFactor);
85199
85050
  const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
85200
85051
  const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
85201
85052
  dielectricSpecular[3] = 1;
@@ -85278,7 +85129,7 @@ function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attri
85278
85129
  ...properties
85279
85130
  };
85280
85131
  for (const propertyName in propertyTableWithObjectIds) {
85281
- const type = getAttributeType(propertyName, attributeStorageInfo);
85132
+ const type = getAttributeType2(propertyName, attributeStorageInfo);
85282
85133
  const value = propertyTableWithObjectIds[propertyName];
85283
85134
  const attributeBuffer = generateAttributeBuffer(type, value);
85284
85135
  attributeBuffers.push(attributeBuffer);
@@ -85288,14 +85139,14 @@ function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attri
85288
85139
  function generateAttributeBuffer(type, value) {
85289
85140
  let attributeBuffer;
85290
85141
  switch (type) {
85291
- case OBJECT_ID_TYPE:
85292
- case SHORT_INT_TYPE:
85142
+ case OBJECT_ID_TYPE2:
85143
+ case SHORT_INT_TYPE2:
85293
85144
  attributeBuffer = generateShortIntegerAttributeBuffer(value);
85294
85145
  break;
85295
- case DOUBLE_TYPE:
85146
+ case DOUBLE_TYPE2:
85296
85147
  attributeBuffer = generateDoubleAttributeBuffer(value);
85297
85148
  break;
85298
- case STRING_TYPE:
85149
+ case STRING_TYPE2:
85299
85150
  attributeBuffer = generateStringAttributeBuffer(value);
85300
85151
  break;
85301
85152
  default:
@@ -85303,7 +85154,7 @@ function generateAttributeBuffer(type, value) {
85303
85154
  }
85304
85155
  return attributeBuffer;
85305
85156
  }
85306
- function getAttributeType(key, attributeStorageInfo) {
85157
+ function getAttributeType2(key, attributeStorageInfo) {
85307
85158
  const attribute = attributeStorageInfo.find((attr) => attr.name === key);
85308
85159
  return attribute.attributeValues.valueType;
85309
85160
  }
@@ -85387,12 +85238,12 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
85387
85238
  }
85388
85239
  return orderedFeatureIndices;
85389
85240
  }
85390
- function getPropertyTable(sourceTile) {
85391
- const batchTableJson = sourceTile?.content?.batchTableJson;
85241
+ function getPropertyTable(tileContent) {
85242
+ const batchTableJson = tileContent?.batchTableJson;
85392
85243
  if (batchTableJson) {
85393
85244
  return batchTableJson;
85394
85245
  }
85395
- const { extensionName, extension } = getPropertyTableExtension(sourceTile);
85246
+ const { extensionName, extension } = getPropertyTableExtension(tileContent);
85396
85247
  switch (extensionName) {
85397
85248
  case EXT_MESH_FEATURES2: {
85398
85249
  console.warn("The I3S converter does not yet support the EXT_mesh_features extension");
@@ -85405,20 +85256,20 @@ function getPropertyTable(sourceTile) {
85405
85256
  return null;
85406
85257
  }
85407
85258
  }
85408
- function getPropertyTableExtension(sourceTile) {
85259
+ function getPropertyTableExtension(tileContent) {
85409
85260
  const extensionsWithPropertyTables = [EXT_FEATURE_METADATA3, EXT_MESH_FEATURES2];
85410
- const extensionsUsed = sourceTile?.content?.gltf?.extensionsUsed;
85261
+ const extensionsUsed = tileContent?.gltf?.extensionsUsed;
85411
85262
  if (!extensionsUsed) {
85412
85263
  return { extensionName: null, extension: null };
85413
85264
  }
85414
85265
  let extensionName = "";
85415
- for (const extensionItem of sourceTile?.content?.gltf?.extensionsUsed) {
85266
+ for (const extensionItem of tileContent?.gltf?.extensionsUsed || []) {
85416
85267
  if (extensionsWithPropertyTables.includes(extensionItem)) {
85417
85268
  extensionName = extensionItem;
85418
85269
  break;
85419
85270
  }
85420
85271
  }
85421
- const extension = sourceTile?.content?.gltf?.extensions?.[extensionName];
85272
+ const extension = tileContent?.gltf?.extensions?.[extensionName];
85422
85273
  return { extensionName, extension };
85423
85274
  }
85424
85275
  function getPropertyTableFromExtFeatureMetadata(extension) {
@@ -86068,7 +85919,7 @@ function transfromTextureDefinitions(textureDefinitionInfos, thisObject, origina
86068
85919
  // src/i3s-converter/helpers/node-debug.ts
86069
85920
  var import_culling6 = __toModule(require_es58());
86070
85921
  var import_engine = __toModule(require_es515());
86071
- var import_core24 = __toModule(require_es56());
85922
+ var import_core23 = __toModule(require_es56());
86072
85923
  var import_geospatial10 = __toModule(require_es57());
86073
85924
  function validateNodeBoundingVolumes(node2) {
86074
85925
  if (!node2?.parentNode?.obb || !node2?.parentNode?.mbs) {
@@ -86113,7 +85964,7 @@ function getTileObbVertices(node2) {
86113
85964
  const obbCenterCartesian = import_geospatial10.Ellipsoid.WGS84.cartographicToCartesian(node2.obb.center);
86114
85965
  let vertices = [];
86115
85966
  for (let i = 0; i < positions.length; i += 3) {
86116
- const positionsVector = new import_core24.Vector3(positions[i] *= halfSize[0], positions[i + 1] *= halfSize[1], positions[i + 2] *= halfSize[2]);
85967
+ const positionsVector = new import_core23.Vector3(positions[i] *= halfSize[0], positions[i + 1] *= halfSize[1], positions[i + 2] *= halfSize[2]);
86117
85968
  const rotatedPositions = positionsVector.transformByQuaternion(node2.obb.quaternion).add(obbCenterCartesian);
86118
85969
  vertices = vertices.concat(rotatedPositions);
86119
85970
  }
@@ -86236,10 +86087,6 @@ var ION_DEFAULT_TOKEN = import_process2.default.env?.IonToken || "eyJhbGciOiJIUz
86236
86087
  var HARDCODED_NODES_PER_PAGE = 64;
86237
86088
  var _3D_TILES = "3DTILES";
86238
86089
  var _3D_OBJECT_LAYER_TYPE = "3DObject";
86239
- var STRING_TYPE2 = "string";
86240
- var SHORT_INT_TYPE2 = "Int32";
86241
- var DOUBLE_TYPE2 = "double";
86242
- var OBJECT_ID_TYPE2 = "OBJECTID";
86243
86090
  var REFRESH_TOKEN_TIMEOUT = 1800;
86244
86091
  var CESIUM_DATASET_PREFIX = "https://";
86245
86092
  var I3SConverter = class {
@@ -86305,7 +86152,18 @@ var I3SConverter = class {
86305
86152
  await this.loadWorkers();
86306
86153
  try {
86307
86154
  const preloadOptions = await this._fetchPreloadOptions();
86308
- const tilesetOptions = { loadOptions: { basis: { format: "rgba32" } } };
86155
+ const tilesetOptions = {
86156
+ loadOptions: {
86157
+ _nodeWorkers: true,
86158
+ reuseWorkers: true,
86159
+ basis: { format: "rgba32" },
86160
+ "basis-nodejs": {
86161
+ format: "rgba32",
86162
+ workerUrl: "./modules/textures/dist/basis-nodejs-worker.js"
86163
+ },
86164
+ "draco-nodejs": { workerUrl: "./modules/draco/dist/draco-nodejs-worker.js" }
86165
+ }
86166
+ };
86309
86167
  if (preloadOptions.headers) {
86310
86168
  tilesetOptions.loadOptions.fetch = { headers: preloadOptions.headers };
86311
86169
  }
@@ -86461,35 +86319,55 @@ var I3SConverter = class {
86461
86319
  await this._addChildren({ ...data, childNodes });
86462
86320
  await this._addNeighborsAndWriteFile(data.parentNode, childNodes);
86463
86321
  }
86322
+ async convertNestedTileset({
86323
+ sourceTile,
86324
+ parentNode,
86325
+ childNodes,
86326
+ parentId,
86327
+ level
86328
+ }) {
86329
+ await this.sourceTileset._loadTile(sourceTile);
86330
+ await this._addChildren({
86331
+ parentNode,
86332
+ sourceTiles: sourceTile.children,
86333
+ childNodes,
86334
+ parentId,
86335
+ level: level + 1
86336
+ });
86337
+ await sourceTile.unloadContent();
86338
+ }
86339
+ async convertNode({
86340
+ sourceTile,
86341
+ parentNode,
86342
+ childNodes,
86343
+ parentId,
86344
+ level
86345
+ }) {
86346
+ const children = await this._createNode(parentNode, sourceTile, parentId, level);
86347
+ parentNode.children = parentNode.children || [];
86348
+ for (const child of children) {
86349
+ parentNode.children.push({
86350
+ id: child.id,
86351
+ href: `../${child.path}`,
86352
+ obb: child.obb,
86353
+ mbs: child.mbs
86354
+ });
86355
+ childNodes.push(child);
86356
+ }
86357
+ }
86464
86358
  async _addChildren(data) {
86465
86359
  const { childNodes, sourceTiles, parentNode, parentId, level } = data;
86466
86360
  if (this.options.maxDepth && level > this.options.maxDepth) {
86467
86361
  return;
86468
86362
  }
86363
+ const promises = [];
86469
86364
  for (const sourceTile of sourceTiles) {
86470
86365
  if (sourceTile.type === "json") {
86471
- await this.sourceTileset._loadTile(sourceTile);
86472
- await this._addChildren({
86473
- parentNode,
86474
- sourceTiles: sourceTile.children,
86475
- childNodes,
86476
- parentId,
86477
- level: level + 1
86478
- });
86479
- await sourceTile.unloadContent();
86366
+ promises.push(this.convertNestedTileset({ sourceTile, parentNode, childNodes, parentId, level }));
86480
86367
  } else {
86481
- const children = await this._createNode(parentNode, sourceTile, parentId, level);
86482
- parentNode.children = parentNode.children || [];
86483
- for (const child of children) {
86484
- parentNode.children.push({
86485
- id: child.id,
86486
- href: `../${child.path}`,
86487
- obb: child.obb,
86488
- mbs: child.mbs
86489
- });
86490
- childNodes.push(child);
86491
- }
86368
+ promises.push(this.convertNode({ sourceTile, parentNode, childNodes, parentId, level }));
86492
86369
  }
86370
+ await Promise.all(promises);
86493
86371
  if (sourceTile.id) {
86494
86372
  console.log(sourceTile.id);
86495
86373
  }
@@ -86524,11 +86402,11 @@ var I3SConverter = class {
86524
86402
  await this._updateTilesetOptions();
86525
86403
  await this.sourceTileset._loadTile(sourceTile);
86526
86404
  let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
86527
- const propertyTable = getPropertyTable(sourceTile);
86405
+ const propertyTable = getPropertyTable(sourceTile.content);
86528
86406
  if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
86529
86407
  this._convertPropertyTableToNodeAttributes(propertyTable);
86530
86408
  }
86531
- const resourcesData = await this._convertResources(sourceTile, propertyTable);
86409
+ const resourcesData = await this._convertResources(sourceTile, parentId, propertyTable);
86532
86410
  const nodes = [];
86533
86411
  const nodesInPage = [];
86534
86412
  const emptyResources = {
@@ -86549,7 +86427,7 @@ var I3SConverter = class {
86549
86427
  }
86550
86428
  const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
86551
86429
  const maxScreenThresholdSQ = lodSelection.find((val) => val.metricType === "maxScreenThresholdSQ") || { maxError: 0 };
86552
- const nodeInPage = this._createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
86430
+ const nodeInPage = this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
86553
86431
  const node2 = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
86554
86432
  if (nodeInPage.mesh) {
86555
86433
  await this._writeResources(resources, node2.path);
@@ -86572,14 +86450,19 @@ var I3SConverter = class {
86572
86450
  });
86573
86451
  return nodes;
86574
86452
  }
86575
- async _convertResources(sourceTile, propertyTable) {
86453
+ async _convertResources(sourceTile, parentId, propertyTable) {
86576
86454
  if (!this.isContentSupported(sourceTile)) {
86577
86455
  return null;
86578
86456
  }
86579
- const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
86457
+ const draftObb = {
86458
+ center: [],
86459
+ halfSize: [],
86460
+ quaternion: []
86461
+ };
86462
+ const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, () => this.nodePages.push({ index: 0, obb: draftObb }, parentId), propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
86580
86463
  return resourcesData;
86581
86464
  }
86582
- _createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
86465
+ _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
86583
86466
  const { meshMaterial, texture, vertexCount, featureCount, geometry } = resources;
86584
86467
  const nodeInPage = {
86585
86468
  index: 0,
@@ -86601,7 +86484,14 @@ var I3SConverter = class {
86601
86484
  }
86602
86485
  };
86603
86486
  }
86604
- const nodeId = this.nodePages.push(nodeInPage, parentId);
86487
+ let nodeId = resources.nodeId;
86488
+ if (nodeId) {
86489
+ this.nodePages.updateAll(nodeId, nodeInPage);
86490
+ const node2 = this.nodePages.getNodeById(nodeId);
86491
+ this.nodePages.updateResourceInMesh(node2);
86492
+ } else {
86493
+ nodeId = this.nodePages.push(nodeInPage, parentId);
86494
+ }
86605
86495
  if (meshMaterial) {
86606
86496
  this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));
86607
86497
  }
@@ -86617,7 +86507,7 @@ var I3SConverter = class {
86617
86507
  if (featureCount) {
86618
86508
  this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);
86619
86509
  }
86620
- return nodeInPage;
86510
+ return this.nodePages.getNodeById(nodeId);
86621
86511
  }
86622
86512
  _createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
86623
86513
  const { texture, attributes } = resources;
@@ -86811,74 +86701,6 @@ var I3SConverter = class {
86811
86701
  this.materialMap.set(hash, newMaterialId);
86812
86702
  return newMaterialId;
86813
86703
  }
86814
- _createdStorageAttribute(attributeIndex, key, attributeType) {
86815
- const storageAttribute = {
86816
- key: `f_${attributeIndex}`,
86817
- name: key,
86818
- ordering: ["attributeValues"],
86819
- header: [{ property: "count", valueType: "UInt32" }],
86820
- attributeValues: { valueType: "Int32", valuesPerElement: 1 }
86821
- };
86822
- switch (attributeType) {
86823
- case OBJECT_ID_TYPE2:
86824
- this._setupIdAttribute(storageAttribute);
86825
- break;
86826
- case STRING_TYPE2:
86827
- this._setupStringAttribute(storageAttribute);
86828
- break;
86829
- case DOUBLE_TYPE2:
86830
- this._setupDoubleAttribute(storageAttribute);
86831
- break;
86832
- case SHORT_INT_TYPE2:
86833
- break;
86834
- default:
86835
- this._setupStringAttribute(storageAttribute);
86836
- }
86837
- return storageAttribute;
86838
- }
86839
- getAttributeType(key, attribute) {
86840
- if (key === OBJECT_ID_TYPE2) {
86841
- return OBJECT_ID_TYPE2;
86842
- }
86843
- if (typeof attribute === STRING_TYPE2) {
86844
- return STRING_TYPE2;
86845
- } else if (typeof attribute === "number") {
86846
- return Number.isInteger(attribute) ? SHORT_INT_TYPE2 : DOUBLE_TYPE2;
86847
- }
86848
- return STRING_TYPE2;
86849
- }
86850
- _setupStringAttribute(storageAttribute) {
86851
- storageAttribute.ordering.unshift("attributeByteCounts");
86852
- storageAttribute.header.push({ property: "attributeValuesByteCount", valueType: "UInt32" });
86853
- storageAttribute.attributeValues = {
86854
- valueType: "String",
86855
- encoding: "UTF-8",
86856
- valuesPerElement: 1
86857
- };
86858
- storageAttribute.attributeByteCounts = {
86859
- valueType: "UInt32",
86860
- valuesPerElement: 1
86861
- };
86862
- }
86863
- _setupIdAttribute(storageAttribute) {
86864
- storageAttribute.attributeValues = {
86865
- valueType: "Oid32",
86866
- valuesPerElement: 1
86867
- };
86868
- }
86869
- _setupDoubleAttribute(storageAttribute) {
86870
- storageAttribute.attributeValues = {
86871
- valueType: "Float64",
86872
- valuesPerElement: 1
86873
- };
86874
- }
86875
- _createFieldAttribute(key, fieldAttributeType) {
86876
- return {
86877
- name: key,
86878
- type: fieldAttributeType,
86879
- alias: key
86880
- };
86881
- }
86882
86704
  _convertPropertyTableToNodeAttributes(propertyTable) {
86883
86705
  let attributeIndex = 0;
86884
86706
  const propertyTableWithObjectId = {
@@ -86887,11 +86709,11 @@ var I3SConverter = class {
86887
86709
  };
86888
86710
  for (const key in propertyTableWithObjectId) {
86889
86711
  const firstAttribute = propertyTableWithObjectId[key][0];
86890
- const attributeType = this.getAttributeType(key, firstAttribute);
86891
- const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);
86892
- const fieldAttributeType = this._getFieldAttributeType(attributeType);
86893
- const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);
86894
- const popupInfo = this._createPopupInfo(propertyTableWithObjectId);
86712
+ const attributeType = getAttributeType(key, firstAttribute);
86713
+ const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
86714
+ const fieldAttributeType = getFieldAttributeType(attributeType);
86715
+ const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
86716
+ const popupInfo = createPopupInfo(propertyTableWithObjectId);
86895
86717
  this.layers0.attributeStorageInfo.push(storageAttribute);
86896
86718
  this.layers0.fields.push(fieldAttribute);
86897
86719
  this.layers0.popupInfo = popupInfo;
@@ -86899,46 +86721,6 @@ var I3SConverter = class {
86899
86721
  attributeIndex += 1;
86900
86722
  }
86901
86723
  }
86902
- _getFieldAttributeType(attributeType) {
86903
- switch (attributeType) {
86904
- case OBJECT_ID_TYPE2:
86905
- return "esriFieldTypeOID";
86906
- case STRING_TYPE2:
86907
- return "esriFieldTypeString";
86908
- case SHORT_INT_TYPE2:
86909
- return "esriFieldTypeInteger";
86910
- case DOUBLE_TYPE2:
86911
- return "esriFieldTypeDouble";
86912
- default:
86913
- return "esriFieldTypeString";
86914
- }
86915
- }
86916
- _createPopupInfo(propertyTable) {
86917
- const title = "{OBJECTID}";
86918
- const mediaInfos = [];
86919
- const fieldInfos = [];
86920
- const popupElements = [];
86921
- const expressionInfos = [];
86922
- for (const key in propertyTable) {
86923
- fieldInfos.push({
86924
- fieldName: key,
86925
- visible: true,
86926
- isEditable: false,
86927
- label: key
86928
- });
86929
- }
86930
- popupElements.push({
86931
- fieldInfos,
86932
- type: "fields"
86933
- });
86934
- return {
86935
- title,
86936
- mediaInfos,
86937
- popupElements,
86938
- fieldInfos,
86939
- expressionInfos
86940
- };
86941
- }
86942
86724
  async _finishConversion(params) {
86943
86725
  const { tilesCount, tilesWithAddRefineCount } = this.refinementCounter;
86944
86726
  const addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
@@ -87065,7 +86847,7 @@ function generateTilesetAttributeUrls(tileset, resource) {
87065
86847
  }
87066
86848
 
87067
86849
  // ../i3s/src/lib/parsers/constants.ts
87068
- var import_constants15 = __toModule(require_es516());
86850
+ var import_constants10 = __toModule(require_es516());
87069
86851
  function getConstructorForDataFormat(dataType) {
87070
86852
  switch (dataType) {
87071
86853
  case DATA_TYPE.UInt8:
@@ -87083,11 +86865,11 @@ function getConstructorForDataFormat(dataType) {
87083
86865
  }
87084
86866
  }
87085
86867
  var GL_TYPE_MAP = {
87086
- UInt8: import_constants15.default.UNSIGNED_BYTE,
87087
- UInt16: import_constants15.default.UNSIGNED_INT,
87088
- Float32: import_constants15.default.FLOAT,
87089
- UInt32: import_constants15.default.UNSIGNED_INT,
87090
- UInt64: import_constants15.default.DOUBLE
86868
+ UInt8: import_constants10.default.UNSIGNED_BYTE,
86869
+ UInt16: import_constants10.default.UNSIGNED_INT,
86870
+ Float32: import_constants10.default.FLOAT,
86871
+ UInt32: import_constants10.default.UNSIGNED_INT,
86872
+ UInt64: import_constants10.default.DOUBLE
87091
86873
  };
87092
86874
  function sizeOf(dataType) {
87093
86875
  switch (dataType) {
@@ -87121,6 +86903,149 @@ var COORDINATE_SYSTEM;
87121
86903
  COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["CARTESIAN"] = 0] = "CARTESIAN";
87122
86904
  })(COORDINATE_SYSTEM || (COORDINATE_SYSTEM = {}));
87123
86905
 
86906
+ // ../i3s/src/lib/parsers/parse-i3s-attribute.ts
86907
+ async function parseI3STileAttribute(arrayBuffer, options) {
86908
+ const { attributeName, attributeType } = options;
86909
+ if (!attributeName) {
86910
+ return {};
86911
+ }
86912
+ return {
86913
+ [attributeName]: attributeType ? parseAttribute(attributeType, arrayBuffer) : null
86914
+ };
86915
+ }
86916
+ function parseAttribute(attributeType, arrayBuffer) {
86917
+ switch (attributeType) {
86918
+ case STRING_ATTRIBUTE_TYPE:
86919
+ return parseStringsAttribute(arrayBuffer);
86920
+ case OBJECT_ID_ATTRIBUTE_TYPE:
86921
+ return parseShortNumberAttribute(arrayBuffer);
86922
+ case FLOAT_64_TYPE:
86923
+ return parseFloatAttribute(arrayBuffer);
86924
+ case INT_16_ATTRIBUTE_TYPE:
86925
+ return parseInt16ShortNumberAttribute(arrayBuffer);
86926
+ default:
86927
+ return parseShortNumberAttribute(arrayBuffer);
86928
+ }
86929
+ }
86930
+ function parseShortNumberAttribute(arrayBuffer) {
86931
+ const countOffset = 4;
86932
+ return new Uint32Array(arrayBuffer, countOffset);
86933
+ }
86934
+ function parseInt16ShortNumberAttribute(arrayBuffer) {
86935
+ const countOffset = 4;
86936
+ return new Int16Array(arrayBuffer, countOffset);
86937
+ }
86938
+ function parseFloatAttribute(arrayBuffer) {
86939
+ const countOffset = 8;
86940
+ return new Float64Array(arrayBuffer, countOffset);
86941
+ }
86942
+ function parseStringsAttribute(arrayBuffer) {
86943
+ const stringsCountOffset = 0;
86944
+ const dataOffset = 8;
86945
+ const bytesPerStringSize = 4;
86946
+ const stringsArray = [];
86947
+ try {
86948
+ const stringsCount = new DataView(arrayBuffer, stringsCountOffset, bytesPerStringSize).getUint32(stringsCountOffset, true);
86949
+ const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);
86950
+ let stringOffset = dataOffset + stringsCount * bytesPerStringSize;
86951
+ for (const stringByteSize of stringSizes) {
86952
+ const textDecoder = new TextDecoder("utf-8");
86953
+ const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);
86954
+ stringsArray.push(textDecoder.decode(stringAttribute));
86955
+ stringOffset += stringByteSize;
86956
+ }
86957
+ } catch (error) {
86958
+ console.error("Parse string attribute error: ", error.message);
86959
+ }
86960
+ return stringsArray;
86961
+ }
86962
+
86963
+ // ../i3s/src/i3s-attribute-loader.ts
86964
+ var VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
86965
+ var I3SAttributeLoader = {
86966
+ name: "I3S Attribute",
86967
+ id: "i3s-attribute",
86968
+ module: "i3s",
86969
+ version: VERSION12,
86970
+ mimeTypes: ["application/binary"],
86971
+ parse: parse6,
86972
+ extensions: ["bin"],
86973
+ options: {},
86974
+ binary: true
86975
+ };
86976
+ async function parse6(data, options) {
86977
+ data = parseI3STileAttribute(data, options);
86978
+ return data;
86979
+ }
86980
+ function getAttributeValueType(attribute) {
86981
+ if (attribute.hasOwnProperty("objectIds")) {
86982
+ return "Oid32";
86983
+ } else if (attribute.hasOwnProperty("attributeValues")) {
86984
+ return attribute.attributeValues.valueType;
86985
+ }
86986
+ return "";
86987
+ }
86988
+
86989
+ // ../i3s/src/lib/utils/customizeColors.ts
86990
+ async function customizeColors(colors, featureIds, tileOptions, tilesetOptions, options) {
86991
+ if (!options?.i3s?.colorsByAttribute) {
86992
+ return colors;
86993
+ }
86994
+ const colorizeAttributeField = tilesetOptions.fields.find(({ name: name10 }) => name10 === options?.i3s?.colorsByAttribute?.attributeName);
86995
+ if (!colorizeAttributeField || !["esriFieldTypeDouble", "esriFieldTypeInteger", "esriFieldTypeSmallInteger"].includes(colorizeAttributeField.type)) {
86996
+ return colors;
86997
+ }
86998
+ const colorizeAttributeData = await loadFeatureAttributeData(colorizeAttributeField.name, tileOptions, tilesetOptions, options);
86999
+ if (!colorizeAttributeData) {
87000
+ return colors;
87001
+ }
87002
+ const objectIdField = tilesetOptions.fields.find(({ type }) => type === "esriFieldTypeOID");
87003
+ if (!objectIdField) {
87004
+ return colors;
87005
+ }
87006
+ const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, tileOptions, tilesetOptions, options);
87007
+ if (!objectIdAttributeData) {
87008
+ return colors;
87009
+ }
87010
+ const attributeValuesMap = {};
87011
+ for (let i = 0; i < objectIdAttributeData[objectIdField.name].length; i++) {
87012
+ attributeValuesMap[objectIdAttributeData[objectIdField.name][i]] = calculateColorForAttribute(colorizeAttributeData[colorizeAttributeField.name][i], options);
87013
+ }
87014
+ for (let i = 0; i < featureIds.value.length; i++) {
87015
+ const color = attributeValuesMap[featureIds.value[i]];
87016
+ if (!color) {
87017
+ continue;
87018
+ }
87019
+ colors.value.set(color, i * 4);
87020
+ }
87021
+ return colors;
87022
+ }
87023
+ function calculateColorForAttribute(attributeValue, options) {
87024
+ if (!options?.i3s?.colorsByAttribute) {
87025
+ return [255, 255, 255, 255];
87026
+ }
87027
+ const { minValue, maxValue, minColor, maxColor } = options.i3s.colorsByAttribute;
87028
+ const rate = (attributeValue - minValue) / (maxValue - minValue);
87029
+ const color = [255, 255, 255, 255];
87030
+ for (let i = 0; i < minColor.length; i++) {
87031
+ color[i] = Math.round((maxColor[i] - minColor[i]) * rate + minColor[i]);
87032
+ }
87033
+ return color;
87034
+ }
87035
+ async function loadFeatureAttributeData(attributeName, { attributeUrls }, { attributeStorageInfo }, options) {
87036
+ const attributeIndex = attributeStorageInfo.findIndex(({ name: name10 }) => attributeName === name10);
87037
+ if (attributeIndex === -1) {
87038
+ return null;
87039
+ }
87040
+ const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], options?.i3s?.token);
87041
+ const attributeType = getAttributeValueType(attributeStorageInfo[attributeIndex]);
87042
+ const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {
87043
+ attributeName,
87044
+ attributeType
87045
+ });
87046
+ return objectIdAttributeData;
87047
+ }
87048
+
87124
87049
  // ../i3s/src/lib/parsers/parse-i3s-tile-content.ts
87125
87050
  var scratchVector6 = new import_core27.Vector3([0, 0, 0]);
87126
87051
  function getLoaderForTextureFormat(textureFormat) {
@@ -87137,18 +87062,17 @@ function getLoaderForTextureFormat(textureFormat) {
87137
87062
  }
87138
87063
  }
87139
87064
  var I3S_ATTRIBUTE_TYPE = "i3s-attribute-type";
87140
- var defaultContent = {
87141
- attributes: {},
87142
- indices: null,
87143
- featureIds: [],
87144
- vertexCount: 0,
87145
- modelMatrix: new import_core27.Matrix4(),
87146
- coordinateSystem: 0,
87147
- byteLength: 0,
87148
- texture: null
87149
- };
87150
87065
  async function parseI3STileContent(arrayBuffer, tileOptions, tilesetOptions, options, context) {
87151
- const content = defaultContent;
87066
+ const content = {
87067
+ attributes: {},
87068
+ indices: null,
87069
+ featureIds: [],
87070
+ vertexCount: 0,
87071
+ modelMatrix: new import_core27.Matrix4(),
87072
+ coordinateSystem: 0,
87073
+ byteLength: 0,
87074
+ texture: null
87075
+ };
87152
87076
  if (tileOptions.textureUrl) {
87153
87077
  const url = getUrlWithToken(tileOptions.textureUrl, options?.i3s?.token);
87154
87078
  const loader = getLoaderForTextureFormat(tileOptions.textureFormat);
@@ -87245,6 +87169,7 @@ async function parseI3SNodeGeometry(arrayBuffer, content, tileOptions, tilesetOp
87245
87169
  content.modelMatrix = getModelMatrix(attributes.position);
87246
87170
  content.coordinateSystem = COORDINATE_SYSTEM.LNGLAT_OFFSETS;
87247
87171
  }
87172
+ attributes.color = await customizeColors(attributes.color, attributes.id, tileOptions, tilesetOptions, options);
87248
87173
  content.attributes = {
87249
87174
  positions: attributes.position,
87250
87175
  normals: attributes.normal,
@@ -87497,21 +87422,21 @@ function getFeatureIdsFromFeatureIndexMetadata(featureIndex) {
87497
87422
  }
87498
87423
 
87499
87424
  // ../i3s/src/i3s-content-loader.ts
87500
- var VERSION12 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
87425
+ var VERSION13 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "beta";
87501
87426
  var I3SContentLoader = {
87502
87427
  name: "I3S Content (Indexed Scene Layers)",
87503
- id: "i3s-content",
87428
+ id: isBrowser2 ? "i3s-content" : "i3s-content-nodejs",
87504
87429
  module: "i3s",
87505
87430
  worker: true,
87506
- version: VERSION12,
87431
+ version: VERSION13,
87507
87432
  mimeTypes: ["application/octet-stream"],
87508
- parse: parse6,
87433
+ parse: parse7,
87509
87434
  extensions: ["bin"],
87510
87435
  options: {
87511
87436
  "i3s-content": {}
87512
87437
  }
87513
87438
  };
87514
- async function parse6(data, options, context) {
87439
+ async function parse7(data, options, context) {
87515
87440
  const { tile, _tileOptions, tileset, _tilesetOptions } = options?.i3s || {};
87516
87441
  const tileOptions = _tileOptions || tile;
87517
87442
  const tilesetOptions = _tilesetOptions || tileset;
@@ -87526,7 +87451,7 @@ var import_culling7 = __toModule(require_es58());
87526
87451
  var import_geospatial12 = __toModule(require_es57());
87527
87452
 
87528
87453
  // ../i3s/src/i3s-node-page-loader.ts
87529
- var VERSION13 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87454
+ var VERSION14 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87530
87455
  async function parseNodePage(data) {
87531
87456
  return JSON.parse(new TextDecoder().decode(data));
87532
87457
  }
@@ -87534,13 +87459,13 @@ var I3SNodePageLoader = {
87534
87459
  name: "I3S Node Page",
87535
87460
  id: "i3s-node-page",
87536
87461
  module: "i3s",
87537
- version: VERSION13,
87462
+ version: VERSION14,
87538
87463
  mimeTypes: ["application/json"],
87539
- parse: parse7,
87464
+ parse: parse8,
87540
87465
  extensions: ["json"],
87541
87466
  options: {}
87542
87467
  };
87543
- async function parse7(data) {
87468
+ async function parse8(data) {
87544
87469
  data = parseNodePage(data);
87545
87470
  return data;
87546
87471
  }
@@ -87790,7 +87715,7 @@ async function normalizeTilesetData(tileset, options, context) {
87790
87715
  }
87791
87716
 
87792
87717
  // ../i3s/src/i3s-loader.ts
87793
- var VERSION14 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87718
+ var VERSION15 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87794
87719
  var TILESET_REGEX = /layers\/[0-9]+$/;
87795
87720
  var TILE_HEADER_REGEX = /nodes\/([0-9-]+|root)$/;
87796
87721
  var SLPK_HEX = "504b0304";
@@ -87798,7 +87723,7 @@ var I3SLoader = {
87798
87723
  name: "I3S (Indexed Scene Layers)",
87799
87724
  id: "i3s",
87800
87725
  module: "i3s",
87801
- version: VERSION14,
87726
+ version: VERSION15,
87802
87727
  mimeTypes: ["application/octet-stream"],
87803
87728
  parse: parseI3S,
87804
87729
  extensions: ["bin"],
@@ -87814,7 +87739,8 @@ var I3SLoader = {
87814
87739
  useDracoGeometry: true,
87815
87740
  useCompressedTextures: true,
87816
87741
  decodeTextures: true,
87817
- coordinateSystem: COORDINATE_SYSTEM.METER_OFFSETS
87742
+ coordinateSystem: COORDINATE_SYSTEM.METER_OFFSETS,
87743
+ colorsByAttribute: null
87818
87744
  }
87819
87745
  }
87820
87746
  };
@@ -87866,81 +87792,6 @@ function getMagicNumber(data) {
87866
87792
  return null;
87867
87793
  }
87868
87794
 
87869
- // ../i3s/src/lib/parsers/parse-i3s-attribute.ts
87870
- async function parseI3STileAttribute(arrayBuffer, options) {
87871
- const { attributeName, attributeType } = options;
87872
- if (!attributeName) {
87873
- return {};
87874
- }
87875
- return {
87876
- [attributeName]: attributeType ? parseAttribute(attributeType, arrayBuffer) : null
87877
- };
87878
- }
87879
- function parseAttribute(attributeType, arrayBuffer) {
87880
- switch (attributeType) {
87881
- case STRING_ATTRIBUTE_TYPE:
87882
- return parseStringsAttribute(arrayBuffer);
87883
- case OBJECT_ID_ATTRIBUTE_TYPE:
87884
- return parseShortNumberAttribute(arrayBuffer);
87885
- case FLOAT_64_TYPE:
87886
- return parseFloatAttribute(arrayBuffer);
87887
- case INT_16_ATTRIBUTE_TYPE:
87888
- return parseInt16ShortNumberAttribute(arrayBuffer);
87889
- default:
87890
- return parseShortNumberAttribute(arrayBuffer);
87891
- }
87892
- }
87893
- function parseShortNumberAttribute(arrayBuffer) {
87894
- const countOffset = 4;
87895
- return new Uint32Array(arrayBuffer, countOffset);
87896
- }
87897
- function parseInt16ShortNumberAttribute(arrayBuffer) {
87898
- const countOffset = 4;
87899
- return new Int16Array(arrayBuffer, countOffset);
87900
- }
87901
- function parseFloatAttribute(arrayBuffer) {
87902
- const countOffset = 8;
87903
- return new Float64Array(arrayBuffer, countOffset);
87904
- }
87905
- function parseStringsAttribute(arrayBuffer) {
87906
- const stringsCountOffset = 0;
87907
- const dataOffset = 8;
87908
- const bytesPerStringSize = 4;
87909
- const stringsArray = [];
87910
- try {
87911
- const stringsCount = new DataView(arrayBuffer, stringsCountOffset, bytesPerStringSize).getUint32(stringsCountOffset, true);
87912
- const stringSizes = new Uint32Array(arrayBuffer, dataOffset, stringsCount);
87913
- let stringOffset = dataOffset + stringsCount * bytesPerStringSize;
87914
- for (const stringByteSize of stringSizes) {
87915
- const textDecoder = new TextDecoder("utf-8");
87916
- const stringAttribute = new Uint8Array(arrayBuffer, stringOffset, stringByteSize);
87917
- stringsArray.push(textDecoder.decode(stringAttribute));
87918
- stringOffset += stringByteSize;
87919
- }
87920
- } catch (error) {
87921
- console.error("Parse string attribute error: ", error.message);
87922
- }
87923
- return stringsArray;
87924
- }
87925
-
87926
- // ../i3s/src/i3s-attribute-loader.ts
87927
- var VERSION15 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
87928
- var I3SAttributeLoader = {
87929
- name: "I3S Attribute",
87930
- id: "i3s-attribute",
87931
- module: "i3s",
87932
- version: VERSION15,
87933
- mimeTypes: ["application/binary"],
87934
- parse: parse8,
87935
- extensions: ["bin"],
87936
- options: {},
87937
- binary: true
87938
- };
87939
- async function parse8(data, options) {
87940
- data = parseI3STileAttribute(data, options);
87941
- return data;
87942
- }
87943
-
87944
87795
  // src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts
87945
87796
  var import_core31 = __toModule(require_es56());
87946
87797
  var import_geospatial13 = __toModule(require_es57());
@@ -87994,230 +87845,6 @@ var TILESET = () => ({
87994
87845
  }
87995
87846
  });
87996
87847
 
87997
- // src/3d-tiles-converter/helpers/b3dm-converter.ts
87998
- var import_core33 = __toModule(require_es56());
87999
- var import_geospatial14 = __toModule(require_es57());
88000
-
88001
- // src/3d-tiles-converter/helpers/texture-atlas.ts
88002
- function convertTextureAtlas(texCoords, uvRegions) {
88003
- const convertedTexCoords = new Float32Array(texCoords.length);
88004
- const normalisedRegions = normalizeRegions(uvRegions);
88005
- for (let index = 0; index < texCoords.length; index += 2) {
88006
- const uv = texCoords.subarray(index, index + 2);
88007
- const regions = normalisedRegions.slice(index * 2, index * 2 + 4);
88008
- const fractatedUV = fract([uv[0], uv[1]]);
88009
- const subtracted = [regions[2] - regions[0], regions[3] - regions[1]];
88010
- const multiplicationResult = [fractatedUV[0] * subtracted[0], fractatedUV[1] * subtracted[1]];
88011
- const convertedUV = [
88012
- multiplicationResult[0] + regions[0],
88013
- multiplicationResult[1] + regions[1]
88014
- ];
88015
- convertedTexCoords[index] = convertedUV[0];
88016
- convertedTexCoords[index + 1] = convertedUV[1];
88017
- }
88018
- return convertedTexCoords;
88019
- }
88020
- function fract(uv) {
88021
- return [uv[0] - Math.floor(uv[0]), uv[1] - Math.floor(uv[1])];
88022
- }
88023
- function normalizeRegions(regions) {
88024
- const MAX_UINT_16_VALUE = 65535;
88025
- const normalizedRegions = [];
88026
- for (let index = 0; index < regions.length; index++) {
88027
- normalizedRegions[index] = regions[index] / MAX_UINT_16_VALUE;
88028
- }
88029
- return normalizedRegions;
88030
- }
88031
-
88032
- // src/3d-tiles-converter/helpers/b3dm-converter.ts
88033
- var Z_UP_TO_Y_UP_MATRIX = new import_core33.Matrix4([1, 0, 0, 0, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 1]);
88034
- var scratchVector7 = new import_core33.Vector3();
88035
- var B3dmConverter = class {
88036
- async convert(i3sAttributesData, featureAttributes = null) {
88037
- const gltf = await this.buildGltf(i3sAttributesData);
88038
- const b3dm = encodeSync({
88039
- gltfEncoded: new Uint8Array(gltf),
88040
- type: "b3dm",
88041
- featuresLength: this._getFeaturesLength(featureAttributes),
88042
- batchTable: featureAttributes
88043
- }, Tile3DWriter);
88044
- return b3dm;
88045
- }
88046
- async buildGltf(i3sAttributesData) {
88047
- const { tileContent, textureFormat } = i3sAttributesData;
88048
- const {
88049
- material,
88050
- attributes,
88051
- indices: originalIndices,
88052
- cartesianOrigin,
88053
- cartographicOrigin,
88054
- modelMatrix
88055
- } = tileContent;
88056
- const gltfBuilder = new GLTFScenegraph();
88057
- const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
88058
- const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
88059
- const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
88060
- const positions = attributes.positions;
88061
- const positionsValue = positions.value;
88062
- if (attributes.uvRegions && attributes.texCoords) {
88063
- attributes.texCoords.value = convertTextureAtlas(attributes.texCoords.value, attributes.uvRegions.value);
88064
- }
88065
- attributes.positions.value = this._normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix);
88066
- if (attributes.normals && !this._checkNormals(attributes.normals.value)) {
88067
- delete attributes.normals;
88068
- }
88069
- const indices = originalIndices || this._generateSynteticIndices(positionsValue.length / positions.size);
88070
- const meshIndex = gltfBuilder.addMesh({
88071
- attributes,
88072
- indices,
88073
- material: materialIndex,
88074
- mode: 4
88075
- });
88076
- const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
88077
- const nodeIndex = gltfBuilder.addNode({ meshIndex, matrix: transformMatrix });
88078
- const sceneIndex = gltfBuilder.addScene({ nodeIndices: [nodeIndex] });
88079
- gltfBuilder.setDefaultScene(sceneIndex);
88080
- gltfBuilder.createBinaryChunk();
88081
- const gltfBuffer = encodeSync(gltfBuilder.gltf, GLTFWriter);
88082
- return gltfBuffer;
88083
- }
88084
- async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
88085
- const { texture, material, attributes } = tileContent;
88086
- let textureIndex = null;
88087
- let selectedTexture = texture;
88088
- if (!texture && material) {
88089
- selectedTexture = material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture && material.pbrMetallicRoughness.baseColorTexture.texture.source.image;
88090
- }
88091
- if (selectedTexture) {
88092
- const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
88093
- const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
88094
- textureIndex = gltfBuilder.addTexture({ imageIndex });
88095
- delete attributes.colors;
88096
- }
88097
- return textureIndex;
88098
- }
88099
- _normalizePositions(positionsValue, cartesianOrigin, cartographicOrigin, modelMatrix) {
88100
- const newPositionsValue = new Float32Array(positionsValue.length);
88101
- for (let index = 0; index < positionsValue.length; index += 3) {
88102
- const vertex = positionsValue.subarray(index, index + 3);
88103
- const cartesianOriginVector = new import_core33.Vector3(cartesianOrigin);
88104
- let vertexVector = new import_core33.Vector3(Array.from(vertex)).transform(modelMatrix).add(cartographicOrigin);
88105
- import_geospatial14.Ellipsoid.WGS84.cartographicToCartesian(vertexVector, scratchVector7);
88106
- vertexVector = scratchVector7.subtract(cartesianOriginVector);
88107
- newPositionsValue.set(vertexVector, index);
88108
- }
88109
- return newPositionsValue;
88110
- }
88111
- _generateTransformMatrix(cartesianOrigin) {
88112
- const translateOriginMatrix = new import_core33.Matrix4().translate(cartesianOrigin);
88113
- const result = translateOriginMatrix.multiplyLeft(Z_UP_TO_Y_UP_MATRIX);
88114
- return result;
88115
- }
88116
- _generateBatchId(faceRanges) {
88117
- const batchIdArraySize = (faceRanges[faceRanges.length - 1] + 1) * 3;
88118
- const batchId = new Float32Array(batchIdArraySize);
88119
- let rangeIndex = 0;
88120
- let currentBatchId = 0;
88121
- for (let index = 0; index < faceRanges.length / 2; index++) {
88122
- const fromIndex = faceRanges[rangeIndex] * 3;
88123
- const untilPosition = (faceRanges[rangeIndex + 1] + 1) * 3;
88124
- batchId.fill(currentBatchId, fromIndex, untilPosition);
88125
- rangeIndex += 2;
88126
- currentBatchId += 1;
88127
- }
88128
- return batchId;
88129
- }
88130
- _generateSynteticIndices(vertexCount) {
88131
- const result = new Uint32Array(vertexCount);
88132
- for (let index = 0; index < vertexCount; index++) {
88133
- result.set([index], index);
88134
- }
88135
- return result;
88136
- }
88137
- _deduceMimeTypeFromFormat(format) {
88138
- switch (format) {
88139
- case "jpg":
88140
- return "image/jpeg";
88141
- case "png":
88142
- return "image/png";
88143
- case "ktx2":
88144
- return "image/ktx2";
88145
- default:
88146
- console.warn(`Unexpected texture format in I3S: ${format}`);
88147
- return "image/jpeg";
88148
- }
88149
- }
88150
- _convertI3sMaterialToGltfMaterial(material, textureIndex) {
88151
- const isTextureIndexExists = textureIndex !== null;
88152
- if (!material) {
88153
- material = {
88154
- alphaMode: "OPAQUE",
88155
- doubleSided: false,
88156
- pbrMetallicRoughness: {
88157
- metallicFactor: 0,
88158
- roughnessFactor: 1
88159
- }
88160
- };
88161
- if (isTextureIndexExists) {
88162
- material.pbrMetallicRoughness.baseColorTexture = {
88163
- index: textureIndex,
88164
- texCoord: 0
88165
- };
88166
- } else {
88167
- material.pbrMetallicRoughness.baseColorFactor = [1, 1, 1, 1];
88168
- }
88169
- return material;
88170
- }
88171
- if (textureIndex !== null) {
88172
- material = this._setGltfTexture(material, textureIndex);
88173
- }
88174
- return material;
88175
- }
88176
- _setGltfTexture(materialDefinition, textureIndex) {
88177
- const material = {
88178
- ...materialDefinition,
88179
- pbrMetallicRoughness: { ...materialDefinition.pbrMetallicRoughness }
88180
- };
88181
- if (materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.baseColorTexture) {
88182
- material.pbrMetallicRoughness.baseColorTexture = {
88183
- index: textureIndex,
88184
- texCoord: 0
88185
- };
88186
- } else if (materialDefinition.emissiveTexture) {
88187
- material.emissiveTexture = {
88188
- index: textureIndex,
88189
- texCoord: 0
88190
- };
88191
- } else if (materialDefinition.pbrMetallicRoughness && materialDefinition.pbrMetallicRoughness.metallicRoughnessTexture) {
88192
- material.pbrMetallicRoughness.metallicRoughnessTexture = {
88193
- index: textureIndex,
88194
- texCoord: 0
88195
- };
88196
- } else if (materialDefinition.normalTexture) {
88197
- material.normalTexture = {
88198
- index: textureIndex,
88199
- texCoord: 0
88200
- };
88201
- } else if (materialDefinition.occlusionTexture) {
88202
- material.occlusionTexture = {
88203
- index: textureIndex,
88204
- texCoord: 0
88205
- };
88206
- }
88207
- return material;
88208
- }
88209
- _getFeaturesLength(attributes) {
88210
- if (!attributes) {
88211
- return 0;
88212
- }
88213
- const firstKey = Object.keys(attributes)[0];
88214
- return firstKey ? attributes[firstKey].length : 0;
88215
- }
88216
- _checkNormals(normals) {
88217
- return normals.find((value) => value);
88218
- }
88219
- };
88220
-
88221
87848
  // src/3d-tiles-attributes-worker.ts
88222
87849
  var VERSION16 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
88223
87850
  var Tile3dAttributesWorker = {
@@ -88229,6 +87856,9 @@ var Tile3dAttributesWorker = {
88229
87856
  attributes: null
88230
87857
  }
88231
87858
  };
87859
+ function transform3DTilesAttributesOnWorker(i3sAttributesData, options) {
87860
+ return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);
87861
+ }
88232
87862
 
88233
87863
  // src/3d-tiles-converter/3d-tiles-converter.ts
88234
87864
  var I3S = "I3S";
@@ -88259,6 +87889,11 @@ var Tiles3DConverter = class {
88259
87889
  const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
88260
87890
  this.sourceTileset = new Tileset3D(sourceTilesetJson, {
88261
87891
  loadOptions: {
87892
+ _nodeWorkers: true,
87893
+ reuseWorkers: true,
87894
+ "i3s-content-nodejs": {
87895
+ workerUrl: "./modules/i3s/dist/i3s-content-nodejs-worker.js"
87896
+ },
88262
87897
  i3s: { coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
88263
87898
  }
88264
87899
  });
@@ -88287,48 +87922,56 @@ var Tiles3DConverter = class {
88287
87922
  const workerFarm = WorkerFarm.getWorkerFarm({});
88288
87923
  workerFarm.destroy();
88289
87924
  }
87925
+ async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
87926
+ const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
87927
+ parentSourceNode.children.push(sourceChild);
87928
+ if (sourceChild.contentUrl) {
87929
+ await this.sourceTileset._loadTile(sourceChild);
87930
+ this.vertexCounter += sourceChild.content.vertexCount;
87931
+ let featureAttributes = null;
87932
+ if (this.attributeStorageInfo) {
87933
+ featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
87934
+ }
87935
+ if (!sourceChild.header.obb) {
87936
+ sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);
87937
+ }
87938
+ const boundingVolume = {
87939
+ box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)
87940
+ };
87941
+ const child = {
87942
+ boundingVolume,
87943
+ geometricError: convertScreenThresholdToGeometricError(sourceChild),
87944
+ children: []
87945
+ };
87946
+ const i3sAttributesData = {
87947
+ tileContent: sourceChild.content,
87948
+ textureFormat: sourceChild?.header?.textureFormat
87949
+ };
87950
+ const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
87951
+ source: this.workerSource.tile3dWorkerSource,
87952
+ featureAttributes
87953
+ });
87954
+ child.content = {
87955
+ uri: `${sourceChild.id}.b3dm`,
87956
+ boundingVolume
87957
+ };
87958
+ await writeFile3(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
87959
+ parentNode.children.push(child);
87960
+ sourceChild.unloadContent();
87961
+ await this._addChildren(sourceChild, child, level + 1);
87962
+ } else {
87963
+ await this._addChildren(sourceChild, parentNode, level + 1);
87964
+ }
87965
+ }
88290
87966
  async _addChildren(parentSourceNode, parentNode, level) {
88291
87967
  if (this.options.maxDepth && level > this.options.maxDepth) {
88292
87968
  return;
88293
87969
  }
87970
+ const promises = [];
88294
87971
  for (const childNodeInfo of parentSourceNode.header.children || []) {
88295
- const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
88296
- parentSourceNode.children.push(sourceChild);
88297
- if (sourceChild.contentUrl) {
88298
- await this.sourceTileset._loadTile(sourceChild);
88299
- this.vertexCounter += sourceChild.content.vertexCount;
88300
- let featureAttributes = null;
88301
- if (this.attributeStorageInfo) {
88302
- featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
88303
- }
88304
- if (!sourceChild.header.obb) {
88305
- sourceChild.header.obb = createObbFromMbs(sourceChild.header.mbs);
88306
- }
88307
- const boundingVolume = {
88308
- box: i3sObbTo3dTilesObb(sourceChild.header.obb, this.geoidHeightModel)
88309
- };
88310
- const child = {
88311
- boundingVolume,
88312
- geometricError: convertScreenThresholdToGeometricError(sourceChild),
88313
- children: []
88314
- };
88315
- const i3sAttributesData = {
88316
- tileContent: sourceChild.content,
88317
- textureFormat: sourceChild?.header?.textureFormat
88318
- };
88319
- const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);
88320
- child.content = {
88321
- uri: `${sourceChild.id}.b3dm`,
88322
- boundingVolume
88323
- };
88324
- await writeFile3(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
88325
- parentNode.children.push(child);
88326
- sourceChild.unloadContent();
88327
- await this._addChildren(sourceChild, child, level + 1);
88328
- } else {
88329
- await this._addChildren(sourceChild, parentNode, level + 1);
88330
- }
87972
+ promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
88331
87973
  }
87974
+ await Promise.all(promises);
88332
87975
  }
88333
87976
  async _loadChildNode(parentNode, childNodeInfo) {
88334
87977
  let header;