Selaa lähdekoodia

Fix freezeWorldMatrix bug

David Catuhe 5 vuotta sitten
vanhempi
commit
60f358f17a

+ 1 - 0
src/Meshes/abstractMesh.ts

@@ -83,6 +83,7 @@ class _InternalAbstractMeshDataInfo {
     public _onlyForInstances = false;
     public _isActiveIntermediate = false;
     public _onlyForInstancesIntermediate = false;
+    public _actAsRegularMesh = false;
 }
 
 /**

+ 2 - 5
src/Meshes/instancedMesh.ts

@@ -23,9 +23,6 @@ export class InstancedMesh extends AbstractMesh {
     private _currentLOD: Mesh;
 
     /** @hidden */
-    public _actAsRegularMesh = false;
-
-    /** @hidden */
     public _indexInSourceMeshInstanceArray = -1;
 
     constructor(name: string, source: Mesh) {
@@ -291,10 +288,10 @@ export class InstancedMesh extends AbstractMesh {
         if (this._currentLOD) {
 
             if (this._currentLOD._getWorldMatrixDeterminant() !== this._getWorldMatrixDeterminant()) {
-                this._actAsRegularMesh = true;
+                this._internalAbstractMeshDataInfo._actAsRegularMesh = true;
                 return true;
             }
-            this._actAsRegularMesh = false;
+            this._internalAbstractMeshDataInfo._actAsRegularMesh = false;
 
             this._currentLOD._registerInstanceForRenderId(this, renderId);
 

+ 1 - 1
src/Meshes/subMesh.ts

@@ -308,7 +308,7 @@ export class SubMesh extends BaseSubMesh implements ICullable {
      * @returns the submesh
      */
     public render(enableAlphaMode: boolean): SubMesh {
-        this._renderingMesh.render(this, enableAlphaMode, (this._mesh as InstancedMesh)._actAsRegularMesh ? this._mesh : undefined);
+        this._renderingMesh.render(this, enableAlphaMode, this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh ? this._mesh : undefined);
         return this;
     }
 

+ 1 - 1
src/Meshes/transformNode.ts

@@ -442,7 +442,7 @@ export class TransformNode extends Node {
      */
     public freezeWorldMatrix(newWorldMatrix: Nullable<Matrix> = null): TransformNode {
         if (newWorldMatrix) {
-            this._worldMatrix = this._worldMatrix;
+            this._worldMatrix = newWorldMatrix;
         } else {
             this._isWorldMatrixFrozen = false;  // no guarantee world is not already frozen, switch off temporarily
             this.computeWorldMatrix(true);

+ 1 - 1
src/scene.ts

@@ -3399,7 +3399,7 @@ export class Scene extends AbstractScene implements IAnimatable {
                     if (!mesh.isAnInstance) {
                         meshToRender._internalAbstractMeshDataInfo._onlyForInstances = false;
                     } else {
-                        if ((mesh as InstancedMesh)._actAsRegularMesh) {
+                        if (mesh._internalAbstractMeshDataInfo._actAsRegularMesh) {
                             meshToRender = mesh;
                         }
                     }