فهرست منبع

Other fix for Promise polyfill
Fix #3949

David Catuhe 7 سال پیش
والد
کامیت
5c9aafac25

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 11684 - 11684
Playground/babylon.d.txt


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 13037 - 13037
dist/preview release/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 3
dist/preview release/babylon.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 4
dist/preview release/babylon.max.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 3
dist/preview release/babylon.worker.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 7431 - 7431
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 2 - 2
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 2 - 3
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -9663,6 +9663,7 @@ var BABYLON;
                         // Transmit children
                         var returnedPromise = returnedValue;
                         returnedPromise._moveChildren(this._children);
+                        value = returnedPromise._result;
                     }
                     else {
                         value = returnedValue;
@@ -9676,12 +9677,10 @@ var BABYLON;
                 this._children.length = 0;
                 delete this._onFulfilled;
                 delete this._onRejected;
-                return returnedValue;
             }
             catch (e) {
                 this._reject(e, true);
             }
-            return null;
         };
         InternalPromise.prototype._reject = function (reason, onLocalThrow) {
             if (onLocalThrow === void 0) { onLocalThrow = false; }
@@ -52958,7 +52957,7 @@ var BABYLON;
             // Better distribution in a cone at normal angles.
             h = 1 - h * h;
             var radius = BABYLON.Scalar.RandomRange(0, this._radius);
-            radius = radius * h / this._height;
+            radius = radius * h;
             var randX = radius * Math.sin(s);
             var randZ = radius * Math.cos(s);
             var randY = h * this._height;

+ 2 - 3
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js

@@ -9636,6 +9636,7 @@ var BABYLON;
                         // Transmit children
                         var returnedPromise = returnedValue;
                         returnedPromise._moveChildren(this._children);
+                        value = returnedPromise._result;
                     }
                     else {
                         value = returnedValue;
@@ -9649,12 +9650,10 @@ var BABYLON;
                 this._children.length = 0;
                 delete this._onFulfilled;
                 delete this._onRejected;
-                return returnedValue;
             }
             catch (e) {
                 this._reject(e, true);
             }
-            return null;
         };
         InternalPromise.prototype._reject = function (reason, onLocalThrow) {
             if (onLocalThrow === void 0) { onLocalThrow = false; }
@@ -52931,7 +52930,7 @@ var BABYLON;
             // Better distribution in a cone at normal angles.
             h = 1 - h * h;
             var radius = BABYLON.Scalar.RandomRange(0, this._radius);
-            radius = radius * h / this._height;
+            radius = radius * h;
             var randX = radius * Math.sin(s);
             var randZ = radius * Math.cos(s);
             var randY = h * this._height;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 4
dist/preview release/es6.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 4 - 4
dist/preview release/viewer/babylon.viewer.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 3 - 4
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 1
src/Particles/EmitterTypes/babylon.coneParticleEmitter.ts

@@ -84,7 +84,7 @@ module BABYLON {
             // Better distribution in a cone at normal angles.
             h = 1 - h * h;
             var radius = Scalar.RandomRange(0, this._radius);
-            radius = radius * h / this._height;
+            radius = radius * h;
 
             var randX = radius * Math.sin(s);
             var randZ = radius * Math.cos(s);

+ 1 - 1
src/Shaders/gpuUpdateParticles.vertex.fx

@@ -133,7 +133,7 @@ void main() {
     // Better distribution in a cone at normal angles.
     h = 1. - h * h;
     float lRadius = radius * randoms2.z;
-    lRadius = lRadius * h / height;
+    lRadius = lRadius * h;
 
     float randX = lRadius * sin(s);
     float randZ = lRadius * cos(s);

+ 2 - 5
src/Tools/babylon.promise.ts

@@ -91,7 +91,7 @@ module BABYLON {
             }
         }
 
-        private _resolve(value?: Nullable<T>): Nullable<InternalPromise<T>> | T {
+        private _resolve(value?: Nullable<T>): void {
             try {
                 this._state = PromiseStates.Fulfilled;
                 let returnedValue: Nullable<InternalPromise<T>> | T = null;
@@ -106,6 +106,7 @@ module BABYLON {
                         let returnedPromise = returnedValue as InternalPromise<T>;
 
                         returnedPromise._moveChildren(this._children);
+                        value = returnedPromise._result;
                     } else {
                         value = <T>returnedValue;
                     }
@@ -120,13 +121,9 @@ module BABYLON {
                 this._children.length = 0;
                 delete this._onFulfilled;
                 delete this._onRejected;
-
-                return returnedValue;
             } catch (e) {
                 this._reject(e, true);
             }
-
-            return null;
         }
 
         private _reject(reason: any, onLocalThrow = false): void {

+ 29 - 0
tests/unit/babylon/src/Tools/babylon.promise.tests.ts

@@ -151,6 +151,35 @@ describe('Babylon.Promise', function () {
                 }, 0);
             });
         });
+
+        it('should chain promises correctly #6', (done) => {
+            var tempString = "";
+            var promise = new Promise(function (resolve) {
+                setTimeout(function () {
+                    resolve(44);
+                }, 100);
+            });
+        
+            promise = promise.then(function () {
+                return Promise.resolve(55);
+            });
+        
+            promise.then(function (value) {
+                tempString += "1: " + value;
+                setTimeout(function () {
+                    promise.then(function (value) {
+                        tempString += " 2: " + value;
+                        try {
+                            expect(tempString).to.eq("1: 55 2: 55");
+                            done();
+                        }
+                        catch(error) {
+                            done(error);
+                        }                        
+                    });
+                }, 0);
+            });
+        });
     });
 
     describe('#Promise.all', () => {