babylonjs-serializers 5.32.2 → 5.33.1

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
@@ -4557,7 +4557,7 @@ __webpack_require__.r(__webpack_exports__);
4557
4557
  /* harmony export */ "_GLTFMaterialExporter": () => (/* binding */ _GLTFMaterialExporter)
4558
4558
  /* harmony export */ });
4559
4559
  /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.js");
4560
- /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Engines/constants */ "core/Maths/math.vector");
4560
+ /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core/Misc/dumpTools */ "core/Maths/math.vector");
4561
4561
  /* harmony import */ var core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
4562
4562
 
4563
4563
 
@@ -4568,6 +4568,7 @@ __webpack_require__.r(__webpack_exports__);
4568
4568
 
4569
4569
 
4570
4570
 
4571
+
4571
4572
  function getFileExtensionFromMimeType(mimeType) {
4572
4573
  switch (mimeType) {
4573
4574
  case "image/jpeg" /* JPEG */:
@@ -4885,7 +4886,7 @@ var _GLTFMaterialExporter = /** @class */ (function () {
4885
4886
  return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)];
4886
4887
  case 2:
4887
4888
  data = _a.sent();
4888
- return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)];
4889
+ return [4 /*yield*/, core_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DumpTools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)];
4889
4890
  case 3: return [2 /*return*/, (_a.sent())];
4890
4891
  }
4891
4892
  });
@@ -5447,17 +5448,18 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5447
5448
  };
5448
5449
  _GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) {
5449
5450
  return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__awaiter)(this, void 0, void 0, function () {
5450
- var textureUid, pixels, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndex, size, data, textureInfo;
5451
- return (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__generator)(this, function (_a) {
5452
- 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) {
5453
5455
  case 0:
5454
5456
  textureUid = babylonTexture.uid;
5455
5457
  if (!(textureUid in this._textureMap)) return [3 /*break*/, 1];
5456
5458
  return [2 /*return*/, this._textureMap[textureUid]];
5457
5459
  case 1: return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)];
5458
5460
  case 2:
5459
- pixels = _a.sent();
5460
- if (!pixels) {
5461
+ pixels_1 = _b.sent();
5462
+ if (!pixels_1) {
5461
5463
  return [2 /*return*/, null];
5462
5464
  }
5463
5465
  samplerIndex = this._exportTextureSampler(babylonTexture);
@@ -5477,17 +5479,26 @@ var _GLTFMaterialExporter = /** @class */ (function () {
5477
5479
  internalTextureToImage = this._internalTextureToImage;
5478
5480
  internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId;
5479
5481
  internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {});
5480
- imageIndex = internalTextureToImage[internalTextureUniqueId][mimeType];
5481
- if (!(imageIndex === undefined)) return [3 /*break*/, 4];
5482
- size = babylonTexture.getSize();
5483
- 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];
5484
5500
  case 3:
5485
- data = _a.sent();
5486
- imageIndex = this._exportImage(babylonTexture.name, mimeType, data);
5487
- internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndex;
5488
- _a.label = 4;
5489
- case 4:
5490
- textureInfo = this._exportTextureInfo(imageIndex, samplerIndex, babylonTexture.coordinatesIndex);
5501
+ textureInfo = _a.apply(this, [_b.sent(), samplerIndex, babylonTexture.coordinatesIndex]);
5491
5502
  this._textureMap[textureUid] = textureInfo;
5492
5503
  return [2 /*return*/, textureInfo];
5493
5504
  }