Bladeren bron

Add Vector.One functions

Gary Hsu 8 jaren geleden
bovenliggende
commit
8ec05da5ad

+ 2 - 2
src/Bones/babylon.bone.ts

@@ -21,8 +21,8 @@ module BABYLON {
         private _parent: Bone;
 
         private _scaleMatrix = Matrix.Identity();
-        private _scaleVector = new Vector3(1, 1, 1);
-        private _negateScaleChildren = new Vector3(1, 1, 1);
+        private _scaleVector = Vector3.One();
+        private _negateScaleChildren = Vector3.One();
         private _scalingDeterminant = 1;
 
         get _matrix():Matrix{

+ 1 - 1
src/Collisions/babylon.collider.ts

@@ -58,7 +58,7 @@
     )();
 
     export class Collider {
-        public radius = new Vector3(1, 1, 1);
+        public radius = Vector3.One();
         public retry = 0;
         public velocity: Vector3;
         public basePoint: Vector3;

+ 19 - 1
src/Math/babylon.math.ts

@@ -874,6 +874,12 @@
             return new Vector2(0, 0);
         }
         /**
+         * Returns a new Vector2(1, 1)
+         */
+        public static One(): Vector2 {
+            return new Vector2(1, 1);
+        }
+        /**
          * Returns a new Vector2 set from the passed index element of the passed array.
          */
         public static FromArray(array: ArrayLike<number>, offset: number = 0): Vector2 {
@@ -1463,12 +1469,18 @@
         }
 
         /**
-         * Returns a new Vector3 set to (0.0, 0.0, 0.0).  
+         * Returns a new Vector3 set to (0.0, 0.0, 0.0).
          */
         public static Zero(): Vector3 {
             return new Vector3(0.0, 0.0, 0.0);
         }
         /**
+         * Returns a new Vector3 set to (1.0, 1.0, 1.0).
+         */
+        public static One(): Vector3 {
+            return new Vector3(1.0, 1.0, 1.0);
+        }
+        /**
          * Returns a new Vector3 set to (0.0, 1.0, 0.0)
          */
         public static Up(): Vector3 {
@@ -2200,6 +2212,12 @@
             return new Vector4(0.0, 0.0, 0.0, 0.0);
         }
         /**
+         * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
+         */
+        public static One(): Vector4 {
+            return new Vector4(1.0, 1.0, 1.0, 1.0);
+        }
+        /**
          * Returns a new normalized Vector4 from the passed one.  
          */
         public static Normalize(vector: Vector4): Vector4 {

+ 3 - 3
src/Mesh/babylon.abstractMesh.ts

@@ -114,10 +114,10 @@
 
         // Properties
         public definedFacingForward = true; // orientation for POV movement & rotation
-        public position = new Vector3(0.0, 0.0, 0.0);
-        private _rotation = new Vector3(0.0, 0.0, 0.0);
+        public position = Vector3.Zero();
+        private _rotation = Vector3.Zero();
         private _rotationQuaternion: Quaternion;
-        private _scaling = new Vector3(1.0, 1.0, 1.0);
+        private _scaling = Vector3.One();
         public billboardMode = AbstractMesh.BILLBOARDMODE_NONE;
         public visibility = 1.0;
         public alphaIndex = Number.MAX_VALUE;

+ 1 - 1
src/Mesh/babylon.meshBuilder.ts

@@ -1005,7 +1005,7 @@
             var normals = sourceMesh.getVerticesData(VertexBuffer.NormalKind);
             var position = options.position || Vector3.Zero();
             var normal = options.normal || Vector3.Up();
-            var size = options.size || new Vector3(1, 1, 1);
+            var size = options.size || Vector3.One();
             var angle = options.angle || 0;
 
             // Getting correct rotation

+ 1 - 1
src/Particles/babylon.solidParticle.ts

@@ -6,7 +6,7 @@ module BABYLON {
         public position = Vector3.Zero();               // position
         public rotation = Vector3.Zero();               // rotation
         public rotationQuaternion: Quaternion;          // quaternion, will overwrite rotation
-        public scaling = new Vector3(1.0, 1.0, 1.0);    // scaling
+        public scaling = Vector3.One();                 // scaling
         public uvs = new Vector4(0.0, 0.0, 1.0, 1.0);   // uvs
         public velocity = Vector3.Zero();               // velocity
         public alive = true;                            // alive