@babylonjs/lite-compat 1.36.0-preview → 1.37.1-preview

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.
@@ -682,8 +682,9 @@ var Quaternion = class Quaternion {
682
682
  this.w = source.w;
683
683
  return this;
684
684
  }
685
+ /** Babylon.js `multiply`: the product `this · other` as a new quaternion. */
685
686
  multiply(other) {
686
- return new Quaternion(other.w * this.x + other.x * this.w + other.y * this.z - other.z * this.y, other.w * this.y - other.x * this.z + other.y * this.w + other.z * this.x, other.w * this.z + other.x * this.y - other.y * this.x + other.z * this.w, other.w * this.w - other.x * this.x - other.y * this.y - other.z * this.z);
687
+ return new Quaternion(this.x * other.w + this.y * other.z - this.z * other.y + this.w * other.x, -this.x * other.z + this.y * other.w + this.z * other.x + this.w * other.y, this.x * other.y - this.y * other.x + this.z * other.w + this.w * other.z, -this.x * other.x - this.y * other.y - this.z * other.z + this.w * other.w);
687
688
  }
688
689
  length() {
689
690
  return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
@@ -794,7 +795,7 @@ var Quaternion = class Quaternion {
794
795
  /** Babylon.js `Quaternion.FromLookDirectionLHToRef(forward, up, result)`. */
795
796
  static FromLookDirectionLHToRef(forward, up, result) {
796
797
  const matrix = lookDirectionRotationScratch ??= /* @__PURE__ */ new Float32Array(16);
797
- writeMat4FromLookDirectionLHIntoBuffer(matrix, forward, up);
798
+ writeMat4FromLookDirectionRHIntoBuffer(matrix, forward, up);
798
799
  return Quaternion._FromRotationStorageToRef(matrix, result);
799
800
  }
800
801
  /** Babylon.js `Quaternion.FromLookDirectionRH(forward, up)`. */
@@ -804,7 +805,7 @@ var Quaternion = class Quaternion {
804
805
  /** Babylon.js `Quaternion.FromLookDirectionRHToRef(forward, up, result)`. */
805
806
  static FromLookDirectionRHToRef(forward, up, result) {
806
807
  const matrix = lookDirectionRotationScratch ??= /* @__PURE__ */ new Float32Array(16);
807
- writeMat4FromLookDirectionRHIntoBuffer(matrix, forward, up);
808
+ writeMat4FromLookDirectionLHIntoBuffer(matrix, forward, up);
808
809
  return Quaternion._FromRotationStorageToRef(matrix, result);
809
810
  }
810
811
  static _FromRotationStorageToRef(matrix, result) {
@@ -940,10 +941,9 @@ var Matrix = class Matrix {
940
941
  determinant() {
941
942
  return determinant(this.m);
942
943
  }
944
+ /** Babylon.js `invert`: inverts this matrix in place and returns it. */
943
945
  invert() {
944
- const result = new Matrix();
945
- this.invertToRef(result);
946
- return result;
946
+ return this.invertToRef(this);
947
947
  }
948
948
  invertToRef(result) {
949
949
  const inv = invertValues(this.m);
@@ -1076,7 +1076,7 @@ var Matrix = class Matrix {
1076
1076
  }
1077
1077
  /** Babylon.js `Matrix.LookDirectionLHToRef(forward, up, result)`. */
1078
1078
  static LookDirectionLHToRef(forward, up, result) {
1079
- writeMat4FromLookDirectionLHIntoBuffer(result.m, forward, up);
1079
+ writeMat4FromLookDirectionRHIntoBuffer(result.m, forward, up);
1080
1080
  return result.markAsUpdated();
1081
1081
  }
1082
1082
  /** Babylon.js `Matrix.LookDirectionRH(forward, up)` orientation matrix. */
@@ -1085,7 +1085,7 @@ var Matrix = class Matrix {
1085
1085
  }
1086
1086
  /** Babylon.js `Matrix.LookDirectionRHToRef(forward, up, result)`. */
1087
1087
  static LookDirectionRHToRef(forward, up, result) {
1088
- writeMat4FromLookDirectionRHIntoBuffer(result.m, forward, up);
1088
+ writeMat4FromLookDirectionLHIntoBuffer(result.m, forward, up);
1089
1089
  return result.markAsUpdated();
1090
1090
  }
1091
1091
  /** Babylon.js `Matrix.OrthoOffCenterLH(left, right, bottom, top, znear, zfar, halfZRange?)` — LH ortho projection. */
@@ -1407,7 +1407,10 @@ var Observable = class {
1407
1407
  return callback;
1408
1408
  }
1409
1409
  addOnce(callback, mask = -1) {
1410
+ let consumed = false;
1410
1411
  const wrapper = (eventData) => {
1412
+ if (consumed) return;
1413
+ consumed = true;
1411
1414
  this.removeCallback(wrapper);
1412
1415
  callback(eventData);
1413
1416
  };
@@ -2845,7 +2848,15 @@ var TransformNode = class extends Node {
2845
2848
  return this;
2846
2849
  }
2847
2850
  _applyParent(parent) {
2848
- this._node.parent = liteNodeOf(parent);
2851
+ const node = this._node;
2852
+ const liteParent = liteNodeOf(parent);
2853
+ const previous = node.parent;
2854
+ if (previous && previous !== liteParent) {
2855
+ const siblings = previous.children;
2856
+ const index = siblings ? siblings.indexOf(node) : -1;
2857
+ if (index !== -1) siblings.splice(index, 1);
2858
+ }
2859
+ node.parent = liteParent;
2849
2860
  }
2850
2861
  /** @internal Remove this wrapper's node without letting Lite recurse for `dispose(true)`. */
2851
2862
  _disposeSelf(doNotRecurse) {
@@ -2867,6 +2878,12 @@ var AbstractMesh = class extends TransformNode {
2867
2878
  /** @internal Underlying Babylon Lite mesh. */
2868
2879
  _lite;
2869
2880
  _material = null;
2881
+ /**
2882
+ * @internal The mesh renders a material that exists only on its Lite node: a natively loaded glTF
2883
+ * material has no compat wrapper, so `material` reads `null`. Clones keep that Lite material, and the
2884
+ * deferred registration does not replace it with `scene.defaultMaterial`. Any `material` assignment clears it.
2885
+ */
2886
+ _liteOnlyMaterial = false;
2870
2887
  _meshBlendingTag = 0;
2871
2888
  _visible = true;
2872
2889
  constructor(name, lite, scene) {
@@ -2890,6 +2907,7 @@ var AbstractMesh = class extends TransformNode {
2890
2907
  }
2891
2908
  set material(value) {
2892
2909
  this._material = value;
2910
+ this._liteOnlyMaterial = false;
2893
2911
  const scene = this._scene;
2894
2912
  const renderMaterial = value ?? scene?.defaultMaterial;
2895
2913
  if (renderMaterial && scene) {
@@ -3094,7 +3112,7 @@ var AbstractMesh = class extends TransformNode {
3094
3112
  let newNormals;
3095
3113
  const normals = lite._cpuNormals;
3096
3114
  if (normals) {
3097
- const nm = matrix.invert().transpose().m;
3115
+ const nm = matrix.invertToRef(new Matrix()).transpose().m;
3098
3116
  newNormals = new Float32Array(normals.length);
3099
3117
  for (let i = 0; i < normals.length; i += 3) {
3100
3118
  const x = normals[i], y = normals[i + 1], z = normals[i + 2];
@@ -3188,6 +3206,7 @@ var Mesh = class Mesh extends AbstractMesh {
3188
3206
  static _fromLite(lite, container, scene) {
3189
3207
  const mesh = new Mesh(lite.name ?? "", lite);
3190
3208
  mesh._container = container;
3209
+ mesh._liteOnlyMaterial = !!lite.material;
3191
3210
  mesh._visible = lite.visible !== false;
3192
3211
  if (scene) mesh._bindLoadedScene(scene);
3193
3212
  return mesh;
@@ -3317,7 +3336,8 @@ var Mesh = class Mesh extends AbstractMesh {
3317
3336
  wrapper.metadata = source.metadata;
3318
3337
  wrapper.setEnabled(source.isEnabled(false));
3319
3338
  if (wrapper instanceof Mesh && source instanceof Mesh) {
3320
- wrapper.material = source.material;
3339
+ if (source._liteOnlyMaterial) wrapper._liteOnlyMaterial = true;
3340
+ else wrapper.material = source.material;
3321
3341
  wrapper.isVisible = source.isVisible;
3322
3342
  wrapper.meshBlendingTag = source.meshBlendingTag;
3323
3343
  }
@@ -3606,7 +3626,7 @@ function addPrimitive(mesh, scene, afterAdd) {
3606
3626
  function registerMeshAtStart(mesh, scene, afterAdd) {
3607
3627
  scene._deferAdd(() => {
3608
3628
  if (mesh.isDisposed()) return;
3609
- const mat = mesh.material ?? scene.defaultMaterial;
3629
+ const mat = mesh.material ?? (mesh._liteOnlyMaterial ? null : scene.defaultMaterial);
3610
3630
  if (mat) attachMaterialToScene(mat, scene);
3611
3631
  if (mat?._lite) mesh._lite.material = mat._lite;
3612
3632
  addToScene(scene._lite, mesh._lite);
@@ -3832,4 +3852,4 @@ function RegisterPolygonBuilder() {}
3832
3852
  //#endregion
3833
3853
  export { Vector4 as $, PBRClearCoatConfiguration as A, Observable as B, RegisterPolygonBuilder as C, registerMeshAtStart as D, VertexData as E, PBRSpecularGlossinessMaterial as F, transformCoordinates as G, BoundingInfo as H, PushMaterial as I, Color3 as J, transformNormal as K, StandardMaterial as L, PBRMaterial as M, PBRMetallicRoughnessMaterial as N, Material as O, PBRSheenConfiguration as P, Vector3 as Q, attachMaterialToScene as R, PolygonBuilder as S, VertexBuffer as T, BoundingSphere as U, BoundingBox as V, Matrix as W, liteBackedColor3 as X, Color4 as Y, Vector2 as Z, GroundMesh as _, CreateDisc as a, Mesh as b, CreateLines as c, CreatePolygonVertexData as d, liteBackedVector3 as et, CreateSphere as f, ExtrudePolygon as g, CreateTorus as h, CreateDashedLines as i, PBRIridescenceConfiguration as j, PBRAnisotropicConfiguration as k, CreatePlane as l, CreateTiledPlane as m, CreateBox as n, unsupported as nt, CreateGround as o, CreateTiledBox as p, Quaternion as q, CreateCylinder as r, CreateLineSystem as s, AbstractMesh as t, LiteCompatError as tt, CreatePolygon as u, InstancedMesh as v, TransformNode as w, MeshBuilder as x, LinesMesh as y, Node as z };
3834
3854
 
3835
- //# sourceMappingURL=meshes-zeNif9yt.js.map
3855
+ //# sourceMappingURL=meshes-BqMDWl4h.js.map