Explorar o código

Changing priorities between rotationQuaternion and rotation when loading/saving

David Catuhe %!s(int64=11) %!d(string=hai) anos
pai
achega
ed4ba5a9e0
Modificáronse 35 ficheiros con 763 adicións e 176 borrados
  1. 45 5
      Babylon/Actions/babylon.actionManager.js
  2. 25 5
      Babylon/Actions/babylon.actionManager.ts
  3. 71 9
      Babylon/Animations/babylon.animation.js
  4. 40 9
      Babylon/Animations/babylon.animation.ts
  5. 2 0
      Babylon/Cameras/babylon.anaglyphCamera.js
  6. 2 0
      Babylon/Cameras/babylon.anaglyphCamera.ts
  7. 5 1
      Babylon/Cameras/babylon.camera.js
  8. 5 1
      Babylon/Cameras/babylon.camera.ts
  9. 5 3
      Babylon/Culling/babylon.BoundingBox.ts
  10. 5 3
      Babylon/Culling/babylon.boundingBox.js
  11. 1 1
      Babylon/Culling/babylon.boundingSphere.js
  12. 1 1
      Babylon/Culling/babylon.boundingSphere.ts
  13. 5 3
      Babylon/Loading/Plugins/babylon.babylonFileLoader.js
  14. 10 1
      Babylon/Materials/babylon.standardMaterial.js
  15. 10 1
      Babylon/Materials/babylon.standardMaterial.ts
  16. 12 6
      Babylon/Materials/textures/babylon.renderTargetTexture.js
  17. 14 7
      Babylon/Materials/textures/babylon.renderTargetTexture.ts
  18. 45 5
      Babylon/Mesh/babylon.mesh.js
  19. 25 5
      Babylon/Mesh/babylon.mesh.ts
  20. 62 7
      Babylon/Mesh/babylon.vertexBuffer.js
  21. 35 7
      Babylon/Mesh/babylon.vertexBuffer.ts
  22. 1 1
      Babylon/Physics/Plugins/babylon.cannonJSPlugin.js
  23. 1 1
      Babylon/Physics/Plugins/babylon.cannonJSPlugin.ts
  24. 3 3
      Babylon/PostProcess/babylon.postProcess.js
  25. 3 3
      Babylon/PostProcess/babylon.postProcess.ts
  26. 11 5
      Babylon/PostProcess/babylon.postProcessManager.js
  27. 11 5
      Babylon/PostProcess/babylon.postProcessManager.ts
  28. 7 3
      Babylon/Shaders/default.fragment.fx
  29. 3 3
      Babylon/Tools/babylon.sceneSerializer.js
  30. 3 3
      Babylon/Tools/babylon.sceneSerializer.ts
  31. 101 19
      Babylon/Tools/babylon.tools.js
  32. 80 20
      Babylon/Tools/babylon.tools.ts
  33. 64 9
      Babylon/babylon.engine.js
  34. 38 9
      Babylon/babylon.engine.ts
  35. 12 12
      babylon.1.12-beta.js

+ 45 - 5
Babylon/Actions/babylon.actionManager.js

@@ -6,6 +6,46 @@
             this.actions = new Array();
             this._scene = scene;
         }
+        Object.defineProperty(ActionManager, "NoneTrigger", {
+            get: function () {
+                return ActionManager._NoneTrigger;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(ActionManager, "OnPickTrigger", {
+            get: function () {
+                return ActionManager._OnPickTrigger;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(ActionManager, "OnPointerOverTrigger", {
+            get: function () {
+                return ActionManager._OnPointerOverTrigger;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(ActionManager, "OnPointerOutTrigger", {
+            get: function () {
+                return ActionManager._OnPointerOutTrigger;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(ActionManager, "OnEveryFrameTrigger", {
+            get: function () {
+                return ActionManager._OnEveryFrameTrigger;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         // Methods
         ActionManager.prototype.getScene = function () {
             return this._scene;
@@ -52,11 +92,11 @@
 
             return properties[properties.length - 1];
         };
-        ActionManager.NoneTrigger = 0;
-        ActionManager.OnPickTrigger = 1;
-        ActionManager.OnPointerOverTrigger = 2;
-        ActionManager.OnPointerOutTrigger = 3;
-        ActionManager.OnEveryFrameTrigger = 4;
+        ActionManager._NoneTrigger = 0;
+        ActionManager._OnPickTrigger = 1;
+        ActionManager._OnPointerOverTrigger = 2;
+        ActionManager._OnPointerOutTrigger = 3;
+        ActionManager._OnEveryFrameTrigger = 4;
         return ActionManager;
     })();
     BABYLON.ActionManager = ActionManager;

+ 25 - 5
Babylon/Actions/babylon.actionManager.ts

@@ -1,11 +1,31 @@
 module BABYLON {
     export class ActionManager {
         // Statics
-        public static NoneTrigger = 0;
-        public static OnPickTrigger = 1;
-        public static OnPointerOverTrigger = 2;
-        public static OnPointerOutTrigger = 3;
-        public static OnEveryFrameTrigger = 4;
+        private static _NoneTrigger = 0;
+        private static _OnPickTrigger = 1;
+        private static _OnPointerOverTrigger = 2;
+        private static _OnPointerOutTrigger = 3;
+        private static _OnEveryFrameTrigger = 4;
+
+        public static get NoneTrigger(): number {
+            return ActionManager._NoneTrigger;
+        }
+
+        public static get OnPickTrigger(): number {
+            return ActionManager._OnPickTrigger;
+        }
+
+        public static get OnPointerOverTrigger(): number {
+            return ActionManager._OnPointerOverTrigger;
+        }
+
+        public static get OnPointerOutTrigger(): number {
+            return ActionManager._OnPointerOutTrigger;
+        }
+
+        public static get OnEveryFrameTrigger(): number {
+            return ActionManager._OnEveryFrameTrigger;
+        }
 
         // Members
         public actions = new Array<Action>();

+ 71 - 9
Babylon/Animations/babylon.animation.js

@@ -213,15 +213,77 @@
             return returnValue;
         };
 
-        Animation.ANIMATIONTYPE_FLOAT = 0;
-        Animation.ANIMATIONTYPE_VECTOR3 = 1;
-        Animation.ANIMATIONTYPE_QUATERNION = 2;
-        Animation.ANIMATIONTYPE_MATRIX = 3;
-        Animation.ANIMATIONTYPE_COLOR3 = 4;
-
-        Animation.ANIMATIONLOOPMODE_RELATIVE = 0;
-        Animation.ANIMATIONLOOPMODE_CYCLE = 1;
-        Animation.ANIMATIONLOOPMODE_CONSTANT = 2;
+        Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_FLOAT;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_VECTOR3;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_QUATERNION;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_MATRIX;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
+            get: function () {
+                return Animation._ANIMATIONTYPE_COLOR3;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_RELATIVE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_CYCLE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
+            get: function () {
+                return Animation._ANIMATIONLOOPMODE_CONSTANT;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Animation._ANIMATIONTYPE_FLOAT = 0;
+        Animation._ANIMATIONTYPE_VECTOR3 = 1;
+        Animation._ANIMATIONTYPE_QUATERNION = 2;
+        Animation._ANIMATIONTYPE_MATRIX = 3;
+        Animation._ANIMATIONTYPE_COLOR3 = 4;
+        Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
+        Animation._ANIMATIONLOOPMODE_CYCLE = 1;
+        Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
         return Animation;
     })();
     BABYLON.Animation = Animation;

+ 40 - 9
Babylon/Animations/babylon.animation.ts

@@ -215,14 +215,45 @@
         }
 
         // Statics
-        public static ANIMATIONTYPE_FLOAT = 0;
-        public static ANIMATIONTYPE_VECTOR3 = 1;
-        public static ANIMATIONTYPE_QUATERNION = 2;
-        public static ANIMATIONTYPE_MATRIX = 3;
-        public static ANIMATIONTYPE_COLOR3 = 4;
-
-        public static ANIMATIONLOOPMODE_RELATIVE = 0;
-        public static ANIMATIONLOOPMODE_CYCLE = 1;
-        public static ANIMATIONLOOPMODE_CONSTANT = 2;
+        private static _ANIMATIONTYPE_FLOAT = 0;
+        private static _ANIMATIONTYPE_VECTOR3 = 1;
+        private static _ANIMATIONTYPE_QUATERNION = 2;
+        private static _ANIMATIONTYPE_MATRIX = 3;
+        private static _ANIMATIONTYPE_COLOR3 = 4;
+        private static _ANIMATIONLOOPMODE_RELATIVE = 0;
+        private static _ANIMATIONLOOPMODE_CYCLE = 1;
+        private static _ANIMATIONLOOPMODE_CONSTANT = 2;
+
+        public static get ANIMATIONTYPE_FLOAT(): number {
+            return Animation._ANIMATIONTYPE_FLOAT;
+        }
+
+        public static get ANIMATIONTYPE_VECTOR3(): number {
+            return Animation._ANIMATIONTYPE_VECTOR3;
+        }
+
+        public static get ANIMATIONTYPE_QUATERNION(): number {
+            return Animation._ANIMATIONTYPE_QUATERNION;
+        }
+
+        public static get ANIMATIONTYPE_MATRIX(): number {
+            return Animation._ANIMATIONTYPE_MATRIX;
+        }
+
+        public static get ANIMATIONTYPE_COLOR3(): number {
+            return Animation._ANIMATIONTYPE_COLOR3;
+        }
+
+        public static get ANIMATIONLOOPMODE_RELATIVE(): number {
+            return Animation._ANIMATIONLOOPMODE_RELATIVE;
+        }
+
+        public static get ANIMATIONLOOPMODE_CYCLE(): number {
+            return Animation._ANIMATIONLOOPMODE_CYCLE;
+        }
+
+        public static get ANIMATIONLOOPMODE_CONSTANT(): number {
+            return Animation._ANIMATIONLOOPMODE_CONSTANT;
+        }
     }
 } 

+ 2 - 0
Babylon/Cameras/babylon.anaglyphCamera.js

@@ -98,6 +98,8 @@ var BABYLON;
 
             camera.fov = this.fov;
 
+            camera.viewport = this.viewport;
+
             camera.setTarget(this.getTarget());
         };
         return AnaglyphFreeCamera;

+ 2 - 0
Babylon/Cameras/babylon.anaglyphCamera.ts

@@ -98,6 +98,8 @@
 
             camera.fov = this.fov;
 
+            camera.viewport = this.viewport;
+
             camera.setTarget(this.getTarget());
         }
     }

+ 5 - 1
Babylon/Cameras/babylon.camera.js

@@ -27,7 +27,7 @@ var BABYLON;
             this.subCameras = [];
             this._computedViewMatrix = BABYLON.Matrix.Identity();
             this._projectionMatrix = new BABYLON.Matrix();
-            this._postProcesses = [];
+            this._postProcesses = new Array();
             this._postProcessesTakenIndices = [];
 
             scene.cameras.push(this);
@@ -270,6 +270,10 @@ var BABYLON;
 
             var engine = this.getEngine();
             if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
+                if (this.minZ <= 0) {
+                    this.minZ = BABYLON.Engine.Epsilon;
+                }
+
                 BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix);
                 return this._projectionMatrix;
             }

+ 5 - 1
Babylon/Cameras/babylon.camera.ts

@@ -22,7 +22,7 @@
         private _computedViewMatrix = BABYLON.Matrix.Identity();
         private _projectionMatrix = new BABYLON.Matrix();
         private _worldMatrix: Matrix;
-        public _postProcesses = [];
+        public _postProcesses = new Array<PostProcess>();
         public _postProcessesTakenIndices = [];
 
         constructor(name: string, public position: Vector3, scene: Scene) {
@@ -286,6 +286,10 @@
 
             var engine = this.getEngine();
             if (this.mode === BABYLON.Camera.PERSPECTIVE_CAMERA) {
+                if (this.minZ <= 0) {
+                    this.minZ = Engine.Epsilon;
+                }
+
                 BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix);
                 return this._projectionMatrix;
             }

+ 5 - 3
Babylon/Culling/babylon.BoundingBox.ts

@@ -84,13 +84,15 @@
         }
 
         public intersectsPoint(point: Vector3): boolean {
-            if (this.maximumWorld.x < point.x || this.minimumWorld.x > point.x)
+            var delta = Engine.Epsilon;
+
+            if (this.maximumWorld.x - point.x < delta || delta > point.x - this.minimumWorld.x)
                 return false;
 
-            if (this.maximumWorld.y < point.y || this.minimumWorld.y > point.y)
+            if (this.maximumWorld.y - point.y < delta || delta > point.y - this.minimumWorld.y)
                 return false;
 
-            if (this.maximumWorld.z < point.z || this.minimumWorld.z > point.z)
+            if (this.maximumWorld.z - point.z < delta || delta > point.z - this.minimumWorld.z)
                 return false;
 
             return true;

+ 5 - 3
Babylon/Culling/babylon.boundingBox.js

@@ -79,13 +79,15 @@
         };
 
         BoundingBox.prototype.intersectsPoint = function (point) {
-            if (this.maximumWorld.x < point.x || this.minimumWorld.x > point.x)
+            var delta = BABYLON.Engine.Epsilon;
+
+            if (this.maximumWorld.x - point.x < delta || delta > point.x - this.minimumWorld.x)
                 return false;
 
-            if (this.maximumWorld.y < point.y || this.minimumWorld.y > point.y)
+            if (this.maximumWorld.y - point.y < delta || delta > point.y - this.minimumWorld.y)
                 return false;
 
-            if (this.maximumWorld.z < point.z || this.minimumWorld.z > point.z)
+            if (this.maximumWorld.z - point.z < delta || delta > point.z - this.minimumWorld.z)
                 return false;
 
             return true;

+ 1 - 1
Babylon/Culling/babylon.boundingSphere.js

@@ -37,7 +37,7 @@
 
             var distance = Math.sqrt((x * x) + (y * y) + (z * z));
 
-            if (this.radiusWorld < distance)
+            if (Math.abs(this.radiusWorld - distance) < BABYLON.Engine.Epsilon)
                 return false;
 
             return true;

+ 1 - 1
Babylon/Culling/babylon.boundingSphere.ts

@@ -40,7 +40,7 @@
 
             var distance = Math.sqrt((x * x) + (y * y) + (z * z));
 
-            if (this.radiusWorld < distance)
+            if (Math.abs(this.radiusWorld - distance) < Engine.Epsilon)
                 return false;
 
             return true;

+ 5 - 3
Babylon/Loading/Plugins/babylon.babylonFileLoader.js

@@ -501,11 +501,13 @@ var BABYLON = BABYLON || {};
         BABYLON.Tags.AddTagsTo(mesh, parsedMesh.tags);
 
         mesh.position = BABYLON.Vector3.FromArray(parsedMesh.position);
-        if (parsedMesh.rotation) {
-            mesh.rotation = BABYLON.Vector3.FromArray(parsedMesh.rotation);
-        } else if (parsedMesh.rotationQuaternion) {
+
+        if (parsedMesh.rotationQuaternion) {
             mesh.rotationQuaternion = BABYLON.Quaternion.FromArray(parsedMesh.rotationQuaternion);
+        } else if (parsedMesh.rotation) {
+            mesh.rotation = BABYLON.Vector3.FromArray(parsedMesh.rotation);
         }
+
         mesh.scaling = BABYLON.Vector3.FromArray(parsedMesh.scaling);
 
         if (parsedMesh.localMatrix) {

+ 10 - 1
Babylon/Materials/babylon.standardMaterial.js

@@ -18,6 +18,7 @@ var BABYLON;
             this.specularColor = new BABYLON.Color3(1, 1, 1);
             this.specularPower = 64;
             this.emissiveColor = new BABYLON.Color3(0, 0, 0);
+            this.useAlphaFromDiffuseTexture = false;
             this._cachedDefines = null;
             this._renderTargets = new BABYLON.SmartArray(16);
             this._worldViewProjectionMatrix = BABYLON.Matrix.Zero();
@@ -38,13 +39,17 @@ var BABYLON;
             };
         }
         StandardMaterial.prototype.needAlphaBlending = function () {
-            return (this.alpha < 1.0) || (this.opacityTexture != null);
+            return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture();
         };
 
         StandardMaterial.prototype.needAlphaTesting = function () {
             return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
         };
 
+        StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
+            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && this.useAlphaFromDiffuseTexture;
+        };
+
         // Methods
         StandardMaterial.prototype.isReady = function (mesh) {
             if (this.checkReadyOnlyOnce) {
@@ -135,6 +140,10 @@ var BABYLON;
                 defines.push("#define ALPHATEST");
             }
 
+            if (this._shouldUseAlphaFromDiffuseTexture()) {
+                defines.push("#define ALPHAFROMDIFFUSE");
+            }
+
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
                 defines.push("#define FOG");

+ 10 - 1
Babylon/Materials/babylon.standardMaterial.ts

@@ -15,6 +15,7 @@
         public specularColor = new BABYLON.Color3(1, 1, 1);
         public specularPower = 64;
         public emissiveColor = new BABYLON.Color3(0, 0, 0);
+        public useAlphaFromDiffuseTexture = false;
 
         private _cachedDefines = null;
         private _renderTargets = new BABYLON.SmartArray(16);
@@ -41,13 +42,17 @@
         }
 
         public needAlphaBlending(): boolean {
-            return (this.alpha < 1.0) || (this.opacityTexture != null);
+            return (this.alpha < 1.0) || (this.opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture();
         }
 
         public needAlphaTesting(): boolean {
             return this.diffuseTexture != null && this.diffuseTexture.hasAlpha;
         }
 
+        private _shouldUseAlphaFromDiffuseTexture(): boolean {
+            return this.diffuseTexture != null && this.diffuseTexture.hasAlpha && this.useAlphaFromDiffuseTexture;
+        }
+
         // Methods   
         public isReady(mesh?: Mesh): boolean {
             if (this.checkReadyOnlyOnce) {
@@ -138,6 +143,10 @@
                 defines.push("#define ALPHATEST");
             }
 
+            if (this._shouldUseAlphaFromDiffuseTexture()) {
+                defines.push("#define ALPHAFROMDIFFUSE");
+            }
+
             // Fog
             if (scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
                 defines.push("#define FOG");

+ 12 - 6
Babylon/Materials/textures/babylon.renderTargetTexture.js

@@ -8,7 +8,7 @@ var BABYLON;
 (function (BABYLON) {
     var RenderTargetTexture = (function (_super) {
         __extends(RenderTargetTexture, _super);
-        function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectratio) {
+        function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio) {
             _super.call(this, null, scene, !generateMipMaps);
             this.renderList = new Array();
             this.renderParticles = true;
@@ -19,7 +19,7 @@ var BABYLON;
             this.isRenderTarget = true;
             this._size = size;
             this._generateMipMaps = generateMipMaps;
-            this._doNotChangeAspectratio = doNotChangeAspectratio;
+            this._doNotChangeAspectRatio = doNotChangeAspectRatio;
 
             this._texture = scene.getEngine().createRenderTargetTexture(size, generateMipMaps);
 
@@ -35,7 +35,7 @@ var BABYLON;
             this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
         };
 
-        RenderTargetTexture.prototype.render = function () {
+        RenderTargetTexture.prototype.render = function (useCameraPostProcess) {
             var scene = this.getScene();
             var engine = scene.getEngine();
 
@@ -54,7 +54,9 @@ var BABYLON;
             }
 
             // Bind
-            engine.bindFramebuffer(this._texture);
+            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
+                engine.bindFramebuffer(this._texture);
+            }
 
             // Clear
             engine.clear(scene.clearColor, true, true);
@@ -73,7 +75,7 @@ var BABYLON;
                 }
             }
 
-            if (!this._doNotChangeAspectratio) {
+            if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
 
@@ -84,6 +86,10 @@ var BABYLON;
             // Render
             this._renderingManager.render(this.customRenderFunction, this.renderList, this.renderParticles, this.renderSprites);
 
+            if (useCameraPostProcess) {
+                scene.postProcessManager._finalizeFrame(false, this._texture);
+            }
+
             if (this.onAfterRender) {
                 this.onAfterRender();
             }
@@ -91,7 +97,7 @@ var BABYLON;
             // Unbind
             engine.unBindFramebuffer(this._texture);
 
-            if (!this._doNotChangeAspectratio) {
+            if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
         };

+ 14 - 7
Babylon/Materials/textures/babylon.renderTargetTexture.ts

@@ -12,16 +12,16 @@
         public _generateMipMaps: boolean;
         private _renderingManager
         public _waitingRenderList: string[];
-        private _doNotChangeAspectratio: boolean;
+        private _doNotChangeAspectRatio: boolean;
 
-        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectratio?: boolean) {
+        constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean) {
             super(null, scene, !generateMipMaps);
 
             this.name = name;
             this.isRenderTarget = true;
             this._size = size;
             this._generateMipMaps = generateMipMaps;
-            this._doNotChangeAspectratio = doNotChangeAspectratio;
+            this._doNotChangeAspectRatio = doNotChangeAspectRatio;
 
             this._texture = scene.getEngine().createRenderTargetTexture(size, generateMipMaps);
 
@@ -38,7 +38,7 @@
             this._texture = this.getScene().getEngine().createRenderTargetTexture(size, generateMipMaps);
         }
 
-        public render() {
+        public render(useCameraPostProcess?: boolean) {
             var scene = this.getScene();
             var engine = scene.getEngine();
 
@@ -57,7 +57,9 @@
             }
 
             // Bind
-            engine.bindFramebuffer(this._texture);
+            if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
+                engine.bindFramebuffer(this._texture);
+            }
 
             // Clear
             engine.clear(scene.clearColor, true, true);
@@ -76,7 +78,7 @@
                 }
             }
 
-            if (!this._doNotChangeAspectratio) {
+            if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
 
@@ -85,8 +87,13 @@
             }
 
             // Render
+
             this._renderingManager.render(this.customRenderFunction, this.renderList, this.renderParticles, this.renderSprites);
 
+            if (useCameraPostProcess) {
+                scene.postProcessManager._finalizeFrame(false, this._texture);
+            }
+
             if (this.onAfterRender) {
                 this.onAfterRender();
             }
@@ -94,7 +101,7 @@
             // Unbind
             engine.unBindFramebuffer(this._texture);
 
-            if (!this._doNotChangeAspectratio) {
+            if (!this._doNotChangeAspectRatio) {
                 scene.updateTransformMatrix(true);
             }
         }

+ 45 - 5
Babylon/Mesh/babylon.mesh.js

@@ -53,6 +53,46 @@ var BABYLON;
 
             scene.meshes.push(this);
         }
+        Object.defineProperty(Mesh, "BILLBOARDMODE_NONE", {
+            get: function () {
+                return Mesh._BILLBOARDMODE_NONE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Mesh, "BILLBOARDMODE_X", {
+            get: function () {
+                return Mesh._BILLBOARDMODE_X;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Mesh, "BILLBOARDMODE_Y", {
+            get: function () {
+                return Mesh._BILLBOARDMODE_Y;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Mesh, "BILLBOARDMODE_Z", {
+            get: function () {
+                return Mesh._BILLBOARDMODE_Z;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Mesh, "BILLBOARDMODE_ALL", {
+            get: function () {
+                return Mesh._BILLBOARDMODE_ALL;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         Mesh.prototype.getBoundingInfo = function () {
             return this._boundingInfo;
         };
@@ -1210,11 +1250,11 @@ var BABYLON;
             var minMaxVector = meshesOrMinMaxVector.min !== undefined ? meshesOrMinMaxVector : BABYLON.Mesh.MinMax(meshesOrMinMaxVector);
             return BABYLON.Vector3.Center(minMaxVector.min, minMaxVector.max);
         };
-        Mesh.BILLBOARDMODE_NONE = 0;
-        Mesh.BILLBOARDMODE_X = 1;
-        Mesh.BILLBOARDMODE_Y = 2;
-        Mesh.BILLBOARDMODE_Z = 4;
-        Mesh.BILLBOARDMODE_ALL = 7;
+        Mesh._BILLBOARDMODE_NONE = 0;
+        Mesh._BILLBOARDMODE_X = 1;
+        Mesh._BILLBOARDMODE_Y = 2;
+        Mesh._BILLBOARDMODE_Z = 4;
+        Mesh._BILLBOARDMODE_ALL = 7;
         return Mesh;
     })(BABYLON.Node);
     BABYLON.Mesh = Mesh;

+ 25 - 5
Babylon/Mesh/babylon.mesh.ts

@@ -1,11 +1,31 @@
 module BABYLON {
     export class Mesh extends Node implements IGetSetVerticesData {
         // Statics
-        public static BILLBOARDMODE_NONE = 0;
-        public static BILLBOARDMODE_X = 1;
-        public static BILLBOARDMODE_Y = 2;
-        public static BILLBOARDMODE_Z = 4;
-        public static BILLBOARDMODE_ALL = 7;
+        private static _BILLBOARDMODE_NONE = 0;
+        private static _BILLBOARDMODE_X = 1;
+        private static _BILLBOARDMODE_Y = 2;
+        private static _BILLBOARDMODE_Z = 4;
+        private static _BILLBOARDMODE_ALL = 7;
+
+        public static get BILLBOARDMODE_NONE(): number {
+            return Mesh._BILLBOARDMODE_NONE;
+        }
+
+        public static get BILLBOARDMODE_X(): number {
+            return Mesh._BILLBOARDMODE_X;
+        }
+
+        public static get BILLBOARDMODE_Y(): number {
+            return Mesh._BILLBOARDMODE_Y;
+        }
+
+        public static get BILLBOARDMODE_Z(): number {
+            return Mesh._BILLBOARDMODE_Z;
+        }
+
+        public static get BILLBOARDMODE_ALL(): number {
+            return Mesh._BILLBOARDMODE_ALL;
+        }
 
         // Members
         public position = new BABYLON.Vector3(0, 0, 0);

+ 62 - 7
Babylon/Mesh/babylon.vertexBuffer.js

@@ -94,13 +94,68 @@
             }
         };
 
-        VertexBuffer.PositionKind = "position";
-        VertexBuffer.NormalKind = "normal";
-        VertexBuffer.UVKind = "uv";
-        VertexBuffer.UV2Kind = "uv2";
-        VertexBuffer.ColorKind = "color";
-        VertexBuffer.MatricesIndicesKind = "matricesIndices";
-        VertexBuffer.MatricesWeightsKind = "matricesWeights";
+        Object.defineProperty(VertexBuffer, "PositionKind", {
+            get: function () {
+                return VertexBuffer._PositionKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "NormalKind", {
+            get: function () {
+                return VertexBuffer._NormalKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "UVKind", {
+            get: function () {
+                return VertexBuffer._UVKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "UV2Kind", {
+            get: function () {
+                return VertexBuffer._UV2Kind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "ColorKind", {
+            get: function () {
+                return VertexBuffer._ColorKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "MatricesIndicesKind", {
+            get: function () {
+                return VertexBuffer._MatricesIndicesKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(VertexBuffer, "MatricesWeightsKind", {
+            get: function () {
+                return VertexBuffer._MatricesWeightsKind;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        VertexBuffer._PositionKind = "position";
+        VertexBuffer._NormalKind = "normal";
+        VertexBuffer._UVKind = "uv";
+        VertexBuffer._UV2Kind = "uv2";
+        VertexBuffer._ColorKind = "color";
+        VertexBuffer._MatricesIndicesKind = "matricesIndices";
+        VertexBuffer._MatricesWeightsKind = "matricesWeights";
         return VertexBuffer;
     })();
     BABYLON.VertexBuffer = VertexBuffer;

+ 35 - 7
Babylon/Mesh/babylon.vertexBuffer.ts

@@ -104,12 +104,40 @@
         }
 
         // Enums
-        public static PositionKind = "position";
-        public static NormalKind = "normal";
-        public static UVKind = "uv";
-        public static UV2Kind = "uv2";
-        public static ColorKind = "color";
-        public static MatricesIndicesKind = "matricesIndices";
-        public static MatricesWeightsKind = "matricesWeights";
+        private static _PositionKind = "position";
+        private static _NormalKind = "normal";
+        private static _UVKind = "uv";
+        private static _UV2Kind = "uv2";
+        private static _ColorKind = "color";
+        private static _MatricesIndicesKind = "matricesIndices";
+        private static _MatricesWeightsKind = "matricesWeights";
+
+        public static get PositionKind(): string {
+            return VertexBuffer._PositionKind;
+        }
+
+        public static get NormalKind(): string {
+            return VertexBuffer._NormalKind;
+        }
+
+        public static get UVKind(): string {
+            return VertexBuffer._UVKind;
+        }
+
+        public static get UV2Kind(): string {
+            return VertexBuffer._UV2Kind;
+        }
+
+        public static get ColorKind(): string {
+            return VertexBuffer._ColorKind;
+        }
+
+        public static get MatricesIndicesKind(): string {
+            return VertexBuffer._MatricesIndicesKind;
+        }
+
+        public static get MatricesWeightsKind(): string {
+            return VertexBuffer._MatricesWeightsKind;
+        }
     }
 } 

+ 1 - 1
Babylon/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -63,7 +63,7 @@
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
                     var box = max.subtract(min).scale(0.5);
-                    return this._createBox(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.z), this._checkWithEpsilon(box.y), mesh, options);
+                    return this._createBox(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z), mesh, options);
                 case BABYLON.PhysicsEngine.PlaneImpostor:
                     return this._createPlane(mesh, options);
                 case BABYLON.PhysicsEngine.MeshImpostor:

+ 1 - 1
Babylon/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -66,7 +66,7 @@
                     var min = bbox.minimumWorld;
                     var max = bbox.maximumWorld;
                     var box = max.subtract(min).scale(0.5);
-                    return this._createBox(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.z), this._checkWithEpsilon(box.y), mesh, options);
+                    return this._createBox(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z), mesh, options);
                 case BABYLON.PhysicsEngine.PlaneImpostor:
                     return this._createPlane(mesh, options);
                 case BABYLON.PhysicsEngine.MeshImpostor:

+ 3 - 3
Babylon/PostProcess/babylon.postProcess.js

@@ -30,12 +30,12 @@
             return this._reusable;
         };
 
-        PostProcess.prototype.activate = function (camera) {
+        PostProcess.prototype.activate = function (camera, sourceTexture) {
             camera = camera || this._camera;
 
             var scene = camera.getScene();
-            var desiredWidth = this._engine.getRenderingCanvas().width * this._renderRatio;
-            var desiredHeight = this._engine.getRenderingCanvas().height * this._renderRatio;
+            var desiredWidth = (sourceTexture ? sourceTexture._width : this._engine.getRenderingCanvas().width) * this._renderRatio;
+            var desiredHeight = (sourceTexture ? sourceTexture._height : this._engine.getRenderingCanvas().height) * this._renderRatio;
             if (this.width !== desiredWidth || this.height !== desiredHeight) {
                 if (this._textures.length > 0) {
                     for (var i = 0; i < this._textures.length; i++) {

+ 3 - 3
Babylon/PostProcess/babylon.postProcess.ts

@@ -44,12 +44,12 @@
             return this._reusable;
         }
 
-        public activate(camera: Camera): void {
+        public activate(camera: Camera, sourceTexture?: WebGLTexture): void {
             camera = camera || this._camera;
 
             var scene = camera.getScene();
-            var desiredWidth = this._engine.getRenderingCanvas().width * this._renderRatio;
-            var desiredHeight = this._engine.getRenderingCanvas().height * this._renderRatio;
+            var desiredWidth =  (sourceTexture ? sourceTexture._width : this._engine.getRenderingCanvas().width) * this._renderRatio;
+            var desiredHeight = (sourceTexture ? sourceTexture._height : this._engine.getRenderingCanvas().height) * this._renderRatio;
             if (this.width !== desiredWidth || this.height !== desiredHeight) {
                 if (this._textures.length > 0) {
                     for (var i = 0; i < this._textures.length; i++) {

+ 11 - 5
Babylon/PostProcess/babylon.postProcessManager.js

@@ -27,18 +27,20 @@
             this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
         }
         // Methods
-        PostProcessManager.prototype._prepareFrame = function () {
+        PostProcessManager.prototype._prepareFrame = function (sourceTexture) {
             var postProcesses = this._scene.activeCamera._postProcesses;
             var postProcessesTakenIndices = this._scene.activeCamera._postProcessesTakenIndices;
 
             if (postProcessesTakenIndices.length === 0 || !this._scene.postProcessesEnabled) {
-                return;
+                return false;
             }
 
-            postProcesses[this._scene.activeCamera._postProcessesTakenIndices[0]].activate(this._scene.activeCamera);
+            postProcesses[this._scene.activeCamera._postProcessesTakenIndices[0]].activate(this._scene.activeCamera, sourceTexture);
+
+            return true;
         };
 
-        PostProcessManager.prototype._finalizeFrame = function (doNotPresent) {
+        PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture) {
             var postProcesses = this._scene.activeCamera._postProcesses;
             var postProcessesTakenIndices = this._scene.activeCamera._postProcessesTakenIndices;
             if (postProcessesTakenIndices.length === 0 || !this._scene.postProcessesEnabled) {
@@ -51,7 +53,11 @@
                 if (index < postProcessesTakenIndices.length - 1) {
                     postProcesses[postProcessesTakenIndices[index + 1]].activate(this._scene.activeCamera);
                 } else {
-                    engine.restoreDefaultFramebuffer();
+                    if (targetTexture) {
+                        engine.bindFramebuffer(targetTexture);
+                    } else {
+                        engine.restoreDefaultFramebuffer();
+                    }
                 }
 
                 if (doNotPresent) {

+ 11 - 5
Babylon/PostProcess/babylon.postProcessManager.ts

@@ -31,18 +31,20 @@
         }
 
         // Methods
-        public _prepareFrame(): void {
+        public _prepareFrame(sourceTexture?: WebGLTexture): boolean {
             var postProcesses = this._scene.activeCamera._postProcesses;
             var postProcessesTakenIndices = this._scene.activeCamera._postProcessesTakenIndices;
 
             if (postProcessesTakenIndices.length === 0 || !this._scene.postProcessesEnabled) {
-                return;
+                return false;
             }
 
-            postProcesses[this._scene.activeCamera._postProcessesTakenIndices[0]].activate(this._scene.activeCamera);
+            postProcesses[this._scene.activeCamera._postProcessesTakenIndices[0]].activate(this._scene.activeCamera, sourceTexture);
+
+            return true;
         }
 
-        public _finalizeFrame(doNotPresent?: boolean): void {
+        public _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture): void {
             var postProcesses = this._scene.activeCamera._postProcesses;
             var postProcessesTakenIndices = this._scene.activeCamera._postProcessesTakenIndices;
             if (postProcessesTakenIndices.length === 0 || !this._scene.postProcessesEnabled) {
@@ -55,7 +57,11 @@
                 if (index < postProcessesTakenIndices.length - 1) {
                     postProcesses[postProcessesTakenIndices[index + 1]].activate(this._scene.activeCamera);
                 } else {
-                    engine.restoreDefaultFramebuffer();
+                    if (targetTexture) {
+                        engine.bindFramebuffer(targetTexture);
+                    } else {
+                        engine.restoreDefaultFramebuffer();
+                    }
                 }
 
                 if (doNotPresent) {

+ 7 - 3
Babylon/Shaders/default.fragment.fx

@@ -414,6 +414,9 @@ void main(void) {
 	vec4 baseColor = vec4(1., 1., 1., 1.);
 	vec3 diffuseColor = vDiffuseColor.rgb;
 
+	// Alpha
+	float alpha = vDiffuseColor.a;
+
 #ifdef VERTEXCOLOR
 	diffuseColor *= vColor;
 #endif
@@ -426,6 +429,10 @@ void main(void) {
 		discard;
 #endif
 
+#ifdef ALPHAFROMDIFFUSE
+	alpha *= baseColor.a;
+#endif
+
 	baseColor.rgb *= vDiffuseInfos.y;
 #endif
 
@@ -565,9 +572,6 @@ void main(void) {
 	}
 #endif
 
-	// Alpha
-	float alpha = vDiffuseColor.a;
-
 #ifdef OPACITY
 	vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);
 	opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11) * opacityMap.a;

+ 3 - 3
Babylon/Tools/babylon.sceneSerializer.js

@@ -517,10 +517,10 @@
 
         serializationObject.position = mesh.position.asArray();
 
-        if (mesh.rotation) {
-            serializationObject.rotation = mesh.rotation.asArray();
-        } else if (mesh.rotationQuaternion) {
+        if (mesh.rotationQuaternion) {
             serializationObject.rotationQuaternion = mesh.rotationQuaternion.asArray();
+        } else if (mesh.rotation) {
+            serializationObject.rotation = mesh.rotation.asArray();
         }
 
         serializationObject.scaling = mesh.scaling.asArray();

+ 3 - 3
Babylon/Tools/babylon.sceneSerializer.ts

@@ -526,10 +526,10 @@
 
         serializationObject.position = mesh.position.asArray();
 
-        if (mesh.rotation) {
-            serializationObject.rotation = mesh.rotation.asArray();
-        } else if (mesh.rotationQuaternion) {
+        if (mesh.rotationQuaternion) {
             serializationObject.rotationQuaternion = mesh.rotationQuaternion.asArray();
+        } else if (mesh.rotation) {
+            serializationObject.rotation = mesh.rotation.asArray();
         }
 
         serializationObject.scaling = mesh.scaling.asArray();

+ 101 - 19
Babylon/Tools/babylon.tools.js

@@ -350,6 +350,14 @@
             var width;
             var height;
 
+            var scene = camera.getScene();
+            var previousCamera = null;
+
+            if (scene.activeCamera !== camera) {
+                previousCamera = scene.activeCamera;
+                scene.activeCamera = camera;
+            }
+
             //If a precision value is specified
             if (size.precision) {
                 width = Math.round(engine.getRenderWidth() * size.precision);
@@ -419,7 +427,7 @@
                     a.href = base64Image;
                     var date = new Date();
                     var stringDate = date.getFullYear() + "/" + date.getMonth() + "/" + date.getDate() + "-" + date.getHours() + ":" + date.getMinutes();
-                    a.setAttribute("download", "screenshot-" + stringDate);
+                    a.setAttribute("download", "screenshot-" + stringDate + ".png");
 
                     window.document.body.appendChild(a);
 
@@ -436,10 +444,55 @@
                 }
             };
 
-            texture.render();
+            texture.render(true);
             texture.dispose();
+
+            if (previousCamera) {
+                scene.activeCamera = previousCamera;
+            }
         };
 
+        Object.defineProperty(Tools, "NoneLogLevel", {
+            get: function () {
+                return Tools._NoneLogLevel;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Tools, "MessageLogLevel", {
+            get: function () {
+                return Tools._MessageLogLevel;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Tools, "WarningLogLevel", {
+            get: function () {
+                return Tools._WarningLogLevel;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Tools, "ErrorLogLevel", {
+            get: function () {
+                return Tools._ErrorLogLevel;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Tools, "AllLogLevel", {
+            get: function () {
+                return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;
+                ;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         Tools._FormatMessage = function (message) {
             var padStr = function (i) {
                 return (i < 10) ? "0" + i : "" + i;
@@ -449,33 +502,62 @@
             return "BJS - [" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
         };
 
-        Tools.Log = function (message) {
-            if (Tools.CurrentLogLevel > Tools.MessageLogLevel) {
-                return;
-            }
+        Tools._LogDisabled = function (message) {
+            // nothing to do
+        };
+        Tools._LogEnabled = function (message) {
             console.log(Tools._FormatMessage(message));
         };
 
-        Tools.Warn = function (message) {
-            if (Tools.CurrentLogLevel > Tools.WarningLogLevel) {
-                return;
-            }
+        Tools._WarnDisabled = function (message) {
+            // nothing to do
+        };
+        Tools._WarnEnabled = function (message) {
             console.warn(Tools._FormatMessage(message));
         };
 
-        Tools.Error = function (message) {
-            if (Tools.CurrentLogLevel > Tools.ErrorLogLevel) {
-                return;
-            }
+        Tools._ErrorDisabled = function (message) {
+            // nothing to do
+        };
+        Tools._ErrorEnabled = function (message) {
             console.error(Tools._FormatMessage(message));
         };
+
+        Object.defineProperty(Tools, "LogLevels", {
+            set: function (level) {
+                if ((level & Tools.MessageLogLevel) === Tools.MessageLogLevel) {
+                    Tools.Log = Tools._LogEnabled;
+                } else {
+                    Tools.Log = Tools._LogDisabled;
+                }
+
+                if ((level & Tools.WarningLogLevel) === Tools.WarningLogLevel) {
+                    Tools.Warn = Tools._WarnEnabled;
+                } else {
+                    Tools.Warn = Tools._WarnDisabled;
+                }
+
+                if ((level & Tools.ErrorLogLevel) === Tools.ErrorLogLevel) {
+                    Tools.Error = Tools._ErrorEnabled;
+                } else {
+                    Tools.Error = Tools._ErrorDisabled;
+                }
+            },
+            enumerable: true,
+            configurable: true
+        });
         Tools.BaseUrl = "";
 
-        Tools.MessageLogLevel = 0;
-        Tools.WarningLogLevel = 1;
-        Tools.ErrorLogLevel = 2;
-        Tools.NoneLogLevel = 3;
-        Tools.CurrentLogLevel = Tools.MessageLogLevel;
+        Tools._NoneLogLevel = 0;
+        Tools._MessageLogLevel = 1;
+        Tools._WarningLogLevel = 2;
+        Tools._ErrorLogLevel = 4;
+
+        Tools.Log = Tools._LogEnabled;
+
+        Tools.Warn = Tools._WarnEnabled;
+
+        Tools.Error = Tools._ErrorEnabled;
         return Tools;
     })();
     BABYLON.Tools = Tools;

+ 80 - 20
Babylon/Tools/babylon.tools.ts

@@ -371,6 +371,14 @@
             var width: number;
             var height: number;
 
+            var scene = camera.getScene();
+            var previousCamera: BABYLON.Camera = null;
+
+            if (scene.activeCamera !== camera) {
+                previousCamera = scene.activeCamera;
+                scene.activeCamera = camera;
+            }
+
             //If a precision value is specified
             if (size.precision) {
                 width = Math.round(engine.getRenderWidth() * size.precision);
@@ -450,7 +458,7 @@
                     a.href = base64Image;
                     var date = new Date();
                     var stringDate = date.getFullYear() + "/" + date.getMonth() + "/" + date.getDate() + "-" + date.getHours() + ":" + date.getMinutes();
-                    a.setAttribute("download", "screenshot-" + stringDate);
+                    a.setAttribute("download", "screenshot-" + stringDate + ".png");
 
                     window.document.body.appendChild(a);
 
@@ -469,43 +477,95 @@
 
             };
 
-            texture.render();
+            texture.render(true);
             texture.dispose();
+
+            if (previousCamera) {
+                scene.activeCamera = previousCamera;
+            }
         }
 
         // Logs
-        public static MessageLogLevel = 0;
-        public static WarningLogLevel = 1;
-        public static ErrorLogLevel = 2;
-        public static NoneLogLevel = 3;
-        public static CurrentLogLevel = Tools.MessageLogLevel;
+        private static _NoneLogLevel = 0;
+        private static _MessageLogLevel = 1;
+        private static _WarningLogLevel = 2;
+        private static _ErrorLogLevel = 4;
+
+        static get NoneLogLevel(): number {
+            return Tools._NoneLogLevel;
+        }
+
+        static get MessageLogLevel(): number {
+            return Tools._MessageLogLevel;
+        }
+
+        static get WarningLogLevel(): number {
+            return Tools._WarningLogLevel;
+        }
+
+        static get ErrorLogLevel(): number {
+            return Tools._ErrorLogLevel;
+        }
+
+        static get AllLogLevel(): number {
+            return Tools._MessageLogLevel | Tools._WarningLogLevel | Tools._ErrorLogLevel;;
+        }
 
         private static _FormatMessage(message: string): string {
             var padStr = i => (i < 10) ? "0" + i : "" + i;
 
             var date = new Date();
-            return "BJS - [" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) +  ":" + padStr(date.getSeconds()) + "]: " + message;
+            return "BJS - [" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
         }
 
-        public static Log(message: string): void {
-            if (Tools.CurrentLogLevel > Tools.MessageLogLevel) {
-                return;
-            }
+        public static Log: (message: string) => void = Tools._LogEnabled;
+
+        private static _LogDisabled(message: string): void {
+            // nothing to do
+        }
+        private static _LogEnabled(message: string): void {
             console.log(Tools._FormatMessage(message));
         }
 
-        public static Warn(message: string): void {
-            if (Tools.CurrentLogLevel > Tools.WarningLogLevel) {
-                return;
-            }
+        public static Warn: (message: string) => void = Tools._WarnEnabled;
+
+        private static _WarnDisabled(message: string): void {
+            // nothing to do
+        }
+        private static _WarnEnabled(message: string): void {
             console.warn(Tools._FormatMessage(message));
         }
 
-        public static Error(message: string): void {
-            if (Tools.CurrentLogLevel > Tools.ErrorLogLevel) {
-                return;
-            }
+        public static Error: (message: string) => void = Tools._ErrorEnabled;
+
+        private static _ErrorDisabled(message: string): void {
+            // nothing to do
+        }
+        private static _ErrorEnabled(message: string): void {
             console.error(Tools._FormatMessage(message));
         }
+
+        public static set LogLevels(level: number) {
+            if ((level & Tools.MessageLogLevel) === Tools.MessageLogLevel) {
+                Tools.Log = Tools._LogEnabled;
+            }
+            else {
+                Tools.Log = Tools._LogDisabled;
+            }
+
+            if ((level & Tools.WarningLogLevel) === Tools.WarningLogLevel) {
+                Tools.Warn = Tools._WarnEnabled;
+            }
+            else {
+                Tools.Warn = Tools._WarnDisabled;
+            }
+
+            if ((level & Tools.ErrorLogLevel) === Tools.ErrorLogLevel) {
+                Tools.Error = Tools._ErrorEnabled;
+            }
+            else {
+                Tools.Error = Tools._ErrorDisabled;
+            }
+        }
     }
 } 

+ 64 - 9
Babylon/babylon.engine.js

@@ -195,6 +195,62 @@
             document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
             document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
         }
+        Object.defineProperty(Engine, "ALPHA_DISABLE", {
+            get: function () {
+                return Engine._ALPHA_DISABLE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "ALPHA_ADD", {
+            get: function () {
+                return Engine._ALPHA_ADD;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "ALPHA_COMBINE", {
+            get: function () {
+                return Engine._ALPHA_COMBINE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "DELAYLOADSTATE_NONE", {
+            get: function () {
+                return Engine._DELAYLOADSTATE_NONE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "DELAYLOADSTATE_LOADED", {
+            get: function () {
+                return Engine._DELAYLOADSTATE_LOADED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "DELAYLOADSTATE_LOADING", {
+            get: function () {
+                return Engine._DELAYLOADSTATE_LOADING;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
+        Object.defineProperty(Engine, "DELAYLOADSTATE_NOTLOADED", {
+            get: function () {
+                return Engine._DELAYLOADSTATE_NOTLOADED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+
         Engine.prototype.getAspectRatio = function (camera) {
             var viewport = camera.viewport;
             return (this.getRenderWidth() * viewport.width) / (this.getRenderHeight() * viewport.height);
@@ -1183,19 +1239,18 @@
                 return false;
             }
         };
-        Engine.ShadersRepository = "Babylon/Shaders/";
+        Engine._ALPHA_DISABLE = 0;
+        Engine._ALPHA_ADD = 1;
+        Engine._ALPHA_COMBINE = 2;
 
-        Engine.ALPHA_DISABLE = 0;
-        Engine.ALPHA_ADD = 1;
-        Engine.ALPHA_COMBINE = 2;
-
-        Engine.DELAYLOADSTATE_NONE = 0;
-        Engine.DELAYLOADSTATE_LOADED = 1;
-        Engine.DELAYLOADSTATE_LOADING = 2;
-        Engine.DELAYLOADSTATE_NOTLOADED = 4;
+        Engine._DELAYLOADSTATE_NONE = 0;
+        Engine._DELAYLOADSTATE_LOADED = 1;
+        Engine._DELAYLOADSTATE_LOADING = 2;
+        Engine._DELAYLOADSTATE_NOTLOADED = 4;
 
         Engine.Epsilon = 0.001;
         Engine.CollisionsEpsilon = 0.001;
+        Engine.ShadersRepository = "Babylon/Shaders/";
         return Engine;
     })();
     BABYLON.Engine = Engine;

+ 38 - 9
Babylon/babylon.engine.ts

@@ -95,20 +95,49 @@
     }
 
     export class Engine {
-        // Statics
-        public static ShadersRepository = "Babylon/Shaders/";
+        // Const statics
+        private static _ALPHA_DISABLE = 0;
+        private static _ALPHA_ADD = 1;
+        private static _ALPHA_COMBINE = 2;
 
-        public static ALPHA_DISABLE = 0;
-        public static ALPHA_ADD = 1;
-        public static ALPHA_COMBINE = 2;
+        private static _DELAYLOADSTATE_NONE = 0;
+        private static _DELAYLOADSTATE_LOADED = 1;
+        private static _DELAYLOADSTATE_LOADING = 2;
+        private static _DELAYLOADSTATE_NOTLOADED = 4;
 
-        public static DELAYLOADSTATE_NONE = 0;
-        public static DELAYLOADSTATE_LOADED = 1;
-        public static DELAYLOADSTATE_LOADING = 2;
-        public static DELAYLOADSTATE_NOTLOADED = 4;
+        public static get ALPHA_DISABLE(): number {
+            return Engine._ALPHA_DISABLE;
+        }
+
+        public static get ALPHA_ADD(): number {
+            return Engine._ALPHA_ADD;
+        }
+
+        public static get ALPHA_COMBINE(): number {
+            return Engine._ALPHA_COMBINE;
+        }
+
+        public static get DELAYLOADSTATE_NONE(): number {
+            return Engine._DELAYLOADSTATE_NONE;
+        }
 
+        public static get DELAYLOADSTATE_LOADED(): number {
+            return Engine._DELAYLOADSTATE_LOADED;
+        }
+
+        public static get DELAYLOADSTATE_LOADING(): number {
+            return Engine._DELAYLOADSTATE_LOADING;
+        }
+
+        public static get DELAYLOADSTATE_NOTLOADED(): number {
+            return Engine._DELAYLOADSTATE_NOTLOADED;
+        }
+
+        // Updatable statics so stick with vars here
         public static Epsilon = 0.001;
         public static CollisionsEpsilon = 0.001;
+        public static ShadersRepository = "Babylon/Shaders/";
+
 
         // Public members
         public isFullscreen = false;

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 12 - 12
babylon.1.12-beta.js