Borut преди 7 години
родител
ревизия
08c45229f8
променени са 2 файла, в които са добавени 6379 реда и са изтрити 6375 реда
  1. 6361 6364
      dist/preview release/babylon.d.ts
  2. 18 11
      src/Physics/babylon.physicsHelper.ts

Файловите разлики са ограничени, защото са твърде много
+ 6361 - 6364
dist/preview release/babylon.d.ts


+ 18 - 11
src/Physics/babylon.physicsHelper.ts

@@ -18,7 +18,7 @@ module BABYLON {
             this._physicsEngine = this._scene.getPhysicsEngine();
             this._physicsEngine = this._scene.getPhysicsEngine();
             
             
             if (!this._physicsEngine) {
             if (!this._physicsEngine) {
-                Tools.Warn('Physics engine not enabled. Please enable the physics before you call this method.');
+                Tools.Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
             }
             }
         }
         }
         
         
@@ -140,7 +140,7 @@ module BABYLON {
                 return null;
                 return null;
             }
             }
 
 
-            return new PhysicsGravitationalFieldEvent(
+            var event = new PhysicsGravitationalFieldEvent(
                 this,
                 this,
                 this._scene,
                 this._scene,
                 origin,
                 origin,
@@ -148,12 +148,15 @@ module BABYLON {
                 strength,
                 strength,
                 falloff
                 falloff
             );
             );
+
+            event.cleanup(false);
+
+            return event;
         }
         }
     }
     }
 
 
-    /**
-     * All the stuff related to the radial explosion.
-     */
+    /***** Radial explosion *****/
+
     export class PhysicsRadialExplosionEvent {
     export class PhysicsRadialExplosionEvent {
         
         
         private _scene: Scene;
         private _scene: Scene;
@@ -210,9 +213,6 @@ module BABYLON {
             return { force: force, contactPoint: contactPoint };
             return { force: force, contactPoint: contactPoint };
         }
         }
 
 
-        /**
-         * Cleanup
-         */
         public cleanup(force: boolean = true) {
         public cleanup(force: boolean = true) {
             if (force) {
             if (force) {
                 this._radialSphere.dispose();
                 this._radialSphere.dispose();
@@ -221,14 +221,12 @@ module BABYLON {
                 setTimeout(function () {
                 setTimeout(function () {
                     if (!self._dataFetched) {
                     if (!self._dataFetched) {
                         self._radialSphere.dispose();
                         self._radialSphere.dispose();
-                    } else {
-                        Tools.Warn('Could not dispose unused objects. Please call "myRadialExplosionEvent.cleanup()" manually after you do not need the data anymore.');
                     }
                     }
                 }, 0);
                 }, 0);
             }
             }
         }
         }
 
 
-        /***** Helpers *****/
+        /*** Helpers ***/
 
 
         private _prepareRadialSphere() {
         private _prepareRadialSphere() {
             if (!this._radialSphere) {
             if (!this._radialSphere) {
@@ -265,6 +263,9 @@ module BABYLON {
         rays: Array<Ray>;
         rays: Array<Ray>;
     }
     }
 
 
+
+    /***** Gravitational Field *****/
+
     export class PhysicsGravitationalFieldEvent {
     export class PhysicsGravitationalFieldEvent {
 
 
         private _physicsHelper: PhysicsHelper;
         private _physicsHelper: PhysicsHelper;
@@ -314,6 +315,12 @@ module BABYLON {
             this._scene.unregisterBeforeRender(this._tickCallback);
             this._scene.unregisterBeforeRender(this._tickCallback);
         }
         }
 
 
+        public cleanup(force: boolean = true) {
+            if (this._radialExplosionEvent) {
+                this._radialExplosionEvent.cleanup();
+            }
+        }
+
         private _tick() {
         private _tick() {
             // Since the params won't change, we fetch the event only once
             // Since the params won't change, we fetch the event only once
             if (this._radialExplosionEvent) {
             if (this._radialExplosionEvent) {