浏览代码

Merge with master

David Catuhe 8 年之前
父节点
当前提交
547232b0f2

文件差异内容过多而无法显示
+ 7 - 7
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 9 - 1
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -24903,6 +24903,9 @@ var BABYLON;
             var scene = this.getScene();
             var engine = scene.getEngine();
             var checkReady = function () {
+                if (!_this._scene || !_this._scene.getEngine()) {
+                    return;
+                }
                 if (subMesh._materialDefines) {
                     subMesh._materialDefines._renderId = -1;
                 }
@@ -34935,8 +34938,11 @@ var BABYLON;
                 subMeshes.push.apply(subMeshes, mesh.subMeshes);
             }
             var checkReady = function () {
+                if (!_this._scene || !_this._scene.getEngine()) {
+                    return;
+                }
                 var subMesh = subMeshes[currentIndex];
-                if (_this._scene && _this._scene.getEngine() && _this.isReady(subMesh, options ? options.useInstances : false)) {
+                if (_this.isReady(subMesh, options ? options.useInstances : false)) {
                     currentIndex++;
                     if (currentIndex >= subMeshes.length) {
                         if (onCompiled) {
@@ -52359,8 +52365,10 @@ var BABYLON;
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
                                         if (_this._parent.onBeforeMaterialReadyAsync) {
+                                            _this.addLoaderPendingData(material);
                                             _this._parent.onBeforeMaterialReadyAsync(babylonMaterial, babylonMesh, babylonMultiMaterial.subMaterials[i] != null, function () {
                                                 babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                                _this.removeLoaderPendingData(material);
                                             });
                                         }
                                         else {

+ 2 - 0
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -648,8 +648,10 @@ var BABYLON;
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
                                         if (_this._parent.onBeforeMaterialReadyAsync) {
+                                            _this.addLoaderPendingData(material);
                                             _this._parent.onBeforeMaterialReadyAsync(babylonMaterial, babylonMesh, babylonMultiMaterial.subMaterials[i] != null, function () {
                                                 babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                                _this.removeLoaderPendingData(material);
                                             });
                                         }
                                         else {

文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 2 - 0
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2806,8 +2806,10 @@ var BABYLON;
                                             _this._parent.onMaterialLoaded(babylonMaterial);
                                         }
                                         if (_this._parent.onBeforeMaterialReadyAsync) {
+                                            _this.addLoaderPendingData(material);
                                             _this._parent.onBeforeMaterialReadyAsync(babylonMaterial, babylonMesh, babylonMultiMaterial.subMaterials[i] != null, function () {
                                                 babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                                _this.removeLoaderPendingData(material);
                                             });
                                         }
                                         else {

文件差异内容过多而无法显示
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 2 - 0
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -414,8 +414,10 @@ module BABYLON.GLTF2 {
                                     }
                                     
                                     if (this._parent.onBeforeMaterialReadyAsync) {
+                                        this.addLoaderPendingData(material);
                                         this._parent.onBeforeMaterialReadyAsync(babylonMaterial, babylonMesh, babylonMultiMaterial.subMaterials[i] != null, () => {
                                             babylonMultiMaterial.subMaterials[i] = babylonMaterial;
+                                            this.removeLoaderPendingData(material);
                                         });
                                     } else {
                                         babylonMultiMaterial.subMaterials[i] = babylonMaterial;

+ 6 - 3
src/Lights/Shadows/babylon.shadowGenerator.ts

@@ -520,15 +520,18 @@
             var subMeshes = new Array<SubMesh>();
             var currentIndex = 0;
 
-
             for(var mesh of this.getShadowMap().renderList) {
                 subMeshes.push(...mesh.subMeshes);
             }
 
             var checkReady = () => {
+                if (!this._scene || !this._scene.getEngine()) {
+                    return;
+                }
+
                 let subMesh = subMeshes[currentIndex];
 
-                if (this._scene && this._scene.getEngine() && this.isReady(subMesh, options ? options.useInstances : false)) {
+                if (this.isReady(subMesh, options ? options.useInstances : false)) {
                     currentIndex++;
                     if (currentIndex >= subMeshes.length) {
                         if (onCompiled) {
@@ -541,7 +544,7 @@
             };
 
             if (subMeshes.length > 0) {
-                checkReady();            
+                checkReady();
             }
         }
 

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

@@ -525,6 +525,10 @@
             var engine = scene.getEngine();
 
             var checkReady = () => {
+                if (!this._scene || !this._scene.getEngine()) {
+                    return;
+                }
+
                 if (subMesh._materialDefines) {
                     subMesh._materialDefines._renderId = -1;
                 }
@@ -555,7 +559,7 @@
                     }
                     else {
                         setTimeout(checkReady, 16);
-                    }                    
+                    }
                 }
 
                 engine.setAlphaTesting(alphaTestState);

+ 41 - 33
src/Tools/babylon.decorators.ts

@@ -2,6 +2,43 @@
     var __decoratorInitialStore = {};
     var __mergedStore = {};
 
+    var _copySource = function<T>(creationFunction: () => T, source: T, instanciate: boolean): T {
+        var destination = creationFunction();
+
+        // Tags
+        if (Tags) {
+            Tags.AddTagsTo(destination, (<any>source).tags);
+        }
+
+        var classStore = getMergedStore(destination);
+
+        // Properties
+        for (var property in classStore) {
+            var propertyDescriptor = classStore[property];
+            var sourceProperty = source[property];
+            var propertyType = propertyDescriptor.type;
+
+            if (sourceProperty !== undefined && sourceProperty !== null) {
+                switch (propertyType) {
+                    case 0:     // Value
+                    case 6:     // Mesh reference
+                        destination[property] = sourceProperty;
+                        break;
+                    case 1:     // Texture
+                    case 2:     // Color3
+                    case 3:     // FresnelParameters
+                    case 4:     // Vector2
+                    case 5:     // Vector3
+                    case 7:     // Color Curves
+                        destination[property] = instanciate?sourceProperty:sourceProperty.clone();
+                        break;
+                }
+            }
+        }
+
+        return destination;
+    };
+
     function getDirectStore(target: any): any {
         var classKey = target.getClassName();
 
@@ -255,40 +292,11 @@
         }
 
         public static Clone<T>(creationFunction: () => T, source: T): T {
-            var destination = creationFunction();
-
-            // Tags
-            if (Tags) {
-                Tags.AddTagsTo(destination, (<any>source).tags);
-            }
-            
-            var classStore = getMergedStore(destination);
-
-            // Properties
-            for (var property in classStore) {
-                var propertyDescriptor = classStore[property];
-                var sourceProperty = source[property];
-                var propertyType = propertyDescriptor.type;
-
-                if (sourceProperty !== undefined && sourceProperty !== null) {
-                    switch (propertyType) {
-                        case 0:     // Value
-                        case 6:     // Mesh reference
-                            destination[property] = sourceProperty;
-                            break;
-                        case 1:     // Texture
-                        case 2:     // Color3
-                        case 3:     // FresnelParameters
-                        case 4:     // Vector2
-                        case 5:     // Vector3
-                        case 7:     // Color Curves
-                            destination[property] = sourceProperty.clone();
-                            break;
-                    }
-                }
-            }
+            return _copySource(creationFunction, source, false);
+        }
 
-            return destination;
+        public static Instanciate<T>(creationFunction: () => T, source: T): T {
+            return _copySource(creationFunction, source, true);
         }
     }
 }