Explorar o código

Merge pull request #3998 from bobalazek/master

Transform forward/up/right directions
David Catuhe %!s(int64=7) %!d(string=hai) anos
pai
achega
3e90a631dc
Modificáronse 2 ficheiros con 38 adicións e 1 borrados
  1. 37 1
      src/Mesh/babylon.transformNode.ts
  2. 1 0
      what's new.md

+ 37 - 1
src/Mesh/babylon.transformNode.ts

@@ -6,6 +6,12 @@ module BABYLON {
         public static BILLBOARDMODE_Y = 2;
         public static BILLBOARDMODE_Z = 4;
         public static BILLBOARDMODE_ALL = 7;
+        
+        private _forward = new Vector3(0, 0, 1);
+        private _forwardInverted = new Vector3(0, 0, -1);
+        private _up = new Vector3(0, 1, 0);
+        private _right = new Vector3(1, 0, 0);
+        private _rightInverted = new Vector3(-1, 0, 0);
 
         // Properties
         @serializeAsVector3()
@@ -112,6 +118,36 @@ module BABYLON {
         }
 
         /**
+         * The forward direction of that transform in world space.
+         */
+        public get forward(): Vector3 {
+            return Vector3.Normalize(Vector3.TransformNormal(
+                this.getScene().useRightHandedSystem ? this._forwardInverted : this._forward,
+                this.getWorldMatrix()
+            ));
+        }
+
+        /**
+         * The up direction of that transform in world space.
+         */
+        public get up(): Vector3 {
+            return Vector3.Normalize(Vector3.TransformNormal(
+                this._up,
+                this.getWorldMatrix()
+            ));
+        }
+
+        /**
+         * The right direction of that transform in world space.
+         */
+        public get right(): Vector3 {
+            return Vector3.Normalize(Vector3.TransformNormal(
+                this.getScene().useRightHandedSystem ? this._rightInverted : this._right,
+                this.getWorldMatrix()
+            ));
+        }
+
+        /**
          * Returns the latest update of the World matrix
          * Returns a Matrix.  
          */
@@ -992,4 +1028,4 @@ module BABYLON {
         }
 
     }
-}
+}

+ 1 - 0
what's new.md

@@ -66,6 +66,7 @@
 - Added scope option to Observerable ([adam](https://github.com/abow))
 - Added shadowBlur, shadowOffsetX, shadowOffsetY, shadowColor to GUI Controls ([adam](https://github.com/abow))
 - Added alignWithNormal to AbstractMesh ([adam](https://github.com/abow))
+- Added transformNode.forward/up/right ([bobalazek](https://github.com/bobalazek))
 
 ## Bug fixes