David Catuhe 10 سال پیش
والد
کامیت
cf6f4f3720

+ 11 - 4
Babylon/Audio/babylon.sound.js

@@ -290,11 +290,17 @@ var BABYLON;
                 this._startOffset += BABYLON.Engine.audioEngine.audioContext.currentTime - this._startTime;
             }
         };
-        Sound.prototype.setVolume = function (newVolume) {
-            this._volume = newVolume;
+        Sound.prototype.setVolume = function (newVolume, time) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
-                this._soundGain.gain.value = newVolume;
+                if (time) {
+                    this._soundGain.gain.linearRampToValueAtTime(this._volume, BABYLON.Engine.audioEngine.audioContext.currentTime);
+                    this._soundGain.gain.linearRampToValueAtTime(newVolume, time);
+                }
+                else {
+                    this._soundGain.gain.value = newVolume;
+                }
             }
+            this._volume = newVolume;
         };
         Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
             this._playbackRate = newPlaybackRate;
@@ -316,11 +322,12 @@ var BABYLON;
                     this.play();
                 }
             }
+            this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh);
             this._registerFunc = function (connectedMesh) { return _this._onRegisterAfterWorldMatrixUpdate(connectedMesh); };
             meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
         };
         Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (connectedMesh) {
-            this.setPosition(connectedMesh.position);
+            this.setPosition(connectedMesh.getBoundingInfo().boundingSphere.centerWorld);
             if (this._isDirectional && this._isPlaying) {
                 this._updateDirection();
             }

+ 9 - 3
Babylon/Audio/babylon.sound.ts

@@ -315,11 +315,17 @@
             }
         }
 
-        public setVolume(newVolume: number) {
-            this._volume = newVolume;
+        public setVolume(newVolume: number, time?: number) {
             if (Engine.audioEngine.canUseWebAudio) {
-                this._soundGain.gain.value = newVolume;
+                if (time) {
+                    this._soundGain.gain.linearRampToValueAtTime(this._volume, Engine.audioEngine.audioContext.currentTime);
+                    this._soundGain.gain.linearRampToValueAtTime(newVolume, time);
+                }
+                else {
+                    this._soundGain.gain.value = newVolume;
+                }
             }
+            this._volume = newVolume;
         }
 
         public setPlaybackRate(newPlaybackRate: number) {

+ 34 - 3
Babylon/Cameras/babylon.camera.js

@@ -26,6 +26,7 @@ var BABYLON;
             this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
             this.subCameras = [];
             this.layerMask = 0xFFFFFFFF;
+            this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
             this._computedViewMatrix = BABYLON.Matrix.Identity();
             this._projectionMatrix = new BABYLON.Matrix();
             this._postProcesses = new Array();
@@ -35,6 +36,34 @@ var BABYLON;
                 scene.activeCamera = this;
             }
         }
+        Object.defineProperty(Camera, "PERSPECTIVE_CAMERA", {
+            get: function () {
+                return Camera._PERSPECTIVE_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "ORTHOGRAPHIC_CAMERA", {
+            get: function () {
+                return Camera._ORTHOGRAPHIC_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_VERTICAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_VERTICAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_HORIZONTAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_HORIZONTAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
         //Cache
         Camera.prototype._initCache = function () {
             _super.prototype._initCache.call(this);
@@ -215,7 +244,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);
+                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
                 return this._projectionMatrix;
             }
             var halfWidth = engine.getRenderWidth() / 2.0;
@@ -232,8 +261,10 @@ var BABYLON;
             }
         };
         // Statics
-        Camera.PERSPECTIVE_CAMERA = 0;
-        Camera.ORTHOGRAPHIC_CAMERA = 1;
+        Camera._PERSPECTIVE_CAMERA = 0;
+        Camera._ORTHOGRAPHIC_CAMERA = 1;
+        Camera._FOVMODE_VERTICAL_FIXED = 0;
+        Camera._FOVMODE_HORIZONTAL_FIXED = 1;
         return Camera;
     })(BABYLON.Node);
     BABYLON.Camera = Camera;

+ 24 - 4
Babylon/Cameras/babylon.camera.ts

@@ -1,8 +1,27 @@
 module BABYLON {
     export class Camera extends Node {
         // Statics
-        public static PERSPECTIVE_CAMERA = 0;
-        public static ORTHOGRAPHIC_CAMERA = 1;
+        private static _PERSPECTIVE_CAMERA = 0;
+        private static _ORTHOGRAPHIC_CAMERA = 1;
+
+        private static _FOVMODE_VERTICAL_FIXED = 0;
+        private static _FOVMODE_HORIZONTAL_FIXED = 1;
+
+        public static get PERSPECTIVE_CAMERA(): number {
+            return Camera._PERSPECTIVE_CAMERA;
+        }
+        
+        public static get ORTHOGRAPHIC_CAMERA(): number {
+            return Camera._ORTHOGRAPHIC_CAMERA;
+        }
+
+        public static get FOVMODE_VERTICAL_FIXED(): number {
+            return Camera._FOVMODE_VERTICAL_FIXED;
+        }
+
+        public static get FOVMODE_HORIZONTAL_FIXED(): number {
+            return Camera._FOVMODE_HORIZONTAL_FIXED;
+        }
 
         // Members
         public upVector = Vector3.Up();
@@ -19,12 +38,13 @@
         public viewport = new Viewport(0, 0, 1.0, 1.0);
         public subCameras = [];
         public layerMask: number = 0xFFFFFFFF;
+        public fovMode: number = Camera.FOVMODE_VERTICAL_FIXED;
 
         private _computedViewMatrix = Matrix.Identity();
         public _projectionMatrix = new Matrix();
         private _worldMatrix: Matrix;
         public _postProcesses = new Array<PostProcess>();
-        public _postProcessesTakenIndices = [];               
+        public _postProcessesTakenIndices = [];
 
         constructor(name: string, public position: Vector3, scene: Scene) {
             super(name, scene);
@@ -291,7 +311,7 @@
                     this.minZ = 0.1;
                 }
 
-                Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix);
+                Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
                 return this._projectionMatrix;
             }
 

+ 15 - 3
Babylon/Math/babylon.math.js

@@ -1658,11 +1658,23 @@ var BABYLON;
             Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
             return matrix;
         };
-        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result) {
+        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, fovMode) {
+            if (fovMode === void 0) { fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED; }
             var tan = 1.0 / (Math.tan(fov * 0.5));
-            result.m[0] = tan / aspect;
+            var v_fixed = (fovMode === BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
+            if (v_fixed) {
+                result.m[0] = tan / aspect;
+            }
+            else {
+                result.m[0] = tan;
+            }
             result.m[1] = result.m[2] = result.m[3] = 0.0;
-            result.m[5] = tan;
+            if (v_fixed) {
+                result.m[5] = tan;
+            }
+            else {
+                result.m[5] = tan * aspect;
+            }
             result.m[4] = result.m[6] = result.m[7] = 0.0;
             result.m[8] = result.m[9] = 0.0;
             result.m[10] = -zfar / (znear - zfar);

+ 18 - 3
Babylon/Math/babylon.math.ts

@@ -2075,12 +2075,27 @@
             return matrix;
         }
 
-        public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix): void {
+        public static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, fovMode = Camera.FOVMODE_VERTICAL_FIXED): void {
             var tan = 1.0 / (Math.tan(fov * 0.5));
 
-            result.m[0] = tan / aspect;
+            var v_fixed = (fovMode === Camera.FOVMODE_VERTICAL_FIXED);
+
+            if (v_fixed) {
+                result.m[0] = tan / aspect;
+            }
+            else {
+                result.m[0] = tan;
+            }
+
             result.m[1] = result.m[2] = result.m[3] = 0.0;
-            result.m[5] = tan;
+
+            if (v_fixed) {
+                result.m[5] = tan;
+            }
+            else {
+                result.m[5] = tan * aspect;
+            }
+
             result.m[4] = result.m[6] = result.m[7] = 0.0;
             result.m[8] = result.m[9] = 0.0;
             result.m[10] = -zfar / (znear - zfar);

+ 32 - 4
Babylon/babylon.scene.js

@@ -137,6 +137,34 @@ var BABYLON;
             this._debugLayer = new BABYLON.DebugLayer(this);
             this.mainSoundTrack = new BABYLON.SoundTrack(this, { mainTrack: true });
         }
+        Object.defineProperty(Scene, "FOGMODE_NONE", {
+            get: function () {
+                return Scene._FOGMODE_NONE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_EXP", {
+            get: function () {
+                return Scene._FOGMODE_EXP;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_EXP2", {
+            get: function () {
+                return Scene._FOGMODE_EXP2;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_LINEAR", {
+            get: function () {
+                return Scene._FOGMODE_LINEAR;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Scene.prototype, "debugLayer", {
             // Properties 
             get: function () {
@@ -1476,10 +1504,10 @@ var BABYLON;
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         };
         // Statics
-        Scene.FOGMODE_NONE = 0;
-        Scene.FOGMODE_EXP = 1;
-        Scene.FOGMODE_EXP2 = 2;
-        Scene.FOGMODE_LINEAR = 3;
+        Scene._FOGMODE_NONE = 0;
+        Scene._FOGMODE_EXP = 1;
+        Scene._FOGMODE_EXP2 = 2;
+        Scene._FOGMODE_LINEAR = 3;
         Scene.MinDeltaTime = 1.0;
         Scene.MaxDeltaTime = 1000.0;
         return Scene;

+ 20 - 4
Babylon/babylon.scene.ts

@@ -9,14 +9,30 @@
      */
     export class Scene {
         // Statics
-        public static FOGMODE_NONE = 0;
-        public static FOGMODE_EXP = 1;
-        public static FOGMODE_EXP2 = 2;
-        public static FOGMODE_LINEAR = 3;
+        private static _FOGMODE_NONE = 0;
+        private static _FOGMODE_EXP = 1;
+        private static _FOGMODE_EXP2 = 2;
+        private static _FOGMODE_LINEAR = 3;
 
         public static MinDeltaTime = 1.0;
         public static MaxDeltaTime = 1000.0;
 
+        public static get FOGMODE_NONE(): number {
+            return Scene._FOGMODE_NONE;
+        }
+
+        public static get FOGMODE_EXP(): number {
+            return Scene._FOGMODE_EXP;
+        }
+
+        public static get FOGMODE_EXP2(): number {
+            return Scene._FOGMODE_EXP2;
+        }
+
+        public static get FOGMODE_LINEAR(): number {
+            return Scene._FOGMODE_LINEAR;
+        }
+
         // Members
         public autoClear = true;
         public clearColor: any = new Color3(0.2, 0.2, 0.3);

+ 92 - 14
babylon.2.0-beta.debug.js

@@ -1663,11 +1663,23 @@ var __extends = this.__extends || function (d, b) {
             Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
             return matrix;
         };
-        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result) {
+        Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, fovMode) {
+            if (fovMode === void 0) { fovMode = BABYLON.Camera.FOVMODE_VERTICAL_FIXED; }
             var tan = 1.0 / (Math.tan(fov * 0.5));
-            result.m[0] = tan / aspect;
+            var v_fixed = (fovMode === BABYLON.Camera.FOVMODE_VERTICAL_FIXED);
+            if (v_fixed) {
+                result.m[0] = tan / aspect;
+            }
+            else {
+                result.m[0] = tan;
+            }
             result.m[1] = result.m[2] = result.m[3] = 0.0;
-            result.m[5] = tan;
+            if (v_fixed) {
+                result.m[5] = tan;
+            }
+            else {
+                result.m[5] = tan * aspect;
+            }
             result.m[4] = result.m[6] = result.m[7] = 0.0;
             result.m[8] = result.m[9] = 0.0;
             result.m[10] = -zfar / (znear - zfar);
@@ -6117,6 +6129,7 @@ var BABYLON;
             this.viewport = new BABYLON.Viewport(0, 0, 1.0, 1.0);
             this.subCameras = [];
             this.layerMask = 0xFFFFFFFF;
+            this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
             this._computedViewMatrix = BABYLON.Matrix.Identity();
             this._projectionMatrix = new BABYLON.Matrix();
             this._postProcesses = new Array();
@@ -6126,6 +6139,34 @@ var BABYLON;
                 scene.activeCamera = this;
             }
         }
+        Object.defineProperty(Camera, "PERSPECTIVE_CAMERA", {
+            get: function () {
+                return Camera._PERSPECTIVE_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "ORTHOGRAPHIC_CAMERA", {
+            get: function () {
+                return Camera._ORTHOGRAPHIC_CAMERA;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_VERTICAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_VERTICAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Camera, "FOVMODE_HORIZONTAL_FIXED", {
+            get: function () {
+                return Camera._FOVMODE_HORIZONTAL_FIXED;
+            },
+            enumerable: true,
+            configurable: true
+        });
         //Cache
         Camera.prototype._initCache = function () {
             _super.prototype._initCache.call(this);
@@ -6306,7 +6347,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);
+                BABYLON.Matrix.PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode);
                 return this._projectionMatrix;
             }
             var halfWidth = engine.getRenderWidth() / 2.0;
@@ -6323,8 +6364,10 @@ var BABYLON;
             }
         };
         // Statics
-        Camera.PERSPECTIVE_CAMERA = 0;
-        Camera.ORTHOGRAPHIC_CAMERA = 1;
+        Camera._PERSPECTIVE_CAMERA = 0;
+        Camera._ORTHOGRAPHIC_CAMERA = 1;
+        Camera._FOVMODE_VERTICAL_FIXED = 0;
+        Camera._FOVMODE_HORIZONTAL_FIXED = 1;
         return Camera;
     })(BABYLON.Node);
     BABYLON.Camera = Camera;
@@ -7507,6 +7550,34 @@ var BABYLON;
             this._debugLayer = new BABYLON.DebugLayer(this);
             this.mainSoundTrack = new BABYLON.SoundTrack(this, { mainTrack: true });
         }
+        Object.defineProperty(Scene, "FOGMODE_NONE", {
+            get: function () {
+                return Scene._FOGMODE_NONE;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_EXP", {
+            get: function () {
+                return Scene._FOGMODE_EXP;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_EXP2", {
+            get: function () {
+                return Scene._FOGMODE_EXP2;
+            },
+            enumerable: true,
+            configurable: true
+        });
+        Object.defineProperty(Scene, "FOGMODE_LINEAR", {
+            get: function () {
+                return Scene._FOGMODE_LINEAR;
+            },
+            enumerable: true,
+            configurable: true
+        });
         Object.defineProperty(Scene.prototype, "debugLayer", {
             // Properties 
             get: function () {
@@ -8846,10 +8917,10 @@ var BABYLON;
             return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
         };
         // Statics
-        Scene.FOGMODE_NONE = 0;
-        Scene.FOGMODE_EXP = 1;
-        Scene.FOGMODE_EXP2 = 2;
-        Scene.FOGMODE_LINEAR = 3;
+        Scene._FOGMODE_NONE = 0;
+        Scene._FOGMODE_EXP = 1;
+        Scene._FOGMODE_EXP2 = 2;
+        Scene._FOGMODE_LINEAR = 3;
         Scene.MinDeltaTime = 1.0;
         Scene.MaxDeltaTime = 1000.0;
         return Scene;
@@ -25721,11 +25792,17 @@ var BABYLON;
                 this._startOffset += BABYLON.Engine.audioEngine.audioContext.currentTime - this._startTime;
             }
         };
-        Sound.prototype.setVolume = function (newVolume) {
-            this._volume = newVolume;
+        Sound.prototype.setVolume = function (newVolume, time) {
             if (BABYLON.Engine.audioEngine.canUseWebAudio) {
-                this._soundGain.gain.value = newVolume;
+                if (time) {
+                    this._soundGain.gain.linearRampToValueAtTime(this._volume, BABYLON.Engine.audioEngine.audioContext.currentTime);
+                    this._soundGain.gain.linearRampToValueAtTime(newVolume, time);
+                }
+                else {
+                    this._soundGain.gain.value = newVolume;
+                }
             }
+            this._volume = newVolume;
         };
         Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
             this._playbackRate = newPlaybackRate;
@@ -25747,11 +25824,12 @@ var BABYLON;
                     this.play();
                 }
             }
+            this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh);
             this._registerFunc = function (connectedMesh) { return _this._onRegisterAfterWorldMatrixUpdate(connectedMesh); };
             meshToConnectTo.registerAfterWorldMatrixUpdate(this._registerFunc);
         };
         Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (connectedMesh) {
-            this.setPosition(connectedMesh.position);
+            this.setPosition(connectedMesh.getBoundingInfo().boundingSphere.centerWorld);
             if (this._isDirectional && this._isPlaying) {
                 this._updateDirection();
             }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 11 - 11
babylon.2.0-beta.js