Browse Source

Merge pull request #3303 from abow/bug_fixes

fixed #3295
David Catuhe 7 năm trước cách đây
mục cha
commit
b29c6dcbd8
3 tập tin đã thay đổi với 13 bổ sung4 xóa
  1. 4 0
      src/Cameras/babylon.camera.ts
  2. 4 4
      src/Mesh/babylon.transformNode.ts
  3. 5 0
      src/babylon.node.ts

+ 4 - 0
src/Cameras/babylon.camera.ts

@@ -907,6 +907,10 @@
             }
         }
 
+        public computeWorldMatrix(): Matrix {
+            return this.getWorldMatrix();
+        }
+
         public static Parse(parsedCamera: any, scene: Scene): Camera {
             var type = parsedCamera.type;
             var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);

+ 4 - 4
src/Mesh/babylon.transformNode.ts

@@ -450,15 +450,15 @@ module BABYLON {
          * The node will remain exactly where it is and its position / rotation will be updated accordingly
          * Returns the TransformNode.
          */
-        public setParent(node: Nullable<TransformNode>): TransformNode {
+        public setParent(node: Nullable<Node>): TransformNode {
 
             if (node == null) {
                 var rotation = Tmp.Quaternion[0];
                 var position = Tmp.Vector3[0];
                 var scale = Tmp.Vector3[1];
-
-                if (this.parent && (<TransformNode>this.parent).computeWorldMatrix) {
-                    (<TransformNode>this.parent).computeWorldMatrix(true);
+                
+                if (this.parent && this.parent.computeWorldMatrix) {
+                    this.parent.computeWorldMatrix(true);
                 }
                 this.computeWorldMatrix(true);
                 this.getWorldMatrix().decompose(scale, rotation, position);

+ 5 - 0
src/babylon.node.ts

@@ -426,6 +426,11 @@
             return serializationRanges;
         }
 
+        // override it in derived class
+        public computeWorldMatrix(force?: boolean): Matrix {
+            return Matrix.Identity();
+        }
+
         public dispose(): void {
             this.parent = null;