Przeglądaj źródła

Merge branch 'master' into morph-target

Michael Dahrea 8 lat temu
rodzic
commit
c429dc4e83

+ 20 - 0
Playground/textures/DemageFont.fnt

@@ -0,0 +1,20 @@
+info face="Arial" size=32 bold=0 italic=0 charset="" unicode=1 stretchH=100 smooth=1 aa=1 padding=0,0,0,0 spacing=1,1 outline=0
+common lineHeight=32 base=26 scaleW=128 scaleH=128 pages=1 packed=0 alphaChnl=1 redChnl=0 greenChnl=0 blueChnl=0
+page id=0 file="DemageFont.png"
+chars count=16
+char id=45   x=62    y=93    width=28    height=30    xoffset=0     yoffset=0     xadvance=28    page=0  chnl=15
+char id=48   x=0     y=0     width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=49   x=91    y=93    width=22    height=30    xoffset=0     yoffset=0     xadvance=22    page=0  chnl=15
+char id=50   x=31    y=0     width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=51   x=62    y=0     width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=52   x=93    y=0     width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=53   x=0     y=31    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=54   x=31    y=31    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=55   x=62    y=31    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=56   x=93    y=31    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=57   x=0     y=62    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=68   x=31    y=62    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=69   x=62    y=62    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=70   x=93    y=62    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=71   x=0     y=93    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15
+char id=74   x=31    y=93    width=30    height=30    xoffset=0     yoffset=0     xadvance=30    page=0  chnl=15

BIN
Playground/textures/DemageFont.png


Plik diff jest za duży
+ 4916 - 0
Playground/textures/HorrorBlue.3dl


Plik diff jest za duży
+ 4916 - 0
Playground/textures/LateSunset.3dl


BIN
Playground/textures/Logo.png


BIN
Playground/textures/SunDiffuse.png


BIN
Playground/textures/big_buck_bunny.mp4


BIN
Playground/textures/candleopacity.png


BIN
Playground/textures/co.png


BIN
Playground/textures/country.hdr


BIN
Playground/textures/distortion.png


BIN
Playground/textures/environment.babylon.hdr


BIN
Playground/textures/fire.png


BIN
Playground/textures/floor.png


BIN
Playground/textures/floor_bump.PNG


BIN
Playground/textures/forest.hdr


BIN
Playground/textures/fur.jpg


BIN
Playground/textures/grass.png


BIN
Playground/textures/grassn.png


BIN
Playground/textures/heightMapTriPlanar.png


BIN
Playground/textures/invmask.png


BIN
Playground/textures/lensdirt.jpg


BIN
Playground/textures/leopard_fur.JPG


BIN
Playground/textures/mixMap.png


BIN
Playground/textures/nba.png


BIN
Playground/textures/night.hdr


BIN
Playground/textures/parking.hdr


BIN
Playground/textures/rock.png


BIN
Playground/textures/rockn.png


BIN
Playground/textures/roundMask.png


BIN
Playground/textures/sand.jpg


BIN
Playground/textures/speckles.jpg


BIN
Playground/textures/walk.png


+ 29 - 37
src/Math/babylon.math.ts

@@ -315,9 +315,9 @@
         }
 
         /**
-         * Creates a new Vector3 from the startind index of the passed array.  
+         * Creates a new Vector3 from the startind index of the passed array.
          */
-        public static FromArray(array: number[], offset: number = 0): Color3 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Color3 {
             return new Color3(array[offset], array[offset + 1], array[offset + 2]);
         }
 
@@ -566,9 +566,9 @@
         }
 
         /**
-         * Creates a new Color4 from the starting index element of the passed array.  
+         * Creates a new Color4 from the starting index element of the passed array.
          */
-        public static FromArray(array: number[], offset: number = 0): Color4 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Color4 {
             return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
         }
 
@@ -850,16 +850,15 @@
             return new Vector2(0, 0);
         }
         /**
-         * Returns a new Vector2 set from the passed index element of the passed array or Float32Array.  
+         * Returns a new Vector2 set from the passed index element of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset: number = 0): Vector2 {
+        public static FromArray(array: ArrayLike<number>, offset: number = 0): Vector2 {
             return new Vector2(array[offset], array[offset + 1]);
         }
         /**
-         * Sets "result" from the passed index element of the passed array or Float32Array.  
-         * Returns the Vector2.  
+         * Sets "result" from the passed index element of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void {
             result.x = array[offset];
             result.y = array[offset + 1];
         }
@@ -1396,9 +1395,9 @@
         }
 
         /**
-         * Returns a new Vector3 set from the index "offset" of the passed array or Float32Array.  
+         * Returns a new Vector3 set from the index "offset" of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset?: number): Vector3 {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Vector3 {
             if (!offset) {
                 offset = 0;
             }
@@ -1406,20 +1405,17 @@
         }
 
         /**
-         * Returns a new Vector3 set from the index "offset" of the passed Float32Array.  
+         * Returns a new Vector3 set from the index "offset" of the passed Float32Array.
+         * This function is deprecated.  Use FromArray instead.
          */
         public static FromFloatArray(array: Float32Array, offset?: number): Vector3 {
-            if (!offset) {
-                offset = 0;
-            }
-
-            return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
+            return Vector3.FromArray(array, offset);
         }
 
         /**
-         * Sets the passed vector "result" with the element values from the index "offset" of the passed array or Float32Array.
+         * Sets the passed vector "result" with the element values from the index "offset" of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void {
             result.x = array[offset];
             result.y = array[offset + 1];
             result.z = array[offset + 2];
@@ -1427,11 +1423,10 @@
 
         /**
          * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array.
+         * This function is deprecated.  Use FromArrayToRef instead.
          */
         public static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void {
-            result.x = array[offset];
-            result.y = array[offset + 1];
-            result.z = array[offset + 2];
+            return Vector3.FromArrayToRef(array, offset, result);
         }
 
         /**
@@ -2142,18 +2137,18 @@
 
         // Statics
         /**
-         * Returns a new Vector4 set from the starting index of the passed array.  
+         * Returns a new Vector4 set from the starting index of the passed array.
          */
-        public static FromArray(array: number[] | Float32Array, offset?: number): Vector4 {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Vector4 {
             if (!offset) {
                 offset = 0;
             }
             return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
         }
         /**
-         * Updates the passed vector "result" from the starting index of the passed array.  
+         * Updates the passed vector "result" from the starting index of the passed array.
          */
-        public static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector4): void {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void {
             result.x = array[offset];
             result.y = array[offset + 1];
             result.z = array[offset + 2];
@@ -2163,10 +2158,7 @@
          * Updates the passed vector "result" from the starting index of the passed Float32Array.
          */
         public static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void {
-            result.x = array[offset];
-            result.y = array[offset + 1];
-            result.z = array[offset + 2];
-            result.w = array[offset + 3];
+            Vector4.FromArrayToRef(array, offset, result);
         }
         /**
          * Updates the passed vector "result" coordinates from the passed floats.  
@@ -2739,9 +2731,9 @@
             return result;
         }
         /**
-         * Retuns a new Quaternion set from the starting index of the passed array.  
+         * Retuns a new Quaternion set from the starting index of the passed array.
          */
-        public static FromArray(array: number[], offset?: number): Quaternion {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Quaternion {
             if (!offset) {
                 offset = 0;
             }
@@ -3294,9 +3286,9 @@
 
         // Statics
         /**
-         * Returns a new Matrix set from the starting index of the passed array.  
+         * Returns a new Matrix set from the starting index of the passed array.
          */
-        public static FromArray(array: number[], offset?: number): Matrix {
+        public static FromArray(array: ArrayLike<number>, offset?: number): Matrix {
             var result = new Matrix();
 
             if (!offset) {
@@ -3306,9 +3298,9 @@
             return result;
         }
         /**
-         * Sets the passed "result" matrix from the starting index of the passed array.  
+         * Sets the passed "result" matrix from the starting index of the passed array.
          */
-        public static FromArrayToRef(array: number[], offset: number, result: Matrix) {
+        public static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix) {
             for (var index = 0; index < 16; index++) {
                 result.m[index] = array[index + offset];
             }
@@ -4315,7 +4307,7 @@
         /**
          * Returns a new Plane from the passed array.  
          */
-        static FromArray(array: number[]): Plane {
+        static FromArray(array: ArrayLike<number>): Plane {
             return new Plane(array[0], array[1], array[2], array[3]);
         }
         /**

+ 42 - 52
src/Mesh/babylon.abstractMesh.ts

@@ -1822,76 +1822,67 @@
 
         /**
          * Defines the passed mesh as the parent of the current mesh.  
-         * If keepWorldPositionRotation is set to `true` (default `false`), the current mesh position and rotation are kept.
          * Returns the AbstractMesh.  
          */
-        public setParent(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-
+        public setParent(mesh:AbstractMesh): AbstractMesh {
+            
             var child = this;
             var parent = mesh;
 
             if(mesh == null){
 
-                if(child.parent && keepWorldPositionRotation){
-                  
-                    var rotation = Tmp.Quaternion[0];
-                    var position = Tmp.Vector3[0];
-                    var scale = Tmp.Vector3[1];
+                var rotation = Tmp.Quaternion[0];
+                var position = Tmp.Vector3[0];
+                var scale = Tmp.Vector3[1];
 
-                    child.getWorldMatrix().decompose(scale, rotation, position);
-
-                    if (child.rotationQuaternion) {
-                        child.rotationQuaternion.copyFrom(rotation);
-                    } else {
-                        rotation.toEulerAnglesToRef(child.rotation);
-                    }
+                child.getWorldMatrix().decompose(scale, rotation, position);
 
-                    child.position.x = position.x;
-                    child.position.y = position.y;
-                    child.position.z = position.z;
+                if (child.rotationQuaternion) {
+                    child.rotationQuaternion.copyFrom(rotation);
+                } else {
+                    rotation.toEulerAnglesToRef(child.rotation);
+                }
 
-               }
+                child.position.x = position.x;
+                child.position.y = position.y;
+                child.position.z = position.z;
 
             } else {
+  
+                var rotation = Tmp.Quaternion[0];
+                var position = Tmp.Vector3[0];
+                var scale = Tmp.Vector3[1];
+                var m1 = Tmp.Matrix[0];
+                var m2 = Tmp.Matrix[1];
 
-                if(keepWorldPositionRotation){
-                    
-                    var rotation = Tmp.Quaternion[0];
-                    var position = Tmp.Vector3[0];
-                    var scale = Tmp.Vector3[1];
-                    var m1 = Tmp.Matrix[0];
-                    var m2 = Tmp.Matrix[1];
+                parent.getWorldMatrix().decompose(scale, rotation, position);
 
-                    parent.getWorldMatrix().decompose(scale, rotation, position);
+                rotation.toRotationMatrix(m1);
+                m2.setTranslation(position);
 
-                    rotation.toRotationMatrix(m1);
-                    m2.setTranslation(position);
+                m2.multiplyToRef(m1, m1);
 
-                    m2.multiplyToRef(m1, m1);
+                var invParentMatrix = Matrix.Invert(m1);
 
-                    var invParentMatrix = Matrix.Invert(m1);
+                var m = child.getWorldMatrix().multiply(invParentMatrix);
 
-                    var m = child.getWorldMatrix().multiply(invParentMatrix);
+                m.decompose(scale, rotation, position);
 
-                    m.decompose(scale, rotation, position);
-
-                    if (child.rotationQuaternion) {
-                        child.rotationQuaternion.copyFrom(rotation);
-                    } else {
-                        rotation.toEulerAnglesToRef(child.rotation);
-                    }
-
-                    invParentMatrix = Matrix.Invert(parent.getWorldMatrix());
+                if (child.rotationQuaternion) {
+                    child.rotationQuaternion.copyFrom(rotation);
+                } else {
+                    rotation.toEulerAnglesToRef(child.rotation);
+                }
 
-                    var m = child.getWorldMatrix().multiply(invParentMatrix);
+                invParentMatrix = Matrix.Invert(parent.getWorldMatrix());
 
-                    m.decompose(scale, rotation, position);
+                var m = child.getWorldMatrix().multiply(invParentMatrix);
 
-                    child.position.x = position.x;
-                    child.position.y = position.y;
-                    child.position.z = position.z;
+                m.decompose(scale, rotation, position);
 
-                }
+                child.position.x = position.x;
+                child.position.y = position.y;
+                child.position.z = position.z;
 
             }
             child.parent = parent;
@@ -1900,11 +1891,10 @@
 
         /**
          * Adds the passed mesh as a child to the current mesh.  
-         * If keepWorldPositionRotation is set to `true` (default `false`), the child world position and rotation are kept.  
          * Returns the AbstractMesh.  
          */
-        public addChild(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-            mesh.setParent(this, keepWorldPositionRotation);
+        public addChild(mesh:AbstractMesh): AbstractMesh {
+            mesh.setParent(this);
             return this;
         }
 
@@ -1912,8 +1902,8 @@
          * Removes the passed mesh from the current mesh children list.  
          * Returns the AbstractMesh.  
          */
-        public removeChild(mesh:AbstractMesh, keepWorldPositionRotation = false): AbstractMesh {
-            mesh.setParent(null, keepWorldPositionRotation);
+        public removeChild(mesh:AbstractMesh): AbstractMesh {
+            mesh.setParent(null);
             return this;
         }