babylonjs-serializers 5.33.0 → 5.33.2

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.
@@ -2516,6 +2516,9 @@ __webpack_require__.r(__webpack_exports__);
2516
2516
 
2517
2517
 
2518
2518
 
2519
+
2520
+ // Matrix that converts handedness on the X-axis.
2521
+ var convertHandednessMatrix = core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(new core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(-1, 1, 1), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.Identity(), core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero());
2519
2522
  /**
2520
2523
  * Converts Babylon Scene into glTF 2.0.
2521
2524
  * @internal
@@ -3910,21 +3913,15 @@ var _Exporter = /** @class */ (function () {
3910
3913
  */
3911
3914
  _Exporter.prototype._isBabylonCoordinateSystemConvertingNode = function (node) {
3912
3915
  if (node instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.TransformNode) {
3913
- if (node.name !== "__root__") {
3914
- return false;
3915
- }
3916
3916
  // Transform
3917
- var matrix = node.getWorldMatrix();
3918
- if (matrix.determinant() === 1) {
3917
+ var matrix = node.getWorldMatrix().multiplyToRef(convertHandednessMatrix, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Matrix[0]);
3918
+ if (!matrix.isIdentity()) {
3919
3919
  return false;
3920
3920
  }
3921
3921
  // Geometry
3922
3922
  if ((node instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh && node.geometry !== null) || (node instanceof core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.InstancedMesh && node.sourceMesh.geometry !== null)) {
3923
3923
  return false;
3924
3924
  }
3925
- if (this._includeCoordinateSystemConversionNodes) {
3926
- return false;
3927
- }
3928
3925
  return true;
3929
3926
  }
3930
3927
  return false;
@@ -3954,6 +3951,9 @@ var _Exporter = /** @class */ (function () {
3954
3951
  });
3955
3952
  // Check if root nodes converting to left-handed are present
3956
3953
  babylonScene.rootNodes.forEach(function (rootNode) {
3954
+ if (_this._includeCoordinateSystemConversionNodes) {
3955
+ return;
3956
+ }
3957
3957
  if (_this._isBabylonCoordinateSystemConvertingNode(rootNode)) {
3958
3958
  rootNodesToLeftHanded.push(rootNode);
3959
3959
  // Exclude the node from list of nodes to export
@@ -5448,17 +5448,18 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5448
5448
  };
5449
5449
  _GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) {
5450
5450
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
5451
- var textureUid, pixels, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndex, size, data, textureInfo;
5452
- return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
5453
- switch (_a.label) {
5451
+ var textureUid, pixels_1, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndexPromise, size_1, textureInfo, _a;
5452
+ var _this = this;
5453
+ return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_b) {
5454
+ switch (_b.label) {
5454
5455
  case 0:
5455
5456
  textureUid = babylonTexture.uid;
5456
5457
  if (!(textureUid in this._textureMap)) return [3 /*break*/, 1];
5457
5458
  return [2 /*return*/, this._textureMap[textureUid]];
5458
5459
  case 1: return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)];
5459
5460
  case 2:
5460
- pixels = _a.sent();
5461
- if (!pixels) {
5461
+ pixels_1 = _b.sent();
5462
+ if (!pixels_1) {
5462
5463
  return [2 /*return*/, null];
5463
5464
  }
5464
5465
  samplerIndex = this._exportTextureSampler(babylonTexture);
@@ -5478,17 +5479,26 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5478
5479
  internalTextureToImage = this._internalTextureToImage;
5479
5480
  internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId;
5480
5481
  internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {});
5481
- imageIndex = internalTextureToImage[internalTextureUniqueId][mimeType];
5482
- if (!(imageIndex === undefined)) return [3 /*break*/, 4];
5483
- size = babylonTexture.getSize();
5484
- return [4 /*yield*/, this._getImageDataAsync(pixels, size.width, size.height, mimeType)];
5482
+ imageIndexPromise = internalTextureToImage[internalTextureUniqueId][mimeType];
5483
+ if (imageIndexPromise === undefined) {
5484
+ size_1 = babylonTexture.getSize();
5485
+ imageIndexPromise = (function () { return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(_this, void 0, void 0, function () {
5486
+ var data;
5487
+ return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
5488
+ switch (_a.label) {
5489
+ case 0: return [4 /*yield*/, this._getImageDataAsync(pixels_1, size_1.width, size_1.height, mimeType)];
5490
+ case 1:
5491
+ data = _a.sent();
5492
+ return [2 /*return*/, this._exportImage(babylonTexture.name, mimeType, data)];
5493
+ }
5494
+ });
5495
+ }); })();
5496
+ internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndexPromise;
5497
+ }
5498
+ _a = this._exportTextureInfo;
5499
+ return [4 /*yield*/, imageIndexPromise];
5485
5500
  case 3:
5486
- data = _a.sent();
5487
- imageIndex = this._exportImage(babylonTexture.name, mimeType, data);
5488
- internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndex;
5489
- _a.label = 4;
5490
- case 4:
5491
- textureInfo = this._exportTextureInfo(imageIndex, samplerIndex, babylonTexture.coordinatesIndex);
5501
+ textureInfo = _a.apply(this, [_b.sent(), samplerIndex, babylonTexture.coordinatesIndex]);
5492
5502
  this._textureMap[textureUid] = textureInfo;
5493
5503
  return [2 /*return*/, textureInfo];
5494
5504
  }