Browse Source

Merge BabylonJS/master

Raanan Weber 9 years ago
parent
commit
6d80841525

File diff suppressed because it is too large
+ 4 - 4
dist/preview release/babylon.core.js


File diff suppressed because it is too large
+ 1500 - 1500
dist/preview release/babylon.d.ts


File diff suppressed because it is too large
+ 6 - 6
dist/preview release/babylon.js


+ 73 - 62
dist/preview release/babylon.max.js

@@ -22627,7 +22627,7 @@ var BABYLON;
             }
             return result;
         };
-        Material.prototype.dispose = function (forceDisposeEffect) {
+        Material.prototype.dispose = function (forceDisposeEffect, keepTextures) {
             // Animations
             this.getScene().stopAnimation(this);
             // Remove from scene
@@ -23423,33 +23423,35 @@ var BABYLON;
             }
             return results;
         };
-        StandardMaterial.prototype.dispose = function (forceDisposeEffect) {
-            if (this.diffuseTexture) {
-                this.diffuseTexture.dispose();
-            }
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
-            if (this.specularTexture) {
-                this.specularTexture.dispose();
-            }
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+        StandardMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                if (this.diffuseTexture) {
+                    this.diffuseTexture.dispose();
+                }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
+                if (this.specularTexture) {
+                    this.specularTexture.dispose();
+                }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
             _super.prototype.dispose.call(this, forceDisposeEffect);
         };
@@ -27528,6 +27530,11 @@ var BABYLON;
             return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
         };
         PhysicsImpostor.prototype.dispose = function () {
+            var _this = this;
+            this._joints.forEach(function (j) {
+                _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
+            });
+            //dispose the physics body
             this.physicsBody = null;
             if (this.parent) {
                 this.parent.forceUpdate();
@@ -34556,12 +34563,14 @@ var BABYLON;
             var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
             return newShaderMaterial;
         };
-        ShaderMaterial.prototype.dispose = function (forceDisposeEffect) {
-            for (var name in this._textures) {
-                this._textures[name].dispose();
+        ShaderMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                for (var name in this._textures) {
+                    this._textures[name].dispose();
+                }
             }
             this._textures = {};
-            _super.prototype.dispose.call(this, forceDisposeEffect);
+            _super.prototype.dispose.call(this, forceDisposeEffect, keepTextures);
         };
         ShaderMaterial.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this);
@@ -35059,8 +35068,8 @@ var BABYLON;
                 });
             }
         };
-        CannonJSPlugin.prototype.removeJoint = function (joint) {
-            //TODO
+        CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
+            this.world.remove(impostorJoint.joint);
         };
         CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
             var index;
@@ -45662,35 +45671,37 @@ var BABYLON;
             }
             return results;
         };
-        PBRMaterial.prototype.dispose = function (forceDisposeEffect) {
-            if (this.albedoTexture) {
-                this.albedoTexture.dispose();
-            }
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
-            if (this.reflectivityTexture) {
-                this.reflectivityTexture.dispose();
-            }
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+        PBRMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                if (this.albedoTexture) {
+                    this.albedoTexture.dispose();
+                }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
+                if (this.reflectivityTexture) {
+                    this.reflectivityTexture.dispose();
+                }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
-            _super.prototype.dispose.call(this, forceDisposeEffect);
+            _super.prototype.dispose.call(this, forceDisposeEffect, keepTextures);
         };
         PBRMaterial.prototype.clone = function (name) {
             var _this = this;

File diff suppressed because it is too large
+ 6 - 6
dist/preview release/babylon.noworker.js


+ 1 - 1
src/Materials/babylon.material.js

@@ -221,7 +221,7 @@ var BABYLON;
             }
             return result;
         };
-        Material.prototype.dispose = function (forceDisposeEffect) {
+        Material.prototype.dispose = function (forceDisposeEffect, keepTextures) {
             // Animations
             this.getScene().stopAnimation(this);
             // Remove from scene

+ 1 - 1
src/Materials/babylon.material.ts

@@ -269,7 +269,7 @@
             return result;
         }
 
-        public dispose(forceDisposeEffect?: boolean): void {
+        public dispose(forceDisposeEffect?: boolean, keepTextures?: boolean): void {
             // Animations
             this.getScene().stopAnimation(this);
 

+ 30 - 28
src/Materials/babylon.pbrMaterial.js

@@ -1004,35 +1004,37 @@ var BABYLON;
             }
             return results;
         };
-        PBRMaterial.prototype.dispose = function (forceDisposeEffect) {
-            if (this.albedoTexture) {
-                this.albedoTexture.dispose();
-            }
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
-            if (this.reflectivityTexture) {
-                this.reflectivityTexture.dispose();
-            }
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+        PBRMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                if (this.albedoTexture) {
+                    this.albedoTexture.dispose();
+                }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
+                if (this.reflectivityTexture) {
+                    this.reflectivityTexture.dispose();
+                }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
-            _super.prototype.dispose.call(this, forceDisposeEffect);
+            _super.prototype.dispose.call(this, forceDisposeEffect, keepTextures);
         };
         PBRMaterial.prototype.clone = function (name) {
             var _this = this;

+ 30 - 28
src/Materials/babylon.pbrMaterial.ts

@@ -1322,44 +1322,46 @@
             return results;
         }
 
-        public dispose(forceDisposeEffect?: boolean): void {
-            if (this.albedoTexture) {
-                this.albedoTexture.dispose();
-            }
+        public dispose(forceDisposeEffect?: boolean, keepTextures?: boolean): void {
+            if (!keepTextures) {
+                if (this.albedoTexture) {
+                    this.albedoTexture.dispose();
+                }
 
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
 
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
 
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
 
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
 
-            if (this.reflectivityTexture) {
-                this.reflectivityTexture.dispose();
-            }
+                if (this.reflectivityTexture) {
+                    this.reflectivityTexture.dispose();
+                }
 
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
 
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
 
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
 
-            super.dispose(forceDisposeEffect);
+            super.dispose(forceDisposeEffect, keepTextures);
         }
 
         public clone(name: string): PBRMaterial {

+ 6 - 4
src/Materials/babylon.shaderMaterial.js

@@ -219,12 +219,14 @@ var BABYLON;
             var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
             return newShaderMaterial;
         };
-        ShaderMaterial.prototype.dispose = function (forceDisposeEffect) {
-            for (var name in this._textures) {
-                this._textures[name].dispose();
+        ShaderMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                for (var name in this._textures) {
+                    this._textures[name].dispose();
+                }
             }
             this._textures = {};
-            _super.prototype.dispose.call(this, forceDisposeEffect);
+            _super.prototype.dispose.call(this, forceDisposeEffect, keepTextures);
         };
         ShaderMaterial.prototype.serialize = function () {
             var serializationObject = BABYLON.SerializationHelper.Serialize(this);

+ 7 - 4
src/Materials/babylon.shaderMaterial.ts

@@ -283,14 +283,17 @@
             return newShaderMaterial;
         }
 
-        public dispose(forceDisposeEffect?: boolean): void {
-            for (var name in this._textures) {
-                this._textures[name].dispose();
+        public dispose(forceDisposeEffect?: boolean, keepTextures?: boolean): void {
+
+            if (!keepTextures) {
+                for (var name in this._textures) {
+                    this._textures[name].dispose();
+                }
             }
 
             this._textures = {};
 
-            super.dispose(forceDisposeEffect);
+            super.dispose(forceDisposeEffect, keepTextures);
         }
 
         public serialize(): any {

+ 29 - 27
src/Materials/babylon.standardMaterial.js

@@ -693,33 +693,35 @@ var BABYLON;
             }
             return results;
         };
-        StandardMaterial.prototype.dispose = function (forceDisposeEffect) {
-            if (this.diffuseTexture) {
-                this.diffuseTexture.dispose();
-            }
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
-            if (this.specularTexture) {
-                this.specularTexture.dispose();
-            }
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+        StandardMaterial.prototype.dispose = function (forceDisposeEffect, keepTextures) {
+            if (!keepTextures) {
+                if (this.diffuseTexture) {
+                    this.diffuseTexture.dispose();
+                }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
+                if (this.specularTexture) {
+                    this.specularTexture.dispose();
+                }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
             _super.prototype.dispose.call(this, forceDisposeEffect);
         };

+ 29 - 27
src/Materials/babylon.standardMaterial.ts

@@ -898,41 +898,43 @@
             return results;
         }
 
-        public dispose(forceDisposeEffect?: boolean): void {
-            if (this.diffuseTexture) {
-                this.diffuseTexture.dispose();
-            }
+        public dispose(forceDisposeEffect?: boolean, keepTextures?: boolean): void {
+            if (!keepTextures) {
+                if (this.diffuseTexture) {
+                    this.diffuseTexture.dispose();
+                }
 
-            if (this.ambientTexture) {
-                this.ambientTexture.dispose();
-            }
+                if (this.ambientTexture) {
+                    this.ambientTexture.dispose();
+                }
 
-            if (this.opacityTexture) {
-                this.opacityTexture.dispose();
-            }
+                if (this.opacityTexture) {
+                    this.opacityTexture.dispose();
+                }
 
-            if (this.reflectionTexture) {
-                this.reflectionTexture.dispose();
-            }
+                if (this.reflectionTexture) {
+                    this.reflectionTexture.dispose();
+                }
 
-            if (this.emissiveTexture) {
-                this.emissiveTexture.dispose();
-            }
+                if (this.emissiveTexture) {
+                    this.emissiveTexture.dispose();
+                }
 
-            if (this.specularTexture) {
-                this.specularTexture.dispose();
-            }
+                if (this.specularTexture) {
+                    this.specularTexture.dispose();
+                }
 
-            if (this.bumpTexture) {
-                this.bumpTexture.dispose();
-            }
+                if (this.bumpTexture) {
+                    this.bumpTexture.dispose();
+                }
 
-            if (this.lightmapTexture) {
-                this.lightmapTexture.dispose();
-            }
+                if (this.lightmapTexture) {
+                    this.lightmapTexture.dispose();
+                }
 
-            if (this.refractionTexture) {
-                this.refractionTexture.dispose();
+                if (this.refractionTexture) {
+                    this.refractionTexture.dispose();
+                }
             }
 
             super.dispose(forceDisposeEffect);

+ 2 - 2
src/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -194,8 +194,8 @@ var BABYLON;
                 });
             }
         };
-        CannonJSPlugin.prototype.removeJoint = function (joint) {
-            //TODO
+        CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
+            this.world.remove(impostorJoint.joint);
         };
         CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
             var index;

+ 5 - 0
src/Physics/babylon.physicsImpostor.js

@@ -321,6 +321,11 @@ var BABYLON;
             return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
         };
         PhysicsImpostor.prototype.dispose = function () {
+            var _this = this;
+            this._joints.forEach(function (j) {
+                _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
+            });
+            //dispose the physics body
             this.physicsBody = null;
             if (this.parent) {
                 this.parent.forceUpdate();

+ 1 - 0
src/Physics/babylon.physicsImpostor.ts

@@ -433,3 +433,4 @@ module BABYLON {
         public static HeightmapImpostor = 9;
     }
 }
+