@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.
@@ -1,3 +1,4 @@
1
+ import { Matrix, TmpVectors } from "@babylonjs/core/Maths/math.vector.js";
1
2
  import { Vector2, Vector3, Vector4, Quaternion } from "@babylonjs/core/Maths/math.vector.js";
2
3
  import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
3
4
  import { Tools } from "@babylonjs/core/Misc/tools.js";
@@ -15,6 +16,8 @@ import { _GLTFAnimation } from "./glTFAnimation.js";
15
16
  import { Camera } from "@babylonjs/core/Cameras/camera.js";
16
17
  import { EngineStore } from "@babylonjs/core/Engines/engineStore.js";
17
18
  import { MultiMaterial } from "@babylonjs/core/Materials/multiMaterial.js";
19
+ // Matrix that converts handedness on the X-axis.
20
+ const convertHandednessMatrix = Matrix.Compose(new Vector3(-1, 1, 1), Quaternion.Identity(), Vector3.Zero());
18
21
  /**
19
22
  * Converts Babylon Scene into glTF 2.0.
20
23
  * @internal
@@ -1382,21 +1385,15 @@ export class _Exporter {
1382
1385
  */
1383
1386
  _isBabylonCoordinateSystemConvertingNode(node) {
1384
1387
  if (node instanceof TransformNode) {
1385
- if (node.name !== "__root__") {
1386
- return false;
1387
- }
1388
1388
  // Transform
1389
- const matrix = node.getWorldMatrix();
1390
- if (matrix.determinant() === 1) {
1389
+ const matrix = node.getWorldMatrix().multiplyToRef(convertHandednessMatrix, TmpVectors.Matrix[0]);
1390
+ if (!matrix.isIdentity()) {
1391
1391
  return false;
1392
1392
  }
1393
1393
  // Geometry
1394
1394
  if ((node instanceof Mesh && node.geometry !== null) || (node instanceof InstancedMesh && node.sourceMesh.geometry !== null)) {
1395
1395
  return false;
1396
1396
  }
1397
- if (this._includeCoordinateSystemConversionNodes) {
1398
- return false;
1399
- }
1400
1397
  return true;
1401
1398
  }
1402
1399
  return false;
@@ -1425,6 +1422,9 @@ export class _Exporter {
1425
1422
  });
1426
1423
  // Check if root nodes converting to left-handed are present
1427
1424
  babylonScene.rootNodes.forEach((rootNode) => {
1425
+ if (this._includeCoordinateSystemConversionNodes) {
1426
+ return;
1427
+ }
1428
1428
  if (this._isBabylonCoordinateSystemConvertingNode(rootNode)) {
1429
1429
  rootNodesToLeftHanded.push(rootNode);
1430
1430
  // Exclude the node from list of nodes to export