浏览代码

Merge remote-tracking branch 'refs/remotes/BabylonJS/master'

Raanan Weber 9 年之前
父节点
当前提交
732041fae3

文件差异内容过多而无法显示
+ 20 - 20
dist/preview release/babylon.core.js


文件差异内容过多而无法显示
+ 3190 - 3191
dist/preview release/babylon.d.ts


文件差异内容过多而无法显示
+ 27 - 27
dist/preview release/babylon.js


文件差异内容过多而无法显示
+ 47 - 54
dist/preview release/babylon.max.js


文件差异内容过多而无法显示
+ 26 - 26
dist/preview release/babylon.noworker.js


+ 1 - 1
src/Cameras/babylon.camera.js

@@ -333,7 +333,7 @@ var BABYLON;
                 if (this.minZ <= 0) {
                     this.minZ = 0.1;
                 }
-                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
+                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
                 return this._projectionMatrix;
             }
             var halfWidth = engine.getRenderWidth() / 2.0;

+ 1 - 1
src/Cameras/babylon.camera.ts

@@ -411,7 +411,7 @@
                     this.minZ = 0.1;
                 }
 
-                Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
+                Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
                 return this._projectionMatrix;
             }
 

+ 1 - 1
src/Debug/babylon.debugLayer.js

@@ -94,7 +94,7 @@ var BABYLON;
                     _this._drawingContext.clearRect(0, 0, _this._drawingCanvas.width, _this._drawingCanvas.height);
                     var engine = _this._scene.getEngine();
                     var viewport = _this._camera.viewport;
-                    var globalViewport = viewport.toGlobal(engine);
+                    var globalViewport = viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
                     // Meshes
                     var meshes = _this._camera.getActiveMeshes();
                     var index;

+ 1 - 1
src/Debug/babylon.debugLayer.ts

@@ -145,7 +145,7 @@
 
                     var engine = this._scene.getEngine();
                     var viewport = this._camera.viewport;
-                    var globalViewport = viewport.toGlobal(engine);
+                    var globalViewport = viewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
 
                     // Meshes
                     var meshes = this._camera.getActiveMeshes();

+ 1 - 1
src/LensFlare/babylon.lensFlareSystem.js

@@ -85,7 +85,7 @@ var BABYLON;
                 return false;
             var engine = this._scene.getEngine();
             var viewport = this._scene.activeCamera.viewport;
-            var globalViewport = viewport.toScreenGlobal(engine);
+            var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
             // Position
             if (!this.computeEffectivePosition(globalViewport)) {
                 return false;

+ 1 - 1
src/LensFlare/babylon.lensFlareSystem.ts

@@ -118,7 +118,7 @@
 
             var engine = this._scene.getEngine();
             var viewport = this._scene.activeCamera.viewport;
-            var globalViewport = viewport.toScreenGlobal(engine);
+            var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
 
             // Position
             if (!this.computeEffectivePosition(globalViewport)) {

+ 37 - 25
src/Math/babylon.math.js

@@ -11,6 +11,26 @@ var BABYLON;
             var num = a - b;
             return -epsilon <= num && num <= epsilon;
         };
+        MathTools.ToHex = function (i) {
+            var str = i.toString(16);
+            if (i <= 15) {
+                return ("0" + str).toUpperCase();
+            }
+            return str.toUpperCase();
+        };
+        // Returns -1 when value is a negative number and
+        // +1 when value is a positive number. 
+        MathTools.Sign = function (value) {
+            value = +value; // convert to a number
+            if (value === 0 || isNaN(value))
+                return value;
+            return value > 0 ? 1 : -1;
+        };
+        MathTools.Clamp = function (value, min, max) {
+            if (min === void 0) { min = 0; }
+            if (max === void 0) { max = 1; }
+            return Math.min(max, Math.max(min, value));
+        };
         return MathTools;
     })();
     BABYLON.MathTools = MathTools;
@@ -109,7 +129,7 @@ var BABYLON;
             var intR = (this.r * 255) | 0;
             var intG = (this.g * 255) | 0;
             var intB = (this.b * 255) | 0;
-            return "#" + BABYLON.Tools.ToHex(intR) + BABYLON.Tools.ToHex(intG) + BABYLON.Tools.ToHex(intB);
+            return "#" + MathTools.ToHex(intR) + MathTools.ToHex(intG) + MathTools.ToHex(intB);
         };
         Color3.prototype.toLinearSpace = function () {
             var convertedColor = new Color3();
@@ -136,7 +156,7 @@ var BABYLON;
         // Statics
         Color3.FromHexString = function (hex) {
             if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
-                BABYLON.Tools.Warn("Color3.FromHexString must be called with a string like #FFFFFF");
+                //Tools.Warn("Color3.FromHexString must be called with a string like #FFFFFF");
                 return new Color3(0, 0, 0);
             }
             var r = parseInt(hex.substring(1, 3), 16);
@@ -240,12 +260,12 @@ var BABYLON;
             var intG = (this.g * 255) | 0;
             var intB = (this.b * 255) | 0;
             var intA = (this.a * 255) | 0;
-            return "#" + BABYLON.Tools.ToHex(intR) + BABYLON.Tools.ToHex(intG) + BABYLON.Tools.ToHex(intB) + BABYLON.Tools.ToHex(intA);
+            return "#" + MathTools.ToHex(intR) + MathTools.ToHex(intG) + MathTools.ToHex(intB) + MathTools.ToHex(intA);
         };
         // Statics
         Color4.FromHexString = function (hex) {
             if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
-                BABYLON.Tools.Warn("Color4.FromHexString must be called with a string like #FFFFFFFF");
+                //Tools.Warn("Color4.FromHexString must be called with a string like #FFFFFFFF");
                 return new Color4(0, 0, 0, 0);
             }
             var r = parseInt(hex.substring(1, 3), 16);
@@ -1731,9 +1751,9 @@ var BABYLON;
             translation.x = this.m[12];
             translation.y = this.m[13];
             translation.z = this.m[14];
-            var xs = BABYLON.Tools.Sign(this.m[0] * this.m[1] * this.m[2] * this.m[3]) < 0 ? -1 : 1;
-            var ys = BABYLON.Tools.Sign(this.m[4] * this.m[5] * this.m[6] * this.m[7]) < 0 ? -1 : 1;
-            var zs = BABYLON.Tools.Sign(this.m[8] * this.m[9] * this.m[10] * this.m[11]) < 0 ? -1 : 1;
+            var xs = MathTools.Sign(this.m[0] * this.m[1] * this.m[2] * this.m[3]) < 0 ? -1 : 1;
+            var ys = MathTools.Sign(this.m[4] * this.m[5] * this.m[6] * this.m[7]) < 0 ? -1 : 1;
+            var zs = MathTools.Sign(this.m[8] * this.m[9] * this.m[10] * this.m[11]) < 0 ? -1 : 1;
             scale.x = xs * Math.sqrt(this.m[0] * this.m[0] + this.m[1] * this.m[1] + this.m[2] * this.m[2]);
             scale.y = ys * Math.sqrt(this.m[4] * this.m[4] + this.m[5] * this.m[5] + this.m[6] * this.m[6]);
             scale.z = zs * Math.sqrt(this.m[8] * this.m[8] + this.m[9] * this.m[9] + this.m[10] * this.m[10]);
@@ -2053,18 +2073,17 @@ var BABYLON;
             Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
             return matrix;
         };
-        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, fovMode) {
-            if (fovMode === void 0) { fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED; }
+        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
+            if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
             var tan = 1.0 / (Math.tan(fov * 0.5));
-            var v_fixed = (fovMode === BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
-            if (v_fixed) {
+            if (isVerticalFovFixed) {
                 result.m[0] = tan / aspect;
             }
             else {
                 result.m[0] = tan;
             }
             result.m[1] = result.m[2] = result.m[3] = 0.0;
-            if (v_fixed) {
+            if (isVerticalFovFixed) {
                 result.m[5] = tan;
             }
             else {
@@ -2255,15 +2274,8 @@ var BABYLON;
             this.width = width;
             this.height = height;
         }
-        Viewport.prototype.toGlobal = function (engine) {
-            var width = engine.getRenderWidth();
-            var height = engine.getRenderHeight();
-            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
-        };
-        Viewport.prototype.toScreenGlobal = function (engine) {
-            var width = engine.getRenderWidth(true);
-            var height = engine.getRenderHeight(true);
-            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
+        Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
+            return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
         };
         return Viewport;
     })();
@@ -2427,7 +2439,7 @@ var BABYLON;
         }
         Path2.prototype.addLineTo = function (x, y) {
             if (closed) {
-                BABYLON.Tools.Error("cannot add lines to closed paths");
+                //Tools.Error("cannot add lines to closed paths");
                 return this;
             }
             var newPoint = new Vector2(x, y);
@@ -2439,7 +2451,7 @@ var BABYLON;
         Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
             if (numberOfSegments === void 0) { numberOfSegments = 36; }
             if (closed) {
-                BABYLON.Tools.Error("cannot add arcs to closed paths");
+                //Tools.Error("cannot add arcs to closed paths");
                 return this;
             }
             var startPoint = this._points[this._points.length - 1];
@@ -2476,7 +2488,7 @@ var BABYLON;
         };
         Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
             if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
-                BABYLON.Tools.Error("normalized length position should be between 0 and 1.");
+                //Tools.Error("normalized length position should be between 0 and 1.");
                 return Vector2.Zero();
             }
             var lengthPosition = normalizedLengthPosition * this.length();
@@ -2494,7 +2506,7 @@ var BABYLON;
                 }
                 previousOffset = nextOffset;
             }
-            BABYLON.Tools.Error("internal error");
+            //Tools.Error("internal error");
             return Vector2.Zero();
         };
         Path2.StartingAt = function (x, y) {

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

@@ -12,7 +12,7 @@
             var num = a - b;
             return -epsilon <= num && num <= epsilon;
         }
-        
+
         public static ToHex(i: number): string {
             var str = i.toString(16);
 
@@ -33,7 +33,7 @@
 
             return value > 0 ? 1 : -1;
         }
-        
+
         public static Clamp(value: number, min = 0, max = 1): number {
             return Math.min(max, Math.max(min, value));
         }
@@ -2601,12 +2601,10 @@
             return matrix;
         }
 
-        public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, fovMode = Camera.FOVMODE_VERTICAL_FIXED): void {
+        public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed = true): void {
             var tan = 1.0 / (Math.tan(fov * 0.5));
-
-            var v_fixed = (fovMode === Camera.FOVMODE_VERTICAL_FIXED);
-
-            if (v_fixed) {
+            
+            if (isVerticalFovFixed) {
                 result.m[0] = tan / aspect;
             }
             else {
@@ -2615,7 +2613,7 @@
 
             result.m[1] = result.m[2] = result.m[3] = 0.0;
 
-            if (v_fixed) {
+            if (isVerticalFovFixed) {
                 result.m[5] = tan;
             }
             else {
@@ -2847,16 +2845,8 @@
         constructor(public x: number, public y: number, public width: number, public height: number) {
         }
 
-        public toGlobal(engine: Engine): Viewport {
-            var width = engine.getRenderWidth();
-            var height = engine.getRenderHeight();
-            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
-        }
-
-        public toScreenGlobal(engine: Engine): Viewport {
-            var width = engine.getRenderWidth(true);
-            var height = engine.getRenderHeight(true);
-            return new Viewport(this.x * width, this.y * height, this.width * width, this.height * height);
+        public toGlobal(renderWidth: number, renderHeight: number): Viewport {
+            return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
         }
     }
 
@@ -3488,4 +3478,4 @@
             Matrix.Zero(), Matrix.Zero(),
             Matrix.Zero(), Matrix.Zero()];                      // 6 temp Matrices at once should be enough
     }
-}
+}

+ 1 - 1
src/PostProcess/babylon.hdrRenderingPipeline.js

@@ -176,7 +176,7 @@ var BABYLON;
                         _this._hdrOutputLuminance = _this._hdrCurrentLuminance;
                     }
                 }
-                _this._hdrOutputLuminance = BABYLON.Tools.Clamp(_this._hdrOutputLuminance, _this.minimumLuminance, _this.maximumLuminance);
+                _this._hdrOutputLuminance = BABYLON.MathTools.Clamp(_this._hdrOutputLuminance, _this.minimumLuminance, _this.maximumLuminance);
                 hdrLastLuminance += scene.getEngine().getDeltaTime();
                 effect.setTextureFromPostProcess("textureSampler", _this._textureAdderPostProcess);
                 effect.setTextureFromPostProcess("otherSampler", _this._originalPostProcess);

+ 2 - 1
src/PostProcess/babylon.volumetricLightScatteringPostProcess.js

@@ -66,7 +66,8 @@ var BABYLON;
             */
             this.density = 0.926;
             scene = (camera === null) ? scene : camera.getScene(); // parameter "scene" can be null.
-            this._viewPort = new BABYLON.Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
+            var engine = scene.getEngine();
+            this._viewPort = new BABYLON.Viewport(0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
             // Configure mesh
             this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);
             // Configure

+ 2 - 1
src/PostProcess/babylon.volumetricLightScatteringPostProcess.ts

@@ -72,7 +72,8 @@
             super(name, "volumetricLightScattering", ["decay", "exposure", "weight", "meshPositionOnScreen", "density"], ["lightScatteringSampler"], ratio.postProcessRatio || ratio, camera, samplingMode, engine, reusable, "#define NUM_SAMPLES " + samples);
             scene = (camera === null) ? scene : camera.getScene(); // parameter "scene" can be null.
 
-            this._viewPort = new Viewport(0, 0, 1, 1).toGlobal(scene.getEngine());
+            var engine = scene.getEngine();
+            this._viewPort = new Viewport(0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
 
             // Configure mesh
             this.mesh = (mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene);

+ 1 - 21
src/Tools/babylon.tools.js

@@ -30,13 +30,6 @@ var BABYLON;
             }
             return fn;
         };
-        Tools.ToHex = function (i) {
-            var str = i.toString(16);
-            if (i <= 15) {
-                return ("0" + str).toUpperCase();
-            }
-            return str.toUpperCase();
-        };
         Tools.SetImmediate = function (action) {
             if (window.setImmediate) {
                 window.setImmediate(action);
@@ -342,20 +335,7 @@ var BABYLON;
             var link = url.createObjectURL(fileBlob);
             return link;
         };
-        // Misc.   
-        Tools.Clamp = function (value, min, max) {
-            if (min === void 0) { min = 0; }
-            if (max === void 0) { max = 1; }
-            return Math.min(max, Math.max(min, value));
-        };
-        // Returns -1 when value is a negative number and
-        // +1 when value is a positive number. 
-        Tools.Sign = function (value) {
-            value = +value; // convert to a number
-            if (value === 0 || isNaN(value))
-                return value;
-            return value > 0 ? 1 : -1;
-        };
+        // Misc.
         Tools.Format = function (value, decimals) {
             if (decimals === void 0) { decimals = 2; }
             return value.toFixed(decimals);

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

@@ -973,7 +973,4 @@
             }, callback);
         }
     }
-} 
-
-
-
+} 

+ 2 - 2
src/babylon.scene.js

@@ -1851,7 +1851,7 @@ var BABYLON;
                 camera = this.activeCamera;
             }
             var cameraViewport = camera.viewport;
-            var viewport = cameraViewport.toGlobal(engine);
+            var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
             // Moving coordinates to local viewport world
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
             y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
@@ -1866,7 +1866,7 @@ var BABYLON;
                 camera = this.activeCamera;
             }
             var cameraViewport = camera.viewport;
-            var viewport = cameraViewport.toGlobal(engine);
+            var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
             var identity = BABYLON.Matrix.Identity();
             // Moving coordinates to local viewport world
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;

+ 2 - 2
src/babylon.scene.ts

@@ -2315,7 +2315,7 @@
             }
 
             var cameraViewport = camera.viewport;
-            var viewport = cameraViewport.toGlobal(engine);
+            var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
 
             // Moving coordinates to local viewport world
             x = x / this._engine.getHardwareScalingLevel() - viewport.x;
@@ -2335,7 +2335,7 @@
             }
 
             var cameraViewport = camera.viewport;
-            var viewport = cameraViewport.toGlobal(engine);
+            var viewport = cameraViewport.toGlobal(engine. getRenderWidth(), engine.getRenderHeight());
             var identity = Matrix.Identity();
 
             // Moving coordinates to local viewport world