瀏覽代碼

Fixed scene.onDispose() issue

David Catuhe 9 年之前
父節點
當前提交
9d316832d1

文件差異過大導致無法顯示
+ 3 - 3
dist/preview release/babylon.core.js


文件差異過大導致無法顯示
+ 1029 - 1030
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 3 - 3
dist/preview release/babylon.js


+ 1 - 10
dist/preview release/babylon.max.js

@@ -16100,9 +16100,7 @@ var BABYLON;
             // Debug layer
             // Debug layer
             this.debugLayer.hide();
             this.debugLayer.hide();
             // Events
             // Events
-            if (this.onDispose) {
-                this.onDispose();
-            }
+            this.onDisposeObservable.notifyObservers(this);
             this.onBeforeRenderObservable.clear();
             this.onBeforeRenderObservable.clear();
             this.onAfterRenderObservable.clear();
             this.onAfterRenderObservable.clear();
             this.detachControl();
             this.detachControl();
@@ -32522,13 +32520,6 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
-        Object.defineProperty(LinesMesh.prototype, "isPickable", {
-            get: function () {
-                return true;
-            },
-            enumerable: true,
-            configurable: true
-        });
         Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
         Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
             get: function () {
             get: function () {
                 return false;
                 return false;

文件差異過大導致無法顯示
+ 3 - 3
dist/preview release/babylon.noworker.js


+ 1 - 1
src/Loading/babylon.sceneLoader.js

@@ -74,7 +74,7 @@ var BABYLON;
                     return plugin;
                     return plugin;
                 }
                 }
             }
             }
-            return this._registeredPlugins[this._registeredPlugins.length - 1];
+            return this._registeredPlugins[0];
         };
         };
         // Public functions
         // Public functions
         SceneLoader.GetPluginForExtension = function (extension) {
         SceneLoader.GetPluginForExtension = function (extension) {

+ 27 - 28
src/Materials/Textures/babylon.hdrcubetexture.ts

@@ -60,17 +60,17 @@ module BABYLON {
          */
          */
         constructor(url: string, scene: Scene, size?: number, noMipmap = false, generateHarmonics = true, useInGammaSpace = false, usePMREMGenerator = false) {
         constructor(url: string, scene: Scene, size?: number, noMipmap = false, generateHarmonics = true, useInGammaSpace = false, usePMREMGenerator = false) {
             super(scene);
             super(scene);
-            
+
             if (!url) {
             if (!url) {
                 return;
                 return;
             }
             }
-            
+
             this.name = url;
             this.name = url;
             this.url = url;
             this.url = url;
             this.hasAlpha = false;
             this.hasAlpha = false;
             this.isCube = true;
             this.isCube = true;
             this._textureMatrix = Matrix.Identity();
             this._textureMatrix = Matrix.Identity();
-            
+
             if (size) {
             if (size) {
                 this._isBABYLONPreprocessed = false;
                 this._isBABYLONPreprocessed = false;
                 this._noMipmap = noMipmap;
                 this._noMipmap = noMipmap;
@@ -85,9 +85,9 @@ module BABYLON {
                 this._usePMREMGenerator = scene.getEngine().getCaps().textureLOD;
                 this._usePMREMGenerator = scene.getEngine().getCaps().textureLOD;
             }
             }
             this.isPMREM = this._usePMREMGenerator;
             this.isPMREM = this._usePMREMGenerator;
-            
+
             this._texture = this._getFromCache(url, this._noMipmap);
             this._texture = this._getFromCache(url, this._noMipmap);
-            
+
             if (!this._texture) {
             if (!this._texture) {
                 if (!scene.useDelayedTextureLoading) {
                 if (!scene.useDelayedTextureLoading) {
                     this.loadTexture();
                     this.loadTexture();
@@ -96,15 +96,15 @@ module BABYLON {
                 }
                 }
             }
             }
         }
         }
-        
+
         /**
         /**
          * Occurs when the file is a preprocessed .babylon.hdr file.
          * Occurs when the file is a preprocessed .babylon.hdr file.
          */
          */
         private loadBabylonTexture() {
         private loadBabylonTexture() {
-            
+
             var mipLevels = 0;
             var mipLevels = 0;
             var floatArrayView: Float32Array = null;
             var floatArrayView: Float32Array = null;
-            
+
             var mipmapGenerator = (data: ArrayBufferView[]) => {
             var mipmapGenerator = (data: ArrayBufferView[]) => {
                 var mips = [];
                 var mips = [];
                 var startIndex = 30;
                 var startIndex = 30;
@@ -113,29 +113,29 @@ module BABYLON {
                     // Fill each pixel of the mip level.
                     // Fill each pixel of the mip level.
                     var faceSize = Math.pow(this._size >> level, 2) * 3;
                     var faceSize = Math.pow(this._size >> level, 2) * 3;
                     for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
                     for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
-                        
+
                         var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
                         var faceData = floatArrayView.subarray(startIndex, startIndex + faceSize);
                         mips[level].push(faceData);
                         mips[level].push(faceData);
-                        
+
                         startIndex += faceSize;
                         startIndex += faceSize;
-                    } 
+                    }
                 }
                 }
 
 
                 return mips;
                 return mips;
             };
             };
-            
+
             var callback = (buffer: ArrayBuffer) => {
             var callback = (buffer: ArrayBuffer) => {
                 // Create Native Array Views
                 // Create Native Array Views
                 var intArrayView = new Int32Array(buffer);
                 var intArrayView = new Int32Array(buffer);
                 floatArrayView = new Float32Array(buffer);
                 floatArrayView = new Float32Array(buffer);
-                
+
                 // Fill header.
                 // Fill header.
                 var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
                 var version = intArrayView[0]; // Version 1. (MAy be use in case of format changes for backward compaibility)
                 this._size = intArrayView[1]; // CubeMap max mip face size.
                 this._size = intArrayView[1]; // CubeMap max mip face size.
-                
+
                 // Update Texture Information.
                 // Update Texture Information.
                 this.getScene().getEngine().updateTextureSize(this._texture, this._size, this._size);
                 this.getScene().getEngine().updateTextureSize(this._texture, this._size, this._size);
-                
+
                 // Fill polynomial information.
                 // Fill polynomial information.
                 this.sphericalPolynomial = new SphericalPolynomial();
                 this.sphericalPolynomial = new SphericalPolynomial();
                 this.sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
                 this.sphericalPolynomial.x.copyFromFloats(floatArrayView[2], floatArrayView[3], floatArrayView[4]);
@@ -156,7 +156,7 @@ module BABYLON {
                 for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
                 for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
                     data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
                     data.push(floatArrayView.subarray(startIndex, startIndex + faceSize));
                 }
                 }
-                
+
                 var results = [];
                 var results = [];
                 var byteArray: Uint8Array = null;
                 var byteArray: Uint8Array = null;
 
 
@@ -200,13 +200,13 @@ module BABYLON {
 
 
                     results.push(dataFace);
                     results.push(dataFace);
                 }
                 }
-                
+
                 return results;
                 return results;
             }
             }
 
 
             this._texture = (<any>this.getScene().getEngine()).createRawCubeTexture(this.url, this.getScene(), this._size, Engine.TEXTUREFORMAT_RGB, Engine.TEXTURETYPE_FLOAT, this._noMipmap, callback, mipmapGenerator);
             this._texture = (<any>this.getScene().getEngine()).createRawCubeTexture(this.url, this.getScene(), this._size, Engine.TEXTUREFORMAT_RGB, Engine.TEXTURETYPE_FLOAT, this._noMipmap, callback, mipmapGenerator);
         }
         }
-        
+
         /**
         /**
          * Occurs when the file is raw .hdr file.
          * Occurs when the file is raw .hdr file.
          */
          */
@@ -286,7 +286,7 @@ module BABYLON {
 
 
             this._texture = (<any>this.getScene().getEngine()).createRawCubeTexture(this.url, this.getScene(), this._size, Engine.TEXTUREFORMAT_RGB, Engine.TEXTURETYPE_FLOAT, this._noMipmap, callback, mipmapGenerator);
             this._texture = (<any>this.getScene().getEngine()).createRawCubeTexture(this.url, this.getScene(), this._size, Engine.TEXTUREFORMAT_RGB, Engine.TEXTURETYPE_FLOAT, this._noMipmap, callback, mipmapGenerator);
         }
         }
-        
+
         /**
         /**
          * Starts the loading process of the texture.
          * Starts the loading process of the texture.
          */
          */
@@ -381,7 +381,7 @@ module BABYLON {
 
 
                 // Returns a URL you can use as a href.
                 // Returns a URL you can use as a href.
                 var objUrl = window.URL.createObjectURL(data);
                 var objUrl = window.URL.createObjectURL(data);
-                
+
                 // Simulates a link to it and click to dowload.
                 // Simulates a link to it and click to dowload.
                 var a = document.createElement("a");
                 var a = document.createElement("a");
                 document.body.appendChild(a);
                 document.body.appendChild(a);
@@ -390,10 +390,10 @@ module BABYLON {
                 (<any>a).download = "envmap.babylon.hdr";
                 (<any>a).download = "envmap.babylon.hdr";
                 a.click();
                 a.click();
             };
             };
-            
+
             HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
             HDRCubeTexture.generateBabylonHDR(url, size, callback, onError);
         }
         }
-        
+
         /**
         /**
          * Serializes the data contained in the texture in a binary format.
          * Serializes the data contained in the texture in a binary format.
          * This can be used to prevent the long loading tie associated with creating the seamless texture as well
          * This can be used to prevent the long loading tie associated with creating the seamless texture as well
@@ -460,11 +460,11 @@ module BABYLON {
                 var buffer = new ArrayBuffer(byteLength);
                 var buffer = new ArrayBuffer(byteLength);
                 var intArrayView = new Int32Array(buffer);
                 var intArrayView = new Int32Array(buffer);
                 var floatArrayView = new Float32Array(buffer);
                 var floatArrayView = new Float32Array(buffer);
-                
+
                 // Fill header.
                 // Fill header.
                 intArrayView[0] = 1; // Version 1.
                 intArrayView[0] = 1; // Version 1.
                 intArrayView[1] = size; // CubeMap max mip face size.
                 intArrayView[1] = size; // CubeMap max mip face size.
-                
+
                 // Fill polynomial information.
                 // Fill polynomial information.
                 sphericalPolynomial.x.toArray(floatArrayView, 2);
                 sphericalPolynomial.x.toArray(floatArrayView, 2);
                 sphericalPolynomial.y.toArray(floatArrayView, 5);
                 sphericalPolynomial.y.toArray(floatArrayView, 5);
@@ -485,13 +485,13 @@ module BABYLON {
                     for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
                     for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
                         floatArrayView.set(<any>mippedData[level][faceIndex], startIndex);
                         floatArrayView.set(<any>mippedData[level][faceIndex], startIndex);
                         startIndex += faceSize;
                         startIndex += faceSize;
-                    } 
+                    }
                 }
                 }
-                
+
                 // Callback.
                 // Callback.
                 callback(buffer);
                 callback(buffer);
             }
             }
-            
+
             // Download and process.
             // Download and process.
             Tools.LoadFile(url, data => {
             Tools.LoadFile(url, data => {
                 getDataCallback(data);
                 getDataCallback(data);
@@ -499,4 +499,3 @@ module BABYLON {
         }
         }
     }
     }
 }
 }
-

+ 0 - 7
src/Mesh/babylon.linesMesh.js

@@ -53,13 +53,6 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
-        Object.defineProperty(LinesMesh.prototype, "isPickable", {
-            get: function () {
-                return true;
-            },
-            enumerable: true,
-            configurable: true
-        });
         Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
         Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
             get: function () {
             get: function () {
                 return false;
                 return false;

+ 0 - 4
src/Mesh/babylon.linesMesh.ts

@@ -48,10 +48,6 @@
             return this._colorShader;
             return this._colorShader;
         }
         }
 
 
-        public get isPickable(): boolean {
-            return true;
-        }
-
         public get checkCollisions(): boolean {
         public get checkCollisions(): boolean {
             return false;
             return false;
         }
         }

+ 7 - 7
src/babylon.engine.ts

@@ -470,7 +470,7 @@
             if (AudioEngine && !Engine.audioEngine) {
             if (AudioEngine && !Engine.audioEngine) {
                 Engine.audioEngine = new AudioEngine();
                 Engine.audioEngine = new AudioEngine();
             }
             }
-			
+
             //default loading screen
             //default loading screen
             this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
             this._loadingScreen = new DefaultLoadingScreen(this._renderingCanvas);
 
 
@@ -1911,12 +1911,12 @@
 
 
             return texture;
             return texture;
         }
         }
-        
+
         public updateTextureSize(texture: WebGLTexture, width: number, height: number) {
         public updateTextureSize(texture: WebGLTexture, width: number, height: number) {
             texture._width = width;
             texture._width = width;
             texture._height = height;
             texture._height = height;
         }
         }
-        
+
         public createRawCubeTexture(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean,
         public createRawCubeTexture(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean,
             callback: (ArrayBuffer) => ArrayBufferView[],
             callback: (ArrayBuffer) => ArrayBufferView[],
             mipmmapGenerator: ((faces: ArrayBufferView[]) => ArrayBufferView[][])): WebGLTexture {
             mipmmapGenerator: ((faces: ArrayBufferView[]) => ArrayBufferView[][])): WebGLTexture {
@@ -1952,11 +1952,11 @@
                     gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
                     gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
                     gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
                     gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
                 ];
                 ];
-                
+
                 width = texture._width;
                 width = texture._width;
                 height = texture._height;
                 height = texture._height;
                 isPot = (Tools.IsExponentOfTwo(width) && Tools.IsExponentOfTwo(height));
                 isPot = (Tools.IsExponentOfTwo(width) && Tools.IsExponentOfTwo(height));
-            
+
                 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
                 gl.bindTexture(gl.TEXTURE_CUBE_MAP, texture);
                 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
                 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0);
 
 
@@ -1972,11 +1972,11 @@
                         arrayTemp.push(rgbeDataArrays[4]); // -Y
                         arrayTemp.push(rgbeDataArrays[4]); // -Y
                         arrayTemp.push(rgbeDataArrays[2]); // +Z
                         arrayTemp.push(rgbeDataArrays[2]); // +Z
                         arrayTemp.push(rgbeDataArrays[5]); // -Z
                         arrayTemp.push(rgbeDataArrays[5]); // -Z
-                        
+
                         var mipData = mipmmapGenerator(arrayTemp);
                         var mipData = mipmmapGenerator(arrayTemp);
                         for (var level = 0; level < mipData.length; level++) {
                         for (var level = 0; level < mipData.length; level++) {
                             var mipSize = width >> level;
                             var mipSize = width >> level;
-                            
+
                             // mipData is order in +X -X +Y -Y +Z -Z
                             // mipData is order in +X -X +Y -Y +Z -Z
                             gl.texImage2D(facesIndex[0], level, internalFormat, mipSize, mipSize, 0, internalFormat, textureType, mipData[level][0]);
                             gl.texImage2D(facesIndex[0], level, internalFormat, mipSize, mipSize, 0, internalFormat, textureType, mipData[level][0]);
                             gl.texImage2D(facesIndex[1], level, internalFormat, mipSize, mipSize, 0, internalFormat, textureType, mipData[level][2]);
                             gl.texImage2D(facesIndex[1], level, internalFormat, mipSize, mipSize, 0, internalFormat, textureType, mipData[level][2]);

+ 1 - 3
src/babylon.scene.js

@@ -1941,9 +1941,7 @@ var BABYLON;
             // Debug layer
             // Debug layer
             this.debugLayer.hide();
             this.debugLayer.hide();
             // Events
             // Events
-            if (this.onDispose) {
-                this.onDispose();
-            }
+            this.onDisposeObservable.notifyObservers(this);
             this.onBeforeRenderObservable.clear();
             this.onBeforeRenderObservable.clear();
             this.onAfterRenderObservable.clear();
             this.onAfterRenderObservable.clear();
             this.detachControl();
             this.detachControl();

+ 1 - 3
src/babylon.scene.ts

@@ -2355,9 +2355,7 @@
             this.debugLayer.hide();
             this.debugLayer.hide();
 
 
             // Events
             // Events
-            if (this.onDispose) {
-                this.onDispose();
-            }
+            this.onDisposeObservable.notifyObservers(this);
 
 
             this.onBeforeRenderObservable.clear();
             this.onBeforeRenderObservable.clear();
             this.onAfterRenderObservable.clear();
             this.onAfterRenderObservable.clear();