David Catuhe 11 anos atrás
pai
commit
7089b52686
51 arquivos alterados com 310 adições e 88 exclusões
  1. 3 1
      Babylon/Collisions/babylon.collider.js
  2. 3 1
      Babylon/Collisions/babylon.pickingInfo.js
  3. 3 1
      Babylon/Culling/Octrees/babylon.octree.js
  4. 3 1
      Babylon/Culling/Octrees/babylon.octreeBlock.js
  5. 3 1
      Babylon/Culling/babylon.boundingBox.js
  6. 3 1
      Babylon/Culling/babylon.boundingInfo.js
  7. 3 1
      Babylon/Culling/babylon.boundingSphere.js
  8. 3 1
      Babylon/Layer/babylon.layer.js
  9. 3 1
      Babylon/LensFlare/babylon.lensFlare.js
  10. 3 1
      Babylon/LensFlare/babylon.lensFlareSystem.js
  11. 3 1
      Babylon/Lights/Shadows/babylon.shadowGenerator.js
  12. 3 1
      Babylon/Lights/babylon.directionalLight.js
  13. 3 1
      Babylon/Lights/babylon.hemisphericLight.js
  14. 3 1
      Babylon/Lights/babylon.light.js
  15. 3 1
      Babylon/Lights/babylon.pointLight.js
  16. 3 1
      Babylon/Lights/babylon.spotLight.js
  17. 3 1
      Babylon/Materials/babylon.effect.js
  18. 3 1
      Babylon/Materials/babylon.material.js
  19. 3 1
      Babylon/Materials/babylon.multiMaterial.js
  20. 3 1
      Babylon/Materials/babylon.standardMaterial.js
  21. 3 1
      Babylon/Materials/textures/babylon.baseTexture.js
  22. 3 1
      Babylon/Materials/textures/babylon.cubeTexture.js
  23. 3 1
      Babylon/Materials/textures/babylon.dynamicTexture.js
  24. 3 1
      Babylon/Materials/textures/babylon.mirrorTexture.js
  25. 4 2
      Babylon/Materials/textures/babylon.renderTargetTexture.js
  26. 3 1
      Babylon/Materials/textures/babylon.texture.js
  27. 4 2
      Babylon/Materials/textures/babylon.videoTexture.js
  28. 3 1
      Babylon/Mesh/babylon.mesh.js
  29. 3 1
      Babylon/Mesh/babylon.subMesh.js
  30. 3 1
      Babylon/Mesh/babylon.vertexBuffer.js
  31. 3 1
      Babylon/Particles/babylon.particle.js
  32. 3 1
      Babylon/Particles/babylon.particleSystem.js
  33. 3 1
      Babylon/PostProcess/babylon.blackAndWhitePostProcess.js
  34. 3 1
      Babylon/PostProcess/babylon.blurPostProcess.js
  35. 3 1
      Babylon/PostProcess/babylon.convolutionPostProcess.js
  36. 3 1
      Babylon/PostProcess/babylon.fxaaPostProcess.js
  37. 3 1
      Babylon/PostProcess/babylon.passPostProcess.js
  38. 3 1
      Babylon/PostProcess/babylon.postProcess.js
  39. 3 1
      Babylon/PostProcess/babylon.postProcessManager.js
  40. 3 1
      Babylon/PostProcess/babylon.refractionPostProcess.js
  41. 3 1
      Babylon/Rendering/babylon.renderingGroup.js
  42. 3 1
      Babylon/Rendering/babylon.renderingManager.js
  43. 3 1
      Babylon/Sprites/babylon.sprite.js
  44. 3 1
      Babylon/Sprites/babylon.spriteManager.js
  45. 28 26
      Babylon/Tools/babylon.database.js
  46. 94 0
      Babylon/Tools/babylon.filesInput.js
  47. 7 3
      Babylon/Tools/babylon.math.js
  48. 18 8
      Babylon/Tools/babylon.sceneLoader.js
  49. 26 2
      Babylon/Tools/babylon.tools.js
  50. 1 1
      Babylon/jscompaktor.bat
  51. 2 2
      babylon.1.7.js

+ 3 - 1
Babylon/Collisions/babylon.collider.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Collider = function () {

+ 3 - 1
Babylon/Collisions/babylon.pickingInfo.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.PickingInfo = function () {

+ 3 - 1
Babylon/Culling/Octrees/babylon.octree.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function() {
     BABYLON.Octree = function(maxBlockCapacity) {

+ 3 - 1
Babylon/Culling/Octrees/babylon.octreeBlock.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.OctreeBlock = function (minPoint, maxPoint, capacity) {

+ 3 - 1
Babylon/Culling/babylon.boundingBox.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BoundingBox = function (minimum, maximum) {

+ 3 - 1
Babylon/Culling/babylon.boundingInfo.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BoundingInfo = function (minimum, maximum) {

+ 3 - 1
Babylon/Culling/babylon.boundingSphere.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BoundingSphere = function (minimum, maximum) {

+ 3 - 1
Babylon/Layer/babylon.layer.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Layer = function (name, imgUrl, scene, isBackground, color) {

+ 3 - 1
Babylon/LensFlare/babylon.lensFlare.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.LensFlare = function (size, position, color, imgUrl, system) {

+ 3 - 1
Babylon/LensFlare/babylon.lensFlareSystem.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.LensFlareSystem = function (name, emitter, scene) {

+ 3 - 1
Babylon/Lights/Shadows/babylon.shadowGenerator.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.ShadowGenerator = function (mapSize, light) {

+ 3 - 1
Babylon/Lights/babylon.directionalLight.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.DirectionalLight = function (name, direction, scene) {

+ 3 - 1
Babylon/Lights/babylon.hemisphericLight.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.HemisphericLight = function (name, direction, scene) {

+ 3 - 1
Babylon/Lights/babylon.light.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Light = function (name, scene) {

+ 3 - 1
Babylon/Lights/babylon.pointLight.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.PointLight = function (name, position, scene) {

+ 3 - 1
Babylon/Lights/babylon.spotLight.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.SpotLight = function (name, position, direction, angle, exponent, scene) {

+ 3 - 1
Babylon/Materials/babylon.effect.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
 

+ 3 - 1
Babylon/Materials/babylon.material.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Material = function (name, scene) {

+ 3 - 1
Babylon/Materials/babylon.multiMaterial.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.MultiMaterial = function (name, scene) {

+ 3 - 1
Babylon/Materials/babylon.standardMaterial.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.StandardMaterial = function (name, scene) {

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

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BaseTexture = function (url, scene) {

+ 3 - 1
Babylon/Materials/textures/babylon.cubeTexture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {    
     BABYLON.CubeTexture = function (rootUrl, scene) {

+ 3 - 1
Babylon/Materials/textures/babylon.dynamicTexture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.DynamicTexture = function (name, options, scene, generateMipMaps) {

+ 3 - 1
Babylon/Materials/textures/babylon.mirrorTexture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.MirrorTexture = function (name, size, scene, generateMipMaps) {

+ 4 - 2
Babylon/Materials/textures/babylon.renderTargetTexture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.RenderTargetTexture = function (name, size, scene, generateMipMaps) {
@@ -71,7 +73,7 @@
         for (var meshIndex = 0; meshIndex < this.renderList.length; meshIndex++) {
             var mesh = this.renderList[meshIndex];
 
-            if (mesh.isEnabled() && mesh.isVisible) {
+            if (mesh && mesh.isEnabled() && mesh.isVisible) {
                 for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
                     var subMesh = mesh.subMeshes[subIndex];
                     scene._activeVertices += subMesh.verticesCount;

+ 3 - 1
Babylon/Materials/textures/babylon.texture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Texture = function (url, scene, noMipmap, invertY) {

+ 4 - 2
Babylon/Materials/textures/babylon.videoTexture.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.VideoTexture = function (name, urls, size, scene, generateMipMaps) {
@@ -10,7 +12,7 @@
         this.wrapU = BABYLON.Texture.WRAP_ADDRESSMODE;
         this.wrapV = BABYLON.Texture.WRAP_ADDRESSMODE;
 
-        this._texture = scene.getEngine().createDynamicTexture(size, generateMipMaps);
+        this._texture = scene.getEngine().createDynamicTexture(size, size, generateMipMaps);
         var textureSize = this.getSize();
 
         this.video = document.createElement("video");

+ 3 - 1
Babylon/Mesh/babylon.mesh.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Mesh = function (name, scene) {

+ 3 - 1
Babylon/Mesh/babylon.subMesh.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.SubMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh) {

+ 3 - 1
Babylon/Mesh/babylon.vertexBuffer.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.VertexBuffer = function (mesh, data, kind, updatable) {

+ 3 - 1
Babylon/Particles/babylon.particle.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Particle = function () {

+ 3 - 1
Babylon/Particles/babylon.particleSystem.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     var randomNumber = function (min, max) {

+ 3 - 1
Babylon/PostProcess/babylon.blackAndWhitePostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BlackAndWhitePostProcess = function (name, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.blurPostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.BlurPostProcess = function (name, direction, blurWidth, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.convolutionPostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.ConvolutionPostProcess = function (name, kernelMatrix, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.fxaaPostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.FxaaPostProcess = function (name, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.passPostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.PassPostProcess = function (name, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.postProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.PostProcess = function (name, fragmentUrl, parameters, samplers, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/PostProcess/babylon.postProcessManager.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.PostProcessManager = function (scene) {

+ 3 - 1
Babylon/PostProcess/babylon.refractionPostProcess.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.RefractionPostProcess = function (name, refractionTextureUrl, color, depth, colorLevel, ratio, camera, samplingMode) {

+ 3 - 1
Babylon/Rendering/babylon.renderingGroup.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.RenderingGroup = function (index, scene) {

+ 3 - 1
Babylon/Rendering/babylon.renderingManager.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.RenderingManager = function (scene) {

+ 3 - 1
Babylon/Sprites/babylon.sprite.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Sprite = function (name, manager) {

+ 3 - 1
Babylon/Sprites/babylon.spriteManager.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {   
     BABYLON.SpriteManager = function (name, imgUrl, capacity, cellSize, scene, epsilon) {

+ 28 - 26
Babylon/Tools/babylon.database.js

@@ -1,12 +1,22 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
+    function parseURL(url) {
+        var a = document.createElement('a');
+        a.href = url;
+        var fileName = url.substring(url.lastIndexOf("/") + 1, url.length);
+        var absLocation = url.substring(0, url.indexOf(fileName, 0));
+        return absLocation;
+    };
+
     // Handling various flavors of prefixed version of IndexedDB
-    window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
+    var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB ||
         window.msIndexedDB;
-    window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction ||
+    var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction ||
         window.msIDBTransaction;
-    window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
+    var IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
 
     BABYLON.Database = function (urlToScene) {
         this.currentSceneUrl = BABYLON.Database.ReturnFullUrlLocation(urlToScene);
@@ -21,14 +31,6 @@
 
     BABYLON.Database.isUASupportingBlobStorage = true;
 
-    function parseURL(url) {
-        var a = document.createElement('a');
-        a.href = url;
-        var fileName = url.substring(url.lastIndexOf("/") + 1, url.length);
-        var absLocation = url.substring(0, url.indexOf(fileName, 0));
-        return absLocation;
-    };
-
     BABYLON.Database.ReturnFullUrlLocation = function (url) {
         if (url.indexOf("http:/") === -1) {
             return (parseURL(window.location.href) + url);
@@ -39,6 +41,12 @@
     };
 
     BABYLON.Database.prototype.checkManifestFile = function () {
+        function noManifestFile() {
+            console.log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
+            that.enableSceneOffline = false;
+            that.enableTexturesOffline = false;
+        };
+
         var that = this;
         var manifestURL = this.currentSceneUrl + ".manifest";
 
@@ -46,16 +54,10 @@
 
         xhr.open("GET", manifestURL, false);
 
-        function noManifestFile() {
-            console.log("Valid manifest file not found. Scene & textures will be loaded directly from the web server.");
-            that.enableSceneOffline = false;
-            that.enableTexturesOffline = false;
-        };
-
         xhr.addEventListener("load", function () {
             if (xhr.status === 200) {
                 try {
-                    manifestFile = JSON.parse(xhr.response);
+                    var manifestFile = JSON.parse(xhr.response);
                     that.enableSceneOffline = manifestFile.enableSceneOffline;
                     that.enableTexturesOffline = manifestFile.enableTexturesOffline;
                     if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
@@ -84,8 +86,13 @@
     };
 
     BABYLON.Database.prototype.openAsync = function (successCallback, errorCallback) {
+        function handleError() {
+            that.isSupported = false;
+            if (errorCallback) errorCallback();
+        }
+
         var that = this;
-        if (!window.indexedDB || !(this.enableSceneOffline || this.enableTexturesOffline)) {
+        if (!indexedDB || !(this.enableSceneOffline || this.enableTexturesOffline)) {
             // Your browser doesn't support IndexedDB
             this.isSupported = false;
             if (errorCallback) errorCallback();
@@ -96,12 +103,7 @@
                 this.hasReachedQuota = false;
                 this.isSupported = true;
 
-                var request = window.indexedDB.open("babylonjs", 1.0);
-
-                function handleError() {
-                    that.isSupported = false;
-                    if (errorCallback) errorCallback();
-                }
+                var request = indexedDB.open("babylonjs", 1.0);
 
                 // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
                 request.onerror = function (event) {

+ 94 - 0
Babylon/Tools/babylon.filesInput.js

@@ -0,0 +1,94 @@
+"use strict";
+
+var BABYLON = BABYLON || {};
+
+(function () {
+    var elementToMonitor;
+    var engine;
+    var canvas;
+    var currentScene;
+
+    // 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) {
+        if (p_elementToMonitor) {
+            elementToMonitor = p_elementToMonitor;
+            elementToMonitor.addEventListener("dragenter", drag, false);
+            elementToMonitor.addEventListener("dragover", drag, false);
+            elementToMonitor.addEventListener("drop", drop, false);
+        }
+        engine = p_engine;
+        canvas = p_canvas;
+
+        engine.runRenderLoop(renderFunction);
+    };
+
+    function renderFunction() {
+        if (currentScene) {
+            currentScene.render();
+        }
+    };
+
+    function drag(e) {
+        e.stopPropagation();
+        e.preventDefault();
+    };
+
+    function drop(eventDrop) {
+        eventDrop.stopPropagation();
+        eventDrop.preventDefault();
+
+        BABYLON.FilesInput.loadFiles(eventDrop);
+    };
+
+    BABYLON.FilesInput.loadFiles = function (event) {
+        var sceneFileToLoad;
+        var filesToLoad;
+        BABYLON.FilesTextures = {};
+
+        // Handling data transfer via drag'n'drop
+        if (event && event.dataTransfer && event.dataTransfer.files) {
+            filesToLoad = event.dataTransfer.files;
+        }
+
+        // Handling files from input files
+        if (event && event.target && event.target.files) {
+            filesToLoad = event.target.files;
+        }
+
+        if (filesToLoad) {
+            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) {
+                    sceneFileToLoad = filesToLoad[i];
+                }
+                else {
+                    if (filesToLoad[i].type.indexOf("image/jpeg") == 0 || filesToLoad[i].type.indexOf("image/png") == 0) {
+                        BABYLON.FilesTextures[filesToLoad[i].name] = filesToLoad[i];
+                    }
+                }
+            }
+
+            // If a ".babylon" file has been provided
+            if (sceneFileToLoad) {
+                BABYLON.SceneLoader.Load("file:", sceneFileToLoad, engine, function (newScene) {
+                    if (currentScene) currentScene.dispose();
+
+                    currentScene = newScene;
+
+                    // Wait for textures and shaders to be ready
+                    currentScene.executeWhenReady(function () {
+                        // Attach camera to canvas inputs
+                        currentScene.activeCamera.attachControl(canvas);
+
+                    });
+                }, function (progress) {
+                    // To do: give progress feedback to user
+                });
+            }
+            else {
+                console.log("Please provide a valid .babylon file.");
+            }
+        }
+    };
+})();

+ 7 - 3
Babylon/Tools/babylon.math.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     ////////////////////////////////// Ray //////////////////////////////////
@@ -1699,10 +1701,12 @@
         var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
         var invPyth;
 
-        if (pyth != 0)
+        if (pyth != 0) {
             invPyth = 1.0 / pyth;
-        else
+        }
+        else {
             invPyth = 0;
+        }
 
         this.normal.x = yz * invPyth;
         this.normal.y = xz * invPyth;

+ 18 - 8
Babylon/Tools/babylon.sceneLoader.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     var loadCubeTexture = function (rootUrl, parsedTexture, scene) {
@@ -587,10 +589,7 @@
             }, progressCallBack, database);
         },
         Load: function (rootUrl, sceneFilename, engine, then, progressCallBack) {
-            // Checking if a manifest file has been set for this scene and if offline mode has been requested
-            var database = new BABYLON.Database(rootUrl + sceneFilename);
-
-            BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {
+            function loadSceneFromData(data) {
                 var parsedData = JSON.parse(data);
                 var scene = new BABYLON.Scene(engine);
                 scene.database = database;
@@ -663,7 +662,7 @@
                         camera.parent = scene.getLastEntryByID(camera._waitingParentId);
                         delete camera._waitingParentId;
                     }
-                    
+
                     if (camera._waitingLockedTargetId) {
                         camera.lockedTarget = scene.getLastEntryByID(camera._waitingLockedTargetId);
                         delete camera._waitingLockedTargetId;
@@ -677,7 +676,7 @@
                         parseParticleSystem(parsedParticleSystem, scene, rootUrl);
                     }
                 }
-                
+
                 // Lens flares
                 if (parsedData.lensFlareSystems) {
                     for (var index = 0; index < parsedData.lensFlareSystems.length; index++) {
@@ -699,7 +698,18 @@
                 if (then) {
                     then(scene);
                 }
-            }, progressCallBack, database);
+            };
+
+            if (rootUrl.indexOf("file:") === -1) {
+                // Checking if a manifest file has been set for this scene and if offline mode has been requested
+                var database = new BABYLON.Database(rootUrl + sceneFilename);
+
+                BABYLON.Tools.LoadFile(rootUrl + sceneFilename, loadSceneFromData, progressCallBack, database);
+            }
+            // Loading file from disk via input file or drag'n'drop
+            else {
+                BABYLON.Tools.ReadFile(sceneFilename, loadSceneFromData, progressCallBack);
+            }
         }
     };
 })();

+ 26 - 2
Babylon/Tools/babylon.tools.js

@@ -1,4 +1,6 @@
-var BABYLON = BABYLON || {};
+"use strict";
+
+var BABYLON = BABYLON || {};
 
 (function () {
     BABYLON.Tools = {};
@@ -170,7 +172,19 @@
             database.openAsync(loadFromIndexedDB, noIndexedDB);
         }
         else {
-            noIndexedDB();
+            if (url.indexOf("file:") === -1) {
+                noIndexedDB();
+            }
+            else {
+                try {
+                    var textureName = url.substring(5);
+                    img.src = URL.createObjectURL(BABYLON.FilesTextures[textureName]);
+                }
+                catch (e) {
+                    console.log("Error while trying to load texture: " + textureName);
+                    img.src = null;
+                }
+            }
         }
 
         return img;
@@ -210,6 +224,16 @@
         }
     };
 
+    BABYLON.Tools.ReadFile = function (fileToLoad, callback, progressCallBack) {
+        var reader = new FileReader();
+        reader.onload = function (e) {
+            callback(e.target.result);
+        };
+        reader.onprogress = progressCallBack;
+        // Asynchronous read
+        reader.readAsText(fileToLoad);
+    };
+
     // Misc.    
     BABYLON.Tools.isIE = function () {
         return window.ActiveXObject !== undefined;

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
Babylon/jscompaktor.bat


Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 2
babylon.1.7.js