Преглед изворни кода

Merge branch 'master' into webVRPositionScaleControllers

Trevor Baron пре 7 година
родитељ
комит
ecbe269100
73 измењених фајлова са 16976 додато и 14695 уклоњено
  1. 2557 2443
      Playground/babylon.d.txt
  2. 39 10
      Tools/Gulp/config.json
  3. 4 3
      Tools/Gulp/gulp-addDtsExport.js
  4. 12 8
      Tools/Gulp/gulp-addModuleExports.js
  5. 2 5
      Tools/Gulp/gulpfile.js
  6. 7 7
      Tools/Gulp/package.json
  7. 14 1
      Tools/Publisher/index.js
  8. 1 1
      Viewer/src/configuration/configuration.ts
  9. 6 2
      Viewer/src/templateManager.ts
  10. 4 5
      Viewer/src/viewer/defaultViewer.ts
  11. 0 2
      Viewer/src/viewer/viewer.ts
  12. 2379 2265
      dist/preview release/babylon.d.ts
  13. 51 51
      dist/preview release/babylon.js
  14. 332 26
      dist/preview release/babylon.max.js
  15. 49 49
      dist/preview release/babylon.worker.js
  16. 9277 9163
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  17. 49 48
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  18. 315 24
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  19. 315 22
      dist/preview release/customConfigurations/minimalGLTFViewer/es6.js
  20. 332 24
      dist/preview release/es6.js
  21. 248 0
      dist/preview release/gltf2Interface/babylon.glTF2Interface.d.ts
  22. 28 0
      dist/preview release/gltf2Interface/package.json
  23. 5 7
      dist/preview release/gui/babylon.gui.js
  24. 1 1
      dist/preview release/gui/babylon.gui.min.js
  25. 1 1
      dist/preview release/gui/package.json
  26. 1 1
      dist/preview release/inspector/babylon.inspector.bundle.js
  27. 1 1
      dist/preview release/inspector/package.json
  28. 3 5
      dist/preview release/loaders/babylonjs.loaders.js
  29. 3 3
      dist/preview release/loaders/babylonjs.loaders.min.js
  30. 1 0
      dist/preview release/loaders/babylonjs.loaders.module.d.ts
  31. 4 1
      dist/preview release/loaders/package.json
  32. 3 5
      dist/preview release/materialsLibrary/babylonjs.materials.js
  33. 1 1
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  34. 1 1
      dist/preview release/materialsLibrary/package.json
  35. 3 5
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.js
  36. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  37. 1 1
      dist/preview release/postProcessesLibrary/package.json
  38. 3 5
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.js
  39. 1 1
      dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js
  40. 1 1
      dist/preview release/proceduralTexturesLibrary/package.json
  41. 3 3
      dist/preview release/serializers/babylon.glTF2Serializer.js
  42. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.min.js
  43. 6 8
      dist/preview release/serializers/babylonjs.serializers.js
  44. 1 1
      dist/preview release/serializers/babylonjs.serializers.min.js
  45. 1 249
      dist/preview release/serializers/babylonjs.serializers.module.d.ts
  46. 4 1
      dist/preview release/serializers/package.json
  47. 2 34
      dist/preview release/typedocValidationBaseline.json
  48. 67 67
      dist/preview release/viewer/babylon.viewer.js
  49. 349 48
      dist/preview release/viewer/babylon.viewer.max.js
  50. 1 4
      dist/preview release/viewer/package.json
  51. 7 2
      dist/preview release/what's new.md
  52. 1 1
      package.json
  53. 3 3
      src/Debug/babylon.debugModules.ts
  54. 240 2
      src/Engine/babylon.engine.ts
  55. 4 0
      src/Engine/babylon.webgl2.ts
  56. 19 7
      src/Helpers/babylon.videoDome.ts
  57. 15 1
      src/Materials/Background/babylon.backgroundMaterial.ts
  58. 9 1
      src/Materials/Textures/babylon.cubeTexture.ts
  59. 36 0
      src/Materials/Textures/babylon.hdrCubeTexture.ts
  60. 22 0
      src/Materials/Textures/babylon.internalTexture.ts
  61. 23 1
      src/Materials/Textures/babylon.renderTargetTexture.ts
  62. 11 1
      src/Materials/Textures/babylon.texture.ts
  63. 2 1
      src/Materials/Textures/babylon.videoTexture.ts
  64. 35 35
      src/Math/babylon.math.ts
  65. 2 1
      src/Particles/babylon.IParticleSystem.ts
  66. 8 2
      src/Particles/babylon.gpuParticleSystem.ts
  67. 4 3
      src/Particles/babylon.particleSystem.ts
  68. 3 3
      src/Probes/babylon.reflectionProbe.ts
  69. 14 9
      src/Shaders/ShadersInclude/reflectionFunction.fx
  70. 4 0
      src/Shaders/background.fragment.fx
  71. 1 0
      src/babylon.mixins.ts
  72. 22 6
      src/babylon.scene.ts
  73. BIN
      tests/validation/ReferenceImages/refprobe.png

Разлика између датотеке није приказан због своје велике величине
+ 2557 - 2443
Playground/babylon.d.txt


+ 39 - 10
Tools/Gulp/config.json

@@ -1315,7 +1315,10 @@
             "buildAsModule": true,
             "moduleName": "babylonjs-materials",
             "outputFilename": "babylonjs.materials",
-            "moduleDeclaration": "BJSMaterials",
+            "moduleDeclaration": {
+                "name": "BJSMaterials",
+                "module": "babylonjs-materials"
+            },
             "extendsRoot": true
         }
     },
@@ -1346,7 +1349,10 @@
             "buildAsModule": true,
             "moduleName": "babylonjs-post-process",
             "outputFilename": "babylonjs.postProcess",
-            "moduleDeclaration": "BJSPostProcess",
+            "moduleDeclaration": {
+                "name": "PostProcesses",
+                "module": "babylonjs-post-process"
+            },
             "extendsRoot": true
         }
     },
@@ -1449,7 +1455,10 @@
             "buildAsModule": true,
             "moduleName": "babylonjs-procedural-textures",
             "outputFilename": "babylonjs.proceduralTextures",
-            "moduleDeclaration": "BJSProceduralTextures",
+            "moduleDeclaration": {
+                "name": "ProceduralTextures",
+                "module": "babylonjs-procedural-textures"
+            },
             "extendsRoot": true
         }
     },
@@ -1522,7 +1531,14 @@
             "buildAsModule": true,
             "moduleName": "babylonjs-loaders",
             "outputFilename": "babylonjs.loaders",
-            "moduleDeclaration": "BJSLoaders",
+            "moduleDeclaration": {
+                "name": "Loaders",
+                "module": "babylonjs-loaders"
+            },
+            "extraTypesDependencies": [
+                "babylonjs",
+                "babylonjs-gltf2interface"
+            ],
             "extendsRoot": true
         }
     },
@@ -1549,11 +1565,15 @@
             "distOutputDirectory": "/serializers/",
             "buildAsModule": true,
             "moduleName": "babylonjs-serializers",
-            "extraDeclarations": [
-                "../../dist/babylon.glTF2Interface.d.ts"
+            "extraTypesDependencies": [
+                "babylonjs",
+                "babylonjs-gltf2interface"
             ],
             "outputFilename": "babylonjs.serializers",
-            "moduleDeclaration": "BJSSerializers",
+            "moduleDeclaration": {
+                "name": "Serializers",
+                "module": "babylonjs-serializers"
+            },
             "extendsRoot": true
         }
     },
@@ -1584,7 +1604,10 @@
                 "output": "babylon.gui.js",
                 "buildAsModule": true,
                 "moduleName": "babylonjs-gui",
-                "moduleDeclaration": "GUI"
+                "moduleDeclaration": {
+                    "name": "GUI",
+                    "module": "babylonjs-gui"
+                }
             }
         ],
         "build": {
@@ -1660,7 +1683,10 @@
                 "output": "babylon.inspector.js",
                 "webpack": "../../inspector/webpack.config.js",
                 "bundle": "true",
-                "moduleDeclaration": "INSPECTOR"
+                "moduleDeclaration": {
+                    "name": "INSPECTOR",
+                    "module": "babylonjs-inspector"
+                }
             }
         ],
         "build": {
@@ -1676,7 +1702,10 @@
                 "output": "babylon.viewer.js",
                 "webpack": "../../Viewer/webpack.gulp.config.js",
                 "bundle": "true",
-                "moduleDeclaration": "BabylonViewer",
+                "moduleDeclaration": {
+                    "name": "BabylonViewer",
+                    "module": "babylonjs-viewer"
+                },
                 "babylonIncluded": true
             }
         ],

+ 4 - 3
Tools/Gulp/gulp-addDtsExport.js

@@ -6,7 +6,7 @@ module.exports = function (varName, moduleName, subModule, extendsRoot, dependen
 
         let exportText = "BABYLON";
         if (subModule && !extendsRoot) {
-            exportText += '.' + varName;
+            exportText += '.' + varName.name;
         }
 
         let referenceText = '';
@@ -17,8 +17,9 @@ module.exports = function (varName, moduleName, subModule, extendsRoot, dependen
         if (dependencies) {
             referenceText = '';
             dependencies.forEach(element => {
-                referenceText += `/// <reference types="babylonjs/${element}"/>
-`
+                // was "babylonjs/${element}""
+                referenceText += `/// <reference types="${element}"/>
+`;
             });
         }
 

+ 12 - 8
Tools/Gulp/gulp-addModuleExports.js

@@ -8,13 +8,20 @@ var through = require('through2');
 module.exports = function (varName, subModule, extendsRoot, externalUsingBabylon, noBabylonInit) {
     return through.obj(function (file, enc, cb) {
 
+        if (typeof varName === 'string') {
+            varName = {
+                base: varName,
+                module: varName
+            }
+        }
+
         var optionalRequire = `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
 var babylonDependency = (globalObject && globalObject.BABYLON) || BABYLON || (typeof require !== 'undefined' && require("babylonjs"));
 var BABYLON = babylonDependency;
 `;
         function moduleExportAddition(varName) {
 
-            let base = subModule ? 'BABYLON' : varName;
+            let base = subModule ? 'BABYLON' : varName.base;
 
             let basicInit = `root["${base}"]${(subModule && !extendsRoot) ? '["' + varName + '"]' : ''} = f;`;
             let sadGlobalPolution = (!subModule) ? `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
@@ -25,21 +32,19 @@ globalObject["${base}"] = f;` : '';
 
             return `\n\n(function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["${base}"]) {
-                    return;
-                }
+                
                 ${sadGlobalPolution}
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["${varName}"], factory);
+        define("${varName.module}", ${subModule || extendsRoot ? '["BABYLON"],' : ''} factory);
     else if(typeof exports === 'object')
-        exports["${varName}"] = f;
+        exports["${varName.module}"] = f;
     else {
         ${basicInit}
     }
 })(this, function() {
-    return ${base}${(subModule && !extendsRoot) ? '.' + varName : ''};
+    return ${base}${(subModule && !extendsRoot) ? '.' + varName.base : ''};
 });
 `;
         }
@@ -81,7 +86,6 @@ globalObject["${base}"] = f;` : '';
 
         try {
             if (externalUsingBabylon) {
-                //file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
                 file.contents = new Buffer(optionalRequire.concat(new Buffer(String(file.contents).concat(moduleExportAddition(varName)))));
             } else {
                 let pretext = subModule ? optionalRequire : '';

+ 2 - 5
Tools/Gulp/gulpfile.js

@@ -325,13 +325,10 @@ var buildExternalLibraries = function (settings) {
             let dtsFiles = files.map(function (filename) {
                 return filename.replace(".js", ".d.ts");
             });
-            if (settings.build.extraDeclarations) {
-                settings.build.extraDeclarations.forEach(file => { dtsFiles.unshift(file) })
-            }
             let dtsTask = gulp.src(dtsFiles)
                 .pipe(concat(settings.build.outputFilename + ".module.d.ts"))
                 .pipe(replace(referenceSearchRegex, ""))
-                .pipe(addDtsExport(settings.build.moduleDeclaration, settings.build.moduleName, true, settings.build.extendsRoot))
+                .pipe(addDtsExport(settings.build.moduleDeclaration, settings.build.moduleName, true, settings.build.extendsRoot, settings.build.extraTypesDependencies))
                 .pipe(gulp.dest(outputDirectory));
 
             return merge2([srcTask, dtsTask]);
@@ -421,7 +418,7 @@ var buildExternalLibrary = function (library, settings, watch) {
             var dts2 = tsProcess.dts
                 .pipe(concat(library.output))
                 .pipe(replace(referenceSearchRegex, ""))
-                .pipe(addDtsExport(library.moduleDeclaration, library.moduleName, true, library.extendsRoot))
+                .pipe(addDtsExport(library.moduleDeclaration, library.moduleName, true, library.extendsRoot, config.build.extraTypesDependencies))
                 .pipe(rename({ extname: ".module.d.ts" }))
                 .pipe(gulp.dest(outputDirectory));
             waitAll = merge2([dev, code, css, dts, dts2]);

+ 7 - 7
Tools/Gulp/package.json

@@ -9,21 +9,21 @@
     "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
     "license": "(Apache-2.0)",
     "devDependencies": {
-        "@types/node": "^8.5.0",
+        "@types/node": "^8.9.4",
         "base64-image-loader": "^1.2.1",
         "chai": "^4.1.2",
         "color-support": "^1.1.3",
         "css-loader": "^0.25.0",
         "deepmerge": "^2.0.1",
         "del": "2.2.2",
-        "es6-promise": "^4.1.1",
+        "es6-promise": "^4.2.4",
         "exports-loader": "^0.6.4",
         "gulp": "^3.8.11",
         "gulp-changed-in-place": "2.0.3",
         "gulp-clean-ts-extends": "~0.1.1",
         "gulp-concat": "~2.5.2",
         "gulp-content-to-variable": "^0.1.0",
-        "gulp-debug": "^3.0.0",
+        "gulp-debug": "^3.2.0",
         "gulp-expect-file": "^0.0.7",
         "gulp-optimize-js": "^1.0.2",
         "gulp-rename": "~1.2.2",
@@ -31,12 +31,12 @@
         "gulp-sass": "3.1.0",
         "gulp-sourcemaps": "~1.9.1",
         "gulp-typedoc": "^2.1.2",
-        "gulp-typescript": "^3.2.3",
+        "gulp-typescript": "^3.2.4",
         "gulp-uglify": "^2.1.2",
         "gulp-util": "~3.0.4",
         "gulp-webserver": "^0.9.1",
         "handlebars": "^4.0.11",
-        "html-loader": "^0.5.1",
+        "html-loader": "^0.5.5",
         "imports-loader": "^0.7.1",
         "json-loader": "^0.5.7",
         "karma": "^2.0.0",
@@ -52,13 +52,13 @@
         "mocha": "^4.0.1",
         "phantomjs": "^2.1.7",
         "run-sequence": "~1.1.0",
-        "sinon": "^4.1.3",
+        "sinon": "^4.3.0",
         "style-loader": "^0.13.2",
         "through2": "~0.6.5",
         "ts-loader": "^2.3.7",
         "typedoc": "^0.9.0",
         "typescript": "~2.6.2",
-        "webpack-stream": "^4.0.0"
+        "webpack-stream": "^4.0.1"
     },
     "scripts": {
         "install": "npm --prefix ../../Playground/ install ../../Playground/ && npm --prefix ../../tests/unit/ install ../../tests/unit/ && gulp deployLocalDev"

+ 14 - 1
Tools/Publisher/index.js

@@ -25,6 +25,10 @@ let packages = [
         path: basePath + '/postProcessesLibrary/'
     },
     {
+        name: 'gltf2interface',
+        path: basePath + '/gltf2interface/'
+    },
+    {
         name: 'loaders',
         path: basePath + '/loaders/'
     },
@@ -70,6 +74,13 @@ function processPackages(version) {
         } else {
             let packageJson = require(package.path + 'package.json');
             packageJson.version = version;
+            if (packageJson.dependencies) {
+                Object.keys(packageJson.dependencies).forEach(key => {
+                    if (key.indexOf("babylonjs") !== -1) {
+                        packageJson.dependencies[key] = version;
+                    }
+                });
+            }
             if (packageJson.peerDependencies) packageJson.peerDependencies.babylonjs = minimumDependency;
             fs.writeFileSync(package.path + 'package.json', JSON.stringify(packageJson, null, 4));
             console.log('Publishing ' + package.name + " from " + package.path);
@@ -89,7 +100,9 @@ if (loginCheck.code === 0) {
     prompt.get(['version'], function (err, result) {
         let version = result.version;
         updateEngineVersion(version);
-        runGulp();
+        if (process.argv.indexOf('--no-build') === -1) {
+            runGulp();
+        }
         processPackages(version);
 
         console.log("done, please tag git with " + version);

+ 1 - 1
Viewer/src/configuration/configuration.ts

@@ -257,5 +257,5 @@ export interface IImageProcessingConfiguration {
     vignetteBlendMode?: number;
     vignetteM?: boolean;
     applyByPostProcess?: boolean;
-
+    isEnabled?: boolean;
 }

+ 6 - 2
Viewer/src/templateManager.ts

@@ -125,6 +125,7 @@ export class TemplateManager {
             let templateStructure = {};
             // now iterate through all templates and check for children:
             let buildTree = (parentObject, name) => {
+                this.templates[name].isInHtmlTree = true;
                 let childNodes = this.templates[name].getChildElements().filter(n => !!this.templates[n]);
                 childNodes.forEach(element => {
                     parentObject[element] = {};
@@ -149,7 +150,7 @@ export class TemplateManager {
 
     private checkLoadedState() {
         let done = Object.keys(this.templates).length === 0 || Object.keys(this.templates).every((key) => {
-            return this.templates[key].isLoaded && !!this.templates[key].parent;
+            return (this.templates[key].isLoaded && !!this.templates[key].parent) || !this.templates[key].isInHtmlTree;
         });
 
         if (done) {
@@ -205,6 +206,8 @@ export class Template {
      */
     public isShown: boolean;
 
+    public isInHtmlTree: boolean;
+
     public parent: HTMLElement;
 
     public initPromise: Promise<Template>;
@@ -225,6 +228,7 @@ export class Template {
 
         this.isLoaded = false;
         this.isShown = false;
+        this.isInHtmlTree = false;
         /*
         if (configuration.id) {
             this.parent.id = configuration.id;
@@ -361,7 +365,7 @@ export class Template {
     private getTemplateAsHtml(templateConfig: ITemplateConfiguration): Promise<string> {
         if (!templateConfig) {
             return Promise.reject('No templateConfig provided');
-        } else if (templateConfig.html) {
+        } else if (templateConfig.html !== undefined) {
             return Promise.resolve(templateConfig.html);
         } else {
             let location = getTemplateLocation(templateConfig);

+ 4 - 5
Viewer/src/viewer/defaultViewer.ts

@@ -260,7 +260,7 @@ export class DefaultViewer extends AbstractViewer {
 
     public showOverlayScreen(subScreen: string) {
         let template = this.templateManager.getTemplate('overlay');
-        if (!template) return Promise.reject('Overlay template not found');
+        if (!template) return Promise.resolve('Overlay template not found');
 
         return template.show((template => {
 
@@ -285,7 +285,7 @@ export class DefaultViewer extends AbstractViewer {
 
     public hideOverlayScreen() {
         let template = this.templateManager.getTemplate('overlay');
-        if (!template) return Promise.reject('Overlay template not found');
+        if (!template) return Promise.resolve('Overlay template not found');
 
         return template.hide((template => {
             template.parent.style.opacity = "0";
@@ -313,7 +313,7 @@ export class DefaultViewer extends AbstractViewer {
 
     public showLoadingScreen() {
         let template = this.templateManager.getTemplate('loadingScreen');
-        if (!template) return Promise.reject('oading Screen template not found');
+        if (!template) return Promise.resolve('Loading Screen template not found');
 
         return template.show((template => {
 
@@ -332,7 +332,7 @@ export class DefaultViewer extends AbstractViewer {
 
     public hideLoadingScreen() {
         let template = this.templateManager.getTemplate('loadingScreen');
-        if (!template) return Promise.reject('oading Screen template not found');
+        if (!template) return Promise.resolve('Loading Screen template not found');
 
         return template.hide((template => {
             template.parent.style.opacity = "0";
@@ -347,7 +347,6 @@ export class DefaultViewer extends AbstractViewer {
 
     protected configureLights(lightsConfiguration: { [name: string]: ILightConfiguration | boolean } = {}, focusMeshes: Array<AbstractMesh> = this.scene.meshes) {
         super.configureLights(lightsConfiguration, focusMeshes);
-        console.log("flashlight", this.configuration.lab);
         // labs feature - flashlight
         if (this.configuration.lab && this.configuration.lab.flashlight) {
             let pointerPosition = BABYLON.Vector3.Zero();

+ 0 - 2
Viewer/src/viewer/viewer.ts

@@ -600,10 +600,8 @@ export abstract class AbstractViewer {
 
             if (unitSize) {
                 meshesToNormalize.forEach(mesh => {
-                    console.log(mesh.scaling.x)
                     mesh.normalizeToUnitCube(true);
                     mesh.computeWorldMatrix(true);
-                    console.log(mesh.scaling.x)
                 });
             }
             if (center) {

Разлика између датотеке није приказан због своје велике величине
+ 2379 - 2265
dist/preview release/babylon.d.ts


Разлика између датотеке није приказан због своје велике величине
+ 51 - 51
dist/preview release/babylon.js


Разлика између датотеке није приказан због своје велике величине
+ 332 - 26
dist/preview release/babylon.max.js


Разлика између датотеке није приказан због своје велике величине
+ 49 - 49
dist/preview release/babylon.worker.js


Разлика између датотеке није приказан због своје велике величине
+ 9277 - 9163
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Разлика између датотеке није приказан због своје велике величине
+ 49 - 48
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


Разлика између датотеке није приказан због своје велике величине
+ 315 - 24
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js


Разлика између датотеке није приказан због своје велике величине
+ 315 - 22
dist/preview release/customConfigurations/minimalGLTFViewer/es6.js


Разлика између датотеке није приказан због своје велике величине
+ 332 - 24
dist/preview release/es6.js


+ 248 - 0
dist/preview release/gltf2Interface/babylon.glTF2Interface.d.ts

@@ -0,0 +1,248 @@
+declare module BABYLON.GLTF2 {
+    const enum AccessorComponentType {
+        BYTE = 5120,
+        UNSIGNED_BYTE = 5121,
+        SHORT = 5122,
+        UNSIGNED_SHORT = 5123,
+        UNSIGNED_INT = 5125,
+        FLOAT = 5126,
+    }
+    const enum AccessorType {
+        SCALAR = "SCALAR",
+        VEC2 = "VEC2",
+        VEC3 = "VEC3",
+        VEC4 = "VEC4",
+        MAT2 = "MAT2",
+        MAT3 = "MAT3",
+        MAT4 = "MAT4",
+    }
+    const enum AnimationChannelTargetPath {
+        TRANSLATION = "translation",
+        ROTATION = "rotation",
+        SCALE = "scale",
+        WEIGHTS = "weights",
+    }
+    const enum AnimationSamplerInterpolation {
+        LINEAR = "LINEAR",
+        STEP = "STEP",
+        CUBICSPLINE = "CUBICSPLINE",
+    }
+    const enum CameraType {
+        PERSPECTIVE = "perspective",
+        ORTHOGRAPHIC = "orthographic",
+    }
+    const enum ImageMimeType {
+        JPEG = "image/jpeg",
+        PNG = "image/png",
+    }
+    const enum MaterialAlphaMode {
+        OPAQUE = "OPAQUE",
+        MASK = "MASK",
+        BLEND = "BLEND",
+    }
+    const enum MeshPrimitiveMode {
+        POINTS = 0,
+        LINES = 1,
+        LINE_LOOP = 2,
+        LINE_STRIP = 3,
+        TRIANGLES = 4,
+        TRIANGLE_STRIP = 5,
+        TRIANGLE_FAN = 6,
+    }
+    const enum TextureMagFilter {
+        NEAREST = 9728,
+        LINEAR = 9729,
+    }
+    const enum TextureMinFilter {
+        NEAREST = 9728,
+        LINEAR = 9729,
+        NEAREST_MIPMAP_NEAREST = 9984,
+        LINEAR_MIPMAP_NEAREST = 9985,
+        NEAREST_MIPMAP_LINEAR = 9986,
+        LINEAR_MIPMAP_LINEAR = 9987,
+    }
+    const enum TextureWrapMode {
+        CLAMP_TO_EDGE = 33071,
+        MIRRORED_REPEAT = 33648,
+        REPEAT = 10497,
+    }
+    interface IProperty {
+        extensions?: {
+            [key: string]: any;
+        };
+        extras?: any;
+    }
+    interface IChildRootProperty extends IProperty {
+        name?: string;
+    }
+    interface IAccessorSparseIndices extends IProperty {
+        bufferView: number;
+        byteOffset?: number;
+        componentType: AccessorComponentType;
+    }
+    interface IAccessorSparseValues extends IProperty {
+        bufferView: number;
+        byteOffset?: number;
+    }
+    interface IAccessorSparse extends IProperty {
+        count: number;
+        indices: IAccessorSparseIndices;
+        values: IAccessorSparseValues;
+    }
+    interface IAccessor extends IChildRootProperty {
+        bufferView?: number;
+        byteOffset?: number;
+        componentType: AccessorComponentType;
+        normalized?: boolean;
+        count: number;
+        type: AccessorType;
+        max?: number[];
+        min?: number[];
+        sparse?: IAccessorSparse;
+    }
+    interface IAnimationChannel extends IProperty {
+        sampler: number;
+        target: IAnimationChannelTarget;
+    }
+    interface IAnimationChannelTarget extends IProperty {
+        node: number;
+        path: AnimationChannelTargetPath;
+    }
+    interface IAnimationSampler extends IProperty {
+        input: number;
+        interpolation?: AnimationSamplerInterpolation;
+        output: number;
+    }
+    interface IAnimation extends IChildRootProperty {
+        channels: IAnimationChannel[];
+        samplers: IAnimationSampler[];
+    }
+    interface IAsset extends IChildRootProperty {
+        copyright?: string;
+        generator?: string;
+        version: string;
+        minVersion?: string;
+    }
+    interface IBuffer extends IChildRootProperty {
+        uri?: string;
+        byteLength: number;
+    }
+    interface IBufferView extends IChildRootProperty {
+        buffer: number;
+        byteOffset?: number;
+        byteLength: number;
+        byteStride?: number;
+    }
+    interface ICameraOrthographic extends IProperty {
+        xmag: number;
+        ymag: number;
+        zfar: number;
+        znear: number;
+    }
+    interface ICameraPerspective extends IProperty {
+        aspectRatio: number;
+        yfov: number;
+        zfar: number;
+        znear: number;
+    }
+    interface ICamera extends IChildRootProperty {
+        orthographic?: ICameraOrthographic;
+        perspective?: ICameraPerspective;
+        type: CameraType;
+    }
+    interface IImage extends IChildRootProperty {
+        uri?: string;
+        mimeType?: ImageMimeType;
+        bufferView?: number;
+    }
+    interface IMaterialNormalTextureInfo extends ITextureInfo {
+        scale?: number;
+    }
+    interface IMaterialOcclusionTextureInfo extends ITextureInfo {
+        strength?: number;
+    }
+    interface IMaterialPbrMetallicRoughness {
+        baseColorFactor?: number[];
+        baseColorTexture?: ITextureInfo;
+        metallicFactor?: number;
+        roughnessFactor?: number;
+        metallicRoughnessTexture?: ITextureInfo;
+    }
+    interface IMaterial extends IChildRootProperty {
+        pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
+        normalTexture?: IMaterialNormalTextureInfo;
+        occlusionTexture?: IMaterialOcclusionTextureInfo;
+        emissiveTexture?: ITextureInfo;
+        emissiveFactor?: number[];
+        alphaMode?: MaterialAlphaMode;
+        alphaCutoff?: number;
+        doubleSided?: boolean;
+    }
+    interface IMeshPrimitive extends IProperty {
+        attributes: {
+            [name: string]: number;
+        };
+        indices?: number;
+        material?: number;
+        mode?: MeshPrimitiveMode;
+        targets?: {
+            [name: string]: number;
+        }[];
+    }
+    interface IMesh extends IChildRootProperty {
+        primitives: IMeshPrimitive[];
+        weights?: number[];
+    }
+    interface INode extends IChildRootProperty {
+        camera?: number;
+        children?: number[];
+        skin?: number;
+        matrix?: number[];
+        mesh?: number;
+        rotation?: number[];
+        scale?: number[];
+        translation?: number[];
+        weights?: number[];
+    }
+    interface ISampler extends IChildRootProperty {
+        magFilter?: TextureMagFilter;
+        minFilter?: TextureMinFilter;
+        wrapS?: TextureWrapMode;
+        wrapT?: TextureWrapMode;
+    }
+    interface IScene extends IChildRootProperty {
+        nodes: number[];
+    }
+    interface ISkin extends IChildRootProperty {
+        inverseBindMatrices?: number;
+        skeleton?: number;
+        joints: number[];
+    }
+    interface ITexture extends IChildRootProperty {
+        sampler?: number;
+        source: number;
+    }
+    interface ITextureInfo {
+        index: number;
+        texCoord?: number;
+    }
+    interface IGLTF extends IProperty {
+        accessors?: IAccessor[];
+        animations?: IAnimation[];
+        asset: IAsset;
+        buffers?: IBuffer[];
+        bufferViews?: IBufferView[];
+        cameras?: ICamera[];
+        extensionsUsed?: string[];
+        extensionsRequired?: string[];
+        images?: IImage[];
+        materials?: IMaterial[];
+        meshes?: IMesh[];
+        nodes?: INode[];
+        samplers?: ISampler[];
+        scene?: number;
+        scenes?: IScene[];
+        skins?: ISkin[];
+        textures?: ITexture[];
+    }
+}

+ 28 - 0
dist/preview release/gltf2Interface/package.json

@@ -0,0 +1,28 @@
+{
+    "name": "babylonjs-gltf2interface",
+    "description": "A typescript declaration of babylon's gltf2 inteface.",
+    "version": "3.2.0-alpha10",
+    "repository": {
+        "type": "git",
+        "url": "https://github.com/BabylonJS/Babylon.js.git"
+    },
+    "files": [
+        "babylon.glTF2Interface.d.ts",
+        "package.json"
+    ],
+    "typings": "babylon.glTF2Interface.d.ts",
+    "keywords": [
+        "3D",
+        "javascript",
+        "html5",
+        "webgl",
+        "gltf2"
+    ],
+    "license": "Apache-2.0",
+    "peerDependencies": {
+        "babylonjs": ">=3.2.0-alpha"
+    },
+    "engines": {
+        "node": "*"
+    }
+}

+ 5 - 7
dist/preview release/gui/babylon.gui.js

@@ -5005,19 +5005,17 @@ var BABYLON;
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["GUI"], factory);
+        define("babylonjs-gui", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["GUI"] = f;
+        exports["babylonjs-gui"] = f;
     else {
-        root["BABYLON"]["GUI"] = f;
+        root["BABYLON"]["[object Object]"] = f;
     }
 })(this, function() {
-    return BABYLON.GUI;
+    return BABYLON.undefined;
 });

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


+ 1 - 1
dist/preview release/gui/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-gui",
     "description": "The Babylon.js GUI library is an extension you can use to generate interactive user interface. It is build on top of the DynamicTexture.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/inspector/babylon.inspector.bundle.js


+ 1 - 1
dist/preview release/inspector/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-inspector",
     "description": "The Babylon.js inspector.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 5
dist/preview release/loaders/babylonjs.loaders.js

@@ -5460,16 +5460,14 @@ var BABYLON;
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["BJSLoaders"], factory);
+        define("babylonjs-loaders", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["BJSLoaders"] = f;
+        exports["babylonjs-loaders"] = f;
     else {
         root["BABYLON"] = f;
     }

Разлика између датотеке није приказан због своје велике величине
+ 3 - 3
dist/preview release/loaders/babylonjs.loaders.min.js


+ 1 - 0
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -1,4 +1,5 @@
 /// <reference types="babylonjs"/>
+/// <reference types="babylonjs-gltf2interface"/>
 
 
 declare module 'babylonjs-loaders' { 

+ 4 - 1
dist/preview release/loaders/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-loaders",
     "description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -26,6 +26,9 @@
         "loaders"
     ],
     "license": "Apache-2.0",
+    "dependencies": {
+        "babylonjs-gltf2interface": "3.2.0-alpha10"
+    },
     "peerDependencies": {
         "babylonjs": ">=3.2.0-alpha"
     },

+ 3 - 5
dist/preview release/materialsLibrary/babylonjs.materials.js

@@ -6348,16 +6348,14 @@ BABYLON.Effect.ShadersStore['cellPixelShader'] = "precision highp float;\n\nunif
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["BJSMaterials"], factory);
+        define("babylonjs-materials", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["BJSMaterials"] = f;
+        exports["babylonjs-materials"] = f;
     else {
         root["BABYLON"] = f;
     }

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/materialsLibrary/babylonjs.materials.min.js


+ 1 - 1
dist/preview release/materialsLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-materials",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 5
dist/preview release/postProcessesLibrary/babylonjs.postProcess.js

@@ -447,16 +447,14 @@ BABYLON.Effect.ShadersStore['digitalrainPixelShader'] = "\nvarying vec2 vUV;\nun
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["BJSPostProcess"], factory);
+        define("babylonjs-post-process", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["BJSPostProcess"] = f;
+        exports["babylonjs-post-process"] = f;
     else {
         root["BABYLON"] = f;
     }

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


+ 1 - 1
dist/preview release/postProcessesLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-post-process",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 5
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.js

@@ -748,16 +748,14 @@ BABYLON.Effect.ShadersStore['perlinNoiseProceduralTexturePixelShader'] = "\nprec
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["BJSProceduralTextures"], factory);
+        define("babylonjs-procedural-textures", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["BJSProceduralTextures"] = f;
+        exports["babylonjs-procedural-textures"] = f;
     else {
         root["BABYLON"] = f;
     }

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/proceduralTexturesLibrary/babylonjs.proceduralTextures.min.js


+ 1 - 1
dist/preview release/proceduralTexturesLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-procedural-textures",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 3
dist/preview release/serializers/babylon.glTF2Serializer.js

@@ -147,7 +147,7 @@ var BABYLON;
                 if (vertexCount) {
                     for (var i = vertexStart; i < end; ++i) {
                         var indexOffset = positionStrideSize * i;
-                        var position = new BABYLON.Vector3(positions[indexOffset], positions[indexOffset + 1], positions[indexOffset + 2]);
+                        var position = BABYLON.Vector3.FromArray(positions, indexOffset);
                         var vector = this.convertToRightHandedSystem ? _Exporter.GetRightHandedVector3(position).asArray() : position.asArray();
                         for (var j = 0; j < positionStrideSize; ++j) {
                             var num = vector[j];
@@ -204,11 +204,11 @@ var BABYLON;
                     var index = k * strideSize;
                     var vector = [];
                     if (vertexBufferKind === BABYLON.VertexBuffer.PositionKind || vertexBufferKind === BABYLON.VertexBuffer.NormalKind) {
-                        var vertexData = new BABYLON.Vector3(meshAttributeArray[index], meshAttributeArray[index + 1], meshAttributeArray[index + 2]);
+                        var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
                         vector = this.convertToRightHandedSystem ? _Exporter.GetRightHandedVector3(vertexData).asArray() : vertexData.asArray();
                     }
                     else if (vertexBufferKind === BABYLON.VertexBuffer.TangentKind || vertexBufferKind === BABYLON.VertexBuffer.ColorKind) {
-                        var vertexData = new BABYLON.Vector4(meshAttributeArray[index], meshAttributeArray[index + 1], meshAttributeArray[index + 2], meshAttributeArray[index + 3]);
+                        var vertexData = BABYLON.Vector4.FromArray(meshAttributeArray, index);
                         vector = (this.convertToRightHandedSystem && !(vertexBufferKind === BABYLON.VertexBuffer.ColorKind)) ? _Exporter.GetRightHandedVector4(vertexData).asArray() : vertexData.asArray();
                     }
                     else if (vertexBufferKind === BABYLON.VertexBuffer.UVKind || vertexBufferKind === BABYLON.VertexBuffer.UV2Kind) {

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


+ 6 - 8
dist/preview release/serializers/babylonjs.serializers.js

@@ -291,7 +291,7 @@ var BABYLON;
                 if (vertexCount) {
                     for (var i = vertexStart; i < end; ++i) {
                         var indexOffset = positionStrideSize * i;
-                        var position = new BABYLON.Vector3(positions[indexOffset], positions[indexOffset + 1], positions[indexOffset + 2]);
+                        var position = BABYLON.Vector3.FromArray(positions, indexOffset);
                         var vector = this.convertToRightHandedSystem ? _Exporter.GetRightHandedVector3(position).asArray() : position.asArray();
                         for (var j = 0; j < positionStrideSize; ++j) {
                             var num = vector[j];
@@ -348,11 +348,11 @@ var BABYLON;
                     var index = k * strideSize;
                     var vector = [];
                     if (vertexBufferKind === BABYLON.VertexBuffer.PositionKind || vertexBufferKind === BABYLON.VertexBuffer.NormalKind) {
-                        var vertexData = new BABYLON.Vector3(meshAttributeArray[index], meshAttributeArray[index + 1], meshAttributeArray[index + 2]);
+                        var vertexData = BABYLON.Vector3.FromArray(meshAttributeArray, index);
                         vector = this.convertToRightHandedSystem ? _Exporter.GetRightHandedVector3(vertexData).asArray() : vertexData.asArray();
                     }
                     else if (vertexBufferKind === BABYLON.VertexBuffer.TangentKind || vertexBufferKind === BABYLON.VertexBuffer.ColorKind) {
-                        var vertexData = new BABYLON.Vector4(meshAttributeArray[index], meshAttributeArray[index + 1], meshAttributeArray[index + 2], meshAttributeArray[index + 3]);
+                        var vertexData = BABYLON.Vector4.FromArray(meshAttributeArray, index);
                         vector = (this.convertToRightHandedSystem && !(vertexBufferKind === BABYLON.VertexBuffer.ColorKind)) ? _Exporter.GetRightHandedVector4(vertexData).asArray() : vertexData.asArray();
                     }
                     else if (vertexBufferKind === BABYLON.VertexBuffer.UVKind || vertexBufferKind === BABYLON.VertexBuffer.UV2Kind) {
@@ -1295,16 +1295,14 @@ var BABYLON;
 
 (function universalModuleDefinition(root, factory) {
                 var f = factory();
-                if (root && root["BABYLON"]) {
-                    return;
-                }
+                
                 
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define(["BJSSerializers"], factory);
+        define("babylonjs-serializers", ["BABYLON"], factory);
     else if(typeof exports === 'object')
-        exports["BJSSerializers"] = f;
+        exports["babylonjs-serializers"] = f;
     else {
         root["BABYLON"] = f;
     }

Разлика између датотеке није приказан због своје велике величине
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


+ 1 - 249
dist/preview release/serializers/babylonjs.serializers.module.d.ts

@@ -1,258 +1,10 @@
 /// <reference types="babylonjs"/>
+/// <reference types="babylonjs-gltf2interface"/>
 
 
 declare module 'babylonjs-serializers' { 
     export = BABYLON; 
 }
-declare module BABYLON.GLTF2 {
-    const enum AccessorComponentType {
-        BYTE = 5120,
-        UNSIGNED_BYTE = 5121,
-        SHORT = 5122,
-        UNSIGNED_SHORT = 5123,
-        UNSIGNED_INT = 5125,
-        FLOAT = 5126,
-    }
-    const enum AccessorType {
-        SCALAR = "SCALAR",
-        VEC2 = "VEC2",
-        VEC3 = "VEC3",
-        VEC4 = "VEC4",
-        MAT2 = "MAT2",
-        MAT3 = "MAT3",
-        MAT4 = "MAT4",
-    }
-    const enum AnimationChannelTargetPath {
-        TRANSLATION = "translation",
-        ROTATION = "rotation",
-        SCALE = "scale",
-        WEIGHTS = "weights",
-    }
-    const enum AnimationSamplerInterpolation {
-        LINEAR = "LINEAR",
-        STEP = "STEP",
-        CUBICSPLINE = "CUBICSPLINE",
-    }
-    const enum CameraType {
-        PERSPECTIVE = "perspective",
-        ORTHOGRAPHIC = "orthographic",
-    }
-    const enum ImageMimeType {
-        JPEG = "image/jpeg",
-        PNG = "image/png",
-    }
-    const enum MaterialAlphaMode {
-        OPAQUE = "OPAQUE",
-        MASK = "MASK",
-        BLEND = "BLEND",
-    }
-    const enum MeshPrimitiveMode {
-        POINTS = 0,
-        LINES = 1,
-        LINE_LOOP = 2,
-        LINE_STRIP = 3,
-        TRIANGLES = 4,
-        TRIANGLE_STRIP = 5,
-        TRIANGLE_FAN = 6,
-    }
-    const enum TextureMagFilter {
-        NEAREST = 9728,
-        LINEAR = 9729,
-    }
-    const enum TextureMinFilter {
-        NEAREST = 9728,
-        LINEAR = 9729,
-        NEAREST_MIPMAP_NEAREST = 9984,
-        LINEAR_MIPMAP_NEAREST = 9985,
-        NEAREST_MIPMAP_LINEAR = 9986,
-        LINEAR_MIPMAP_LINEAR = 9987,
-    }
-    const enum TextureWrapMode {
-        CLAMP_TO_EDGE = 33071,
-        MIRRORED_REPEAT = 33648,
-        REPEAT = 10497,
-    }
-    interface IProperty {
-        extensions?: {
-            [key: string]: any;
-        };
-        extras?: any;
-    }
-    interface IChildRootProperty extends IProperty {
-        name?: string;
-    }
-    interface IAccessorSparseIndices extends IProperty {
-        bufferView: number;
-        byteOffset?: number;
-        componentType: AccessorComponentType;
-    }
-    interface IAccessorSparseValues extends IProperty {
-        bufferView: number;
-        byteOffset?: number;
-    }
-    interface IAccessorSparse extends IProperty {
-        count: number;
-        indices: IAccessorSparseIndices;
-        values: IAccessorSparseValues;
-    }
-    interface IAccessor extends IChildRootProperty {
-        bufferView?: number;
-        byteOffset?: number;
-        componentType: AccessorComponentType;
-        normalized?: boolean;
-        count: number;
-        type: AccessorType;
-        max?: number[];
-        min?: number[];
-        sparse?: IAccessorSparse;
-    }
-    interface IAnimationChannel extends IProperty {
-        sampler: number;
-        target: IAnimationChannelTarget;
-    }
-    interface IAnimationChannelTarget extends IProperty {
-        node: number;
-        path: AnimationChannelTargetPath;
-    }
-    interface IAnimationSampler extends IProperty {
-        input: number;
-        interpolation?: AnimationSamplerInterpolation;
-        output: number;
-    }
-    interface IAnimation extends IChildRootProperty {
-        channels: IAnimationChannel[];
-        samplers: IAnimationSampler[];
-    }
-    interface IAsset extends IChildRootProperty {
-        copyright?: string;
-        generator?: string;
-        version: string;
-        minVersion?: string;
-    }
-    interface IBuffer extends IChildRootProperty {
-        uri?: string;
-        byteLength: number;
-    }
-    interface IBufferView extends IChildRootProperty {
-        buffer: number;
-        byteOffset?: number;
-        byteLength: number;
-        byteStride?: number;
-    }
-    interface ICameraOrthographic extends IProperty {
-        xmag: number;
-        ymag: number;
-        zfar: number;
-        znear: number;
-    }
-    interface ICameraPerspective extends IProperty {
-        aspectRatio: number;
-        yfov: number;
-        zfar: number;
-        znear: number;
-    }
-    interface ICamera extends IChildRootProperty {
-        orthographic?: ICameraOrthographic;
-        perspective?: ICameraPerspective;
-        type: CameraType;
-    }
-    interface IImage extends IChildRootProperty {
-        uri?: string;
-        mimeType?: ImageMimeType;
-        bufferView?: number;
-    }
-    interface IMaterialNormalTextureInfo extends ITextureInfo {
-        scale?: number;
-    }
-    interface IMaterialOcclusionTextureInfo extends ITextureInfo {
-        strength?: number;
-    }
-    interface IMaterialPbrMetallicRoughness {
-        baseColorFactor?: number[];
-        baseColorTexture?: ITextureInfo;
-        metallicFactor?: number;
-        roughnessFactor?: number;
-        metallicRoughnessTexture?: ITextureInfo;
-    }
-    interface IMaterial extends IChildRootProperty {
-        pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
-        normalTexture?: IMaterialNormalTextureInfo;
-        occlusionTexture?: IMaterialOcclusionTextureInfo;
-        emissiveTexture?: ITextureInfo;
-        emissiveFactor?: number[];
-        alphaMode?: MaterialAlphaMode;
-        alphaCutoff?: number;
-        doubleSided?: boolean;
-    }
-    interface IMeshPrimitive extends IProperty {
-        attributes: {
-            [name: string]: number;
-        };
-        indices?: number;
-        material?: number;
-        mode?: MeshPrimitiveMode;
-        targets?: {
-            [name: string]: number;
-        }[];
-    }
-    interface IMesh extends IChildRootProperty {
-        primitives: IMeshPrimitive[];
-        weights?: number[];
-    }
-    interface INode extends IChildRootProperty {
-        camera?: number;
-        children?: number[];
-        skin?: number;
-        matrix?: number[];
-        mesh?: number;
-        rotation?: number[];
-        scale?: number[];
-        translation?: number[];
-        weights?: number[];
-    }
-    interface ISampler extends IChildRootProperty {
-        magFilter?: TextureMagFilter;
-        minFilter?: TextureMinFilter;
-        wrapS?: TextureWrapMode;
-        wrapT?: TextureWrapMode;
-    }
-    interface IScene extends IChildRootProperty {
-        nodes: number[];
-    }
-    interface ISkin extends IChildRootProperty {
-        inverseBindMatrices?: number;
-        skeleton?: number;
-        joints: number[];
-    }
-    interface ITexture extends IChildRootProperty {
-        sampler?: number;
-        source: number;
-    }
-    interface ITextureInfo {
-        index: number;
-        texCoord?: number;
-    }
-    interface IGLTF extends IProperty {
-        accessors?: IAccessor[];
-        animations?: IAnimation[];
-        asset: IAsset;
-        buffers?: IBuffer[];
-        bufferViews?: IBufferView[];
-        cameras?: ICamera[];
-        extensionsUsed?: string[];
-        extensionsRequired?: string[];
-        images?: IImage[];
-        materials?: IMaterial[];
-        meshes?: IMesh[];
-        nodes?: INode[];
-        samplers?: ISampler[];
-        scene?: number;
-        scenes?: IScene[];
-        skins?: ISkin[];
-        textures?: ITexture[];
-    }
-}
-
 
 declare module BABYLON {
     class OBJExport {

+ 4 - 1
dist/preview release/serializers/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-serializers",
     "description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -26,6 +26,9 @@
         "serializers"
     ],
     "license": "Apache-2.0",
+    "dependencies": {
+        "babylonjs-gltf2interface": "3.2.0-alpha10"
+    },
     "peerDependencies": {
         "babylonjs": ">=3.2.0-alpha"
     },

+ 2 - 34
dist/preview release/typedocValidationBaseline.json

@@ -1,7 +1,7 @@
 {
-  "errors": 7238,
+  "errors": 7232,
   "babylon.typedoc.json": {
-    "errors": 7238,
+    "errors": 7232,
     "AnimationKeyInterpolation": {
       "Enumeration": {
         "Comments": {
@@ -10010,38 +10010,6 @@
             }
           }
         },
-        "bindFramebuffer": {
-          "Comments": {
-            "MissingText": true
-          },
-          "Parameter": {
-            "texture": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "faceIndex": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "requiredWidth": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "requiredHeight": {
-              "Comments": {
-                "MissingText": true
-              }
-            },
-            "forceFullscreenViewport": {
-              "Comments": {
-                "MissingText": true
-              }
-            }
-          }
-        },
         "bindSamplers": {
           "Comments": {
             "MissingText": true

Разлика између датотеке није приказан због своје велике величине
+ 67 - 67
dist/preview release/viewer/babylon.viewer.js


Разлика између датотеке није приказан због своје велике величине
+ 349 - 48
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 4
dist/preview release/viewer/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-viewer",
     "description": "A simple-to-use viewer based on BabylonJS to display 3D elements natively",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -27,9 +27,6 @@
         "viewer"
     ],
     "license": "Apache-2.0",
-    "peerDependencies": {
-        "babylonjs": ">=3.2.0-alpha"
-    },
     "engines": {
         "node": "*"
     }

+ 7 - 2
dist/preview release/what's new.md

@@ -14,10 +14,12 @@
 - Added [VideoDome](http://doc.babylonjs.com/how_to/360videodome) class to easily support 360 videos ([DavidHGillen](https://github.com/DavidHGillen))
 - Added [GlowLayer](https://doc.babylonjs.com/how_to/glow_layer) to easily support glow from emissive materials ([sebavan](https://github.com/sebavan))
 - New [AssetContainer](http://doc.babylonjs.com/how_to/how_to_use_assetcontainer) Class and loading methods ([trevordev](https://github.com/trevordev))
+- Added depth of field effect to the default pipeline ([trevordev](https://github.com/trevordev))
 
 ## Updates
 
 - Tons of functions and classes received the code comments they deserved (All the community)
+- New `Texture.UseSerializedUrlIfAny` static property to let textures serialize complete URL instead of using side by side loading ([deltakosh](https://github.com/deltakosh))
 - Added `particleSystem.reset()` to clear a particle system ([deltakosh](https://github.com/deltakosh))
 - Added support for all RGBA orders (BGR, RGB, etc..) for the DDS loader ([deltakosh](https://github.com/deltakosh))
 - Improved [SceneOptimizer](http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer) to provide better adaptability ([deltakosh](https://github.com/deltakosh))
@@ -42,7 +44,6 @@
    ([carloslanderas](https://github.com/carloslanderas))
 - (Viewer) initScene and initEngine can now be extended. onProgress during model loading is implemented as observable. ([RaananW](https://github.com/RaananW))
 - glTF loader now supports the KHR_lights extension ([MiiBond](https://github.com/MiiBond))
-- Added depth of field effect to the default pipeline ([trevordev](https://github.com/trevordev))
 - The observable can now notify observers using promise-based callback chain. ([RaananW](https://github.com/RaananW))
 - Added base64 helper functions to `Tools` ([bghgary](https://github.com/bghgary))
 - Added `createDefaultCamera` and `createDefaultLight` functions to `Scene` ([bghgary](https://github.com/bghgary))
@@ -50,7 +51,7 @@
 - (Viewer) Scene Optimizer intergrated in viewer. ([RaananW](https://github.com/RaananW))
 - (Viewer) The viewer supports custom shaders in the configuration. ([RaananW](https://github.com/RaananW))
 - Documented PostProcessRenderEffect, DefaultRenderingPipeline, BlurPostProcess, DepthOfFieldEffect, PostProcess, PostProcessManager, Effect classes ([trevordev](https://github.com/trevordev))
-- SPS internal storage of each solid particle rotation matrix ([jbousquie](https://github.com/jbousquie)) 
+- SPS internal storage of each solid particle rotation matrix ([jbousquie](https://github.com/jbousquie))
 - SPS particle parenting feature ([jbousquie](https://github.com/jbousquie))
 - (Viewer) Introducing the viewer labs - testing new features. ([RaananW](https://github.com/RaananW))
 - KeepAssets class and AssetContainer.moveAllFromScene ([HoloLite](http://www.html5gamedevs.com/profile/28694-hololite/) [trevordev](https://github.com/trevordev))
@@ -77,6 +78,8 @@
 - (Viewer) XHR requests not use Tools.LoadFile and are disposed correctly - [#3671](https://github.com/BabylonJS/Babylon.js/issues/3671) ([RaananW](https://github.com/RaananW))
 - Added `Tools.WorkerPool` class for web worker management. ([bghgary](https://github.com/bghgary))
 - Support depth maps for multiple active cameras for post processes like depth of field ([trevordev](https://github.com/trevordev))
+- Integrates depth texture support in the engine ([sebavan](https://github.com/sebavan))
+- NPM package now has a dependency system, updated during build. ([RaananW](https://github.com/RaananW))
 
 ## Bug fixes
 
@@ -88,6 +91,8 @@
 - Enabling teleportation in the vr helper class caused a redundant post process to be added ([trevordev](https://github.com/trevordev))
 - (Viewer) Fixed a bug where loading another mesh positioned it incorrectly ([RaananW](https://github.com/RaananW))
 - Scale vr controllers by deviceScale when it is set in VRExperienceHelper ([trevordev](https://github.com/trevordev))
+- (Viewer) Disabling templates now work correctly ([RaananW](https://github.com/RaananW))
+- AMD "define" declaration is no longer anonymous ([RaananW](https://github.com/RaananW))
 
 ## Breaking changes
 

+ 1 - 1
package.json

@@ -9,7 +9,7 @@
     ],
     "name": "babylonjs",
     "description": "Babylon.js is a JavaScript 3D engine based on webgl.",
-    "version": "3.2.0-alpha8",
+    "version": "3.2.0-alpha10",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 3
src/Debug/babylon.debugModules.ts

@@ -368,7 +368,7 @@ module BABYLON {
 
                 if (x !== 0 || y !== 0 || z !== 0) {
                     var tmat2 = Tmp.Matrix[1];
-                    BABYLON.Matrix.IdentityToRef(tmat2);
+                    Matrix.IdentityToRef(tmat2);
                     tmat2.m[12] = x;
                     tmat2.m[13] = y;
                     tmat2.m[14] = z;
@@ -438,10 +438,10 @@ module BABYLON {
                 }
 
                 if (!this._debugMesh) {
-                    this._debugMesh = BABYLON.MeshBuilder.CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, this._scene);
+                    this._debugMesh = MeshBuilder.CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, this._scene);
                     this._debugMesh.renderingGroupId = this.renderingGroupId;
                 } else {
-                    BABYLON.MeshBuilder.CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, this._scene);
+                    MeshBuilder.CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, this._scene);
                 }
                 this._debugMesh.position.copyFrom(this.mesh.position);
                 this._debugMesh.color = this.color;

+ 240 - 2
src/Engine/babylon.engine.ts

@@ -217,6 +217,18 @@
     }
 
     /**
+     * Define options used to create a depth texture
+     */
+    export class DepthTextureCreationOptions {
+        /** Specifies wether or not a stencil should be allocated in the texture */
+        generateStencil?: boolean;
+        /** Specifies wether or not bilinear filtering is enable on the texture */
+        bilinearFiltering?: boolean;
+        /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
+        comparisonFunction?: number;
+    }
+
+    /**
      * Regroup several parameters relative to the browser in use
      */
     export class EngineCapabilities {
@@ -285,6 +297,7 @@
             { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
             { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
             { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
+            { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
         ];
 
         public static Instances = new Array<Engine>();
@@ -573,7 +586,7 @@
         }
 
         public static get Version(): string {
-            return "3.2.0-alpha8";
+            return "3.2.0-alpha10";
         }
 
         // Updatable statics so stick with vars here
@@ -1290,6 +1303,7 @@
 
                 if (depthTextureExtension != null) {
                     this._caps.depthTextureExtension = true;
+                    this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
                 }
             }
 
@@ -1927,7 +1941,16 @@
             });
         }
 
-        public bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void {
+        /**
+         * Binds the frame buffer to the specified texture.
+         * @param texture The texture to render to or null for the default canvas
+         * @param faceIndex The face of the texture to render to in case of cube texture
+         * @param requiredWidth The width of the target to render to
+         * @param requiredHeight The height of the target to render to
+         * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
+         * @param depthStencilTexture The depth stencil texture to use to render
+         */
+        public bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture): void {
             if (this._currentRenderTarget) {
                 this.unBindFramebuffer(this._currentRenderTarget);
             }
@@ -1939,6 +1962,15 @@
                     faceIndex = 0;
                 }
                 gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, 0);
+
+                if (depthStencilTexture) {
+                    if (depthStencilTexture._generateStencilBuffer) {
+                        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture, 0);
+                    }
+                    else {
+                        gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture, 0);
+                    }
+                }
             }
 
             if (this._cachedViewport && !forceFullscreenViewport) {
@@ -3637,6 +3669,212 @@
             }
         }
 
+        /**
+         * Updates a depth texture Comparison Mode and Function.
+         * If the comparison Function is equal to 0, the mode will be set to none.
+         * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
+         * @param texture The texture to set the comparison function for
+         * @param comparisonFunction The comparison function to set, 0 if no comparison required
+         */
+        public updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void {
+            if (this.webGLVersion === 1) {
+                Tools.Error("WebGL 1 does not support texture comparison.");
+                return;
+            }
+
+            var gl = this._gl;
+
+            if (texture.isCube) {
+                this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
+
+                if (comparisonFunction === 0) {
+                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
+                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
+                }
+                else {
+                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
+                    gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
+                }
+
+                this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
+            } else {
+                this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
+
+                if (comparisonFunction === 0) {
+                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
+                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
+                }
+                else {
+                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
+                    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
+                }
+
+                this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
+            }
+
+            texture._comparisonFunction = comparisonFunction;
+        }
+
+        private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | { width: number, height: number }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number) : void {
+            var width = (<{ width: number, height: number }>size).width || <number>size;
+            var height = (<{ width: number, height: number }>size).height || <number>size;
+            internalTexture.baseWidth = width;
+            internalTexture.baseHeight = height;
+            internalTexture.width = width;
+            internalTexture.height = height;
+            internalTexture.isReady = true;
+            internalTexture.samples = 1;
+            internalTexture.generateMipMaps = false;
+            internalTexture._generateDepthBuffer = true;
+            internalTexture._generateStencilBuffer = generateStencil;
+            internalTexture.samplingMode = bilinearFiltering ? Texture.NEAREST_SAMPLINGMODE : Texture.BILINEAR_SAMPLINGMODE;
+            internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
+            internalTexture._comparisonFunction = comparisonFunction;
+
+            var gl = this._gl;
+            var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
+            var samplingParameters = getSamplingParameters(internalTexture.samplingMode, false, gl);
+            gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
+            gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
+            gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+            gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+
+            if (comparisonFunction === 0) {
+                gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
+                gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
+            }
+            else {
+                gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
+                gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
+            }
+        }
+
+        /**
+         * Creates a depth stencil texture.
+         * This is only available in WebGL 2 or with the depth texture extension available.
+         * @param size The size of face edge in the texture.
+         * @param options The options defining the texture.
+         * @returns The texture
+         */
+        public createDepthStencilTexture(size: number | { width: number, height: number }, options: DepthTextureCreationOptions) : InternalTexture {
+            var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_DEPTHTEXTURE);
+
+            if (!this._caps.depthTextureExtension) {
+                Tools.Error("Depth texture is not supported by your browser or hardware.");
+                return internalTexture;
+            }
+
+            var internalOptions = {
+                bilinearFiltering: false,
+                comparisonFunction: 0,
+                generateStencil: false,
+                ...options
+            }
+
+            var gl = this._gl;
+            this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
+
+            this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
+
+            if (this.webGLVersion > 1) {
+                if (internalOptions.generateStencil) {
+                    gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
+                }
+                else {
+                    gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
+                }
+            }
+            else {
+                if (internalOptions.generateStencil) {
+                    gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
+                }
+                else {
+                    gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
+                }
+            }
+
+            this._bindTextureDirectly(gl.TEXTURE_2D, null);
+
+            return internalTexture;
+        }
+
+        /**
+         * Creates a depth stencil cube texture.
+         * This is only available in WebGL 2.
+         * @param size The size of face edge in the cube texture.
+         * @param options The options defining the cube texture.
+         * @returns The cube texture
+         */
+        public createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions) : InternalTexture {
+            var internalTexture = new InternalTexture(this, InternalTexture.DATASOURCE_UNKNOWN);
+            internalTexture.isCube = true;
+
+            if (this.webGLVersion === 1) {
+                Tools.Error("Depth cube texture is not supported by WebGL 1.");
+                return internalTexture;
+            }
+
+            var internalOptions = {
+                bilinearFiltering: false,
+                comparisonFunction: 0,
+                generateStencil: false,
+                ...options
+            }
+
+            var gl = this._gl;
+            this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
+
+            this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
+
+            // Create the depth/stencil buffer
+            for (var face = 0; face < 6; face++) {
+                if (internalOptions.generateStencil) {
+                    gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH24_STENCIL8, size, size, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
+                }
+                else {
+                    gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
+                }
+            }
+
+            this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
+
+            return internalTexture;
+        }
+
+        /**
+         * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
+         * @param renderTarget The render target to set the frame buffer for
+         */
+        public setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void {
+            // Create the framebuffer
+            var internalTexture = renderTarget.getInternalTexture();
+            if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
+                return;
+            }
+
+            var gl = this._gl;
+            var depthStencilTexture = renderTarget.depthStencilTexture;
+
+            this.bindUnboundFramebuffer(internalTexture._framebuffer);
+            if (depthStencilTexture.isCube) {
+                if (depthStencilTexture._generateStencilBuffer) {
+                    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture, 0);
+                }
+                else {
+                    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture, 0);
+                }
+            }
+            else {
+                if (depthStencilTexture._generateStencilBuffer) {
+                    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture, 0);
+                }
+                else {
+                    gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture, 0);
+                }
+            }
+            this.bindUnboundFramebuffer(null);
+        }
+
         public createRenderTargetTexture(size: number | { width: number, height: number }, options: boolean | RenderTargetCreationOptions): InternalTexture {
             let fullOptions = new RenderTargetCreationOptions();
 

+ 4 - 0
src/Engine/babylon.webgl2.ts

@@ -5,8 +5,12 @@
 
 interface WebGLRenderingContext {
     readonly RASTERIZER_DISCARD: number;
+    readonly DEPTH_COMPONENT24: number;
     readonly TEXTURE_3D: number;
     readonly TEXTURE_2D_ARRAY: number;
+    readonly TEXTURE_COMPARE_FUNC: number;
+    readonly TEXTURE_COMPARE_MODE: number;
+    readonly COMPARE_REF_TO_TEXTURE: number;
     readonly TEXTURE_WRAP_R: number;
 
     texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;

+ 19 - 7
src/Helpers/babylon.videoDome.ts

@@ -62,18 +62,18 @@ module BABYLON {
             options.size = Math.abs(options.size as any) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
 
             // create
-            let tempOptions:VideoTextureSettings = {loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true};
-            let material = this._material = new BABYLON.BackgroundMaterial(name+"_material", scene);
-            let texture = this._videoTexture = new BABYLON.VideoTexture(name+"_texture", urlsOrVideo, scene, false, false, Texture.TRILINEAR_SAMPLINGMODE, tempOptions);
-            this._mesh = BABYLON.MeshBuilder.CreateIcoSphere(name+"_mesh", {
+            let tempOptions: VideoTextureSettings = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true };
+            let material = this._material = new BackgroundMaterial(name + "_material", scene);
+            let texture = this._videoTexture = new VideoTexture(name + "_texture", urlsOrVideo, scene, false, false, Texture.TRILINEAR_SAMPLINGMODE, tempOptions);
+            this._mesh = MeshBuilder.CreateIcoSphere(name + "_mesh", {
                 flat: false, // saves on vertex data
                 radius: options.size,
                 subdivisions: options.resolution,
-                sideOrientation: BABYLON.Mesh.BACKSIDE // needs to be inside out
+                sideOrientation: Mesh.BACKSIDE // needs to be inside out
             }, scene);
 
             // configure material
-            texture.coordinatesMode = BABYLON.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
+            texture.coordinatesMode = Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
             texture.wrapV = Texture.CLAMP_ADDRESSMODE; // always clamp the up/down
             material.reflectionTexture = this._videoTexture;
             material.useEquirectangularFOV = true;
@@ -84,11 +84,23 @@ module BABYLON {
             this._mesh.parent = this;
 
             // optional configuration
-            if(options.clickToPlay) {
+            if (options.clickToPlay) {
                 scene.onPointerUp = () => {
                     this._videoTexture.video.play();
                 }
             }
         }
+
+        /**
+         * Releases all associated resources
+         */
+        public dispose(): void {
+            super.dispose();
+
+            this._videoTexture.dispose();
+            this._mesh.dispose();
+            this._material.dispose();
+
+        }
     }
 }

+ 15 - 1
src/Materials/Background/babylon.backgroundMaterial.ts

@@ -64,7 +64,14 @@
          */
         public NOISE = false;
 
-        // Image Processing Configuration.
+
+
+        /**
+         * is the reflection texture in BGR color scheme? 
+         * Mainly used to solve a bug in ios10 video tag
+         */
+        public REFLECTIONBGR = false;
+
         public IMAGEPROCESSING = false;
         public VIGNETTE = false;
         public VIGNETTEBLENDMODEMULTIPLY = false;
@@ -521,6 +528,12 @@
             (<ImageProcessingConfiguration>this.imageProcessingConfiguration).colorCurves = value;
         }
 
+        /**
+         * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
+         * Setting this flag to true (not done automatically!) will convert it back to RGB.
+         */
+        public switchToBGR: boolean = false;
+
         // Temp values kept as cache in the material.
         private _renderTargets = new SmartArray<RenderTargetTexture>(16);
         private _reflectionControls = Vector4.Zero();
@@ -635,6 +648,7 @@
                         defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
                         defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
                         defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
+                        defines.REFLECTIONBGR = this.switchToBGR;
 
                         if (reflectionTexture.coordinatesMode === Texture.INVCUBIC_MODE) {
                             defines.INVERTCUBICMAP = true;

+ 9 - 1
src/Materials/Textures/babylon.cubeTexture.ts

@@ -40,7 +40,7 @@
 
         public static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean) {
             let rootUrlKey = "";
-            
+
             files.forEach(url => rootUrlKey += url);
 
             return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
@@ -150,6 +150,14 @@
                 return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions);
             }, parsedTexture, scene);
 
+            // Local Cubemaps
+            if (parsedTexture.boundingBoxPosition) {
+                texture.boundingBoxPosition = Vector3.FromArray(parsedTexture.boundingBoxPosition);
+            }
+            if (parsedTexture.boundingBoxSize) {
+                texture.boundingBoxSize = Vector3.FromArray(parsedTexture.boundingBoxSize);
+            }
+
             // Animations
             if (parsedTexture.animations) {
                 for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {

+ 36 - 0
src/Materials/Textures/babylon.hdrCubeTexture.ts

@@ -58,6 +58,34 @@ module BABYLON {
         }
 
         /**
+         * Gets or sets the center of the bounding box associated with the cube texture
+         * It must define where the camera used to render the texture was set
+         */
+        public boundingBoxPosition = Vector3.Zero();
+
+        private _boundingBoxSize: Vector3;
+
+        /**
+         * Gets or sets the size of the bounding box associated with the cube texture
+         * When defined, the cubemap will switch to local mode
+         * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
+         * @example https://www.babylonjs-playground.com/#RNASML
+         */
+        public set boundingBoxSize(value: Vector3) {
+            if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
+                return;
+            }
+            this._boundingBoxSize = value;
+            let scene = this.getScene();
+            if (scene) {
+                scene.markAllMaterialsAsDirty(Material.TextureDirtyFlag);
+            }
+        }
+        public get boundingBoxSize(): Vector3 {
+            return this._boundingBoxSize;
+        }
+
+        /**
          * Instantiates an HDRTexture from the following parameters.
          * 
          * @param url The location of the HDR raw data (Panorama stored in RGBE format)
@@ -442,6 +470,14 @@ module BABYLON {
                 texture.coordinatesMode = parsedTexture.coordinatesMode;
                 texture.isBlocking = parsedTexture.isBlocking;
             }
+            if (texture) {
+                if (parsedTexture.boundingBoxPosition) {
+                    (<any>texture).boundingBoxPosition = Vector3.FromArray(parsedTexture.boundingBoxPosition);
+                }
+                if (parsedTexture.boundingBoxSize) {
+                    (<any>texture).boundingBoxSize = Vector3.FromArray(parsedTexture.boundingBoxSize);
+                }
+            }
             return texture;
         }
 

+ 22 - 0
src/Materials/Textures/babylon.internalTexture.ts

@@ -49,6 +49,10 @@ module BABYLON {
          * Texture content is raw 3D data
          */
         public static DATASOURCE_RAW3D = 10;
+        /**
+         * Texture content is a depth texture
+         */
+        public static DATASOURCE_DEPTHTEXTURE = 11;
 
         /**
          * Defines if the texture is ready
@@ -180,6 +184,8 @@ module BABYLON {
         /** @ignore */
         public _generateDepthBuffer: boolean;
         /** @ignore */
+        public _comparisonFunction: number = 0;
+        /** @ignore */
         public _sphericalPolynomial: Nullable<SphericalPolynomial>;
         /** @ignore */
         public _lodGenerationScale: number;
@@ -311,6 +317,22 @@ module BABYLON {
 
                     this.isReady = true;
                     return;
+                case InternalTexture.DATASOURCE_DEPTHTEXTURE:
+                    let depthTextureOptions = {
+                        bilinearFiltering: this.samplingMode !== Texture.BILINEAR_SAMPLINGMODE,
+                        comparisonFunction: this._comparisonFunction,
+                        generateStencil: this._generateStencilBuffer,
+                    };
+
+                    if (this.isCube) {
+                        proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
+                    } else {
+                        proxy = this._engine.createDepthStencilCubeTexture(this.width, depthTextureOptions);
+                    }
+                    proxy._swapAndDie(this);
+
+                    this.isReady = true;
+                    return;
 
                 case InternalTexture.DATASOURCE_CUBE:
                     proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, () => {

+ 23 - 1
src/Materials/Textures/babylon.renderTargetTexture.ts

@@ -156,6 +156,28 @@
             return this._boundingBoxSize;
         }
 
+        /**
+         * In case the RTT has been created with a depth texture, get the associated 
+         * depth texture.
+         * Otherwise, return null.
+         */
+        public depthStencilTexture: Nullable<InternalTexture>;
+
+        /**
+         * Instantiate a render target texture. This is mainly to render of screen the scene to for instance apply post processse
+         * or used a shadow, depth texture...
+         * @param name The friendly name of the texture
+         * @param size The size of the RTT (number if square, or {with: number, height:number} or {ratio:} to define a ratio from the main scene)
+         * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
+         * @param generateMipMaps True if mip maps need to be generated after render.
+         * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
+         * @param type The type of the buffer in the RTT (int, half float, float...)
+         * @param isCube True if a cube texture needs to be created
+         * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
+         * @param generateDepthBuffer True to generate a depth buffer
+         * @param generateStencilBuffer True to generate a stencil buffer
+         * @param isMulti True if multiple textures need to be created (Draw Buffers)
+         */
         constructor(name: string, size: number | {width: number, height: number} | {ratio: number}, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio: boolean = true, type: number = Engine.TEXTURETYPE_UNSIGNED_INT, public isCube = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, generateDepthBuffer = true, generateStencilBuffer = false, isMulti = false) {
             super(null, scene, !generateMipMaps);
             scene = this.getScene();
@@ -551,7 +573,7 @@
             }
             else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
                 if (this._texture) {
-                    engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport);
+                    engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
                 }
             }
 

+ 11 - 1
src/Materials/Textures/babylon.texture.ts

@@ -35,6 +35,11 @@
         public static WRAP_ADDRESSMODE = 1;
         public static MIRROR_ADDRESSMODE = 2;
 
+        /**
+         * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
+         */
+        public static UseSerializedUrlIfAny = false;
+
         // Members
         @serialize()
         public url: Nullable<string>;
@@ -449,7 +454,12 @@
                     if (parsedTexture.base64String) {
                         texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
                     } else {
-                        texture = new Texture(rootUrl + parsedTexture.name, scene, !generateMipMaps);
+                        let url = rootUrl + parsedTexture.name; 
+
+                        if (Texture.UseSerializedUrlIfAny && parsedTexture.url ) {
+                            url = parsedTexture.url;
+                        }
+                        texture = new Texture(url, scene, !generateMipMaps);
                     }
 
                     return texture;

+ 2 - 1
src/Materials/Textures/babylon.videoTexture.ts

@@ -205,11 +205,12 @@
         }
 
         public dispose(): void {
-            super.dispose();
+            super.dispose();            
             this.video.removeEventListener("canplay", this._createInternalTexture);
             this.video.removeEventListener("paused", this._updateInternalTexture);
             this.video.removeEventListener("seeked", this._updateInternalTexture);
             this.video.removeEventListener("emptied", this.reset);
+            this.video.pause();
         }
 
         public static CreateFromWebCam(

+ 35 - 35
src/Math/babylon.math.ts

@@ -18,11 +18,11 @@
             /**
              * Defines the red component (between 0 and 1, default is 0)
              */
-            public r: number = 0, 
+            public r: number = 0,
             /**
              * Defines the green component (between 0 and 1, default is 0) 
              */
-            public g: number = 0, 
+            public g: number = 0,
             /**
              * Defines the blue component (between 0 and 1, default is 0)
              */
@@ -175,9 +175,9 @@
          * @returns the original Color3
          */
         public clampToRef(min: number = 0, max: number = 1, result: Color3): Color3 {
-            result.r = BABYLON.Scalar.Clamp(this.r, min, max);
-            result.g = BABYLON.Scalar.Clamp(this.g, min, max);
-            result.b = BABYLON.Scalar.Clamp(this.b, min, max);
+            result.r = Scalar.Clamp(this.r, min, max);
+            result.g = Scalar.Clamp(this.g, min, max);
+            result.b = Scalar.Clamp(this.b, min, max);
             return this;
         }
 
@@ -387,58 +387,58 @@
         /**
          * Returns a Color3 value containing a green color
          * @returns a new Color3 object
-         */        
+         */
         public static Green(): Color3 { return new Color3(0, 1, 0); }
         /**
          * Returns a Color3 value containing a blue color
          * @returns a new Color3 object
-         */        
+         */
         public static Blue(): Color3 { return new Color3(0, 0, 1); }
         /**
          * Returns a Color3 value containing a black color
          * @returns a new Color3 object
-         */        
+         */
         public static Black(): Color3 { return new Color3(0, 0, 0); }
         /**
          * Returns a Color3 value containing a white color
          * @returns a new Color3 object
-         */        
+         */
         public static White(): Color3 { return new Color3(1, 1, 1); }
         /**
          * Returns a Color3 value containing a purple color
          * @returns a new Color3 object
-         */        
+         */
         public static Purple(): Color3 { return new Color3(0.5, 0, 0.5); }
         /**
          * Returns a Color3 value containing a magenta color
          * @returns a new Color3 object
-         */        
+         */
         public static Magenta(): Color3 { return new Color3(1, 0, 1); }
         /**
          * Returns a Color3 value containing a yellow color
          * @returns a new Color3 object
-         */        
+         */
         public static Yellow(): Color3 { return new Color3(1, 1, 0); }
         /**
          * Returns a Color3 value containing a gray color
          * @returns a new Color3 object
-         */        
+         */
         public static Gray(): Color3 { return new Color3(0.5, 0.5, 0.5); }
         /**
          * Returns a Color3 value containing a teal color
          * @returns a new Color3 object
-         */        
+         */
         public static Teal(): Color3 { return new Color3(0, 1.0, 1.0); }
         /**
          * Returns a Color3 value containing a random color
          * @returns a new Color3 object
-         */     
+         */
         public static Random(): Color3 { return new Color3(Math.random(), Math.random(), Math.random()); }
     }
 
     /**
      * Class used to hold a RBGA color
-     */    
+     */
     export class Color4 {
         /**
          * Creates a new Color4 object from red, green, blue values, all between 0 and 1
@@ -451,15 +451,15 @@
             /**
              * Defines the red component (between 0 and 1, default is 0)
              */
-            public r: number = 0, 
+            public r: number = 0,
             /**
              * Defines the green component (between 0 and 1, default is 0) 
              */
-            public g: number = 0, 
+            public g: number = 0,
             /**
              * Defines the blue component (between 0 and 1, default is 0)
              */
-            public b: number = 0, 
+            public b: number = 0,
             /**
              * Defines the alpha component (between 0 and 1, default is 1)
              */
@@ -571,10 +571,10 @@
          * @returns the cuurent Color4
          */
         public clampToRef(min: number = 0, max: number = 1, result: Color4): Color4 {
-            result.r = BABYLON.Scalar.Clamp(this.r, min, max);
-            result.g = BABYLON.Scalar.Clamp(this.g, min, max);
-            result.b = BABYLON.Scalar.Clamp(this.b, min, max);
-            result.a = BABYLON.Scalar.Clamp(this.a, min, max);
+            result.r = Scalar.Clamp(this.r, min, max);
+            result.g = Scalar.Clamp(this.g, min, max);
+            result.b = Scalar.Clamp(this.b, min, max);
+            result.a = Scalar.Clamp(this.a, min, max);
             return this;
         }
 
@@ -1294,11 +1294,11 @@
             /**
              * Defines the first coordinates (on X axis)
              */
-            public x: number, 
+            public x: number,
             /**
              * Defines the second coordinates (on Y axis)
              */
-            public y: number, 
+            public y: number,
             /**
              * Defines the third coordinates (on Z axis)
              */
@@ -1798,10 +1798,10 @@
          * @param normal direction of the normal
          * @return the angle between vector0 and vector1
          */
-        public static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3):number {
-            var v0:Vector3 = vector0.clone().normalize();
-            var v1:Vector3 = vector1.clone().normalize();
-            var dot:number = Vector3.Dot(v0, v1);
+        public static GetAngleBetweenVectors(vector0: Vector3, vector1: Vector3, normal: Vector3): number {
+            var v0: Vector3 = vector0.clone().normalize();
+            var v1: Vector3 = vector1.clone().normalize();
+            var dot: number = Vector3.Dot(v0, v1);
             var n = Vector3.Cross(v0, v1);
             if (Vector3.Dot(n, normal) > 0) {
                 return Math.acos(dot);
@@ -2301,7 +2301,7 @@
          * @param left defines the first operand
          * @param right defines the second operand
          * @returns the new Vector3
-         */        
+         */
         public static Maximize(left: Vector3, right: Vector3): Vector3 {
             var max = left.clone();
             max.maximizeInPlace(right);
@@ -3897,15 +3897,15 @@
          * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).  
          * @param ref matrix to store the result
          */
-        public toNormalMatrix(ref : Matrix): void {            
+        public toNormalMatrix(ref: Matrix): void {
             this.invertToRef(ref)
             ref.transpose();
             var m = ref.m;
             Matrix.FromValuesToRef(
-                m[0], m[1], m[2],  0,
-                m[4], m[5], m[6],  0,
+                m[0], m[1], m[2], 0,
+                m[4], m[5], m[6], 0,
                 m[8], m[9], m[10], 0,
-                0,    0,    0,     1, ref);
+                0, 0, 0, 1, ref);
         }
 
         /**
@@ -3916,7 +3916,7 @@
             this.getRotationMatrixToRef(result);
             return result;
         }
-       
+
         /**
          * Extracts the rotation matrix from the current one and sets it as the passed "result".  
          * Returns the current Matrix.  

+ 2 - 1
src/Particles/babylon.IParticleSystem.ts

@@ -131,8 +131,9 @@ module BABYLON {
         render(): number;
         /**
          * Dispose the particle system and frees its associated resources.
+         * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
          */
-        dispose(): void;
+        dispose(disposeTexture?: boolean): void;
         /**
          * Clones the particle system.
          * @param name The name of the cloned object

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

@@ -638,9 +638,10 @@
         }
 
         /**
-         * Disposes the particle system and free the associated resources.
+         * Disposes the particle system and free the associated resources
+         * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
          */
-        public dispose(): void {
+        public dispose(disposeTexture = true): void {
             var index = this._scene.particleSystems.indexOf(this);
             if (index > -1) {
                 this._scene.particleSystems.splice(index, 1);
@@ -655,6 +656,11 @@
                 (<any>this._randomTexture) = null;
             }
 
+            if (disposeTexture && this.particleTexture) {
+                this.particleTexture.dispose();
+                this.particleTexture = null;
+            }            
+
             // Callback
             this.onDisposeObservable.notifyObservers(this);
             this.onDisposeObservable.clear();

+ 4 - 3
src/Particles/babylon.particleSystem.ts

@@ -831,9 +831,10 @@
         }
 
         /**
-         * Disposes the particle system and free the associated resources.
+         * Disposes the particle system and free the associated resources
+         * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
          */
-        public dispose(): void {
+        public dispose(disposeTexture = true): void {
             if (this._vertexBuffer) {
                 this._vertexBuffer.dispose();
                 this._vertexBuffer = null;
@@ -844,7 +845,7 @@
                 this._indexBuffer = null;
             }
 
-            if (this.particleTexture) {
+            if (disposeTexture && this.particleTexture) {
                 this.particleTexture.dispose();
                 this.particleTexture = null;
             }

+ 3 - 3
src/Probes/babylon.reflectionProbe.ts

@@ -8,7 +8,7 @@
         private _add = Vector3.Zero();
         private _attachedMesh: AbstractMesh;
 
-        public invertYAxis = false;
+        private _invertYAxis = false;
         public position = Vector3.Zero();
           
         constructor(public name: string, size: number, scene: Scene, generateMipMaps = true) {
@@ -27,10 +27,10 @@
                         this._add.copyFromFloats(-1, 0, 0);
                         break;
                     case 2:
-                        this._add.copyFromFloats(0, this.invertYAxis ? 1 : -1, 0);
+                        this._add.copyFromFloats(0, this._invertYAxis ? 1 : -1, 0);
                         break;
                     case 3:
-                        this._add.copyFromFloats(0, this.invertYAxis ? -1 : 1, 0);
+                        this._add.copyFromFloats(0, this._invertYAxis ? -1 : 1, 0);
                         break;
                     case 4:
                         this._add.copyFromFloats(0, 0, 1);

+ 14 - 9
src/Shaders/ShadersInclude/reflectionFunction.fx

@@ -61,20 +61,25 @@ vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
 #endif
 
 #ifdef REFLECTIONMAP_CUBIC
-	vec3 viewDir = worldPos.xyz - vEyePosition.xyz;
-	vec3 coords = reflect(viewDir, worldNormal);
-#ifdef INVERTCUBICMAP
-	coords.y = 1.0 - coords.y;
-#endif
+    vec3 viewDir = normalize(worldPos.xyz - vEyePosition.xyz);
 
-#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
-	coords = parallaxCorrectNormal(worldPos.xyz, coords, vReflectionSize, vReflectionPosition );
-#endif
+    // worldNormal has already been normalized.
+    vec3 coords = reflect(viewDir, worldNormal);
 
+    #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
+        coords = parallaxCorrectNormal(worldPos.xyz, coords, vReflectionSize, vReflectionPosition);
+    #endif
 
-	return vec3(reflectionMatrix * vec4(coords, 0));
+    coords = vec3(reflectionMatrix * vec4(coords, 0));
+    
+    #ifdef INVERTCUBICMAP
+        coords.y *= -1.0;
+    #endif
+
+    return coords;
 #endif
 
+
 #ifdef REFLECTIONMAP_PROJECTION
 	return vec3(reflectionMatrix * (view * worldPos));
 #endif

+ 4 - 0
src/Shaders/background.fragment.fx

@@ -190,6 +190,10 @@ vec3 reflectionColor = vec3(1., 1., 1.);
         reflectionColor = toLinearSpace(reflectionColor.rgb);
     #endif
 
+    #ifdef REFLECTIONBGR
+        reflectionColor = reflectionColor.bgr;
+    #endif
+
     // _____________________________ Levels _____________________________________
     reflectionColor *= vReflectionInfos.x;
 #endif

+ 1 - 0
src/babylon.mixins.ts

@@ -60,6 +60,7 @@ interface WebGLRenderingContext {
     RED: number;
     RG: number;
 
+    UNSIGNED_INT_24_8: number;
     DEPTH24_STENCIL8: number;
 
     /* Multiple Render Targets */

+ 22 - 6
src/babylon.scene.ts

@@ -3389,7 +3389,6 @@
             // Camera
             this.resetCachedMaterial();
             this._renderId++;
-            this.activeCamera.update();
             this.updateTransformMatrix();
 
             if (camera._alternateCamera) {
@@ -3568,11 +3567,6 @@
                 return;
             }
 
-            // Update camera
-            if (this.activeCamera) {
-                this.activeCamera.update();
-            }
-
             // rig cameras
             for (var index = 0; index < camera._rigCameras.length; index++) {
                 this._renderForCamera(camera._rigCameras[index], camera);
@@ -3715,6 +3709,28 @@
             // Before render
             this.onBeforeRenderObservable.notifyObservers(this);
 
+            // Update Cameras
+            if (this.activeCameras.length > 0) {
+                for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
+                    let camera = this.activeCameras[cameraIndex];
+                    camera.update();
+                    if (camera.cameraRigMode !== Camera.RIG_MODE_NONE) {
+                        // rig cameras
+                        for (var index = 0; index < camera._rigCameras.length; index++) {
+                            camera._rigCameras[index].update();
+                        }
+                    }
+                }
+            } else if (this.activeCamera) {
+                this.activeCamera.update();
+                if (this.activeCamera.cameraRigMode !== Camera.RIG_MODE_NONE) {
+                    // rig cameras
+                    for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
+                        this.activeCamera._rigCameras[index].update();
+                    }
+                }
+            }
+
             // Customs render targets
             this.OnBeforeRenderTargetsRenderObservable.notifyObservers(this);
             var engine = this.getEngine();

BIN
tests/validation/ReferenceImages/refprobe.png