瀏覽代碼

Merge remote-tracking branch 'BabylonJS/master' into viewer-catch-errors

# Conflicts:
#	dist/preview release/viewer/babylon.viewer.js
Raanan Weber 7 年之前
父節點
當前提交
85308a43fb

文件差異過大導致無法顯示
+ 11684 - 11684
Playground/babylon.d.txt


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


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


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


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


文件差異過大導致無法顯示
+ 3995 - 3996
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


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


+ 2 - 4
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;
@@ -81241,7 +81240,6 @@ var BABYLON;
             _this._lensCenterOffset = vrMetrics.lensCenterOffset;
             _this.adaptScaleToCurrentViewport = true;
             _this.onSizeChangedObservable.add(function () {
-                _this.aspectRatio = _this.width * .5 / _this.height;
                 _this._scaleIn = new BABYLON.Vector2(2, 2 / _this.aspectRatio);
                 _this._scaleFactor = new BABYLON.Vector2(.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
                 _this._lensCenter = new BABYLON.Vector2(_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);

+ 2 - 4
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;
@@ -81214,7 +81213,6 @@ var BABYLON;
             _this._lensCenterOffset = vrMetrics.lensCenterOffset;
             _this.adaptScaleToCurrentViewport = true;
             _this.onSizeChangedObservable.add(function () {
-                _this.aspectRatio = _this.width * .5 / _this.height;
                 _this._scaleIn = new BABYLON.Vector2(2, 2 / _this.aspectRatio);
                 _this._scaleFactor = new BABYLON.Vector2(.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
                 _this._lensCenter = new BABYLON.Vector2(_this._isRightEye ? 0.5 - _this._lensCenterOffset * 0.5 : 0.5 + _this._lensCenterOffset * 0.5, 0.5);

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


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


+ 18 - 2
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -902,6 +902,9 @@
                     this._effect.setMatrices("mBones", (<Skeleton>mesh.skeleton).getTransformMatrices((mesh)));
                 }
 
+                // Morph targets
+                MaterialHelper.BindMorphTargetParameters(mesh, this._effect);
+
                 if (this.forceBackFacesOnly) {
                     engine.setState(true, 0, false, true);
                 }
@@ -1075,6 +1078,18 @@
                 defines.push("#define NUM_BONE_INFLUENCERS 0");
             }
 
+            // Morph targets         
+            var manager = (<Mesh>mesh).morphTargetManager;
+            let morphInfluencers = 0;
+            if (manager) {
+                if (manager.numInfluencers > 0) {
+                    defines.push("#define MORPHTARGETS");
+                    morphInfluencers = manager.numInfluencers;
+                    defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
+                    MaterialHelper.PrepareAttributesForMorphTargets(attribs, mesh, {"NUM_MORPH_INFLUENCERS": morphInfluencers });
+                }
+            }
+
             // Instances
             if (useInstances) {
                 defines.push("#define INSTANCES");
@@ -1090,8 +1105,9 @@
                 this._cachedDefines = join;
                 this._effect = this._scene.getEngine().createEffect("shadowMap",
                     attribs,
-                    ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale"],
-                    ["diffuseSampler"], join);
+                    ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences"],
+                    ["diffuseSampler"], join,
+                undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
             }
 
             if (!this._effect.isReady()) {

+ 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);

+ 8 - 2
src/Particles/babylon.gpuParticleSystem.ts

@@ -262,8 +262,14 @@
          * @return true if the system is ready
          */
         public isReady(): boolean {
-            if (!this.emitter || !this._updateEffect || !this._renderEffect || 
-                !this._updateEffect.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
+            if (!this._updateEffect) {
+                this._recreateUpdateEffect();
+                this._recreateRenderEffect();
+                return false;
+            }
+
+
+            if (!this.emitter || !this._updateEffect.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
                 return false;
             }
 

+ 0 - 3
src/PostProcess/babylon.vrDistortionCorrectionPostProcess.ts

@@ -1,7 +1,5 @@
 module BABYLON {
     export class VRDistortionCorrectionPostProcess extends PostProcess {
-        public aspectRatio: number;
-
         private _isRightEye: boolean;
         private _distortionFactors: number[];
         private _postProcessScaleFactor: number;
@@ -25,7 +23,6 @@
             this.adaptScaleToCurrentViewport = true;
 
             this.onSizeChangedObservable.add(() => {
-                this.aspectRatio = this.width * .5 / this.height;
                 this._scaleIn = new Vector2(2, 2 / this.aspectRatio);
                 this._scaleFactor = new Vector2(.5 * (1 / this._postProcessScaleFactor), .5 * (1 / this._postProcessScaleFactor) * this.aspectRatio);
                 this._lensCenter = new Vector2(this._isRightEye ? 0.5 - this._lensCenterOffset * 0.5 : 0.5 + this._lensCenterOffset * 0.5, 0.5);

+ 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);

+ 8 - 1
src/Shaders/shadowMap.vertex.fx

@@ -8,6 +8,9 @@ attribute vec3 position;
 
 #include<bonesDeclaration>
 
+#include<morphTargetsVertexGlobalDeclaration>
+#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]
+
 // Uniforms
 #include<instancesDeclaration>
 #include<helperFunctions>
@@ -31,10 +34,14 @@ attribute vec2 uv2;
 
 void main(void)
 {
+vec3 positionUpdated = position;
+
+#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]
+
 #include<instancesVertex>
 #include<bonesVertex>
 
-vec4 worldPos = finalWorld * vec4(position, 1.0);
+vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);
 
 // Normal inset Bias.
 #ifdef NORMAL

+ 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', () => {