nockawa 9 лет назад
Родитель
Сommit
10239ff725

Разница между файлами не показана из-за своего большого размера
+ 21 - 21
dist/preview release/babylon.core.js


Разница между файлами не показана из-за своего большого размера
+ 4419 - 4388
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 37 - 37
dist/preview release/babylon.js


Разница между файлами не показана из-за своего большого размера
+ 135 - 8
dist/preview release/babylon.max.js


Разница между файлами не показана из-за своего большого размера
+ 37 - 37
dist/preview release/babylon.noworker.js


+ 6 - 4
dist/preview release/what's new.md

@@ -15,10 +15,10 @@
     - Unity3D exporter: Added support for export and run (local webserver) ([davrous](https://github.com/davrous), [deltakosh](https://github.com/deltakosh))
     - Moved PBR Material to core ([deltakosh](https://github.com/deltakosh))
     - StandardMaterial.maxSimultaneousLights can define how many dynamic lights the material can handle ([deltakosh](https://github.com/deltakosh))
-	  - Introduced Canvas2D feature: a 2D engine to render primitives, sprites in 2D, text. Canvas2D can be displayed in Screen Space (above the 3D scene) or in World Space to be a part of the Scene. [overview](http://doc.babylonjs.com/overviews/Using_The_Canvas2D), [tutorial](http://doc.babylonjs.com/tutorials/Using_the_Canvas2D) ([nockawa](https://github.com/nockawa))
-	  - Added two new types of Texture: FontTexture and MapTexture ([quick doc](http://www.html5gamedevs.com/topic/22565-two-new-texture-types-fonttexture-and-maptexture/)) ([nockawa](https://github.com/nockawa))
-	  - Added a dynamic [2D Bin Packing Algorithm](http://stackoverflow.com/questions/8762569/how-is-2d-bin-packing-achieved-programmatically), ([more info here](http://www.html5gamedevs.com/topic/22565-two-new-texture-types-fonttexture-and-maptexture/)) ([nockawa](https://github.com/nockawa))
-	  - Introduced Canvas2D feature: a 2D engine to render primitives, sprites in 2D, text. Canvas2D can be displayed in Screen Space (above the 3D scene) or in World Space to be a part of the Scene. [overview](http://doc.babylonjs.com/overviews/Using_The_Canvas2D), [tutorial](http://doc.babylonjs.com/tutorials/Using_the_Canvas2D) ([nockawa](https://github.com/nockawa))	
+    - Introduced Canvas2D feature: a 2D engine to render primitives, sprites in 2D, text. Canvas2D can be displayed in Screen Space (above the 3D scene) or in World Space to be a part of the Scene. [overview](http://doc.babylonjs.com/overviews/Using_The_Canvas2D), [tutorial](http://doc.babylonjs.com/tutorials/Using_the_Canvas2D) ([nockawa](https://github.com/nockawa))
+    - Added two new types of Texture: FontTexture and MapTexture ([quick doc](http://www.html5gamedevs.com/topic/22565-two-new-texture-types-fonttexture-and-maptexture/)) ([nockawa](https://github.com/nockawa))
+    - Added a dynamic [2D Bin Packing Algorithm](http://stackoverflow.com/questions/8762569/how-is-2d-bin-packing-achieved-programmatically), ([more info here](http://www.html5gamedevs.com/topic/22565-two-new-texture-types-fonttexture-and-maptexture/)) ([nockawa](https://github.com/nockawa))
+    - Introduced Canvas2D feature: a 2D engine to render primitives, sprites in 2D, text. Canvas2D can be displayed in Screen Space (above the 3D scene) or in World Space to be a part of the Scene. [overview](http://doc.babylonjs.com/overviews/Using_The_Canvas2D), [tutorial](http://doc.babylonjs.com/tutorials/Using_the_Canvas2D) ([nockawa](https://github.com/nockawa))	
   - **Updates**
     - Renderlists can now also be defined using predicates ([deltakosh](https://github.com/deltakosh))
     - Added support for various normal maps conventions ([deltakosh](https://github.com/deltakosh))
@@ -45,6 +45,8 @@
 	  - Added DynamicFloatArray class to store float32 based elements of a given size (stride) into one big Float32Array, with allocation/free/pack operations to then access an optimal buffer that can be used to update a WebGLBuffer dynamically.([quick doc](http://www.html5gamedevs.com/topic/22567-dynamicfloatarray-to-the-rescue-for-efficient-instanced-array/)) ([nockawa](https://github.com/nockawa))
 	  - Scene.onPointerObservable property added to enable a unique Observable event for user input (see ArcRotateCamera inputs for examples) ([nockawa](https://github.com/nockawa))
   - **Exporters**
+    - Unity3D exporter: Added support for lightmaps ([davrous](https://github.com/davrous), [deltakosh](https://github.com/deltakosh))
+    - Unity3D exporter: Added support for export and run (local webserver) ([davrous](https://github.com/davrous), [deltakosh](https://github.com/deltakosh))
     - Unity exporter now support skeletons ([sebavan](https://github.com/sebavan))
     - Support for 3dsmax 2017 ([deltakosh](https://github.com/deltakosh))
     - Added support for up to 8 bones influences per vertex for 3dsmax exporter ([deltakosh](https://github.com/deltakosh))

+ 85 - 0
src/Math/babylon.math.js

@@ -46,6 +46,15 @@ var BABYLON;
         Color3.prototype.toString = function () {
             return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
         };
+        Color3.prototype.getClassName = function () {
+            return "Color3";
+        };
+        Color3.prototype.getHashCode = function () {
+            var hash = this.r || 0;
+            hash = (hash * 397) ^ (this.g || 0);
+            hash = (hash * 397) ^ (this.b || 0);
+            return hash;
+        };
         // Operators
         Color3.prototype.toArray = function (array, index) {
             if (index === undefined) {
@@ -245,6 +254,16 @@ var BABYLON;
         Color4.prototype.toString = function () {
             return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
         };
+        Color4.prototype.getClassName = function () {
+            return "Color4";
+        };
+        Color4.prototype.getHashCode = function () {
+            var hash = this.r || 0;
+            hash = (hash * 397) ^ (this.g || 0);
+            hash = (hash * 397) ^ (this.b || 0);
+            hash = (hash * 397) ^ (this.a || 0);
+            return hash;
+        };
         Color4.prototype.clone = function () {
             return new Color4(this.r, this.g, this.b, this.a);
         };
@@ -318,6 +337,14 @@ var BABYLON;
         Vector2.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + "}";
         };
+        Vector2.prototype.getClassName = function () {
+            return "Vector2";
+        };
+        Vector2.prototype.getHashCode = function () {
+            var hash = this.x || 0;
+            hash = (hash * 397) ^ (this.y || 0);
+            return hash;
+        };
         // Operators
         Vector2.prototype.toArray = function (array, index) {
             if (index === void 0) { index = 0; }
@@ -513,6 +540,15 @@ var BABYLON;
         Vector3.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
         };
+        Vector3.prototype.getClassName = function () {
+            return "Vector3";
+        };
+        Vector3.prototype.getHashCode = function () {
+            var hash = this.x || 0;
+            hash = (hash * 397) ^ (this.y || 0);
+            hash = (hash * 397) ^ (this.z || 0);
+            return hash;
+        };
         // Operators
         Vector3.prototype.asArray = function () {
             var result = [];
@@ -1014,6 +1050,16 @@ var BABYLON;
         Vector4.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "W:" + this.w + "}";
         };
+        Vector4.prototype.getClassName = function () {
+            return "Vector4";
+        };
+        Vector4.prototype.getHashCode = function () {
+            var hash = this.x || 0;
+            hash = (hash * 397) ^ (this.y || 0);
+            hash = (hash * 397) ^ (this.z || 0);
+            hash = (hash * 397) ^ (this.w || 0);
+            return hash;
+        };
         // Operators
         Vector4.prototype.asArray = function () {
             var result = [];
@@ -1268,6 +1314,17 @@ var BABYLON;
             this.width = width;
             this.height = height;
         }
+        Size.prototype.toString = function () {
+            return "{W: " + this.width + ", H: " + this.height + "}";
+        };
+        Size.prototype.getClassName = function () {
+            return "Size";
+        };
+        Size.prototype.getHashCode = function () {
+            var hash = this.width || 0;
+            hash = (hash * 397) ^ (this.height || 0);
+            return hash;
+        };
         Size.prototype.clone = function () {
             return new Size(this.width, this.height);
         };
@@ -1317,6 +1374,16 @@ var BABYLON;
         Quaternion.prototype.toString = function () {
             return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
         };
+        Quaternion.prototype.getClassName = function () {
+            return "Quaternion";
+        };
+        Quaternion.prototype.getHashCode = function () {
+            var hash = this.x || 0;
+            hash = (hash * 397) ^ (this.y || 0);
+            hash = (hash * 397) ^ (this.z || 0);
+            hash = (hash * 397) ^ (this.w || 0);
+            return hash;
+        };
         Quaternion.prototype.asArray = function () {
             return [this.x, this.y, this.z, this.w];
         };
@@ -1799,6 +1866,16 @@ var BABYLON;
         Matrix.prototype.clone = function () {
             return Matrix.FromValues(this.m[0], this.m[1], this.m[2], this.m[3], this.m[4], this.m[5], this.m[6], this.m[7], this.m[8], this.m[9], this.m[10], this.m[11], this.m[12], this.m[13], this.m[14], this.m[15]);
         };
+        Matrix.prototype.getClassName = function () {
+            return "Matrix";
+        };
+        Matrix.prototype.getHashCode = function () {
+            var hash = this.m[0] || 0;
+            for (var i = 1; i < 16; i++) {
+                hash = (hash * 397) ^ (this.m[i] || 0);
+            }
+            return hash;
+        };
         Matrix.prototype.decompose = function (scale, rotation, translation) {
             translation.x = this.m[12];
             translation.y = this.m[13];
@@ -2263,6 +2340,14 @@ var BABYLON;
         Plane.prototype.clone = function () {
             return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
         };
+        Plane.prototype.getClassName = function () {
+            return "Plane";
+        };
+        Plane.prototype.getHashCode = function () {
+            var hash = this.normal.getHashCode();
+            hash = (hash * 397) ^ (this.d || 0);
+            return hash;
+        };
         Plane.prototype.normalize = function () {
             var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
             var magnitude = 0;

+ 49 - 7
src/Tools/babylon.tools.js

@@ -794,12 +794,17 @@ var BABYLON;
         Tools.getClassName = function (object, isType) {
             if (isType === void 0) { isType = false; }
             var name = null;
-            if (object instanceof Object) {
-                var classObj = isType ? object : Object.getPrototypeOf(object);
-                name = classObj.constructor["__bjsclassName__"];
+            if (!isType && object.getClassName) {
+                name = object.getClassName();
             }
-            if (!name) {
-                name = typeof object;
+            else {
+                if (object instanceof Object) {
+                    var classObj = isType ? object : Object.getPrototypeOf(object);
+                    name = classObj.constructor["__bjsclassName__"];
+                }
+                if (!name) {
+                    name = typeof object;
+                }
             }
             return name;
         };
@@ -811,6 +816,43 @@ var BABYLON;
                 }
             }
         };
+        /**
+         * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
+         * @param array
+         */
+        Tools.arrayOrStringFeeder = function (array) {
+            return function (index) {
+                if (index >= array.length) {
+                    return null;
+                }
+                var val = array.charCodeAt ? array.charCodeAt(index) : array[index];
+                if (val && val.getHashCode) {
+                    val = val.getHashCode();
+                }
+                if (typeof val === "string") {
+                    return Tools.hashCodeFromStream(Tools.arrayOrStringFeeder(val));
+                }
+                return val;
+            };
+        };
+        /**
+         * Compute the hashCode of a stream of number
+         * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
+         * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
+         * @return the hash code computed
+         */
+        Tools.hashCodeFromStream = function (feeder) {
+            // Based from here: http://stackoverflow.com/a/7616484/802124
+            var hash = 0;
+            var index = 0;
+            var chr = feeder(index++);
+            while (chr != null) {
+                hash = ((hash << 5) - hash) + chr;
+                hash |= 0; // Convert to 32bit integer
+                chr = feeder(index++);
+            }
+            return hash;
+        };
         Tools.BaseUrl = "";
         Tools.CorsBehavior = "anonymous";
         Tools.UseFallbackTexture = true;
@@ -847,8 +889,8 @@ var BABYLON;
     }
     BABYLON.className = className;
     /**
-     * An implementation of a loop for asynchronous functions.
-     */
+    * An implementation of a loop for asynchronous functions.
+    */
     var AsyncLoop = (function () {
         /**
          * Constroctor.

+ 4 - 4
src/Tools/babylon.tools.ts

@@ -1031,9 +1031,9 @@
         }
     }
 
-     /**
-     * An implementation of a loop for asynchronous functions.
-     */
+    /**
+    * An implementation of a loop for asynchronous functions.
+    */
     export class AsyncLoop {
         public index: number;
         private _done: boolean;
@@ -1114,4 +1114,4 @@
             }, callback);
         }
     }
-} 
+}