浏览代码

Added the possibility to disable fog for a specific sprite manager
Fixed a bug with pause/restart on animations

David Catuhe 10 年之前
父节点
当前提交
5d77cb87ae

+ 9 - 0
Babylon/Animations/babylon.animatable.js

@@ -45,6 +45,9 @@
         };
 
         Animatable.prototype.pause = function () {
+            if (this._paused) {
+                return;
+            }
             this._paused = true;
         };
 
@@ -66,11 +69,17 @@
 
         Animatable.prototype._animate = function (delay) {
             if (this._paused) {
+                if (!this._pausedDelay) {
+                    this._pausedDelay = delay;
+                }
                 return true;
             }
 
             if (!this._localDelayOffset) {
                 this._localDelayOffset = delay;
+            } else if (this._pausedDelay) {
+                this._localDelayOffset += delay - this._pausedDelay;
+                this._pausedDelay = null;
             }
 
             // Animating

+ 10 - 0
Babylon/Animations/babylon.animatable.ts

@@ -1,6 +1,7 @@
 module BABYLON {
     export class Animatable {
         private _localDelayOffset: number;
+        private _pausedDelay: number;
         private _animations = new Array<Animation>();
         private _paused = false;
         private _scene: Scene;
@@ -39,6 +40,9 @@
         }
 
         public pause(): void {
+            if (this._paused) {
+                return;
+            }
             this._paused = true;
         }
 
@@ -60,11 +64,17 @@
 
         public _animate(delay: number): boolean {
             if (this._paused) {
+                if (!this._pausedDelay) {
+                    this._pausedDelay = delay;
+                }
                 return true;
             }
 
             if (!this._localDelayOffset) {
                 this._localDelayOffset = delay;
+            } else if (this._pausedDelay) {
+                this._localDelayOffset += delay - this._pausedDelay;
+                this._pausedDelay = null;
             }
 
             // Animating

+ 0 - 92
Babylon/Loading/scenelLoadedr.waiting.for.database.ts

@@ -1,92 +0,0 @@
-//module BABYLON {
-
-//    export interface IFileLoader {
-//        extensions: string;
-//        importMesh(meshesNames: any, scene: Scene, data: string, rootUrl: string, meshes: Mesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]): boolean;
-//        load(scene: Scene, data: string, rootUrl: string): void;
-//    }
-
-//    export class SceneLoader {
-//        private static _registeredPlugins = new Array<IFileLoader>();
-
-//        // Methods
-//        private static _GetPluginForFilename(sceneFilename: string): IFileLoader {
-//            var dotPosition = sceneFilename.lastIndexOf(".");
-//            var extension = sceneFilename.substring(dotPosition).toLowerCase();
-
-//            for (var index = 0; index < this._registeredPlugins.length; index++) {
-//                var plugin = this._registeredPlugins[index];
-
-//                if (plugin.extensions.indexOf(extension) !== -1) {
-//                    return plugin;
-//                }
-//            }
-
-//            throw new Error("No plugin found to load this file: " + sceneFilename);
-//        }
-
-//        // Public functions
-//        public static RegisterPlugin(plugin: IFileLoader): void {
-//            plugin.extensions = plugin.extensions.toLowerCase();
-//            SceneLoader._registeredPlugins.push(plugin);
-//        }
-
-//        public static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene,
-//            onsuccess: (meshes: Mesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack: () => void, onerror: (scene: Scene) => void): void {
-//            // Checking if a manifest file has been set for this scene and if offline mode has been requested
-//            var database = new BABYLON.Database(rootUrl + sceneFilename);
-//            scene.database = database;
-
-//            var plugin = SceneLoader._GetPluginForFilename(sceneFilename);
-
-//            BABYLON.Tools.LoadFile(rootUrl + sceneFilename, data => {
-//                var meshes = [];
-//                var particleSystems = [];
-//                var skeletons = [];
-
-//                if (!plugin.importMesh(meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons)) {
-//                    if (onerror) {
-//                        onerror(scene);
-//                    }
-
-//                    return;
-//                }
-
-//                if (onsuccess) {
-//                    onsuccess(meshes, particleSystems, skeletons);
-//                }
-//            }, progressCallBack, database);
-//        }
-
-//        public static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess: (scene: Scene) => void, progressCallBack: () => void, onerror: (scene: Scene) => void): void {
-//            var plugin = SceneLoader._GetPluginForFilename(sceneFilename.name || sceneFilename);
-//            var database;
-
-//            var loadSceneFromData = data => {
-//                var scene = new BABYLON.Scene(engine);
-//                scene.database = database;
-
-//                if (!plugin.load(scene, data, rootUrl)) {
-//                    if (onerror) {
-//                        onerror(scene);
-//                    }
-
-//                    return;
-//                }
-
-//                if (onsuccess) {
-//                    onsuccess(scene);
-//                }
-//            }
-
-//            if (rootUrl.indexOf("file:") === -1) {
-//                // Checking if a manifest file has been set for this scene and if offline mode has been requested
-//                database = new BABYLON.Database(rootUrl + sceneFilename);
-
-//                BABYLON.Tools.LoadFile(rootUrl + sceneFilename, loadSceneFromData, progressCallBack, database);
-//            } else { // Loading file from disk via input file or drag'n'drop
-//                BABYLON.Tools.ReadFile(sceneFilename, loadSceneFromData, progressCallBack);
-//            }
-//        }
-//    }
-//}

+ 3 - 2
Babylon/Sprites/babylon.spriteManager.js

@@ -6,6 +6,7 @@
             this.cellSize = cellSize;
             this.sprites = new Array();
             this.renderingGroupId = 0;
+            this.fogEnabled = true;
             this._vertexDeclaration = [3, 4, 4, 4];
             this._vertexStrideSize = 15 * 4;
             this._capacity = capacity;
@@ -107,7 +108,7 @@
             // Render
             var effect = this._effectBase;
 
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect = this._effectFog;
             }
 
@@ -121,7 +122,7 @@
             effect.setFloat2("textureInfos", this.cellSize / baseSize.width, this.cellSize / baseSize.height);
 
             // Fog
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
                 effect.setColor3("vFogColor", this._scene.fogColor);
             }

+ 3 - 2
Babylon/Sprites/babylon.spriteManager.ts

@@ -3,6 +3,7 @@
         public sprites = new Array<Sprite>();
         public renderingGroupId = 0;
         public onDispose: () => void;
+        public fogEnabled = true;
 
         private _capacity: number;
         private _spriteTexture: Texture;
@@ -124,7 +125,7 @@
             // Render
             var effect = this._effectBase;
 
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect = this._effectFog;
             }
 
@@ -138,7 +139,7 @@
             effect.setFloat2("textureInfos", this.cellSize / baseSize.width, this.cellSize / baseSize.height);
 
             // Fog
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
                 effect.setColor3("vFogColor", this._scene.fogColor);
             }

+ 12 - 2
babylon.2.0-alpha.debug.js

@@ -14995,6 +14995,7 @@ var BABYLON;
             this.cellSize = cellSize;
             this.sprites = new Array();
             this.renderingGroupId = 0;
+            this.fogEnabled = true;
             this._vertexDeclaration = [3, 4, 4, 4];
             this._vertexStrideSize = 15 * 4;
             this._capacity = capacity;
@@ -15096,7 +15097,7 @@ var BABYLON;
            
             var effect = this._effectBase;
 
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect = this._effectFog;
             }
 
@@ -15110,7 +15111,7 @@ var BABYLON;
             effect.setFloat2("textureInfos", this.cellSize / baseSize.width, this.cellSize / baseSize.height);
 
            
-            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE) {
+            if (this._scene.fogMode !== BABYLON.Scene.FOGMODE_NONE && this.fogEnabled) {
                 effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
                 effect.setColor3("vFogColor", this._scene.fogColor);
             }
@@ -16140,6 +16141,9 @@ var BABYLON;
         };
 
         Animatable.prototype.pause = function () {
+            if (this._paused) {
+                return;
+            }
             this._paused = true;
         };
 
@@ -16161,11 +16165,17 @@ var BABYLON;
 
         Animatable.prototype._animate = function (delay) {
             if (this._paused) {
+                if (!this._pausedDelay) {
+                    this._pausedDelay = delay;
+                }
                 return true;
             }
 
             if (!this._localDelayOffset) {
                 this._localDelayOffset = delay;
+            } else if (this._pausedDelay) {
+                this._localDelayOffset += delay - this._pausedDelay;
+                this._pausedDelay = null;
             }
 
            

文件差异内容过多而无法显示
+ 8 - 8
babylon.2.0-alpha.js


+ 2 - 0
babylon.2.0.d.ts

@@ -708,6 +708,7 @@ declare module BABYLON {
         public speedRatio: number;
         public onAnimationEnd: any;
         private _localDelayOffset;
+        private _pausedDelay;
         private _animations;
         private _paused;
         private _scene;
@@ -3307,6 +3308,7 @@ declare module BABYLON {
         public sprites: Sprite[];
         public renderingGroupId: number;
         public onDispose: () => void;
+        public fogEnabled: boolean;
         private _capacity;
         private _spriteTexture;
         private _epsilon;