David Catuhe 11 年之前
父節點
當前提交
e6b77ec45d

+ 5 - 1
Babylon/Cameras/babylon.arcRotateCamera.js

@@ -179,7 +179,11 @@ var BABYLON = BABYLON || {};
                 pointerId = null;
             };
 
-            this._onGestureStart = function(e) {
+            this._onGestureStart = function (e) {
+                if (window.MSGesture === undefined) {
+                    return;
+                }
+
                 if (!that._MSGestureHandler) {
                     that._MSGestureHandler = new MSGesture();
                     that._MSGestureHandler.target = canvas;

+ 2 - 0
Babylon/Materials/babylon.material.js

@@ -13,10 +13,12 @@ var BABYLON = BABYLON || {};
     
     // Members
     BABYLON.Material.prototype.checkReadyOnEveryCall = true;
+    BABYLON.Material.prototype.checkReadyOnlyOnce = false;
     BABYLON.Material.prototype.alpha = 1.0;
     BABYLON.Material.prototype.wireframe = false;
     BABYLON.Material.prototype.backFaceCulling = true;
     BABYLON.Material.prototype._effect = null;
+    BABYLON.Material.prototype._wasPreviouslyReady = false;
 
     BABYLON.Material.prototype.onDispose = null;
     

+ 130 - 121
Babylon/Materials/babylon.standardMaterial.js

@@ -46,63 +46,71 @@ var BABYLON = BABYLON || {};
 
     // Methods   
     BABYLON.StandardMaterial.prototype.isReady = function (mesh) {
+        if (this.checkReadyOnlyOnce) {
+            if (this._wasPreviouslyReady) {
+                return true;
+            }
+        }
+
         if (!this.checkReadyOnEveryCall) {
             if (this._renderId === this._scene.getRenderId()) {
                 return true;
             }
-        }
+        }       
 
         var engine = this._scene.getEngine();
         var defines = [];
         var optionalDefines = [];
 
         // Textures
-        if (this.diffuseTexture) {
-            if (!this.diffuseTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define DIFFUSE");
+        if (this._scene.texturesEnabled) {
+            if (this.diffuseTexture) {
+                if (!this.diffuseTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define DIFFUSE");
+                }
             }
-        }
 
-        if (this.ambientTexture) {
-            if (!this.ambientTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define AMBIENT");
+            if (this.ambientTexture) {
+                if (!this.ambientTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define AMBIENT");
+                }
             }
-        }
 
-        if (this.opacityTexture) {
-            if (!this.opacityTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define OPACITY");
+            if (this.opacityTexture) {
+                if (!this.opacityTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define OPACITY");
+                }
             }
-        }
 
-        if (this.reflectionTexture) {
-            if (!this.reflectionTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define REFLECTION");
+            if (this.reflectionTexture) {
+                if (!this.reflectionTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define REFLECTION");
+                }
             }
-        }
 
-        if (this.emissiveTexture) {
-            if (!this.emissiveTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define EMISSIVE");
+            if (this.emissiveTexture) {
+                if (!this.emissiveTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define EMISSIVE");
+                }
             }
-        }
 
-        if (this.specularTexture) {
-            if (!this.specularTexture.isReady()) {
-                return false;
-            } else {
-                defines.push("#define SPECULAR");
-                optionalDefines.push(defines[defines.length - 1]);
+            if (this.specularTexture) {
+                if (!this.specularTexture.isReady()) {
+                    return false;
+                } else {
+                    defines.push("#define SPECULAR");
+                    optionalDefines.push(defines[defines.length - 1]);
+                }
             }
         }
 
@@ -132,62 +140,64 @@ var BABYLON = BABYLON || {};
 
         var shadowsActivated = false;
         var lightIndex = 0;
-        for (var index = 0; index < this._scene.lights.length; index++) {
-            var light = this._scene.lights[index];
+        if (this._scene.lightsEnabled) {
+            for (var index = 0; index < this._scene.lights.length; index++) {
+                var light = this._scene.lights[index];
 
-            if (!light.isEnabled()) {
-                continue;
-            }
+                if (!light.isEnabled()) {
+                    continue;
+                }
 
-            if (mesh && light.excludedMeshes.indexOf(mesh) !== -1) {
-                continue;
-            }
+                if (mesh && light.excludedMeshes.indexOf(mesh) !== -1) {
+                    continue;
+                }
 
-            defines.push("#define LIGHT" + lightIndex);
-            
-            if (lightIndex > 0) {
-                optionalDefines.push(defines[defines.length - 1]);
-            }
+                defines.push("#define LIGHT" + lightIndex);
 
-            var type;
-            if (light instanceof BABYLON.SpotLight) {
-                type = "#define SPOTLIGHT" + lightIndex;
-            } else if (light instanceof BABYLON.HemisphericLight) {
-                type = "#define HEMILIGHT" + lightIndex;
-            } else {
-                type = "#define POINTDIRLIGHT" + lightIndex;
-            }
-            
-            defines.push(type);
-            if (lightIndex > 0) {
-                optionalDefines.push(defines[defines.length - 1]);
-            }
+                if (lightIndex > 0) {
+                    optionalDefines.push(defines[defines.length - 1]);
+                }
 
-            // Shadows
-            var shadowGenerator = light.getShadowGenerator();
-            if (mesh && mesh.receiveShadows && shadowGenerator) {
-                defines.push("#define SHADOW" + lightIndex);
+                var type;
+                if (light instanceof BABYLON.SpotLight) {
+                    type = "#define SPOTLIGHT" + lightIndex;
+                } else if (light instanceof BABYLON.HemisphericLight) {
+                    type = "#define HEMILIGHT" + lightIndex;
+                } else {
+                    type = "#define POINTDIRLIGHT" + lightIndex;
+                }
 
+                defines.push(type);
                 if (lightIndex > 0) {
                     optionalDefines.push(defines[defines.length - 1]);
                 }
 
-                if (!shadowsActivated) {
-                    defines.push("#define SHADOWS");
-                    shadowsActivated = true;
-                }
+                // Shadows
+                var shadowGenerator = light.getShadowGenerator();
+                if (mesh && mesh.receiveShadows && shadowGenerator) {
+                    defines.push("#define SHADOW" + lightIndex);
 
-                if (shadowGenerator.useVarianceShadowMap) {
-                    defines.push("#define SHADOWVSM" + lightIndex);
                     if (lightIndex > 0) {
                         optionalDefines.push(defines[defines.length - 1]);
                     }
+
+                    if (!shadowsActivated) {
+                        defines.push("#define SHADOWS");
+                        shadowsActivated = true;
+                    }
+
+                    if (shadowGenerator.useVarianceShadowMap) {
+                        defines.push("#define SHADOWVSM" + lightIndex);
+                        if (lightIndex > 0) {
+                            optionalDefines.push(defines[defines.length - 1]);
+                        }
+                    }
                 }
-            }
 
-            lightIndex++;
-            if (lightIndex == 4)
-                break;
+                lightIndex++;
+                if (lightIndex == 4)
+                    break;
+            }
         }
 
         var attribs = [BABYLON.VertexBuffer.PositionKind, BABYLON.VertexBuffer.NormalKind];
@@ -227,7 +237,7 @@ var BABYLON = BABYLON || {};
 
             this._effect = this._scene.getEngine().createEffect(shaderName,
                 attribs,
-                ["world", "view", "worldViewProjection", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
+                ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
                 "vLightData0", "vLightDiffuse0", "vLightSpecular0", "vLightDirection0", "vLightGround0", "lightMatrix0",
                 "vLightData1", "vLightDiffuse1", "vLightSpecular1", "vLightDirection1", "vLightGround1", "lightMatrix1",
                 "vLightData2", "vLightDiffuse2", "vLightSpecular2", "vLightDirection2", "vLightGround2", "lightMatrix2",
@@ -246,6 +256,7 @@ var BABYLON = BABYLON || {};
         }
 
         this._renderId = this._scene.getRenderId();
+        this._wasPreviouslyReady = true;
         return true;
     };
 
@@ -270,15 +281,11 @@ var BABYLON = BABYLON || {};
 
         // Matrices        
         this._effect.setMatrix("world", world);
+        this._effect.setMatrix("viewProjection", this._scene.getTransformMatrix());
 
         // Bones
         if (mesh.skeleton && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesIndicesKind) && mesh.isVerticesDataPresent(BABYLON.VertexBuffer.MatricesWeightsKind)) {
-            this._effect.setMatrix("viewProjection", this._scene.getTransformMatrix());
-
             this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices());
-        } else {
-            world.multiplyToRef(this._scene.getTransformMatrix(), this._worldViewProjectionMatrix);
-            this._effect.setMatrix("worldViewProjection", this._worldViewProjectionMatrix);
         }
 
         // Textures        
@@ -346,49 +353,51 @@ var BABYLON = BABYLON || {};
         this._effect.setColor4("vSpecularColor", this.specularColor, this.specularPower);
         this._effect.setColor3("vEmissiveColor", this.emissiveColor);
 
-        var lightIndex = 0;
-        for (var index = 0; index < this._scene.lights.length; index++) {
-            var light = this._scene.lights[index];
+        if (this._scene.lightsEnabled) {
+            var lightIndex = 0;
+            for (var index = 0; index < this._scene.lights.length; index++) {
+                var light = this._scene.lights[index];
 
-            if (!light.isEnabled()) {
-                continue;
-            }
-            
-            if (mesh && light.excludedMeshes.indexOf(mesh) !== -1) {
-                continue;
-            }
+                if (!light.isEnabled()) {
+                    continue;
+                }
 
-            if (light instanceof BABYLON.PointLight) {
-                // Point Light
-                light.transferToEffect(this._effect, "vLightData" + lightIndex);
-            } else if (light instanceof BABYLON.DirectionalLight) {
-                // Directional Light
-                light.transferToEffect(this._effect, "vLightData" + lightIndex);
-            } else if (light instanceof BABYLON.SpotLight) {
-                // Spot Light
-                light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
-            } else if (light instanceof BABYLON.HemisphericLight) {
-                // Hemispheric Light
-                light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
-            }
+                if (mesh && light.excludedMeshes.indexOf(mesh) !== -1) {
+                    continue;
+                }
 
-            light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
-            light.specular.scaleToRef(light.intensity, this._scaledSpecular);
-            this._effect.setColor3("vLightDiffuse" + lightIndex, this._scaledDiffuse);
-            this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
-
-            // Shadows
-            var shadowGenerator = light.getShadowGenerator();
-            if (mesh.receiveShadows && shadowGenerator) {
-                world.multiplyToRef(shadowGenerator.getTransformMatrix(), this._lightMatrix);
-                this._effect.setMatrix("lightMatrix" + lightIndex, this._lightMatrix);
-                this._effect.setTexture("shadowSampler" + lightIndex, shadowGenerator.getShadowMap());
-            }
+                if (light instanceof BABYLON.PointLight) {
+                    // Point Light
+                    light.transferToEffect(this._effect, "vLightData" + lightIndex);
+                } else if (light instanceof BABYLON.DirectionalLight) {
+                    // Directional Light
+                    light.transferToEffect(this._effect, "vLightData" + lightIndex);
+                } else if (light instanceof BABYLON.SpotLight) {
+                    // Spot Light
+                    light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightDirection" + lightIndex);
+                } else if (light instanceof BABYLON.HemisphericLight) {
+                    // Hemispheric Light
+                    light.transferToEffect(this._effect, "vLightData" + lightIndex, "vLightGround" + lightIndex);
+                }
+
+                light.diffuse.scaleToRef(light.intensity, this._scaledDiffuse);
+                light.specular.scaleToRef(light.intensity, this._scaledSpecular);
+                this._effect.setColor3("vLightDiffuse" + lightIndex, this._scaledDiffuse);
+                this._effect.setColor3("vLightSpecular" + lightIndex, this._scaledSpecular);
+
+                // Shadows
+                var shadowGenerator = light.getShadowGenerator();
+                if (mesh.receiveShadows && shadowGenerator) {
+                    world.multiplyToRef(shadowGenerator.getTransformMatrix(), this._lightMatrix);
+                    this._effect.setMatrix("lightMatrix" + lightIndex, this._lightMatrix);
+                    this._effect.setTexture("shadowSampler" + lightIndex, shadowGenerator.getShadowMap());
+                }
 
-            lightIndex++;
+                lightIndex++;
 
-            if (lightIndex == 4)
-                break;
+                if (lightIndex == 4)
+                    break;
+            }
         }
 
         if (BABYLON.clipPlane) {

+ 7 - 3
Babylon/Materials/textures/babylon.baseTexture.js

@@ -94,15 +94,19 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.BaseTexture.prototype.dispose = function () {
+        // Remove from scene
+        var index = this._scene.textures.indexOf(this);
+
+        if (index >= 0) {
+            this._scene.textures.splice(index, 1);
+        }
+
         if (this._texture === undefined) {
             return;
         }
 
         this.releaseInternalTexture();
 
-        // Remove from scene
-        var index = this._scene.textures.indexOf(this);
-        this._scene.textures.splice(index, 1);
 
         // Callback
         if (this.onDispose) {

+ 2 - 4
Babylon/Mesh/babylon.mesh.js

@@ -34,7 +34,6 @@ var BABYLON = BABYLON || {};
         this._positions = null;
         this._cache = {
             localMatrixUpdated: false,
-            infiniteDistance: true,
             position: BABYLON.Vector3.Zero(),
             scaling: BABYLON.Vector3.Zero(),
             rotation: BABYLON.Vector3.Zero(),
@@ -152,7 +151,7 @@ var BABYLON = BABYLON || {};
             return false;
         }
         
-        if (this._cache.infiniteDistance !== this.infiniteDistance) {
+        if (this.infiniteDistance) {
             return false;
         }
 
@@ -232,13 +231,12 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Mesh.prototype.computeWorldMatrix = function (force) {
-        if (this._currentRenderId == this._scene.getRenderId() || !force && this.isSynchronized()) {
+        if (!force && (this._currentRenderId == this._scene.getRenderId() || this.isSynchronized())) {
             this._childrenFlag = false;
             return this._worldMatrix;
         }
 
         this._childrenFlag = true;
-        this._cache.infiniteDistance = this.infiniteDistance;
         this._cache.position.copyFrom(this.position);
         this._cache.scaling.copyFrom(this.scaling);
         this._cache.pivotMatrixUpdated = false;

+ 2 - 4
Babylon/Rendering/babylon.renderingGroup.js

@@ -69,7 +69,6 @@ var BABYLON = BABYLON || {};
             });
 
             // Rendering
-            engine.setDepthWrite(false);
             engine.setAlphaMode(BABYLON.Engine.ALPHA_COMBINE);
             for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
                 submesh = sortedArray[subIndex];
@@ -78,7 +77,6 @@ var BABYLON = BABYLON || {};
                 submesh.render();
             }
             engine.setAlphaMode(BABYLON.Engine.ALPHA_DISABLE);
-            engine.setDepthWrite(true);
         }
         return true;
     };
@@ -96,12 +94,12 @@ var BABYLON = BABYLON || {};
 
         if (material.needAlphaBlending() || mesh.visibility < 1.0) { // Transparent
             if (material.alpha > 0 || mesh.visibility < 1.0) {
-                this._transparentSubMeshes.push(subMesh); // Opaque
+                this._transparentSubMeshes.push(subMesh);
             }
         } else if (material.needAlphaTesting()) { // Alpha test
             this._alphaTestSubMeshes.push(subMesh);
         } else {
-            this._opaqueSubMeshes.push(subMesh);
+            this._opaqueSubMeshes.push(subMesh); // Opaque
         }
     };
 })();

+ 2 - 1
Babylon/Shaders/default.fragment.fx

@@ -559,7 +559,8 @@ void main(void) {
 	float alpha = vDiffuseColor.a;
 
 #ifdef OPACITY
-	vec3 opacityMap = texture2D(opacitySampler, vOpacityUV).rgb * vec3(0.3, 0.59, 0.11);
+	vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);
+	opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11) * opacityMap.a;
 	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
 #endif
 

+ 2 - 5
Babylon/Shaders/default.vertex.fx

@@ -22,6 +22,7 @@ attribute vec4 matricesWeights;
 // Uniforms
 uniform mat4 world;
 uniform mat4 view;
+uniform mat4 viewProjection;
 
 #ifdef DIFFUSE
 varying vec2 vDiffuseUV;
@@ -61,9 +62,6 @@ uniform mat4 bumpMatrix;
 
 #ifdef BONES
 uniform mat4 mBones[BonesPerMesh];
-uniform mat4 viewProjection;
-#else
-uniform mat4 worldViewProjection;
 #endif
 
 // Output
@@ -125,11 +123,10 @@ void main(void) {
 	finalWorld = world * (m0 + m1 + m2);
 #endif 
 
-	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 #else
 	finalWorld = world;
-	gl_Position = worldViewProjection * vec4(position, 1.0);
 #endif
+	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
 
 	vec4 worldPos = finalWorld * vec4(position, 1.0);
 	vPositionW = vec3(worldPos);

+ 2 - 1
Babylon/Shaders/iedefault.fragment.fx

@@ -473,7 +473,8 @@ void main(void) {
 	float alpha = vDiffuseColor.a;
 
 #ifdef OPACITY
-	vec3 opacityMap = texture2D(opacitySampler, vOpacityUV).rgb * vec3(0.3, 0.59, 0.11);
+	vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);
+	opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11) * opacityMap.a;
 	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
 #endif
 

+ 4 - 6
Babylon/Shaders/iedefault.vertex.fx

@@ -29,6 +29,7 @@ attribute vec4 matricesWeights;
 // Uniforms
 uniform mat4 world;
 uniform mat4 view;
+uniform mat4 viewProjection;
 
 #ifdef DIFFUSE
 varying vec2 vDiffuseUV;
@@ -75,9 +76,6 @@ uniform mat4 bumpMatrix;
 
 #ifdef BONES
 uniform mat4 mBones[BonesPerMesh];
-uniform mat4 viewProjection;
-#else
-uniform mat4 worldViewProjection;
 #endif
 
 // Output
@@ -166,13 +164,13 @@ void main(void) {
 #else
 	finalWorld = world * (m0 + m1 + m2);
 #endif 
-	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
-#else
 
+#else
 	finalWorld = world;
-	gl_Position = worldViewProjection * vec4(position, 1.0);
 #endif
 
+	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
+
 	vec4 worldPos = finalWorld * vec4(position, 1.0);
 	vPositionW = vec3(worldPos);
 	vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));

+ 54 - 25
Babylon/Tools/babylon.filesInput.js

@@ -3,29 +3,50 @@
 var BABYLON = BABYLON || {};
 
 (function () {
-    var elementToMonitor;
-    var engine;
-    var canvas;
-    var currentScene;
+    var that;
+
+    /// Register to core BabylonJS object: engine, scene, rendering canvas, callback function when the scene will be loaded,
+    /// loading progress callback and optionnal addionnal logic to call in the rendering loop
+    BABYLON.FilesInput = function (p_engine, p_scene, p_canvas, p_sceneLoadedCallback,
+                                   p_progressCallback, p_additionnalRenderLoopLogicCallback, p_textureLoadingCallback, p_startingProcessingFilesCallback) {
+        that = this;
+        this.engine = p_engine;
+        this.canvas = p_canvas;
+        this.originalScene = p_scene;
+        this.sceneLoadedCallback = p_sceneLoadedCallback;
+        this.progressCallback = p_progressCallback;
+        this.additionnalRenderLoopLogicCallback = p_additionnalRenderLoopLogicCallback;
+        this.textureLoadingCallback = p_textureLoadingCallback;
+        this.startingProcessingFilesCallback = p_startingProcessingFilesCallback;
+
+        this.engine.runRenderLoop(renderFunction);
+    };
 
     // elementToMonitor is the HTML element that will listen to drag'n'drop events
     // it could be the rendering canvas or whatever element on the page
-    BABYLON.FilesInput = function (p_engine, p_canvas, p_elementToMonitor) {
+    BABYLON.FilesInput.prototype.monitorElementForDragNDrop = function (p_elementToMonitor) {
         if (p_elementToMonitor) {
-            elementToMonitor = p_elementToMonitor;
-            elementToMonitor.addEventListener("dragenter", drag, false);
-            elementToMonitor.addEventListener("dragover", drag, false);
-            elementToMonitor.addEventListener("drop", drop, false);
+            this.elementToMonitor = p_elementToMonitor;
+            this.elementToMonitor.addEventListener("dragenter", drag, false);
+            this.elementToMonitor.addEventListener("dragover", drag, false);
+            this.elementToMonitor.addEventListener("drop", drop, false);
         }
-        engine = p_engine;
-        canvas = p_canvas;
-
-        engine.runRenderLoop(renderFunction);
     };
 
     function renderFunction() {
-        if (currentScene) {
-            currentScene.render();
+        if (that.additionnalRenderLoopLogicCallback) {
+            that.additionnalRenderLoopLogicCallback();
+        }
+
+        if (that.currentScene) {
+            if (that.textureLoadingCallback) {
+                var remaining = that.currentScene.getWaitingItemsCount();
+
+                if (remaining > 0) {
+                    that.textureLoadingCallback(remaining);
+                }
+            }
+            that.currentScene.render();
         }
     };
 
@@ -38,10 +59,12 @@ var BABYLON = BABYLON || {};
         eventDrop.stopPropagation();
         eventDrop.preventDefault();
 
-        BABYLON.FilesInput.loadFiles(eventDrop);
+        that.loadFiles(eventDrop);
     };
 
-    BABYLON.FilesInput.loadFiles = function (event) {
+    BABYLON.FilesInput.prototype.loadFiles = function (event) {
+        if (that.startingProcessingFilesCallback) that.startingProcessingFilesCallback();
+
         var sceneFileToLoad;
         var filesToLoad;
         BABYLON.FilesTextures = {};
@@ -56,7 +79,7 @@ var BABYLON = BABYLON || {};
             filesToLoad = event.target.files;
         }
 
-        if (filesToLoad) {
+        if (filesToLoad && filesToLoad.length > 0) {
             for (var i = 0; i < filesToLoad.length; i++) {
                 if (filesToLoad[i].name.indexOf(".babylon") !== -1 && filesToLoad[i].name.indexOf(".manifest") === -1
 				 && filesToLoad[i].name.indexOf(".incremental") === -1 && filesToLoad[i].name.indexOf(".babylonmeshdata") === -1) {
@@ -71,19 +94,25 @@ var BABYLON = BABYLON || {};
 
             // If a ".babylon" file has been provided
             if (sceneFileToLoad) {
-                BABYLON.SceneLoader.Load("file:", sceneFileToLoad, engine, function (newScene) {
-                    if (currentScene) currentScene.dispose();
+                if (that.currentScene) {
+                    that.currentScene.dispose();
+                }
 
-                    currentScene = newScene;
+                BABYLON.SceneLoader.Load("file:", sceneFileToLoad, that.engine, function (newScene) {
+                    that.currentScene = newScene;
 
                     // Wait for textures and shaders to be ready
-                    currentScene.executeWhenReady(function () {
+                    that.currentScene.executeWhenReady(function () {
                         // Attach camera to canvas inputs
-                        currentScene.activeCamera.attachControl(canvas);
-
+                        that.currentScene.activeCamera.attachControl(that.canvas);
+                        if (that.sceneLoadedCallback) {
+                            that.sceneLoadedCallback(sceneFileToLoad, that.currentScene);
+                        }
                     });
                 }, function (progress) {
-                    // To do: give progress feedback to user
+                    if (that.progressCallback) {
+                        that.progressCallback(progress);
+                    }
                 });
             }
             else {

+ 9 - 1
Babylon/Tools/babylon.tools.js

@@ -178,7 +178,15 @@ var BABYLON = BABYLON || {};
             else {
                 try {
                     var textureName = url.substring(5);
-                    img.src = URL.createObjectURL(BABYLON.FilesTextures[textureName]);
+                    var blobURL;
+                    try {
+                        blobURL = URL.createObjectURL(BABYLON.FilesTextures[textureName], { oneTimeOnly: true });
+                    }
+                    catch (ex) {
+                        // Chrome doesn't support oneTimeOnly parameter
+                        blobURL = URL.createObjectURL(BABYLON.FilesTextures[textureName]);
+                    }
+                    img.src = blobURL;
                 }
                 catch (e) {
                     console.log("Error while trying to load texture: " + textureName);

+ 9 - 4
Babylon/babylon.scene.js

@@ -37,6 +37,7 @@ var BABYLON = BABYLON || {};
         this.fogEnd = 1000.0;
 
         // Lights
+        this.lightsEnabled = true;
         this.lights = [];
 
         // Cameras
@@ -62,6 +63,7 @@ var BABYLON = BABYLON || {};
         this.defaultMaterial = new BABYLON.StandardMaterial("default material", this);
 
         // Textures
+        this.texturesEnabled = true;
         this.textures = [];
 
         // Particles
@@ -99,6 +101,7 @@ var BABYLON = BABYLON || {};
         this.postProcessManager = new BABYLON.PostProcessManager(this);
 
         // Customs render targets
+        this.renderTargetsEnabled = true;
         this.customRenderTargets = [];
 
         // Multi-cameras
@@ -604,10 +607,12 @@ var BABYLON = BABYLON || {};
 
         // Render targets
         var beforeRenderTargetDate = new Date();
-        for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
-            var renderTarget = this._renderTargets.data[renderIndex];
-            this._renderId++;
-            renderTarget.render();
+        if (this.renderTargetsEnabled) {
+            for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
+                var renderTarget = this._renderTargets.data[renderIndex];
+                this._renderId++;
+                renderTarget.render();
+            }
         }
 
         if (this._renderTargets.length > 0) { // Restore back buffer

+ 0 - 1
Exporters/XNA - OBJ/BabylonExport.Core/BabylonExport.Core.csproj

@@ -171,7 +171,6 @@
     <Compile Include="Tools.cs" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="Exporters\Blender\io_export_babylon.py" />
     <None Include="Exporters\ThroughXNA\XNA\XNA Game Studio\Microsoft.Xna.GameStudio.ContentPipelineExtensions.targets">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </None>

文件差異過大導致無法顯示
+ 0 - 1003
Exporters/XNA - OBJ/BabylonExport.Core/Exporters/Blender/io_export_babylon.py


二進制
Exporters/XNA - OBJ/BabylonExport.zip


+ 6 - 8
Exporters/XNA - OBJ/BabylonExport/BabylonExport.csproj

@@ -99,6 +99,12 @@
     <StartupObject />
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="ColladaXnaBase">
+      <HintPath>..\BabylonExport.Core\Refs\ColladaXnaBase.dll</HintPath>
+    </Reference>
+    <Reference Include="ColladaXnaImporter">
+      <HintPath>..\BabylonExport.Core\Refs\ColladaXnaImporter.dll</HintPath>
+    </Reference>
     <Reference Include="Microsoft.Xna.Framework.Content.Pipeline">
       <HintPath>..\BabylonExport.Core\Refs\Microsoft.Xna.Framework.Content.Pipeline.dll</HintPath>
       <Private>True</Private>
@@ -916,14 +922,6 @@
       <Project>{ce70b051-fb63-420d-80c0-51cc03a214ba}</Project>
       <Name>BabylonExport.Core</Name>
     </ProjectReference>
-    <ProjectReference Include="..\BabylonExport.Core\Exporters\ThroughXNA\DAE\ColladaXna\ColladaXnaBase\ColladaXnaBase.csproj">
-      <Project>{65FE2973-B4E6-49DE-8F57-55490D4B4FD4}</Project>
-      <Name>ColladaXnaBase</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\BabylonExport.Core\Exporters\ThroughXNA\DAE\ColladaXna\ColladaXnaImporter\ColladaXnaImporter.csproj">
-      <Project>{625E5D7F-86F6-4961-89D0-3835BF261ACC}</Project>
-      <Name>ColladaXnaImporter</Name>
-    </ProjectReference>
     <ProjectReference Include="..\BabylonExport.Interface\BabylonExport.Interface.csproj">
       <Project>{dec52846-ffcb-4a66-9f13-64f65b61edba}</Project>
       <Name>BabylonExport.Interface</Name>

二進制
Exporters/XNA - OBJ/BabylonExport/Exporters/Blender/io_export_babylon.zip


+ 2 - 1
Exporters/XNA - OBJ/readme.md

@@ -4,6 +4,7 @@
 BabylonExporter can create a .babylon scene from the following formats:
  - FBX
  - OBJ
+ - DAE
 
 Command line usage:
 BabylonExporter.exe /i:"source.fbx" /o:"outputDir" [/sk]
@@ -22,7 +23,7 @@ BabylonExporter.exe /i:"source.fbx" /o:"outputDir" [/sk]
    * Specular color
    * Specular power
 
-* FBX engine can export:
+* FBX/DAE engine can export:
  * Geometries
  * Meshes hierarchies
  * Bones and bones' animations

文件差異過大導致無法顯示
+ 22 - 0
babylon.1.7.2.js


文件差異過大導致無法顯示
+ 0 - 22
babylon.1.7.js