Explorar o código

Fixed issue with getData() callback

Borut %!s(int64=7) %!d(string=hai) anos
pai
achega
1ab1acc6cd
Modificáronse 2 ficheiros con 7440 adicións e 7444 borrados
  1. 7431 7429
      dist/preview release/babylon.d.ts
  2. 9 15
      src/Physics/babylon.physicsHelper.ts

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7431 - 7429
dist/preview release/babylon.d.ts


+ 9 - 15
src/Physics/babylon.physicsHelper.ts

@@ -276,7 +276,7 @@ module BABYLON {
         private _falloff: PhysicsRadialImpulseFallof;
         private _falloff: PhysicsRadialImpulseFallof;
         private _tickCallback: any;
         private _tickCallback: any;
         private _radialSphere: Mesh;
         private _radialSphere: Mesh;
-        private _dataRequested: boolean = false; // check if the has been requested the data. If not, do cleanup
+        private _dataFetched: boolean = false; // check if the has been fetched the data. If not, do cleanup
 
 
         constructor(
         constructor(
             physicsHelper: PhysicsHelper,
             physicsHelper: PhysicsHelper,
@@ -295,22 +295,16 @@ module BABYLON {
             this._tickCallback = this._tick.bind(this);
             this._tickCallback = this._tick.bind(this);
         }
         }
 
 
-        public getData(callback: (data: PhysicsGravitationalFieldEventData) => void) {
-            this._dataRequested = true;
-
-            var self = this;
-            // wait until the first tick has ran, so we can the the radialExplosionEvent (& it's data)
-            var interval = setInterval(function() {
-                if (self._radialSphere) {
-                    clearInterval(interval);
-                    callback({
-                        radialSphere: self._radialSphere,
-                    });
-                }
-            }, 16.66);
+        public getData() {
+            this._dataFetched = true;
+
+            return {
+                radialSphere: this._radialSphere,
+            };
         }
         }
 
 
         public enable() {
         public enable() {
+            this._tickCallback.call(this);
             this._scene.registerBeforeRender(this._tickCallback);
             this._scene.registerBeforeRender(this._tickCallback);
         }
         }
 
 
@@ -324,7 +318,7 @@ module BABYLON {
             } else {
             } else {
                 var self = this;
                 var self = this;
                 setTimeout(function () {
                 setTimeout(function () {
-                    if (!self._dataRequested) {
+                    if (!self._dataFetched) {
                         self._radialSphere.dispose();
                         self._radialSphere.dispose();
                     }
                     }
                 }, 0);
                 }, 0);