sevan %!s(int64=8) %!d(string=hai) anos
pai
achega
20f2fe0cf8
Modificáronse 81 ficheiros con 4627 adicións e 5374 borrados
  1. 7 3
      .gitignore
  2. 24 15
      .vscode/settings.json
  3. 128 0
      Tools/DevLoader/BabylonLoader.js
  4. 58 24
      Tools/Gulp/config.json
  5. 3 2
      Tools/Gulp/gulp-appendSrcToVariable.js
  6. 108 109
      Tools/Gulp/gulpfile.js
  7. 0 1
      dist/materialsLibrary/babylon.gradientMaterial.min.js
  8. 0 1
      dist/materialsLibrary/babylon.lavaMaterial.min.js
  9. 0 1
      dist/materialsLibrary/babylon.normalMaterial.min.js
  10. 4053 4053
      dist/preview release/babylon.d.ts
  11. 15 0
      loaders/glTF/babylon.glTFFileLoader.js
  12. 1 0
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  13. 3 1
      loaders/OBJ/babylon.objFileLoader.js
  14. 1 0
      dist/preview release/loaders/babylon.objFileLoader.min.js
  15. 3 0
      loaders/STL/babylon.stlFileLoader.js
  16. 1 0
      dist/preview release/loaders/babylon.stlFileLoader.min.js
  17. 7 3
      dist/materialsLibrary/babylon.fireMaterial.js
  18. 0 0
      dist/preview release/materialsLibrary/babylon.fireMaterial.min.js
  19. 7 3
      dist/materialsLibrary/babylon.furMaterial.js
  20. 0 0
      dist/preview release/materialsLibrary/babylon.furMaterial.min.js
  21. 8 4
      dist/materialsLibrary/babylon.gradientMaterial.js
  22. 1 0
      dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js
  23. 7 3
      dist/materialsLibrary/babylon.gridMaterial.js
  24. 0 0
      dist/preview release/materialsLibrary/babylon.gridMaterial.min.js
  25. 8 4
      dist/materialsLibrary/babylon.lavaMaterial.js
  26. 1 0
      dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js
  27. 8 4
      dist/materialsLibrary/babylon.normalMaterial.js
  28. 1 0
      dist/preview release/materialsLibrary/babylon.normalMaterial.min.js
  29. 7 3
      dist/materialsLibrary/babylon.simpleMaterial.js
  30. 0 0
      dist/preview release/materialsLibrary/babylon.simpleMaterial.min.js
  31. 7 3
      dist/materialsLibrary/babylon.skyMaterial.js
  32. 0 0
      dist/preview release/materialsLibrary/babylon.skyMaterial.min.js
  33. 7 3
      dist/materialsLibrary/babylon.terrainMaterial.js
  34. 0 0
      dist/preview release/materialsLibrary/babylon.terrainMaterial.min.js
  35. 7 3
      dist/materialsLibrary/babylon.triPlanarMaterial.js
  36. 0 0
      dist/preview release/materialsLibrary/babylon.triPlanarMaterial.min.js
  37. 7 3
      dist/materialsLibrary/babylon.waterMaterial.js
  38. 0 0
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  39. 7 3
      dist/postProcessesLibrary/babylon.asciiArtPostProcess.js
  40. 0 0
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  41. 7 3
      dist/postProcessesLibrary/babylon.digitalRainPostProcess.js
  42. 0 0
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  43. 7 3
      dist/proceduralTexturesLibrary/babylon.brickProceduralTexture.js
  44. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js
  45. 7 3
      dist/proceduralTexturesLibrary/babylon.cloudProceduralTexture.js
  46. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js
  47. 7 3
      dist/proceduralTexturesLibrary/babylon.fireProceduralTexture.js
  48. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js
  49. 7 3
      dist/proceduralTexturesLibrary/babylon.grassProceduralTexture.js
  50. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js
  51. 7 3
      dist/proceduralTexturesLibrary/babylon.marbleProceduralTexture.js
  52. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js
  53. 7 3
      dist/proceduralTexturesLibrary/babylon.roadProceduralTexture.js
  54. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js
  55. 7 3
      dist/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.js
  56. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js
  57. 7 3
      dist/proceduralTexturesLibrary/babylon.woodProceduralTexture.js
  58. 0 0
      dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js
  59. 0 74
      loaders/OBJ/README.md
  60. 0 872
      loaders/OBJ/babylon.objFileLoader.ts
  61. 0 31
      loaders/config.json
  62. 0 41
      loaders/gulpfile.js
  63. 0 14
      loaders/package.json
  64. 3 1
      loaders/STL/babylon.stlFileLoader.ts
  65. 0 0
      loaders/src/glTF/README.md
  66. 3 1
      loaders/glTF/babylon.glTFBinaryExtension.ts
  67. 3 1
      loaders/glTF/babylon.glTFFileLoader.ts
  68. 3 1
      loaders/glTF/babylon.glTFFileLoaderExtension.ts
  69. 3 1
      loaders/glTF/babylon.glTFFileLoaderInterfaces.ts
  70. 3 1
      loaders/glTF/babylon.glTFFileLoaderUtils.ts
  71. 7 0
      loaders/src/tsconfig.json
  72. 4 14
      materialsLibrary/index.html
  73. 1 1
      materialsLibrary/src/gradient/babylon.gradientMaterial.ts
  74. 1 1
      materialsLibrary/src/lava/babylon.lavaMaterial.ts
  75. 1 1
      materialsLibrary/src/normal/babylon.normalMaterial.ts
  76. 5 5
      materialsLibrary/src/tsconfig.json
  77. 0 7
      materialsLibrary/tsconfig.json
  78. 12 8
      postProcessLibrary/index.html
  79. 0 0
      postProcessLibrary/src/tsconfig.json
  80. 20 23
      proceduralTexturesLibrary/index.html
  81. 0 0
      proceduralTexturesLibrary/src/tsconfig.json

+ 7 - 3
.gitignore

@@ -16,6 +16,10 @@ TestResults
 
 # javascript files
 src/**/*.js
+loaders/src/**/*.js
+materialsLibrary/src/**/*.js
+proceduralTexturesLibrary/src/**/*.js
+postProcessLibrary/src/**/*.js
 
 # Build results
 [Dd]ebug/
@@ -130,8 +134,8 @@ node_modules
 .idea
 
 # for VSCode
-/.vs
-/Playground/project.lock.json
+.vs
 .tempChromeProfileForDebug
 .temp
-*.js.map
+*.js.map
+*.js.fx

+ 24 - 15
.vscode/settings.json

@@ -1,20 +1,24 @@
 // Place your settings in this file to overwrite default and user settings.
+// "files.exclude": {
+//         "**/.git": true,
+//         "**/.svn": true,
+//         "**/.hg": true,
+//         "**/.DS_Store": true,
+//         "**/.vs": true,        
+//         "**/.tempChromeProfileForDebug": true,
+//         "**/node_modules": true,
+//         "**/temp": true,
+//         "**/.temp": true,
+//         "**/*.js.map": true,
+//         "**/*.fx.js": true,
+//         "**/*.js": { 
+//             "when":"$(basename).ts"
+//         }
+//     },
+
 {
     // Configure glob patterns for excluding files and folders.
-    "files.exclude": {
-        "**/.git": true,
-        "**/.svn": true,
-        "**/.hg": true,
-        "**/.DS_Store": true,
-        "**/.vs": true,        
-        "**/.tempChromeProfileForDebug": true,
-        "**/node_modules": true,
-        "**/temp": true,
-        "**/*.js.map": true,
-        "**/*.js": { 
-            "when":"$(basename).ts"
-        }
-    },
+    
     "files.associations": {
         "*.fx": "glsl"
     },
@@ -23,6 +27,11 @@
         "**/bower_components": true,
         "**/.vs": true,
         "**/.tempChromeProfileForDebug": true,
-        "**/.temp": true
+        "**/.temp": true,
+        "**/dist": true,
+        "**/*.map": true,
+        "**/*.js": { 
+             "when":"$(basename).ts"
+         }       
     }
 }

+ 128 - 0
Tools/DevLoader/BabylonLoader.js

@@ -0,0 +1,128 @@
+// Old Fashion Way for IE 11 Devs. Yes, that still exists ;-)
+
+var BABYLONDEVTOOLS;
+(function (BABYLONDEVTOOLS) {
+    
+    var getJson = function(url, callback, errorCallback) {
+        var xhr = new XMLHttpRequest();
+        xhr.open('GET', url);
+        xhr.onload = function () {
+            if (this.status >= 200 && this.status < 300) {
+                var data = JSON.parse(xhr.response);
+                callback(data)
+            } else {
+                errorCallback({
+                status: this.status,
+                statusText: xhr.statusText
+                });
+            }
+        };
+        xhr.onerror = function () {
+            errorCallback({
+                status: this.status,
+                statusText: xhr.statusText
+            });
+        };
+        xhr.send();
+    }
+
+    var Loader = (function () {
+        var queue;
+        var callback = null;
+
+        function Loader() {
+            queue = [];
+        }
+
+        Loader.prototype.onReady = function (callback) {
+            this.callback = callback;
+        }
+
+        Loader.prototype.dequeue = function () {
+            if (queue.length == 0) {
+                console.log('Scripts loaded');
+                BABYLON.Engine.ShadersRepository = "/src/Shaders/"; 
+                if (this.callback) {                    
+                    this.callback();
+                }
+                return;                
+            }
+
+            var url = queue.shift();
+            
+            var head = document.getElementsByTagName('head')[0];
+            var script = document.createElement('script');
+            script.type = 'text/javascript';
+            script.src = url;
+
+            var self = this;
+            script.onload = function() {
+                self.dequeue();
+            };
+            head.appendChild(script);
+        }
+
+        Loader.prototype.loadScript = function (url) {
+            queue.push(url);
+        }
+
+        Loader.prototype.loadScripts = function (urls) {
+            for (var i = 0; i< urls.length; i++) {
+                this.loadScript(urls[i]);
+            }
+        }
+
+        Loader.prototype.loadLibrary = function (library) {
+            var i = 0;
+            for (; i < library.files.length; i++) {
+                var file = library.files[i];
+                file = file.replace('.ts', '.js');
+                this.loadScript(file);
+            }
+
+            if (library.shaderFiles && library.shaderFiles.length > 0) {
+                var shaderFile = library.shaderFiles[0];
+                var endDirectoryIndex = shaderFile.lastIndexOf('/');
+                shaderFile = shaderFile.substring(0, endDirectoryIndex + 1);
+                shaderFile += library.output.replace('.js', '.js.fx');
+                this.loadScript(shaderFile);
+            }
+        }
+
+        Loader.prototype.loadModule = function (module) {
+            for (var i = 0; i< module.libraries.length; i++) {
+                this.loadLibrary(module.libraries[i]);
+            }
+        }
+
+        Loader.prototype.loadBJSScripts = function (settings) {
+            this.loadScripts(settings.core.files);
+            this.loadScripts(settings.extras.files);
+            
+            for (var i = 0; i< settings.modules.length; i++) {
+                this.loadModule(settings[settings.modules[i]]);
+            }
+        }
+
+        Loader.prototype.load = function () {
+            var self = this;
+            getJson('/Tools/Gulp/config.json',
+                function(data) {
+                    self.loadBJSScripts(data);
+                    self.dequeue();
+                },
+                function(reason) { 
+                    console.error(reason);
+                });
+
+        };
+
+        return Loader;
+    }());    
+
+    var loader = new Loader();
+    loader.load();
+
+    BABYLONDEVTOOLS.Loader = loader;
+
+})(BABYLONDEVTOOLS || (BABYLONDEVTOOLS = {}))

+ 58 - 24
Tools/Gulp/config.json

@@ -228,10 +228,12 @@
     ]
   },
 
+  "modules": ["materialsLibrary", "postProcessesLibrary", "proceduralTexturesLibrary", "loaders"],
+
   "materialsLibrary": {
     "libraries": [
       {
-        "file": "../../materialsLibrary/src/gradient/babylon.gradientMaterial.ts",
+        "files": ["../../materialsLibrary/src/gradient/babylon.gradientMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/gradient/gradient.vertex.fx",
           "../../materialsLibrary/src/gradient/gradient.fragment.fx"
@@ -239,7 +241,7 @@
         "output": "babylon.gradientMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/normal/babylon.normalMaterial.ts",
+        "files": ["../../materialsLibrary/src/normal/babylon.normalMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/normal/normal.vertex.fx",
           "../../materialsLibrary/src/normal/normal.fragment.fx"
@@ -247,7 +249,7 @@
         "output": "babylon.normalMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/lava/babylon.lavaMaterial.ts",
+        "files": ["../../materialsLibrary/src/lava/babylon.lavaMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/lava/lava.vertex.fx",
           "../../materialsLibrary/src/lava/lava.fragment.fx"
@@ -255,7 +257,7 @@
         "output": "babylon.lavaMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/simple/babylon.simpleMaterial.ts",
+        "files": ["../../materialsLibrary/src/simple/babylon.simpleMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/simple/simple.vertex.fx",
           "../../materialsLibrary/src/simple/simple.fragment.fx"
@@ -263,7 +265,7 @@
         "output": "babylon.simpleMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/water/babylon.waterMaterial.ts",
+        "files": ["../../materialsLibrary/src/water/babylon.waterMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/water/water.vertex.fx",
           "../../materialsLibrary/src/water/water.fragment.fx"
@@ -271,7 +273,7 @@
         "output": "babylon.waterMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/fire/babylon.fireMaterial.ts",
+        "files": ["../../materialsLibrary/src/fire/babylon.fireMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/fire/fire.vertex.fx",
           "../../materialsLibrary/src/fire/fire.fragment.fx"
@@ -279,7 +281,7 @@
         "output": "babylon.fireMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/fur/babylon.furMaterial.ts",
+        "files": ["../../materialsLibrary/src/fur/babylon.furMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/fur/fur.vertex.fx",
           "../../materialsLibrary/src/fur/fur.fragment.fx"
@@ -287,7 +289,7 @@
         "output": "babylon.furMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/terrain/babylon.terrainMaterial.ts",
+        "files": ["../../materialsLibrary/src/terrain/babylon.terrainMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/terrain/terrain.vertex.fx",
           "../../materialsLibrary/src/terrain/terrain.fragment.fx"
@@ -295,7 +297,7 @@
         "output": "babylon.terrainMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/triPlanar/babylon.triPlanarMaterial.ts",
+        "files": ["../../materialsLibrary/src/triPlanar/babylon.triPlanarMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/triPlanar/triplanar.vertex.fx",
           "../../materialsLibrary/src/triPlanar/triplanar.fragment.fx"
@@ -303,7 +305,7 @@
         "output": "babylon.triPlanarMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/sky/babylon.skyMaterial.ts",
+        "files": ["../../materialsLibrary/src/sky/babylon.skyMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/sky/sky.vertex.fx",
           "../../materialsLibrary/src/sky/sky.fragment.fx"
@@ -311,7 +313,7 @@
         "output": "babylon.skyMaterial.js"
       },
       {
-        "file": "../../materialsLibrary/src/grid/babylon.gridMaterial.ts",
+        "files": ["../../materialsLibrary/src/grid/babylon.gridMaterial.ts"],
         "shaderFiles": [
           "../../materialsLibrary/src/grid/grid.vertex.fx",
           "../../materialsLibrary/src/grid/grid.fragment.fx",
@@ -322,21 +324,22 @@
       }
     ],
     "build": {
-      "distOutputDirectory": "../../dist/materialsLibrary/"
+      "srcOutputDirectory": "../../materialsLibrary/",
+      "distOutputDirectory": "/materialsLibrary/"
     }
   },
 
   "postProcessesLibrary": {
       "libraries": [    
       {
-        "file": "../../postProcessLibrary/src/asciiArt/babylon.asciiArtPostProcess.ts",
+        "files": ["../../postProcessLibrary/src/asciiArt/babylon.asciiArtPostProcess.ts"],
         "shaderFiles": [
           "../../postProcessLibrary/src/asciiArt/asciiart.fragment.fx"
         ],
         "output": "babylon.asciiArtPostProcess.js"
       },
       {
-        "file": "../../postProcessLibrary/src/digitalRain/babylon.digitalRainPostProcess.ts",
+        "files": ["../../postProcessLibrary/src/digitalRain/babylon.digitalRainPostProcess.ts"],
         "shaderFiles": [
           "../../postProcessLibrary/src/digitalRain/digitalrain.fragment.fx"
         ],
@@ -344,63 +347,64 @@
       }
     ],
     "build": {
-      "distOutputDirectory": "../../dist/postProcessesLibrary/"
+      "srcOutputDirectory": "../../postProcessLibrary/",
+      "distOutputDirectory": "/postProcessesLibrary/"
     }
   },
 
   "proceduralTexturesLibrary": {
     "libraries": [
       {
-        "file": "../../proceduralTexturesLibrary/src/wood/babylon.woodProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/wood/babylon.woodProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/wood/woodProceduralTexture.fragment.fx"
         ],
         "output": "babylon.woodProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/fire/babylon.fireProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/fire/babylon.fireProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/fire/fireProceduralTexture.fragment.fx"
         ],
         "output": "babylon.fireProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/cloud/babylon.cloudProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/cloud/babylon.cloudProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/cloud/cloudProceduralTexture.fragment.fx"
         ],
         "output": "babylon.cloudProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/grass/babylon.grassProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/grass/babylon.grassProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/grass/grassProceduralTexture.fragment.fx"
         ],
         "output": "babylon.grassProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/road/babylon.roadProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/road/babylon.roadProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/road/roadProceduralTexture.fragment.fx"
         ],
         "output": "babylon.roadProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/brick/babylon.brickProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/brick/babylon.brickProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/brick/brickProceduralTexture.fragment.fx"
         ],
         "output": "babylon.brickProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/marble/babylon.marbleProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/marble/babylon.marbleProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/marble/marbleProceduralTexture.fragment.fx"
         ],
         "output": "babylon.marbleProceduralTexture.js"
       },
       {
-        "file": "../../proceduralTexturesLibrary/src/starfield/babylon.starfieldProceduralTexture.ts",
+        "files": ["../../proceduralTexturesLibrary/src/starfield/babylon.starfieldProceduralTexture.ts"],
         "shaderFiles": [
           "../../proceduralTexturesLibrary/src/starfield/starfieldProceduralTexture.fragment.fx"
         ],
@@ -408,7 +412,37 @@
       }
     ],
     "build": {
-      "distOutputDirectory": "../../dist/proceduralTexturesLibrary/"
+      "srcOutputDirectory": "../../proceduralTexturesLibrary/",      
+      "distOutputDirectory": "/proceduralTexturesLibrary/"
+    }
+  },
+
+  "loaders": {
+    "libraries": [
+     {
+      "files": ["../../loaders/src/STL/babylon.stlFileLoader.ts"],
+      "output": "babylon.stlFileLoader.js"
+    },
+
+    {
+      "files": ["../../loaders/src/OBJ/babylon.objFileLoader.ts"],
+      "output": "babylon.objFileLoader.js"
+    },
+
+    {
+      "files": [
+        "../../loaders/src/glTF/babylon.glTFFileLoaderInterfaces.ts",
+        "../../loaders/src/glTF/babylon.glTFFileLoader.ts",
+        "../../loaders/src/glTF/babylon.glTFFileLoaderUtils.ts",
+        "../../loaders/src/glTF/babylon.glTFFileLoaderExtension.ts",
+        "../../loaders/src/glTF/babylon.glTFBinaryExtension.ts"
+      ],
+      "output": "babylon.glTFFileLoader.js"
+    }],
+
+    "build": {
+      "srcOutputDirectory": "../../loaders/",
+      "distOutputDirectory": "/loaders/"
     }
   }
 }

+ 3 - 2
Tools/Gulp/gulp-appendSrcToVariable.js

@@ -7,7 +7,7 @@ var File = gutil.File;
 // Consts
 const PLUGIN_NAME = 'gulp-appendSrcToVariable';
 
-var appendSrcToVariable = function appendSrcToVariable(varName, asMap, namingCallback) {
+var appendSrcToVariable = function appendSrcToVariable(varName, namingCallback, output) {
 
     var content;
     var firstFile;
@@ -48,7 +48,8 @@ var appendSrcToVariable = function appendSrcToVariable(varName, asMap, namingCal
             return;
         }
 
-        var joinedPath = path.join(firstFile.base, varName);
+        var pathObject = path.parse(firstFile.path);
+        var joinedPath = path.join(pathObject.dir, output);
 
         var joinedFile = new File({
             cwd: firstFile.cwd,

+ 108 - 109
Tools/Gulp/gulpfile.js

@@ -55,7 +55,8 @@ var externalTsConfig = {
  * Shader Management.
  */
 function shadersName(filename) {
-    return filename.replace('.fragment', 'Pixel')
+    return path.basename(filename)
+        .replace('.fragment', 'Pixel')
         .replace('.vertex', 'Vertex')
         .replace('.fx', 'Shader');
 }
@@ -103,6 +104,67 @@ gulp.task("workers", function (cb) {
     cb();
 });
 
+/**
+ * Build tasks to concat minify uflify optimise the BJS js in different flavor (workers...).
+ */
+gulp.task("buildCore", ["shaders"], function () {
+    return merge2(
+        gulp.src(config.core.files).        
+            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
+        shadersStream,
+        includeShadersStream
+        )
+        .pipe(concat(config.build.minCoreFilename))
+        .pipe(cleants())
+        .pipe(replace(extendsSearchRegex, ""))
+        .pipe(replace(decorateSearchRegex, ""))
+        .pipe(addModuleExports("BABYLON"))
+        .pipe(uglify())
+        .pipe(optimisejs())
+        .pipe(gulp.dest(config.build.outputDirectory));
+});
+
+gulp.task("buildNoWorker", ["shaders"], function () {
+    return merge2(
+        gulp.src(config.core.files).        
+            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
+        gulp.src(config.extras.files).        
+            pipe(expect.real({ errorOnFailure: true }, config.extras.files)),
+        shadersStream,
+        includeShadersStream
+        )
+        .pipe(concat(config.build.minNoWorkerFilename))
+        .pipe(cleants())
+        .pipe(replace(extendsSearchRegex, ""))
+        .pipe(replace(decorateSearchRegex, ""))
+        .pipe(addModuleExports("BABYLON"))
+        .pipe(uglify())
+        .pipe(optimisejs())
+        .pipe(gulp.dest(config.build.outputDirectory));
+});
+
+gulp.task("build", ["workers", "shaders"], function () {
+    return merge2(
+        gulp.src(config.core.files).        
+            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
+        gulp.src(config.extras.files).        
+            pipe(expect.real({ errorOnFailure: true }, config.extras.files)),   
+        shadersStream,
+        includeShadersStream,
+        workersStream
+        )
+        .pipe(concat(config.build.filename))
+        .pipe(cleants())
+        .pipe(replace(extendsSearchRegex, ""))
+        .pipe(replace(decorateSearchRegex, ""))
+        .pipe(addModuleExports("BABYLON"))
+        .pipe(gulp.dest(config.build.outputDirectory))
+        .pipe(rename(config.build.minFilename))
+        .pipe(uglify())
+        .pipe(optimisejs())
+        .pipe(gulp.dest(config.build.outputDirectory));
+});
+
 /*
 * Compiles all typescript files and creating a js and a declaration file.
 */
@@ -142,21 +204,6 @@ gulp.task('typescript-compile', function () {
 });
 
 /**
- * External library Build (mat, post processes, ...).
- */
-gulp.task('materialsLibrary', function () {
-    return buildExternalLibraries(config.materialsLibrary);
-});
-
-gulp.task('postProcessesLibrary', function () {
-    return buildExternalLibraries(config.postProcessesLibrary);
-});
-
-gulp.task('proceduralTexturesLibrary', function () {
-    return buildExternalLibraries(config.proceduralTexturesLibrary);
-});
-
-/**
  * Helper methods to build external library (mat, post processes, ...).
  */
 var buildExternalLibraries = function(settings) {
@@ -168,100 +215,39 @@ var buildExternalLibraries = function(settings) {
 }
 
 var buildExternalLibrary= function(library, settings) {
-    var compilOutput = gulp.src(library.file, { base: '../../' })
+    var tsProcess = gulp.src(library.files, {base: settings.build.srcOutputDirectory})
         .pipe(sourcemaps.init())
         .pipe(typescript(externalTsConfig));
 
-    var js = compilOutput.js;        
-    var shader = gulp.src(library.shaderFiles)
-            .pipe(uncommentShader())
-            .pipe(appendSrcToVariable("BABYLON.Effect.ShadersStore", true, shadersName));
+    var shader = gulp.src(library.shaderFiles || [], {base: settings.build.srcOutputDirectory} )
+            .pipe(uncommentShader())            
+            .pipe(appendSrcToVariable("BABYLON.Effect.ShadersStore", shadersName, library.output + '.fx'))
+            .pipe(gulp.dest(settings.build.srcOutputDirectory));
 
-    var fulljs = merge2(js, shader)
-        .pipe(concat(library.output));
-
-    var unminifiedAndMaps = fulljs.pipe(sourcemaps.write('.temp', {
-                includeContent:false,
-                sourceRoot: function (file) {
-                    return '../';
+    var dev = tsProcess.js.pipe(sourcemaps.write("./", {
+                includeContent:false, 
+                sourceRoot: (filePath) => {
+                    return ''; 
                 }
             }))
-        .pipe(gulp.dest(settings.build.distOutputDirectory));
+            .pipe(gulp.dest(settings.build.srcOutputDirectory));
 
-    var minified = fulljs
+    var outputDirectory = config.build.outputDirectory + settings.build.distOutputDirectory;
+    var dist = merge2(tsProcess.js, shader)
+        .pipe(concat(library.output))
+        .pipe(gulp.dest(outputDirectory))
         .pipe(cleants())
         .pipe(replace(extendsSearchRegex, ""))
         .pipe(replace(decorateSearchRegex, ""))
         .pipe(rename({extname: ".min.js"}))
         .pipe(uglify())
         .pipe(optimisejs())
-        .pipe(gulp.dest(settings.build.distOutputDirectory));
+        .pipe(gulp.dest(outputDirectory));
 
-    return merge2(unminifiedAndMaps, minified);
+    return merge2(dev, dist);
 }
 
 /**
- * Build tasks to concat minify uflify optimise the BJS js in different flavor (workers...).
- */
-gulp.task("buildCore", ["shaders"], function () {
-    return merge2(
-        gulp.src(config.core.files).        
-            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
-        shadersStream,
-        includeShadersStream
-        )
-        .pipe(concat(config.build.minCoreFilename))
-        .pipe(cleants())
-        .pipe(replace(extendsSearchRegex, ""))
-        .pipe(replace(decorateSearchRegex, ""))
-        .pipe(addModuleExports("BABYLON"))
-        .pipe(uglify())
-        .pipe(optimisejs())
-        .pipe(gulp.dest(config.build.outputDirectory));
-});
-
-gulp.task("buildNoWorker", ["shaders"], function () {
-    return merge2(
-        gulp.src(config.core.files).        
-            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
-        gulp.src(config.extras.files).        
-            pipe(expect.real({ errorOnFailure: true }, config.extras.files)),
-        shadersStream,
-        includeShadersStream
-        )
-        .pipe(concat(config.build.minNoWorkerFilename))
-        .pipe(cleants())
-        .pipe(replace(extendsSearchRegex, ""))
-        .pipe(replace(decorateSearchRegex, ""))
-        .pipe(addModuleExports("BABYLON"))
-        .pipe(uglify())
-        .pipe(optimisejs())
-        .pipe(gulp.dest(config.build.outputDirectory));
-});
-
-gulp.task("build", ["workers", "shaders"], function () {
-    return merge2(
-        gulp.src(config.core.files).        
-            pipe(expect.real({ errorOnFailure: true }, config.core.files)),
-        gulp.src(config.extras.files).        
-            pipe(expect.real({ errorOnFailure: true }, config.extras.files)),   
-        shadersStream,
-        includeShadersStream,
-        workersStream
-        )
-        .pipe(concat(config.build.filename))
-        .pipe(cleants())
-        .pipe(replace(extendsSearchRegex, ""))
-        .pipe(replace(decorateSearchRegex, ""))
-        .pipe(addModuleExports("BABYLON"))
-        .pipe(gulp.dest(config.build.outputDirectory))
-        .pipe(rename(config.build.minFilename))
-        .pipe(uglify())
-        .pipe(optimisejs())
-        .pipe(gulp.dest(config.build.outputDirectory));
-});
-
-/**
  * The default task, concat and min the main BJS files.
  */
 gulp.task('default', function (cb) {
@@ -275,9 +261,21 @@ gulp.task("typescript", function (cb) {
     runSequence("typescript-compile", "default", cb);
 });
 
-gulp.task("typescript-libraries", ["materialsLibrary", "postProcessesLibrary", "proceduralTexturesLibrary"], function () {
+/**
+ * Dynamic module creation.
+ */
+config.modules.map(function (module) {
+    gulp.task(module, function () {
+        return buildExternalLibraries(config[module]);
+    });
+});
+
+gulp.task("typescript-libraries", config.modules, function () {
 });
 
+/**
+ * Do it all.
+ */
 gulp.task("typescript-all", function (cb) {
     runSequence("typescript", "typescript-libraries", cb);
 });
@@ -285,24 +283,25 @@ gulp.task("typescript-all", function (cb) {
 /**
  * Watch ts files and fire repective tasks.
  */
-gulp.task('watch', ['typescript-compile'], function () {
+gulp.task('watch', [], function () {
     var tasks = [gulp.watch(config.core.typescript, ['typescript-compile'])];
 
-    config.materialsLibrary.libraries.map(function (material) {
-        tasks.push(gulp.watch(material.file, () => buildExternalLibrary(material, config.materialsLibrary)));
-        tasks.push(gulp.watch(material.shaderFiles, () => buildExternalLibrary(material, config.materialsLibrary)));
-    });
-
-    config.postProcessesLibrary.libraries.map(function (postProcess) {
-        tasks.push(gulp.watch(postProcess.file, buildExternalLibrary(postProcess, config.postProcessesLibrary)));
-        tasks.push(gulp.watch(postProcess.shaderFiles, buildExternalLibrary(postProcess, config.postProcessesLibrary)));
-    });
-
-    config.proceduralTexturesLibrary.libraries.map(function (proceduralTexture) {
-        tasks.push(gulp.watch(proceduralTexture.file, buildExternalLibrary(proceduralTexture, config.proceduralTexturesLibrary)));
-        tasks.push(gulp.watch(proceduralTexture.shaderFiles, buildExternalLibrary(proceduralTexture, config.proceduralTexturesLibrary)));
+    config.modules.map(function (module) { 
+        config[module].libraries.map(function (library) {
+            
+            tasks.push(gulp.watch(library.files, function() { 
+                console.log(library.output);
+                return buildExternalLibrary(library, config[module])
+                .pipe(debug()); 
+            }));
+            tasks.push(gulp.watch(library.shaderFiles, function() { 
+                console.log(library.output);
+                return buildExternalLibrary(library, config[module])
+                .pipe(debug()) 
+            }));
+        }); 
     });
-
+    
     return tasks;
 });
 

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1
dist/materialsLibrary/babylon.gradientMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1
dist/materialsLibrary/babylon.lavaMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 1
dist/materialsLibrary/babylon.normalMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 4053 - 4053
dist/preview release/babylon.d.ts


+ 15 - 0
loaders/glTF/babylon.glTFFileLoader.js

@@ -1,3 +1,4 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     /**
@@ -89,6 +90,9 @@ var BABYLON;
     var EBlendingFunction = BABYLON.EBlendingFunction;
 })(BABYLON || (BABYLON = {}));
 
+//# sourceMappingURL=babylon.glTFFileLoaderInterfaces.js.map
+
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     /**
@@ -1496,6 +1500,9 @@ var BABYLON;
     BABYLON.SceneLoader.RegisterPlugin(new GLTFFileLoader());
 })(BABYLON || (BABYLON = {}));
 
+//# sourceMappingURL=babylon.glTFFileLoader.js.map
+
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     /**
@@ -1696,6 +1703,9 @@ var BABYLON;
     BABYLON.GLTFUtils = GLTFUtils;
 })(BABYLON || (BABYLON = {}));
 
+//# sourceMappingURL=babylon.glTFFileLoaderUtils.js.map
+
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     var GLTFFileLoaderExtension = (function () {
@@ -1815,6 +1825,9 @@ var BABYLON;
     BABYLON.GLTFFileLoaderExtension = GLTFFileLoaderExtension;
 })(BABYLON || (BABYLON = {}));
 
+//# sourceMappingURL=babylon.glTFFileLoaderExtension.js.map
+
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var __extends = (this && this.__extends) || function (d, b) {
     for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
     function __() { this.constructor = d; }
@@ -1955,3 +1968,5 @@ var BABYLON;
     }());
     BABYLON.GLTFFileLoader.RegisterExtension(new GLTFBinaryExtension());
 })(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.glTFBinaryExtension.js.map

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 3 - 1
loaders/OBJ/babylon.objFileLoader.js

@@ -1,4 +1,4 @@
-/// <reference path="../../dist/preview release/babylon.d.ts"/>
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     /**
@@ -739,3 +739,5 @@ var BABYLON;
     //Add this loader into the register plugin
     BABYLON.SceneLoader.RegisterPlugin(new OBJFileLoader());
 })(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.objFileLoader.js.map

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 3 - 0
loaders/STL/babylon.stlFileLoader.js

@@ -1,3 +1,4 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     var STLFileLoader = (function () {
@@ -78,3 +79,5 @@ var BABYLON;
     BABYLON.STLFileLoader = STLFileLoader;
     BABYLON.SceneLoader.RegisterPlugin(new STLFileLoader());
 })(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.stlFileLoader.js.map

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/loaders/babylon.stlFileLoader.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.fireMaterial.js


dist/materialsLibrary/babylon.fireMaterial.min.js → dist/preview release/materialsLibrary/babylon.fireMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.furMaterial.js


dist/materialsLibrary/babylon.furMaterial.min.js → dist/preview release/materialsLibrary/babylon.furMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8 - 4
dist/materialsLibrary/babylon.gradientMaterial.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/materialsLibrary/babylon.gradientMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.gridMaterial.js


dist/materialsLibrary/babylon.gridMaterial.min.js → dist/preview release/materialsLibrary/babylon.gridMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8 - 4
dist/materialsLibrary/babylon.lavaMaterial.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/materialsLibrary/babylon.lavaMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8 - 4
dist/materialsLibrary/babylon.normalMaterial.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 0
dist/preview release/materialsLibrary/babylon.normalMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.simpleMaterial.js


dist/materialsLibrary/babylon.simpleMaterial.min.js → dist/preview release/materialsLibrary/babylon.simpleMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.skyMaterial.js


dist/materialsLibrary/babylon.skyMaterial.min.js → dist/preview release/materialsLibrary/babylon.skyMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.terrainMaterial.js


dist/materialsLibrary/babylon.terrainMaterial.min.js → dist/preview release/materialsLibrary/babylon.terrainMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.triPlanarMaterial.js


dist/materialsLibrary/babylon.triPlanarMaterial.min.js → dist/preview release/materialsLibrary/babylon.triPlanarMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/materialsLibrary/babylon.waterMaterial.js


dist/materialsLibrary/babylon.waterMaterial.min.js → dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/postProcessesLibrary/babylon.asciiArtPostProcess.js


dist/postProcessesLibrary/babylon.asciiArtPostProcess.min.js → dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/postProcessesLibrary/babylon.digitalRainPostProcess.js


dist/postProcessesLibrary/babylon.digitalRainPostProcess.min.js → dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.brickProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.cloudProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.fireProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.grassProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.marbleProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.roadProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 7 - 3
dist/proceduralTexturesLibrary/babylon.woodProceduralTexture.js


dist/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js → dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js


+ 0 - 74
loaders/OBJ/README.md

@@ -1,74 +0,0 @@
-# Babylon.js .obj File Loader
-
-#[Demo](http://www.babylonjs-playground.com/#28YUR5)
-To use it, you just have to reference the loader file:
-
-```
-<script src="babylon.2.1.js"></script>
-<script src="babylon.objFileLoader.js"></script>
-```
-
-Babylon.js will know how to load the obj file and its mtl file automatically: 
-```
-BABYLON.SceneLoader.Load("/assets/", "batman.obj", engine, function (newScene) { 
-   // ...
-});
-```
-```
-var loader = new BABYLON.AssetsManager(scene);
-var batman = loader.addMeshTask("batman", "", "assets/", "batman.obj");
-```
-```
-BABYLON.SceneLoader.ImportMesh("batmanface", "", "batman.obj", scene, function (meshes) { 
-   // ...
-});
-```
-
-## Good things to know
-* Your model doesn't have to be triangulated, as this loader will do it automatically.
-* A Babylon.Mesh will be created for each object/group
-* The obj model should be exported with -Z axis forward, and Y axis upward to be compatible with Babylon.js
-
-![Axis](http://geomorph.sourceforge.net/preview/axes.jpg)
-
-* By default, due to optimization in the code for loading time, UVs problems can appear, like this :
-
-![Batman UVs problem](http://i.imgur.com/vjWKNRK.png)
-
-If you meet this problem, set the variable 
-```
-BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true;
-```
-Then, you'll have a better texture, but with a longer loading.
-
-![Batman UVs ok](http://i.imgur.com/Dajwlvq.png)
-
-## Supported
-* Object/group
-* Faces
-    * triangles
-    * quads
-    * polygons
-* Colors
-    * diffuseColor
-    * ambientColor
-    * specularColor
-    * specularPower
-    * alpha
-* Textures
-    * ambientTexture
-    * diffuseTexture
-    * specularTexture
-    * bumpTexture
-    * opacityTexture
-* Multimaterial
-	* For each material defined in the same mesh, it creates a new BABYLON.Mesh.
-	* The name of the created BABYLON.Mesh follows this syntax: meshName_mmX 
-	* X is the nth BABYLON.Mesh created with this method
-
-    
-## Not supported currently
-* Smoothing groups (s parameter in OBJ file)
-* Illumination (illum parameter in MTL file)
-* The differents options for loading textures in MTL file.
-* A good description about MTL file and his options could be found here: http://paulbourke.net/dataformats/mtl/

+ 0 - 872
loaders/OBJ/babylon.objFileLoader.ts

@@ -1,872 +0,0 @@
-/// <reference path="../../dist/preview release/babylon.d.ts"/>
-
-module BABYLON {
-
-    /**
-     * Class reading and parsing the MTL file bundled with the obj file.
-     */
-    export class MTLFileLoader {
-
-        // All material loaded from the mtl will be set here
-        public materials: BABYLON.StandardMaterial[] = [];
-
-        /**
-         * This function will read the mtl file and create each material described inside
-         * This function could be improve by adding :
-         * -some component missing (Ni, Tf...)
-         * -including the specific options available
-         *
-         * @param scene
-         * @param data
-         * @param rootUrl
-         */
-        public parseMTL = function (scene: BABYLON.Scene, data: string, rootUrl: string) {
-            //Split the lines from the file
-            var lines = data.split('\n');
-            //Space char
-            var delimiter_pattern = /\s+/;
-            //Array with RGB colors
-            var color: number[];
-            //New material
-            var material: BABYLON.StandardMaterial;
-
-            //Look at each line
-            for (var i = 0; i < lines.length; i++) {
-                var line = lines[i].trim();
-
-                // Blank line or comment
-                if (line.length === 0 || line.charAt(0) === '#') {
-                    continue;
-                }
-
-                //Get the first parameter (keyword)
-                var pos = line.indexOf(' ');
-                var key = (pos >= 0) ? line.substring(0, pos) : line;
-                key = key.toLowerCase();
-
-                //Get the data following the key
-                var value: any = (pos >= 0) ? line.substring(pos + 1).trim() : "";
-
-                //This mtl keyword will create the new material
-                if (key === "newmtl") {
-                    //Check if it is the first material.
-                    // Materials specifications are described after this keyword.
-                    if (material) {
-                        //Add the previous material in the material array.
-                        this.materials.push(material);
-                    }
-                    //Create a new material.
-                    // value is the name of the material read in the mtl file
-                    material = new BABYLON.StandardMaterial(value, scene);
-                } else if (key === "kd") {
-                    // Diffuse color (color under white light) using RGB values
-
-                    //value  = "r g b"
-                    color = <number[]>value.split(delimiter_pattern, 3);
-                    //color = [r,g,b]
-                    //Set tghe color into the material
-                    material.diffuseColor = BABYLON.Color3.FromArray(color);
-                } else if (key === "ka") {
-                    // Ambient color (color under shadow) using RGB values
-
-                    //value = "r g b"
-                    color = <number[]>value.split(delimiter_pattern, 3);
-                    //color = [r,g,b]
-                    //Set tghe color into the material
-                    material.ambientColor = BABYLON.Color3.FromArray(color);
-                } else if (key === "ks") {
-                    // Specular color (color when light is reflected from shiny surface) using RGB values
-
-                    //value = "r g b"
-                    color = <number[]>value.split(delimiter_pattern, 3);
-                    //color = [r,g,b]
-                    //Set the color into the material
-                    material.specularColor = BABYLON.Color3.FromArray(color);
-                } else if (key === "ns") {
-
-                    //value = "Integer"
-                    material.specularPower = value;
-                } else if (key === "d") {
-                    //d is dissolve for current material. It mean alpha for BABYLON
-                    material.alpha = value;
-
-                    //Texture
-                    //This part can be improved by adding the possible options of texture
-                } else if (key === "map_ka") {
-                    // ambient texture map with a loaded image
-                    //We must first get the folder of the image
-                    material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
-                } else if (key === "map_kd") {
-                    // Diffuse texture map with a loaded image
-                    material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
-                } else if (key === "map_ks") {
-                    // Specular texture map with a loaded image
-                    //We must first get the folder of the image
-                    material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
-                } else if (key === "map_ns") {
-                    //Specular
-                    //Specular highlight component
-                    //We must first get the folder of the image
-                    //
-                    //Not supported by BABYLON
-                    //
-                    //    continue;
-                } else if (key === "map_bump") {
-                    //The bump texture
-                    material.bumpTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
-                } else if (key === "map_d") {
-                    // The dissolve of the material
-                    material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
-
-
-                    //Options for illumination
-                } else if (key === "illum") {
-                    //Illumination
-                    if (value === "0") {
-                        //That mean Kd == Kd
-                    } else if (value === "1") {
-                        //Color on and Ambient on
-                    } else if (value === "2") {
-                        //Highlight on
-                    } else if (value === "3") {
-                        //Reflection on and Ray trace on
-                    } else if (value === "4") {
-                        //Transparency: Glass on, Reflection: Ray trace on
-                    } else if (value === "5") {
-                        //Reflection: Fresnel on and Ray trace on
-                    } else if (value === "6") {
-                        //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
-                    } else if (value === "7") {
-                        //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
-                    } else if (value === "8") {
-                        //Reflection on and Ray trace off
-                    } else if (value === "9") {
-                        //Transparency: Glass on, Reflection: Ray trace off
-                    } else if (value === "10") {
-                        //Casts shadows onto invisible surfaces
-                    }
-                } else {
-                    // console.log("Unhandled expression at line : " + i +'\n' + "with value : " + line);
-                }
-            }
-            //At the end of the file, add the last material
-            this.materials.push(material);
-        }
-
-        /**
-         * Gets the texture for the material.
-         * 
-         * If the material is imported from input file,
-         * We sanitize the url to ensure it takes the textre from aside the material.
-         * 
-         * @param rootUrl The root url to load from
-         * @param value The value stored in the mtl
-         * @return The Texture
-         */
-        private static _getTexture(rootUrl: string, value: string, scene: Scene): Texture {
-            var url = rootUrl;
-            // Load from input file.
-            if (rootUrl === "file:") {
-                var lastDelimiter = value.lastIndexOf("\\");
-                if (lastDelimiter === -1) {
-                    lastDelimiter = value.lastIndexOf("/");
-                }
-
-                if (lastDelimiter > -1) {
-                    url += value.substr(lastDelimiter + 1);
-                }
-                else {
-                    url += value;
-                }
-            }
-            // Not from input file.
-            else {
-                url += value;
-            }
-
-            return new BABYLON.Texture(url, scene);
-        }
-    }
-
-    export class OBJFileLoader implements ISceneLoaderPlugin {
-
-        public static OPTIMIZE_WITH_UV = false;
-
-        public extensions = ".obj";
-        public obj = /^o/;
-        public group = /^g/;
-        public mtllib = /^mtllib /;
-        public usemtl = /^usemtl /;
-        public smooth = /^s /;
-        public vertexPattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
-        // vn float float float
-        public normalPattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
-        // vt float float
-        public uvPattern = /vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
-        // f vertex vertex vertex ...
-        public facePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/;
-        // f vertex/uvs vertex/uvs vertex/uvs ...
-        public facePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
-        // f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal ...
-        public facePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
-        // f vertex//normal vertex//normal vertex//normal ...
-        public facePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;
-
-
-        /**
-         * Calls synchronously the MTL file attached to this obj.
-         * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
-         * Without this function materials are not displayed in the first frame (but displayed after).
-         * In consequence it is impossible to get material information in your HTML file
-         *
-         * @param url The URL of the MTL file
-         * @param rootUrl
-         * @param onSuccess Callback function to be called when the MTL file is loaded
-         * @private
-         */
-        private _loadMTL(url: string, rootUrl: string, onSuccess: (response: string) => any) {
-            //The complete path to the mtl file
-            var pathOfFile = BABYLON.Tools.BaseUrl + rootUrl + url;
-
-            // Loads through the babylon tools to allow fileInput search.
-            BABYLON.Tools.LoadFile(pathOfFile, 
-                onSuccess, 
-                null, 
-                null, 
-                false, 
-                () => { console.warn("Error - Unable to load " + pathOfFile); });
-        }
-
-        public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]): boolean {
-            //get the meshes from OBJ file
-            var loadedMeshes = this._parseSolid(meshesNames, scene, data, rootUrl);
-            //Push meshes from OBJ file into the variable mesh of this function
-            if (meshes) {
-                loadedMeshes.forEach(function (mesh) {
-                    meshes.push(mesh);
-                });
-            }
-            return true;
-        }
-
-        public load(scene: Scene, data: string, rootUrl: string): boolean {
-            //Get the 3D model
-            return this.importMesh(null, scene, data, rootUrl, null, null, null);
-        }
-
-        /**
-         * Read the OBJ file and create an Array of meshes.
-         * Each mesh contains all information given by the OBJ and the MTL file.
-         * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
-         *
-         * @param meshesNames
-         * @param scene BABYLON.Scene The scene where are displayed the data
-         * @param data String The content of the obj file
-         * @param rootUrl String The path to the folder
-         * @returns Array<AbstractMesh>
-         * @private
-         */
-        private _parseSolid(meshesNames: any, scene: BABYLON.Scene, data: string, rootUrl: string): Array<AbstractMesh> {
-
-            var positions: Array<BABYLON.Vector3> = [];      //values for the positions of vertices
-            var normals: Array<BABYLON.Vector3> = [];      //Values for the normals
-            var uvs: Array<BABYLON.Vector2> = [];      //Values for the textures
-            var meshesFromObj: Array<any> = [];      //[mesh] Contains all the obj meshes
-            var handledMesh: any;      //The current mesh of meshes array
-            var indicesForBabylon: Array<number> = [];      //The list of indices for VertexData
-            var wrappedPositionForBabylon: Array<BABYLON.Vector3> = [];      //The list of position in vectors
-            var wrappedUvsForBabylon: Array<BABYLON.Vector2> = [];      //Array with all value of uvs to match with the indices
-            var wrappedNormalsForBabylon: Array<BABYLON.Vector3> = [];      //Array with all value of normals to match with the indices
-            var tuplePosNorm: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }> = [];      //Create a tuple with indice of Position, Normal, UV  [pos, norm, uvs]
-            var curPositionInIndices = 0;
-            var hasMeshes: Boolean = false;   //Meshes are defined in the file
-            var unwrappedPositionsForBabylon: Array<number> = [];      //Value of positionForBabylon w/o Vector3() [x,y,z]
-            var unwrappedNormalsForBabylon: Array<number> = [];      //Value of normalsForBabylon w/o Vector3()  [x,y,z]
-            var unwrappedUVForBabylon: Array<number> = [];      //Value of uvsForBabylon w/o Vector3()      [x,y,z]
-            var triangles: Array<string> = [];      //Indices from new triangles coming from polygons
-            var materialNameFromObj: string = "";      //The name of the current material
-            var fileToLoad: string = "";      //The name of the mtlFile to load
-            var materialsFromMTLFile: MTLFileLoader = new MTLFileLoader();
-            var objMeshName: string = "";      //The name of the current obj mesh
-            var increment: number = 1;      //Id for meshes created by the multimaterial
-            var isFirstMaterial: boolean = true;
-
-            /**
-             * Search for obj in the given array.
-             * This function is called to check if a couple of data already exists in an array.
-             *
-             * If found, returns the index of the founded tuple index. Returns -1 if not found
-             * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
-             * @param obj Array<number>
-             * @returns {boolean}
-             */
-            var isInArray = (arr: Array<{ normals: Array<number>; idx: Array<number> }>, obj: Array<number>) => {
-                if (!arr[obj[0]]) arr[obj[0]] = { normals: [], idx: [] };
-                var idx = arr[obj[0]].normals.indexOf(obj[1]);
-
-                return idx === -1 ? -1 : arr[obj[0]].idx[idx];
-            };
-            var isInArrayUV = (arr: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }>, obj: Array<number>) => {
-                if (!arr[obj[0]]) arr[obj[0]] = { normals: [], idx: [], uv: [] };
-                var idx = arr[obj[0]].normals.indexOf(obj[1]);
-
-                if (idx != 1 && (obj[2] == arr[obj[0]].uv[idx])) {
-                    return arr[obj[0]].idx[idx];
-                }
-                return -1;
-            };
-
-            /**
-             * This function set the data for each triangle.
-             * Data are position, normals and uvs
-             * If a tuple of (position, normal) is not set, add the data into the corresponding array
-             * If the tuple already exist, add only their indice
-             *
-             * @param indicePositionFromObj Integer The index in positions array
-             * @param indiceUvsFromObj Integer The index in uvs array
-             * @param indiceNormalFromObj Integer The index in normals array
-             * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
-             * @param textureVectorFromOBJ Vector3 The value of uvs
-             * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
-             */
-            var setData = (indicePositionFromObj: number, indiceUvsFromObj: number, indiceNormalFromObj: number, positionVectorFromOBJ: BABYLON.Vector3, textureVectorFromOBJ: BABYLON.Vector2, normalsVectorFromOBJ: BABYLON.Vector3) => {
-                //Check if this tuple already exists in the list of tuples
-                var _index: number;
-                if (OBJFileLoader.OPTIMIZE_WITH_UV) {
-                    _index = isInArrayUV(
-                        tuplePosNorm,
-                        [
-                            indicePositionFromObj,
-                            indiceNormalFromObj,
-                            indiceUvsFromObj
-                        ]
-                    );
-                }
-                else {
-                    _index = isInArray(
-                        tuplePosNorm,
-                        [
-                            indicePositionFromObj,
-                            indiceNormalFromObj
-                        ]
-                    );
-                }
-
-                //If it not exists
-                if (_index == -1) {
-                    //Add an new indice.
-                    //The array of indices is only an array with his length equal to the number of triangles - 1.
-                    //We add vertices data in this order
-                    indicesForBabylon.push(wrappedPositionForBabylon.length);
-                    //Push the position of vertice for Babylon
-                    //Each element is a BABYLON.Vector3(x,y,z)
-                    wrappedPositionForBabylon.push(positionVectorFromOBJ);
-                    //Push the uvs for Babylon
-                    //Each element is a BABYLON.Vector3(u,v)
-                    wrappedUvsForBabylon.push(textureVectorFromOBJ);
-                    //Push the normals for Babylon
-                    //Each element is a BABYLON.Vector3(x,y,z)
-                    wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
-                    //Add the tuple in the comparison list
-                    tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
-                    tuplePosNorm[indicePositionFromObj].idx.push(curPositionInIndices++);
-                    if (OBJFileLoader.OPTIMIZE_WITH_UV) tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);
-                } else {
-                    //The tuple already exists
-                    //Add the index of the already existing tuple
-                    //At this index we can get the value of position, normal and uvs of vertex
-                    indicesForBabylon.push(_index);
-                }
-            };
-
-            /**
-             * Transform BABYLON.Vector() object onto 3 digits in an array
-             */
-            var unwrapData = () => {
-                //Every array has the same length
-                for (var l = 0; l < wrappedPositionForBabylon.length; l++) {
-                    //Push the x, y, z values of each element in the unwrapped array
-                    unwrappedPositionsForBabylon.push(wrappedPositionForBabylon[l].x, wrappedPositionForBabylon[l].y, wrappedPositionForBabylon[l].z);
-                    unwrappedNormalsForBabylon.push(wrappedNormalsForBabylon[l].x, wrappedNormalsForBabylon[l].y, wrappedNormalsForBabylon[l].z);
-                    unwrappedUVForBabylon.push(wrappedUvsForBabylon[l].x, wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
-                }
-                // Reset arrays for the next new meshes
-                wrappedPositionForBabylon = [];
-                wrappedNormalsForBabylon = [];
-                wrappedUvsForBabylon = [];
-                tuplePosNorm = [];
-                curPositionInIndices = 0;
-            };
-
-            /**
-             * Create triangles from polygons by recursion
-             * The best to understand how it works is to draw it in the same time you get the recursion.
-             * It is important to notice that a triangle is a polygon
-             * We get 4 patterns of face defined in OBJ File :
-             * facePattern1 = ["1","2","3","4","5","6"]
-             * facePattern2 = ["1/1","2/2","3/3","4/4","5/5","6/6"]
-             * facePattern3 = ["1/1/1","2/2/2","3/3/3","4/4/4","5/5/5","6/6/6"]
-             * facePattern4 = ["1//1","2//2","3//3","4//4","5//5","6//6"]
-             * Each pattern is divided by the same method
-             * @param face Array[String] The indices of elements
-             * @param v Integer The variable to increment
-             */
-            var getTriangles = (face: Array<string>, v: number) => {
-                //Work for each element of the array
-                if (v + 1 < face.length) {
-                    //Add on the triangle variable the indexes to obtain triangles
-                    triangles.push(face[0], face[v], face[v + 1]);
-                    //Incrementation for recursion
-                    v += 1;
-                    //Recursion
-                    getTriangles(face, v);
-                }
-
-                //Result obtained after 2 iterations:
-                //Pattern1 => triangle = ["1","2","3","1","3","4"];
-                //Pattern2 => triangle = ["1/1","2/2","3/3","1/1","3/3","4/4"];
-                //Pattern3 => triangle = ["1/1/1","2/2/2","3/3/3","1/1/1","3/3/3","4/4/4"];
-                //Pattern4 => triangle = ["1//1","2//2","3//3","1//1","3//3","4//4"];
-            };
-
-            /**
-             * Create triangles and push the data for each polygon for the pattern 1
-             * In this pattern we get vertice positions
-             * @param face
-             * @param v
-             */
-            var setDataForCurrentFaceWithPattern1 = (face: Array<string>, v: number) => {
-                //Get the indices of triangles for each polygon
-                getTriangles(face, v);
-                //For each element in the triangles array.
-                //This var could contains 1 to an infinity of triangles
-                for (var k = 0; k < triangles.length; k++) {
-                    // Set position indice
-                    var indicePositionFromObj = parseInt(triangles[k]) - 1;
-
-                    setData(
-                        indicePositionFromObj,
-                        0, 0,                                           //In the pattern 1, normals and uvs are not defined
-                        positions[indicePositionFromObj],               //Get the vectors data
-                        BABYLON.Vector2.Zero(), BABYLON.Vector3.Up()    //Create default vectors
-                    );
-                }
-                //Reset variable for the next line
-                triangles = [];
-            };
-
-
-            /**
-             * Create triangles and push the data for each polygon for the pattern 2
-             * In this pattern we get vertice positions and uvsu
-             * @param face
-             * @param v
-             */
-            var setDataForCurrentFaceWithPattern2 = (face: Array<string>, v: number) => {
-                //Get the indices of triangles for each polygon
-                getTriangles(face, v);
-                for (var k = 0; k < triangles.length; k++) {
-                    //triangle[k] = "1/1"
-                    //Split the data for getting position and uv
-                    var point = triangles[k].split("/"); // ["1", "1"]
-                    //Set position indice
-                    var indicePositionFromObj = parseInt(point[0]) - 1;
-                    //Set uv indice
-                    var indiceUvsFromObj = parseInt(point[1]) - 1;
-
-                    setData(
-                        indicePositionFromObj,
-                        indiceUvsFromObj,
-                        0,                                  //Default value for normals
-                        positions[indicePositionFromObj],   //Get the values for each element
-                        uvs[indiceUvsFromObj],
-                        BABYLON.Vector3.Up()                //Default value for normals
-                    );
-                }
-
-                //Reset variable for the next line
-                triangles = [];
-            };
-
-            /**
-             * Create triangles and push the data for each polygon for the pattern 3
-             * In this pattern we get vertice positions, uvs and normals
-             * @param face
-             * @param v
-             */
-            var setDataForCurrentFaceWithPattern3 = (face: Array<string>, v: number) => {
-                //Get the indices of triangles for each polygon
-                getTriangles(face, v);
-
-                for (var k = 0; k < triangles.length; k++) {
-                    //triangle[k] = "1/1/1"
-                    //Split the data for getting position, uv, and normals
-                    var point = triangles[k].split("/"); // ["1", "1", "1"]
-                    // Set position indice
-                    var indicePositionFromObj = parseInt(point[0]) - 1;
-                    // Set uv indice
-                    var indiceUvsFromObj = parseInt(point[1]) - 1;
-                    // Set normal indice
-                    var indiceNormalFromObj = parseInt(point[2]) - 1;
-
-                    setData(
-                        indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj,
-                        positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
-                    );
-
-                }
-                //Reset variable for the next line
-                triangles = [];
-            };
-
-
-            /**
-             * Create triangles and push the data for each polygon for the pattern 4
-             * In this pattern we get vertice positions and normals
-             * @param face
-             * @param v
-             */
-            var setDataForCurrentFaceWithPattern4 = (face: Array<string>, v: number) => {
-                getTriangles(face, v);
-
-                for (var k = 0; k < triangles.length; k++) {
-                    //triangle[k] = "1//1"
-                    //Split the data for getting position and normals
-                    var point = triangles[k].split("//"); // ["1", "1"]
-                    // We check indices, and normals
-                    var indicePositionFromObj = parseInt(point[0]) - 1;
-                    var indiceNormalFromObj = parseInt(point[1]) - 1;
-
-                    setData(
-                        indicePositionFromObj,
-                        1, //Default value for uv
-                        indiceNormalFromObj,
-                        positions[indicePositionFromObj], //Get each vector of data
-                        BABYLON.Vector2.Zero(),
-                        normals[indiceNormalFromObj]
-                    );
-                }
-                //Reset variable for the next line
-                triangles = [];
-            };
-
-            var addPreviousObjMesh = () => {
-
-                //Check if it is not the first mesh. Otherwise we don't have data.
-                if (meshesFromObj.length > 0) {
-                    //Get the previous mesh for applying the data about the faces
-                    //=> in obj file, faces definition append after the name of the mesh
-                    handledMesh = meshesFromObj[meshesFromObj.length - 1];
-
-                    //Set the data into Array for the mesh
-                    unwrapData();
-
-                    // Reverse tab. Otherwise face are displayed in the wrong sens
-                    indicesForBabylon.reverse();
-                    //Set the information for the mesh
-                    //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited
-                    handledMesh.indices = indicesForBabylon.slice();
-                    handledMesh.positions = unwrappedPositionsForBabylon.slice();
-                    handledMesh.normals = unwrappedNormalsForBabylon.slice();
-                    handledMesh.uvs = unwrappedUVForBabylon.slice();
-
-                    //Reset the array for the next mesh
-                    indicesForBabylon = [];
-                    unwrappedPositionsForBabylon = [];
-                    unwrappedNormalsForBabylon = [];
-                    unwrappedUVForBabylon = [];
-                }
-            };
-            //Main function
-
-            //Split the file into lines
-            var lines = data.split('\n');
-            //Look at each line
-            for (var i = 0; i < lines.length; i++) {
-                var line = lines[i].trim();
-                var result;
-
-                //Comment or newLine
-                if (line.length === 0 || line.charAt(0) === '#') {
-                    continue;
-
-                    //Get information about one position possible for the vertices
-                } else if ((result = this.vertexPattern.exec(line)) !== null) {
-                    //Create a Vector3 with the position x, y, z
-                    //Value of result:
-                    // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
-                    //Add the Vector in the list of positions
-                    positions.push(new BABYLON.Vector3(
-                        parseFloat(result[1]),
-                        parseFloat(result[2]),
-                        parseFloat(result[3])
-                    ));
-
-                } else if ((result = this.normalPattern.exec(line)) !== null) {
-                    //Create a Vector3 with the normals x, y, z
-                    //Value of result
-                    // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
-                    //Add the Vector in the list of normals
-                    normals.push(new BABYLON.Vector3(
-                        parseFloat(result[1]),
-                        parseFloat(result[2]),
-                        parseFloat(result[3])
-                    ));
-
-                } else if ((result = this.uvPattern.exec(line)) !== null) {
-                    //Create a Vector2 with the normals u, v
-                    //Value of result
-                    // ["vt 0.1 0.2 0.3", "0.1", "0.2"]
-                    //Add the Vector in the list of uvs
-                    uvs.push(new BABYLON.Vector2(
-                        parseFloat(result[1]),
-                        parseFloat(result[2])
-                    ));
-
-
-                    //Identify patterns of faces
-                    //Face could be defined in different type of pattern
-                } else if ((result = this.facePattern3.exec(line)) !== null) {
-                    //Value of result:
-                    //["f 1/1/1 2/2/2 3/3/3", "1/1/1 2/2/2 3/3/3"...]
-
-                    //Set the data for this face
-                    setDataForCurrentFaceWithPattern3(
-                        result[1].trim().split(" "), // ["1/1/1", "2/2/2", "3/3/3"]
-                        1
-                    );
-
-
-                } else if ((result = this.facePattern4.exec(line)) !== null) {
-                    //Value of result:
-                    //["f 1//1 2//2 3//3", "1//1 2//2 3//3"...]
-
-                    //Set the data for this face
-                    setDataForCurrentFaceWithPattern4(
-                        result[1].trim().split(" "), // ["1//1", "2//2", "3//3"]
-                        1
-                    );
-
-                } else if ((result = this.facePattern2.exec(line)) !== null) {
-                    //Value of result:
-                    //["f 1/1 2/2 3/3", "1/1 2/2 3/3"...]
-
-                    //Set the data for this face
-                    setDataForCurrentFaceWithPattern2(
-                        result[1].trim().split(" "), // ["1/1", "2/2", "3/3"]
-                        1
-                    );
-
-                } else if ((result = this.facePattern1.exec(line)) !== null) {
-                    //Value of result
-                    //["f 1 2 3", "1 2 3"...]
-
-                    //Set the data for this face
-                    setDataForCurrentFaceWithPattern1(
-                        result[1].trim().split(" "), // ["1", "2", "3"]
-                        1
-                    );
-
-                    //Define a mesh or an object
-                    //Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh
-                } else if (this.group.test(line) || this.obj.test(line)) {
-                    //Create a new mesh corresponding to the name of the group.
-                    //Definition of the mesh
-                    var objMesh: {
-                        name: string;
-                        indices: Array<number>;
-                        positions: Array<number>;
-                        normals: Array<number>;
-                        uvs: Array<number>;
-                        materialName: string;
-                    } =
-                        //Set the name of the current obj mesh
-                        {
-                            name: line.substring(2).trim(),
-                            indices: undefined,
-                            positions: undefined,
-                            normals: undefined,
-                            uvs: undefined,
-                            materialName: ""
-                        };
-                    addPreviousObjMesh();
-
-                    //Push the last mesh created with only the name
-                    meshesFromObj.push(objMesh);
-
-                    //Set this variable to indicate that now meshesFromObj has objects defined inside
-                    hasMeshes = true;
-                    isFirstMaterial = true;
-                    increment = 1;
-                    //Keyword for applying a material
-                } else if (this.usemtl.test(line)) {
-                    //Get the name of the material
-                    materialNameFromObj = line.substring(7).trim();
-
-                    //If this new material is in the same mesh
-
-                    if (!isFirstMaterial) {
-                        //Set the data for the previous mesh
-                        addPreviousObjMesh();
-                        //Create a new mesh
-                        var objMesh: {
-                            name: string;
-                            indices: Array<number>;
-                            positions: Array<number>;
-                            normals: Array<number>;
-                            uvs: Array<number>;
-                            materialName: string;
-                        } =
-                            //Set the name of the current obj mesh
-                            {
-                                name: objMeshName + "_mm" + increment.toString(),
-                                indices: undefined,
-                                positions: undefined,
-                                normals: undefined,
-                                uvs: undefined,
-                                materialName: materialNameFromObj
-                            };
-                        increment++;
-                        //If meshes are already defined
-                        meshesFromObj.push(objMesh);
-                    }
-                    //Set the material name if the previous line define a mesh
-
-                    if (hasMeshes && isFirstMaterial) {
-                        //Set the material name to the previous mesh (1 material per mesh)
-                        meshesFromObj[meshesFromObj.length - 1].materialName = materialNameFromObj;
-                        isFirstMaterial = false;
-                    }
-                    //Keyword for loading the mtl file
-                } else if (this.mtllib.test(line)) {
-                    //Get the name of mtl file
-                    fileToLoad = line.substring(7).trim();
-
-                    //Apply smoothing
-                } else if (this.smooth.test(line)) {
-                    // smooth shading => apply smoothing
-                    //Toda  y I don't know it work with babylon and with obj.
-                    //With the obj file  an integer is set
-                } else {
-                    //If there is another possibility
-                    console.log("Unhandled expression at line : " + line);
-                }
-            }
-
-            //At the end of the file, add the last mesh into the meshesFromObj array
-            if (hasMeshes) {
-                //Set the data for the last mesh
-                handledMesh = meshesFromObj[meshesFromObj.length - 1];
-
-                //Reverse indices for displaying faces in the good sens
-                indicesForBabylon.reverse();
-                //Get the good array
-                unwrapData();
-                //Set array
-                handledMesh.indices = indicesForBabylon;
-                handledMesh.positions = unwrappedPositionsForBabylon;
-                handledMesh.normals = unwrappedNormalsForBabylon;
-                handledMesh.uvs = unwrappedUVForBabylon;
-            }
-
-            //If any o or g keyword found, create a mesj with a random id
-            if (!hasMeshes) {
-                // reverse tab of indices
-                indicesForBabylon.reverse();
-                //Get positions normals uvs
-                unwrapData();
-                //Set data for one mesh
-                meshesFromObj.push({
-                    name: BABYLON.Geometry.RandomId(),
-                    indices: indicesForBabylon,
-                    positions: unwrappedPositionsForBabylon,
-                    normals: unwrappedNormalsForBabylon,
-                    uvs: unwrappedUVForBabylon,
-                    materialName: materialNameFromObj
-                });
-            }
-
-            //Create a BABYLON.Mesh list
-            var babylonMeshesArray: Array<BABYLON.Mesh> = []; //The mesh for babylon
-            var materialToUse = [];
-
-            //Set data for each mesh
-            for (var j = 0; j < meshesFromObj.length; j++) {
-
-                //check meshesNames (stlFileLoader)
-                if (meshesNames && meshesFromObj[j].name) {
-                    if (meshesNames instanceof Array) {
-                        if (meshesNames.indexOf(meshesFromObj[j].name) == -1) {
-                            continue;
-                        }
-                    }
-                    else {
-                        if (meshesFromObj[j].name !== meshesNames) {
-                            continue;
-                        }
-                    }
-                }
-
-                //Get the current mesh
-                //Set the data with VertexBuffer for each mesh
-                handledMesh = meshesFromObj[j];
-                //Create a BABYLON.Mesh with the name of the obj mesh
-                var babylonMesh = new BABYLON.Mesh(meshesFromObj[j].name, scene);
-                //Push the name of the material to an array
-                //This is indispensable for the importMesh function
-                materialToUse.push(meshesFromObj[j].materialName);
-
-                var vertexData: VertexData = new BABYLON.VertexData(); //The container for the values
-                //Set the data for the babylonMesh
-                vertexData.positions = handledMesh.positions;
-                vertexData.normals = handledMesh.normals;
-                vertexData.uvs = handledMesh.uvs;
-                vertexData.indices = handledMesh.indices;
-                //Set the data from the VertexBuffer to the current BABYLON.Mesh
-                vertexData.applyToMesh(babylonMesh);
-                //Push the mesh into an array
-                babylonMeshesArray.push(babylonMesh);
-            }
-            //load the materials
-            //Check if we have a file to load
-            if (fileToLoad !== "") {
-                //Load the file synchronously
-                this._loadMTL(fileToLoad, rootUrl, function (dataLoaded) {
-                    //Create materials thanks MTLLoader function
-                    materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl);
-                    //Look at each material loaded in the mtl file
-                    for (var n = 0; n < materialsFromMTLFile.materials.length; n++) {
-                        //Three variables to get all meshes with the same material
-                        var startIndex = 0;
-                        var _indices = [];
-                        var _index;
-
-                        //The material from MTL file is used in the meshes loaded
-                        //Push the indice in an array
-                        //Check if the material is not used for another mesh
-                        while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {
-                            _indices.push(_index);
-                            startIndex = _index + 1;
-                        }
-                        //If the material is not used dispose it
-                        if (_index == -1 && _indices.length == 0) {
-                            //If the material is not needed, remove it
-                            materialsFromMTLFile.materials[n].dispose();
-                        } else {
-                            for (var o = 0; o < _indices.length; o++) {
-                                //Apply the material to the BABYLON.Mesh for each mesh with the material
-                                babylonMeshesArray[_indices[o]].material = materialsFromMTLFile.materials[n];
-                            }
-                        }
-                    }
-
-                });
-            }
-            //Return an array with all BABYLON.Mesh
-            return babylonMeshesArray;
-        }
-
-    }
-    //Add this loader into the register plugin
-    BABYLON.SceneLoader.RegisterPlugin(new OBJFileLoader());
-}

+ 0 - 31
loaders/config.json

@@ -1,31 +0,0 @@
-{
-  "loaders": {
-    "stl": {
-      "files": ["STL/babylon.stlFileLoader.ts"],
-      "output": "./STL",
-      "filename": "babylon.stlFileLoader.js"
-    },
-
-    "obj": {
-      "files": ["OBJ/babylon.objFileLoader.ts"],
-      "output": "./OBJ",
-      "filename": "babylon.objFileLoader.js"
-    },
-
-    "gltf": {
-      "files": [
-        "glTF/babylon.glTFFileLoaderInterfaces.ts",
-        "glTF/babylon.glTFFileLoader.ts",
-        "glTF/babylon.glTFFileLoaderUtils.ts",
-        "glTF/babylon.glTFFileLoaderExtension.ts",
-        "glTF/babylon.glTFBinaryExtension.ts"
-      ],
-      "output": "./glTF",
-      "filename": "babylon.glTFFileLoader.js"
-    }
-  },
-
-  "defines": [
-    "../dist/preview release/*.d.ts"
-  ]
-}

+ 0 - 41
loaders/gulpfile.js

@@ -1,41 +0,0 @@
-var gulp = require("gulp");
-var typescript = require("gulp-typescript");
-var concat = require("gulp-concat");
-var config = require("./config.json");
-var packageConfig = require("./package.json");
-
-/*
-* Compiles all typescript files and merges in single loader files
-*/
-gulp.task("build", function () {
-    for (var loaderName in config.loaders) {
-        var loader = config.loaders[loaderName];
-
-        var result = gulp.src(loader.files.concat(config.defines))
-            .pipe(typescript({
-                target: "ES5",
-                declarationFiles: true,
-                experimentalDecorators: false
-            }));
-        
-        result.js
-            .pipe(concat(loader.filename))
-            .pipe(gulp.dest(loader.output));
-    }
-});
-
-/*
-* Automatically call the "default" task when a TS file changes
-*/
-gulp.task("watch", function() {
-    var files = [];
-    for (var loaderName in config.loaders) {
-        files = files.concat(config.loaders[loaderName].files);
-    }
-
-	gulp.watch(files, ["build"]);
-});
-
-gulp.task("default", ["build"], function() {
-    // Nothing...
-});

+ 0 - 14
loaders/package.json

@@ -1,14 +0,0 @@
-{
-  "name": "BabylonJSLoaders",
-  "version": "0.8.0",
-  "description": "Babylon.js file loaders",
-  "repository": { "url": "https://github.com/BabylonJS/BabylonJS/" },
-  "readme": "https://github.com/BabylonJS/BabylonJS/blob/master/README.md",
-  "license": "(Apache-2.0)",
-  "devDependencies": {
-    "gulp": "^3.8.11",
-    "typescript": "^1.8.10",
-    "gulp-typescript": "~2.13.0",
-    "gulp-concat": "~2.6.0"
-  }
-}

+ 3 - 1
loaders/STL/babylon.stlFileLoader.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
 
     export class STLFileLoader implements ISceneLoaderPlugin {
 

loaders/glTF/README.md → loaders/src/glTF/README.md


+ 3 - 1
loaders/glTF/babylon.glTFBinaryExtension.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
     const BinaryExtensionBufferName = "binary_glTF";
 
     enum EContentFormat {

+ 3 - 1
loaders/glTF/babylon.glTFFileLoader.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
     /**
     * Tokenizer. Used for shaders compatibility
     * Automatically map world, view, projection, worldViewProjection, attributes and so on

+ 3 - 1
loaders/glTF/babylon.glTFFileLoaderExtension.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
     export abstract class GLTFFileLoaderExtension {
         private _name: string;
 

+ 3 - 1
loaders/glTF/babylon.glTFFileLoaderInterfaces.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
     /**
     * Enums
     */

+ 3 - 1
loaders/glTF/babylon.glTFFileLoaderUtils.ts

@@ -1,4 +1,6 @@
-module BABYLON {
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+
+module BABYLON {
     /**
     * Utils functions for GLTF
     */

+ 7 - 0
loaders/src/tsconfig.json

@@ -0,0 +1,7 @@
+{
+    "compilerOptions": {
+        "experimentalDecorators": true,
+        "module": "commonjs", 
+        "target": "es5"
+    }
+}

+ 4 - 14
materialsLibrary/index.html

@@ -3,18 +3,7 @@
 <head>
 	<title>Shaders Library</title>
 	<script src="../assets/refs/dat.gui.min.js"></script>
-	<script src="../dist/preview release/babylon.max.js"></script>
-	<script src="../dist/materialsLibrary/babylon.simpleMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.normalMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.waterMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.fireMaterial.js"></script>
-    <script src="../dist/materialsLibrary/babylon.lavaMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.terrainMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.furMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.triPlanarMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.gradientMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.skyMaterial.js"></script>
-	<script src="../dist/materialsLibrary/babylon.gridMaterial.js"></script>
+	<script src="../tools/DevLoader/BabylonLoader.js"></script>
 
 	<style>
 		html, body {
@@ -62,12 +51,13 @@
     <script src="test/addpbr.js"></script>
 	
 	<script>
+	BABYLONDEVTOOLS.Loader.onReady(function() {
 		if (BABYLON.Engine.isSupported()) {
 			var canvas = document.getElementById("renderCanvas");
 			var engine = new BABYLON.Engine(canvas, true);
 			var divFps = document.getElementById("fps");
 
-			var scene = new BABYLON.Scene(engine);
+			scene = new BABYLON.Scene(engine);
 
 			var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 6, 50, BABYLON.Vector3.Zero(), scene);
 			camera.attachControl(canvas, true);
@@ -361,7 +351,7 @@
 				});
 			});
 		}
-
+	});
 	</script>
 </body>
 </html>

+ 1 - 1
materialsLibrary/src/gradient/babylon.gradientMaterial.ts

@@ -265,7 +265,7 @@ module BABYLON {
                     ["diffuseSampler",
                         "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
                     ],
-                    join, fallbacks, this.onCompiled, this.onError);
+                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: 4 });
             }
             if (!this._effect.isReady()) {
                 return false;

+ 1 - 1
materialsLibrary/src/lava/babylon.lavaMaterial.ts

@@ -279,7 +279,7 @@ module BABYLON {
                     ["diffuseSampler",
                         "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3", "noiseTexture"
                     ],
-                    join, fallbacks, this.onCompiled, this.onError);
+                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: this.maxSimultaneousLights - 1 });
             }
             if (!this._effect.isReady()) {
                 return false;

+ 1 - 1
materialsLibrary/src/normal/babylon.normalMaterial.ts

@@ -255,7 +255,7 @@ module BABYLON {
                     ["diffuseSampler",
                         "shadowSampler0", "shadowSampler1", "shadowSampler2", "shadowSampler3"
                     ],
-                    join, fallbacks, this.onCompiled, this.onError);
+                    join, fallbacks, this.onCompiled, this.onError, { maxSimultaneousLights: 4 });
             }
             if (!this._effect.isReady()) {
                 return false;

+ 5 - 5
materialsLibrary/src/tsconfig.json

@@ -1,7 +1,7 @@
 {
-    "compilerOptions": {
-        "experimentalDecorators": true,
-        "module": "commonjs", 
-        "target": "es5"
-    }
+  "compilerOptions": {
+    "experimentalDecorators": true,
+    "module": "commonjs",
+    "target": "es5"
+  }
 }

+ 0 - 7
materialsLibrary/tsconfig.json

@@ -1,7 +0,0 @@
-{
-  "compilerOptions": {
-    "experimentalDecorators": true,
-    "module": "commonjs",
-    "target": "es5"
-  }
-}

+ 12 - 8
postProcessLibrary/index.html

@@ -1,26 +1,26 @@
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
+
 <head>
 	<title>Shaders Library</title>
 	<script src="../assets/refs/dat.gui.min.js"></script>
-	<script src="../dist/preview release/babylon.max.js"></script>
-	<script src="../dist/postProcessesLibrary/babylon.asciiArtPostProcess.js"></script>
-	<script src="../dist/postProcessesLibrary/babylon.digitalRainPostProcess.js"></script>
+	<script src="../tools/DevLoader/BabylonLoader.js"></script>
 
 	<style>
-		html, body {
+		html,
+		body {
 			width: 100%;
 			height: 100%;
 			padding: 0;
 			margin: 0;
 			overflow: hidden;
 		}
-
+		
 		#renderCanvas {
 			width: 100%;
 			height: 100%;
 		}
-
+		
 		#fps {
 			position: absolute;
 			background-color: black;
@@ -35,11 +35,13 @@
 		}
 	</style>
 </head>
+
 <body>
 	<div id="fps">0</div>
 	<canvas id="renderCanvas"></canvas>
-	
+
 	<script>
+	BABYLONDEVTOOLS.Loader.onReady(function() {
 		if (BABYLON.Engine.isSupported()) {
 			var canvas = document.getElementById("renderCanvas");
 			var engine = new BABYLON.Engine(canvas, true);
@@ -95,7 +97,9 @@
 				}
 			});
 		}
+	});
 
 	</script>
 </body>
-</html>
+
+</html>

proceduralTexturesLibrary/tsconfig.json → postProcessLibrary/src/tsconfig.json


+ 20 - 23
proceduralTexturesLibrary/index.html

@@ -1,32 +1,26 @@
 <!DOCTYPE html>
 <html xmlns="http://www.w3.org/1999/xhtml">
+
 <head>
 	<title>Procedural textures Library</title>
 	<script src="../assets/refs/dat.gui.min.js"></script>
-	<script src="../dist/preview release/babylon.max.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.fireProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.woodProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.cloudProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.grassProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.roadProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.brickProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.marbleProceduralTexture.js"></script>
-	<script src="../dist/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.js"></script>
+	<script src="../tools/DevLoader/BabylonLoader.js"></script>
 
 	<style>
-		html, body {
+		html,
+		body {
 			width: 100%;
 			height: 100%;
 			padding: 0;
 			margin: 0;
 			overflow: hidden;
 		}
-
+		
 		#renderCanvas {
 			width: 100%;
 			height: 100%;
 		}
-
+		
 		#fps {
 			position: absolute;
 			background-color: black;
@@ -41,26 +35,28 @@
 		}
 	</style>
 </head>
+
 <body>
 	<div id="fps">0</div>
 	<canvas id="renderCanvas"></canvas>
 
 	<script src="test/index.js"></script>
-    <script src="test/addCloudPT.js"></script>
-    <script src="test/addFirePT.js"></script>
-    <script src="test/addWoodPT.js"></script>
-    <script src="test/addGrassPT.js"></script>
-    <script src="test/addRoadPT.js"></script>
-    <script src="test/addBrickPT.js"></script>
-    <script src="test/addMarblePT.js"></script>
-    <script src="test/addStarfieldPT.js"></script>
+	<script src="test/addCloudPT.js"></script>
+	<script src="test/addFirePT.js"></script>
+	<script src="test/addWoodPT.js"></script>
+	<script src="test/addGrassPT.js"></script>
+	<script src="test/addRoadPT.js"></script>
+	<script src="test/addBrickPT.js"></script>
+	<script src="test/addMarblePT.js"></script>
+	<script src="test/addStarfieldPT.js"></script>
 	<script>
+		BABYLONDEVTOOLS.Loader.onReady(function() {
 		if (BABYLON.Engine.isSupported()) {
 			var canvas = document.getElementById("renderCanvas");
 			var engine = new BABYLON.Engine(canvas, true);
 			var divFps = document.getElementById("fps");
 
-			var scene = new BABYLON.Scene(engine);
+			scene = new BABYLON.Scene(engine);
 
 			var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 6, 50, BABYLON.Vector3.Zero(), scene);
 			camera.attachControl(canvas, true);
@@ -409,7 +405,8 @@
 				});
 			});
 		}
-
+		});
 	</script>
 </body>
-</html>
+
+</html>

postProcessLibrary/tsconfig.json → proceduralTexturesLibrary/src/tsconfig.json