Browse Source

Merge master

David Catuhe 7 years ago
parent
commit
90cf734a0f
25 changed files with 1374 additions and 780 deletions
  1. 6 5
      Tools/Gulp/config.json
  2. 24 10
      Tools/Gulp/gulp-addModuleExports.js
  3. 5 4
      Tools/Gulp/gulpfile.js
  4. 4 0
      Tools/Publisher/index.js
  5. 323 323
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  6. 52 5
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  7. 74 3
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  8. 323 323
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  9. 33 0
      dist/preview release/inspector/package.json
  10. 34 0
      dist/preview release/inspector/readme.md
  11. 34 0
      dist/preview release/materialsLibrary/babylon.backgroundMaterial.d.ts
  12. 74 3
      dist/preview release/materialsLibrary/babylon.backgroundMaterial.js
  13. 1 1
      dist/preview release/materialsLibrary/babylon.backgroundMaterial.min.js
  14. 74 3
      dist/preview release/materialsLibrary/babylonjs.materials.js
  15. 2 2
      dist/preview release/materialsLibrary/babylonjs.materials.min.js
  16. 34 0
      dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts
  17. 1 1
      inspector/webpack.config.js
  18. 2 2
      materialsLibrary/src/background/babylon.backgroundMaterial.js.include.fx
  19. 87 0
      materialsLibrary/src/background/babylon.backgroundMaterial.ts
  20. 109 73
      materialsLibrary/src/background/background.fragment.fx
  21. 8 0
      materialsLibrary/src/background/backgroundFragmentDeclaration.fx
  22. 8 0
      materialsLibrary/src/background/backgroundUboDeclaration.fx
  23. 57 18
      materialsLibrary/test/addbackground.js
  24. 0 4
      src/Physics/Plugins/babylon.cannonJSPlugin.ts
  25. 5 0
      src/Physics/babylon.physicsImpostor.ts

+ 6 - 5
Tools/Gulp/config.json

@@ -242,7 +242,7 @@
             "dependUpon": [
             "dependUpon": [
                 "core"
                 "core"
             ]
             ]
-        },    
+        },
         "instrumentation": {
         "instrumentation": {
             "files": [
             "files": [
                 "../../src/Instrumentation/babylon.engineInstrumentation.js",
                 "../../src/Instrumentation/babylon.engineInstrumentation.js",
@@ -252,7 +252,7 @@
             "dependUpon": [
             "dependUpon": [
                 "core"
                 "core"
             ]
             ]
-        },      
+        },
         "cameraBehaviors": {
         "cameraBehaviors": {
             "files": [
             "files": [
                 "../../src/Behaviors/Cameras/babylon.framingBehavior.js",
                 "../../src/Behaviors/Cameras/babylon.framingBehavior.js",
@@ -405,7 +405,7 @@
                 "defaultUboDeclaration",
                 "defaultUboDeclaration",
                 "shadowsFragmentFunctions",
                 "shadowsFragmentFunctions",
                 "fresnelFunction",
                 "fresnelFunction",
-                "reflectionFunction",                
+                "reflectionFunction",
                 "imageProcessingDeclaration",
                 "imageProcessingDeclaration",
                 "imageProcessingFunctions",
                 "imageProcessingFunctions",
                 "bumpFragmentFunctions",
                 "bumpFragmentFunctions",
@@ -461,7 +461,7 @@
                 "shadowsFragmentFunctions",
                 "shadowsFragmentFunctions",
                 "pbrFunctions",
                 "pbrFunctions",
                 "imageProcessingDeclaration",
                 "imageProcessingDeclaration",
-                "imageProcessingFunctions",                
+                "imageProcessingFunctions",
                 "harmonicsFunctions",
                 "harmonicsFunctions",
                 "pbrLightFunctions",
                 "pbrLightFunctions",
                 "helperFunctions",
                 "helperFunctions",
@@ -1594,7 +1594,8 @@
                 ],
                 ],
                 "output": "babylon.inspector.js",
                 "output": "babylon.inspector.js",
                 "webpack": "../../inspector/webpack.config.js",
                 "webpack": "../../inspector/webpack.config.js",
-                "bundle": "true"
+                "bundle": "true",
+                "moduleDeclaration": "GUI"
             }
             }
         ],
         ],
         "build": {
         "build": {

+ 24 - 10
Tools/Gulp/gulp-addModuleExports.js

@@ -1,34 +1,45 @@
 var gutil = require('gulp-util');
 var gutil = require('gulp-util');
 var through = require('through2');
 var through = require('through2');
 
 
-module.exports = function (varName, subModule, extendsRoot) {
+/**
+ * The parameters for this function has grown during development.
+ * Eventually, this function will need to be reorganized. 
+ */
+module.exports = function (varName, subModule, extendsRoot, requireOnly) {
     return through.obj(function (file, enc, cb) {
     return through.obj(function (file, enc, cb) {
 
 
-        var optionalRequire = `var babylonDependency; try { babylonDependency = BABYLON || (typeof require !== 'undefined' && require("../babylon.max")); } catch (e) { babylonDependency = BABYLON || (typeof require !== 'undefined' && require("babylonjs")); } 
+        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;
 var BABYLON = babylonDependency;
 `;
 `;
         function moduleExportAddition(varName) {
         function moduleExportAddition(varName) {
 
 
-            let basicInit = `root["BABYLON"]${(subModule && !extendsRoot) ? '["' + varName + '"]' : ''} = factory();`;
+            let base = subModule ? 'BABYLON' : varName;
+
+            let basicInit = `root["${base}"]${(subModule && !extendsRoot) ? '["' + varName + '"]' : ''} = f;`;
+            let sadGlobalPolution = (!subModule) ? `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
+globalObject["${base}"] = f;` : '';
             /*if (extendsRoot) {
             /*if (extendsRoot) {
                 basicInit = `__extends(root["BABYLON"], factory()); `
                 basicInit = `__extends(root["BABYLON"], factory()); `
             }*/
             }*/
 
 
             return `\n\n(function universalModuleDefinition(root, factory) {
             return `\n\n(function universalModuleDefinition(root, factory) {
-                if (root && root["BABYLON"]) {
+                if (root && root["${base}"]) {
                     return;
                     return;
                 }
                 }
+                var f = factory();
+                ${sadGlobalPolution}
     if(typeof exports === 'object' && typeof module === 'object')
     if(typeof exports === 'object' && typeof module === 'object')
-        module.exports = factory();
+        module.exports = f;
     else if(typeof define === 'function' && define.amd)
     else if(typeof define === 'function' && define.amd)
         define([], factory);
         define([], factory);
     else if(typeof exports === 'object')
     else if(typeof exports === 'object')
-        exports["${varName}"] = factory();
+        exports["${varName}"] = f;
     else {
     else {
         ${basicInit}
         ${basicInit}
     }
     }
 })(this, function() {
 })(this, function() {
-    return BABYLON${(subModule && !extendsRoot) ? '.' + varName : ''};
+    return ${base}${(subModule && !extendsRoot) ? '.' + varName : ''};
 });
 });
 `;
 `;
         }
         }
@@ -65,10 +76,13 @@ var BABYLON = babylonDependency;
         }
         }
 
 
         try {
         try {
-            let pretext = subModule ? optionalRequire : '';
-            file.contents = new Buffer(pretext.concat(decorateAddition).concat(new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportAddition(varName)))));
+            if (requireOnly) {
+                file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
+            } else {
+                let pretext = subModule ? optionalRequire : '';
+                file.contents = new Buffer(pretext.concat(decorateAddition).concat(new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportAddition(varName)))));
+            }
             this.push(file);
             this.push(file);
-
         } catch (err) {
         } catch (err) {
             this.emit('error', new gutil.PluginError('gulp-add-module-exports', err, { fileName: file.path }));
             this.emit('error', new gutil.PluginError('gulp-add-module-exports', err, { fileName: file.path }));
         }
         }

+ 5 - 4
Tools/Gulp/gulpfile.js

@@ -402,6 +402,7 @@ var buildExternalLibrary = function (library, settings, watch) {
             return waitAll.on("end", function () {
             return waitAll.on("end", function () {
                 webpack(require(library.webpack))
                 webpack(require(library.webpack))
                     .pipe(rename(library.output.replace(".js", ".bundle.js")))
                     .pipe(rename(library.output.replace(".js", ".bundle.js")))
+                    .pipe(addModuleExports(library.moduleDeclaration, false, false, true))
                     .pipe(gulp.dest(outputDirectory))
                     .pipe(gulp.dest(outputDirectory))
             });
             });
         }
         }
@@ -474,21 +475,21 @@ gulp.task("typescript-all", function (cb) {
  */
  */
 gulp.task("watch", [], function () {
 gulp.task("watch", [], function () {
     var interval = 1000;
     var interval = 1000;
-    var tasks = [gulp.watch(config.typescript, { interval: interval}, ["typescript-compile"])];
+    var tasks = [gulp.watch(config.typescript, { interval: interval }, ["typescript-compile"])];
 
 
     config.modules.map(function (module) {
     config.modules.map(function (module) {
         config[module].libraries.map(function (library) {
         config[module].libraries.map(function (library) {
-            tasks.push(gulp.watch(library.files, { interval: interval}, function () {
+            tasks.push(gulp.watch(library.files, { interval: interval }, function () {
                 console.log(library.output);
                 console.log(library.output);
                 return buildExternalLibrary(library, config[module], true)
                 return buildExternalLibrary(library, config[module], true)
                     .pipe(debug());
                     .pipe(debug());
             }));
             }));
-            tasks.push(gulp.watch(library.shaderFiles, { interval: interval}, function () {
+            tasks.push(gulp.watch(library.shaderFiles, { interval: interval }, function () {
                 console.log(library.output);
                 console.log(library.output);
                 return buildExternalLibrary(library, config[module], true)
                 return buildExternalLibrary(library, config[module], true)
                     .pipe(debug())
                     .pipe(debug())
             }));
             }));
-            tasks.push(gulp.watch(library.sassFiles, { interval: interval}, function () {
+            tasks.push(gulp.watch(library.sassFiles, { interval: interval }, function () {
                 console.log(library.output);
                 console.log(library.output);
                 return buildExternalLibrary(library, config[module], true)
                 return buildExternalLibrary(library, config[module], true)
                     .pipe(debug())
                     .pipe(debug())

+ 4 - 0
Tools/Publisher/index.js

@@ -35,6 +35,10 @@ let packages = [
     {
     {
         name: 'proceduralTextures',
         name: 'proceduralTextures',
         path: basePath + '/proceduralTexturesLibrary/'
         path: basePath + '/proceduralTexturesLibrary/'
+    },
+    {
+        name: 'inspector',
+        path: basePath + '/inspector/'
     }
     }
 ];
 ];
 
 

+ 323 - 323
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts

@@ -3967,6 +3967,69 @@ declare module BABYLON.Debug {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
+    class KeyboardEventTypes {
+        static _KEYDOWN: number;
+        static _KEYUP: number;
+        static readonly KEYDOWN: number;
+        static readonly KEYUP: number;
+    }
+    class KeyboardInfo {
+        type: number;
+        event: KeyboardEvent;
+        constructor(type: number, event: KeyboardEvent);
+    }
+    /**
+     * This class is used to store keyboard related info for the onPreKeyboardObservable event.
+     * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
+     */
+    class KeyboardInfoPre extends KeyboardInfo {
+        constructor(type: number, event: KeyboardEvent);
+        skipOnPointerObservable: boolean;
+    }
+}
+
+declare module BABYLON {
+    class PointerEventTypes {
+        static _POINTERDOWN: number;
+        static _POINTERUP: number;
+        static _POINTERMOVE: number;
+        static _POINTERWHEEL: number;
+        static _POINTERPICK: number;
+        static _POINTERTAP: number;
+        static _POINTERDOUBLETAP: number;
+        static readonly POINTERDOWN: number;
+        static readonly POINTERUP: number;
+        static readonly POINTERMOVE: number;
+        static readonly POINTERWHEEL: number;
+        static readonly POINTERPICK: number;
+        static readonly POINTERTAP: number;
+        static readonly POINTERDOUBLETAP: number;
+    }
+    class PointerInfoBase {
+        type: number;
+        event: PointerEvent | MouseWheelEvent;
+        constructor(type: number, event: PointerEvent | MouseWheelEvent);
+    }
+    /**
+     * This class is used to store pointer related info for the onPrePointerObservable event.
+     * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
+     */
+    class PointerInfoPre extends PointerInfoBase {
+        constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
+        localPosition: Vector2;
+        skipOnPointerObservable: boolean;
+    }
+    /**
+     * This type contains all the data related to a pointer event in Babylon.js.
+     * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
+     */
+    class PointerInfo extends PointerInfoBase {
+        pickInfo: Nullable<PickingInfo>;
+        constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
+    }
+}
+
+declare module BABYLON {
     class InstancingAttributeInfo {
     class InstancingAttributeInfo {
         /**
         /**
          * Index/offset of the attribute in the vertex shader
          * Index/offset of the attribute in the vertex shader
@@ -4812,69 +4875,6 @@ declare var WebGLVertexArrayObject: {
 };
 };
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class KeyboardEventTypes {
-        static _KEYDOWN: number;
-        static _KEYUP: number;
-        static readonly KEYDOWN: number;
-        static readonly KEYUP: number;
-    }
-    class KeyboardInfo {
-        type: number;
-        event: KeyboardEvent;
-        constructor(type: number, event: KeyboardEvent);
-    }
-    /**
-     * This class is used to store keyboard related info for the onPreKeyboardObservable event.
-     * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
-     */
-    class KeyboardInfoPre extends KeyboardInfo {
-        constructor(type: number, event: KeyboardEvent);
-        skipOnPointerObservable: boolean;
-    }
-}
-
-declare module BABYLON {
-    class PointerEventTypes {
-        static _POINTERDOWN: number;
-        static _POINTERUP: number;
-        static _POINTERMOVE: number;
-        static _POINTERWHEEL: number;
-        static _POINTERPICK: number;
-        static _POINTERTAP: number;
-        static _POINTERDOUBLETAP: number;
-        static readonly POINTERDOWN: number;
-        static readonly POINTERUP: number;
-        static readonly POINTERMOVE: number;
-        static readonly POINTERWHEEL: number;
-        static readonly POINTERPICK: number;
-        static readonly POINTERTAP: number;
-        static readonly POINTERDOUBLETAP: number;
-    }
-    class PointerInfoBase {
-        type: number;
-        event: PointerEvent | MouseWheelEvent;
-        constructor(type: number, event: PointerEvent | MouseWheelEvent);
-    }
-    /**
-     * This class is used to store pointer related info for the onPrePointerObservable event.
-     * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
-     */
-    class PointerInfoPre extends PointerInfoBase {
-        constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
-        localPosition: Vector2;
-        skipOnPointerObservable: boolean;
-    }
-    /**
-     * This type contains all the data related to a pointer event in Babylon.js.
-     * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
-     */
-    class PointerInfo extends PointerInfoBase {
-        pickInfo: Nullable<PickingInfo>;
-        constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
-    }
-}
-
-declare module BABYLON {
     class StickValues {
     class StickValues {
         x: number;
         x: number;
         y: number;
         y: number;
@@ -15082,75 +15082,6 @@ declare module BABYLON {
     }
     }
 }
 }
 
 
-declare module BABYLON {
-    class Sprite {
-        name: string;
-        position: Vector3;
-        color: Color4;
-        width: number;
-        height: number;
-        angle: number;
-        cellIndex: number;
-        invertU: number;
-        invertV: number;
-        disposeWhenFinishedAnimating: boolean;
-        animations: Animation[];
-        isPickable: boolean;
-        actionManager: ActionManager;
-        private _animationStarted;
-        private _loopAnimation;
-        private _fromIndex;
-        private _toIndex;
-        private _delay;
-        private _direction;
-        private _manager;
-        private _time;
-        private _onAnimationEnd;
-        size: number;
-        constructor(name: string, manager: SpriteManager);
-        playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
-        stopAnimation(): void;
-        _animate(deltaTime: number): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
-    class SpriteManager {
-        name: string;
-        sprites: Sprite[];
-        renderingGroupId: number;
-        layerMask: number;
-        fogEnabled: boolean;
-        isPickable: boolean;
-        cellWidth: number;
-        cellHeight: number;
-        /**
-        * An event triggered when the manager is disposed.
-        * @type {BABYLON.Observable}
-        */
-        onDisposeObservable: Observable<SpriteManager>;
-        private _onDisposeObserver;
-        onDispose: () => void;
-        private _capacity;
-        private _spriteTexture;
-        private _epsilon;
-        private _scene;
-        private _vertexData;
-        private _buffer;
-        private _vertexBuffers;
-        private _indexBuffer;
-        private _effectBase;
-        private _effectFog;
-        texture: Texture;
-        constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
-        private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
-        intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
-        render(): void;
-        dispose(): void;
-    }
-}
-
 declare module BABYLON.Internals {
 declare module BABYLON.Internals {
     class _AlphaState {
     class _AlphaState {
         private _isAlphaBlendDirty;
         private _isAlphaBlendDirty;
@@ -16379,24 +16310,93 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
-        readonly name: string;
-        private _zoomStopsAnimation;
-        private _idleRotationSpeed;
-        private _idleRotationWaitTime;
-        private _idleRotationSpinupTime;
-        /**
-        * Gets the flag that indicates if user zooming should stop animation.
-        */
-        /**
-        * Sets the flag that indicates if user zooming should stop animation.
-        */
-        zoomStopsAnimation: boolean;
-        /**
-        * Gets the default speed at which the camera rotates around the model.
-        */
+    class Sprite {
+        name: string;
+        position: Vector3;
+        color: Color4;
+        width: number;
+        height: number;
+        angle: number;
+        cellIndex: number;
+        invertU: number;
+        invertV: number;
+        disposeWhenFinishedAnimating: boolean;
+        animations: Animation[];
+        isPickable: boolean;
+        actionManager: ActionManager;
+        private _animationStarted;
+        private _loopAnimation;
+        private _fromIndex;
+        private _toIndex;
+        private _delay;
+        private _direction;
+        private _manager;
+        private _time;
+        private _onAnimationEnd;
+        size: number;
+        constructor(name: string, manager: SpriteManager);
+        playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
+        stopAnimation(): void;
+        _animate(deltaTime: number): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class SpriteManager {
+        name: string;
+        sprites: Sprite[];
+        renderingGroupId: number;
+        layerMask: number;
+        fogEnabled: boolean;
+        isPickable: boolean;
+        cellWidth: number;
+        cellHeight: number;
         /**
         /**
-        * Sets the default speed at which the camera rotates around the model.
+        * An event triggered when the manager is disposed.
+        * @type {BABYLON.Observable}
+        */
+        onDisposeObservable: Observable<SpriteManager>;
+        private _onDisposeObserver;
+        onDispose: () => void;
+        private _capacity;
+        private _spriteTexture;
+        private _epsilon;
+        private _scene;
+        private _vertexData;
+        private _buffer;
+        private _vertexBuffers;
+        private _indexBuffer;
+        private _effectBase;
+        private _effectFog;
+        texture: Texture;
+        constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
+        private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
+        intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
+        render(): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
+        readonly name: string;
+        private _zoomStopsAnimation;
+        private _idleRotationSpeed;
+        private _idleRotationWaitTime;
+        private _idleRotationSpinupTime;
+        /**
+        * Gets the flag that indicates if user zooming should stop animation.
+        */
+        /**
+        * Sets the flag that indicates if user zooming should stop animation.
+        */
+        zoomStopsAnimation: boolean;
+        /**
+        * Gets the default speed at which the camera rotates around the model.
+        */
+        /**
+        * Sets the default speed at which the camera rotates around the model.
         */
         */
         idleRotationSpeed: number;
         idleRotationSpeed: number;
         /**
         /**
@@ -16663,6 +16663,180 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
+    class VRCameraMetrics {
+        hResolution: number;
+        vResolution: number;
+        hScreenSize: number;
+        vScreenSize: number;
+        vScreenCenter: number;
+        eyeToScreenDistance: number;
+        lensSeparationDistance: number;
+        interpupillaryDistance: number;
+        distortionK: number[];
+        chromaAbCorrection: number[];
+        postProcessScaleFactor: number;
+        lensCenterOffset: number;
+        compensateDistortion: boolean;
+        readonly aspectRatio: number;
+        readonly aspectRatioFov: number;
+        readonly leftHMatrix: Matrix;
+        readonly rightHMatrix: Matrix;
+        readonly leftPreViewMatrix: Matrix;
+        readonly rightPreViewMatrix: Matrix;
+        static GetDefault(): VRCameraMetrics;
+    }
+}
+
+declare module BABYLON {
+    class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
+        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+    class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
+        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+    class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
+        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+}
+
+declare module BABYLON {
+    class VRExperienceHelper {
+        webVROptions: WebVROptions;
+        private _scene;
+        private _position;
+        private _btnVR;
+        private _webVRsupported;
+        private _webVRready;
+        private _webVRrequesting;
+        private _webVRpresenting;
+        private _fullscreenVRpresenting;
+        private _canvas;
+        private _webVRCamera;
+        private _vrDeviceOrientationCamera;
+        private _deviceOrientationCamera;
+        private _onKeyDown;
+        private _onVrDisplayPresentChange;
+        private _onVRDisplayChanged;
+        private _onVRRequestPresentStart;
+        private _onVRRequestPresentComplete;
+        onEnteringVR: () => void;
+        onExitingVR: () => void;
+        onControllerMeshLoaded: (controller: WebVRController) => void;
+        constructor(scene: Scene, webVROptions?: WebVROptions);
+        private _onDefaultMeshLoaded(webVRController);
+        private _onFullscreenChange();
+        private isInVRMode();
+        private onVrDisplayPresentChange();
+        private onVRDisplayChanged(eventArgs);
+        private updateButtonVisibility();
+        /**
+         * Attempt to enter VR. If a headset is connected and ready, will request present on that.
+         * Otherwise, will use the fullscreen API.
+         */
+        enterVR(): void;
+        /**
+         * Attempt to exit VR, or fullscreen.
+         */
+        exitVR(): void;
+        position: Vector3;
+        dispose(): void;
+        getClassName(): string;
+    }
+}
+
+declare var HMDVRDevice: any;
+declare var VRDisplay: any;
+declare var VRFrameData: any;
+declare module BABYLON {
+    /**
+     * This is a copy of VRPose.
+     * IMPORTANT!! The data is right-hand data.
+     * @export
+     * @interface DevicePose
+     */
+    interface DevicePose {
+        readonly position?: Float32Array;
+        readonly linearVelocity?: Float32Array;
+        readonly linearAcceleration?: Float32Array;
+        readonly orientation?: Float32Array;
+        readonly angularVelocity?: Float32Array;
+        readonly angularAcceleration?: Float32Array;
+    }
+    interface PoseControlled {
+        position: Vector3;
+        rotationQuaternion: Quaternion;
+        devicePosition?: Vector3;
+        deviceRotationQuaternion: Quaternion;
+        rawPose: Nullable<DevicePose>;
+        deviceScaleFactor: number;
+        updateFromDevice(poseData: DevicePose): void;
+    }
+    interface WebVROptions {
+        trackPosition?: boolean;
+        positionScale?: number;
+        displayName?: string;
+        controllerMeshes?: boolean;
+        defaultLightingOnControllers?: boolean;
+    }
+    class WebVRFreeCamera extends FreeCamera implements PoseControlled {
+        private webVROptions;
+        _vrDevice: any;
+        rawPose: Nullable<DevicePose>;
+        private _onVREnabled;
+        private _specsVersion;
+        private _attached;
+        private _frameData;
+        protected _descendants: Array<Node>;
+        devicePosition: Vector3;
+        deviceRotationQuaternion: Quaternion;
+        deviceScaleFactor: number;
+        controllers: Array<WebVRController>;
+        onControllersAttachedObservable: Observable<WebVRController[]>;
+        onControllerMeshLoadedObservable: Observable<WebVRController>;
+        rigParenting: boolean;
+        private _lightOnControllers;
+        constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
+        dispose(): void;
+        getControllerByName(name: string): Nullable<WebVRController>;
+        private _leftController;
+        readonly leftController: Nullable<WebVRController>;
+        private _rightController;
+        readonly rightController: Nullable<WebVRController>;
+        getForwardRay(length?: number): Ray;
+        _checkInputs(): void;
+        updateFromDevice(poseData: DevicePose): void;
+        /**
+         * WebVR's attach control will start broadcasting frames to the device.
+         * Note that in certain browsers (chrome for example) this function must be called
+         * within a user-interaction callback. Example:
+         * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
+         *
+         * @param {HTMLElement} element
+         * @param {boolean} [noPreventDefault]
+         *
+         * @memberOf WebVRFreeCamera
+         */
+        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
+        detachControl(element: HTMLElement): void;
+        getClassName(): string;
+        resetToCurrentRotation(): void;
+        _updateRigCameras(): void;
+        /**
+         * This function is called by the two RIG cameras.
+         * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
+         */
+        protected _getWebVRViewMatrix(): Matrix;
+        protected _getWebVRProjectionMatrix(): Matrix;
+        private _onGamepadConnectedObserver;
+        private _onGamepadDisconnectedObserver;
+        initControllers(): void;
+    }
+}
+
+declare module BABYLON {
     class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
     class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
         camera: ArcRotateCamera;
         camera: ArcRotateCamera;
         gamepad: Nullable<Gamepad>;
         gamepad: Nullable<Gamepad>;
@@ -16891,180 +17065,6 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class VRCameraMetrics {
-        hResolution: number;
-        vResolution: number;
-        hScreenSize: number;
-        vScreenSize: number;
-        vScreenCenter: number;
-        eyeToScreenDistance: number;
-        lensSeparationDistance: number;
-        interpupillaryDistance: number;
-        distortionK: number[];
-        chromaAbCorrection: number[];
-        postProcessScaleFactor: number;
-        lensCenterOffset: number;
-        compensateDistortion: boolean;
-        readonly aspectRatio: number;
-        readonly aspectRatioFov: number;
-        readonly leftHMatrix: Matrix;
-        readonly rightHMatrix: Matrix;
-        readonly leftPreViewMatrix: Matrix;
-        readonly rightPreViewMatrix: Matrix;
-        static GetDefault(): VRCameraMetrics;
-    }
-}
-
-declare module BABYLON {
-    class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
-        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-    class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
-        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-    class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
-        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-}
-
-declare module BABYLON {
-    class VRExperienceHelper {
-        webVROptions: WebVROptions;
-        private _scene;
-        private _position;
-        private _btnVR;
-        private _webVRsupported;
-        private _webVRready;
-        private _webVRrequesting;
-        private _webVRpresenting;
-        private _fullscreenVRpresenting;
-        private _canvas;
-        private _webVRCamera;
-        private _vrDeviceOrientationCamera;
-        private _deviceOrientationCamera;
-        private _onKeyDown;
-        private _onVrDisplayPresentChange;
-        private _onVRDisplayChanged;
-        private _onVRRequestPresentStart;
-        private _onVRRequestPresentComplete;
-        onEnteringVR: () => void;
-        onExitingVR: () => void;
-        onControllerMeshLoaded: (controller: WebVRController) => void;
-        constructor(scene: Scene, webVROptions?: WebVROptions);
-        private _onDefaultMeshLoaded(webVRController);
-        private _onFullscreenChange();
-        private isInVRMode();
-        private onVrDisplayPresentChange();
-        private onVRDisplayChanged(eventArgs);
-        private updateButtonVisibility();
-        /**
-         * Attempt to enter VR. If a headset is connected and ready, will request present on that.
-         * Otherwise, will use the fullscreen API.
-         */
-        enterVR(): void;
-        /**
-         * Attempt to exit VR, or fullscreen.
-         */
-        exitVR(): void;
-        position: Vector3;
-        dispose(): void;
-        getClassName(): string;
-    }
-}
-
-declare var HMDVRDevice: any;
-declare var VRDisplay: any;
-declare var VRFrameData: any;
-declare module BABYLON {
-    /**
-     * This is a copy of VRPose.
-     * IMPORTANT!! The data is right-hand data.
-     * @export
-     * @interface DevicePose
-     */
-    interface DevicePose {
-        readonly position?: Float32Array;
-        readonly linearVelocity?: Float32Array;
-        readonly linearAcceleration?: Float32Array;
-        readonly orientation?: Float32Array;
-        readonly angularVelocity?: Float32Array;
-        readonly angularAcceleration?: Float32Array;
-    }
-    interface PoseControlled {
-        position: Vector3;
-        rotationQuaternion: Quaternion;
-        devicePosition?: Vector3;
-        deviceRotationQuaternion: Quaternion;
-        rawPose: Nullable<DevicePose>;
-        deviceScaleFactor: number;
-        updateFromDevice(poseData: DevicePose): void;
-    }
-    interface WebVROptions {
-        trackPosition?: boolean;
-        positionScale?: number;
-        displayName?: string;
-        controllerMeshes?: boolean;
-        defaultLightingOnControllers?: boolean;
-    }
-    class WebVRFreeCamera extends FreeCamera implements PoseControlled {
-        private webVROptions;
-        _vrDevice: any;
-        rawPose: Nullable<DevicePose>;
-        private _onVREnabled;
-        private _specsVersion;
-        private _attached;
-        private _frameData;
-        protected _descendants: Array<Node>;
-        devicePosition: Vector3;
-        deviceRotationQuaternion: Quaternion;
-        deviceScaleFactor: number;
-        controllers: Array<WebVRController>;
-        onControllersAttachedObservable: Observable<WebVRController[]>;
-        onControllerMeshLoadedObservable: Observable<WebVRController>;
-        rigParenting: boolean;
-        private _lightOnControllers;
-        constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
-        dispose(): void;
-        getControllerByName(name: string): Nullable<WebVRController>;
-        private _leftController;
-        readonly leftController: Nullable<WebVRController>;
-        private _rightController;
-        readonly rightController: Nullable<WebVRController>;
-        getForwardRay(length?: number): Ray;
-        _checkInputs(): void;
-        updateFromDevice(poseData: DevicePose): void;
-        /**
-         * WebVR's attach control will start broadcasting frames to the device.
-         * Note that in certain browsers (chrome for example) this function must be called
-         * within a user-interaction callback. Example:
-         * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
-         *
-         * @param {HTMLElement} element
-         * @param {boolean} [noPreventDefault]
-         *
-         * @memberOf WebVRFreeCamera
-         */
-        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
-        detachControl(element: HTMLElement): void;
-        getClassName(): string;
-        resetToCurrentRotation(): void;
-        _updateRigCameras(): void;
-        /**
-         * This function is called by the two RIG cameras.
-         * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
-         */
-        protected _getWebVRViewMatrix(): Matrix;
-        protected _getWebVRProjectionMatrix(): Matrix;
-        private _onGamepadConnectedObserver;
-        private _onGamepadDisconnectedObserver;
-        initControllers(): void;
-    }
-}
-
-declare module BABYLON {
     interface IOctreeContainer<T> {
     interface IOctreeContainer<T> {
         blocks: Array<OctreeBlock<T>>;
         blocks: Array<OctreeBlock<T>>;
     }
     }

File diff suppressed because it is too large
+ 52 - 5
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


File diff suppressed because it is too large
+ 74 - 3
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js


+ 323 - 323
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts

@@ -3972,6 +3972,69 @@ declare module BABYLON.Debug {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
+    class KeyboardEventTypes {
+        static _KEYDOWN: number;
+        static _KEYUP: number;
+        static readonly KEYDOWN: number;
+        static readonly KEYUP: number;
+    }
+    class KeyboardInfo {
+        type: number;
+        event: KeyboardEvent;
+        constructor(type: number, event: KeyboardEvent);
+    }
+    /**
+     * This class is used to store keyboard related info for the onPreKeyboardObservable event.
+     * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
+     */
+    class KeyboardInfoPre extends KeyboardInfo {
+        constructor(type: number, event: KeyboardEvent);
+        skipOnPointerObservable: boolean;
+    }
+}
+
+declare module BABYLON {
+    class PointerEventTypes {
+        static _POINTERDOWN: number;
+        static _POINTERUP: number;
+        static _POINTERMOVE: number;
+        static _POINTERWHEEL: number;
+        static _POINTERPICK: number;
+        static _POINTERTAP: number;
+        static _POINTERDOUBLETAP: number;
+        static readonly POINTERDOWN: number;
+        static readonly POINTERUP: number;
+        static readonly POINTERMOVE: number;
+        static readonly POINTERWHEEL: number;
+        static readonly POINTERPICK: number;
+        static readonly POINTERTAP: number;
+        static readonly POINTERDOUBLETAP: number;
+    }
+    class PointerInfoBase {
+        type: number;
+        event: PointerEvent | MouseWheelEvent;
+        constructor(type: number, event: PointerEvent | MouseWheelEvent);
+    }
+    /**
+     * This class is used to store pointer related info for the onPrePointerObservable event.
+     * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
+     */
+    class PointerInfoPre extends PointerInfoBase {
+        constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
+        localPosition: Vector2;
+        skipOnPointerObservable: boolean;
+    }
+    /**
+     * This type contains all the data related to a pointer event in Babylon.js.
+     * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
+     */
+    class PointerInfo extends PointerInfoBase {
+        pickInfo: Nullable<PickingInfo>;
+        constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
+    }
+}
+
+declare module BABYLON {
     class InstancingAttributeInfo {
     class InstancingAttributeInfo {
         /**
         /**
          * Index/offset of the attribute in the vertex shader
          * Index/offset of the attribute in the vertex shader
@@ -4817,69 +4880,6 @@ declare var WebGLVertexArrayObject: {
 };
 };
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class KeyboardEventTypes {
-        static _KEYDOWN: number;
-        static _KEYUP: number;
-        static readonly KEYDOWN: number;
-        static readonly KEYUP: number;
-    }
-    class KeyboardInfo {
-        type: number;
-        event: KeyboardEvent;
-        constructor(type: number, event: KeyboardEvent);
-    }
-    /**
-     * This class is used to store keyboard related info for the onPreKeyboardObservable event.
-     * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
-     */
-    class KeyboardInfoPre extends KeyboardInfo {
-        constructor(type: number, event: KeyboardEvent);
-        skipOnPointerObservable: boolean;
-    }
-}
-
-declare module BABYLON {
-    class PointerEventTypes {
-        static _POINTERDOWN: number;
-        static _POINTERUP: number;
-        static _POINTERMOVE: number;
-        static _POINTERWHEEL: number;
-        static _POINTERPICK: number;
-        static _POINTERTAP: number;
-        static _POINTERDOUBLETAP: number;
-        static readonly POINTERDOWN: number;
-        static readonly POINTERUP: number;
-        static readonly POINTERMOVE: number;
-        static readonly POINTERWHEEL: number;
-        static readonly POINTERPICK: number;
-        static readonly POINTERTAP: number;
-        static readonly POINTERDOUBLETAP: number;
-    }
-    class PointerInfoBase {
-        type: number;
-        event: PointerEvent | MouseWheelEvent;
-        constructor(type: number, event: PointerEvent | MouseWheelEvent);
-    }
-    /**
-     * This class is used to store pointer related info for the onPrePointerObservable event.
-     * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
-     */
-    class PointerInfoPre extends PointerInfoBase {
-        constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
-        localPosition: Vector2;
-        skipOnPointerObservable: boolean;
-    }
-    /**
-     * This type contains all the data related to a pointer event in Babylon.js.
-     * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
-     */
-    class PointerInfo extends PointerInfoBase {
-        pickInfo: Nullable<PickingInfo>;
-        constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
-    }
-}
-
-declare module BABYLON {
     class StickValues {
     class StickValues {
         x: number;
         x: number;
         y: number;
         y: number;
@@ -15087,75 +15087,6 @@ declare module BABYLON {
     }
     }
 }
 }
 
 
-declare module BABYLON {
-    class Sprite {
-        name: string;
-        position: Vector3;
-        color: Color4;
-        width: number;
-        height: number;
-        angle: number;
-        cellIndex: number;
-        invertU: number;
-        invertV: number;
-        disposeWhenFinishedAnimating: boolean;
-        animations: Animation[];
-        isPickable: boolean;
-        actionManager: ActionManager;
-        private _animationStarted;
-        private _loopAnimation;
-        private _fromIndex;
-        private _toIndex;
-        private _delay;
-        private _direction;
-        private _manager;
-        private _time;
-        private _onAnimationEnd;
-        size: number;
-        constructor(name: string, manager: SpriteManager);
-        playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
-        stopAnimation(): void;
-        _animate(deltaTime: number): void;
-        dispose(): void;
-    }
-}
-
-declare module BABYLON {
-    class SpriteManager {
-        name: string;
-        sprites: Sprite[];
-        renderingGroupId: number;
-        layerMask: number;
-        fogEnabled: boolean;
-        isPickable: boolean;
-        cellWidth: number;
-        cellHeight: number;
-        /**
-        * An event triggered when the manager is disposed.
-        * @type {BABYLON.Observable}
-        */
-        onDisposeObservable: Observable<SpriteManager>;
-        private _onDisposeObserver;
-        onDispose: () => void;
-        private _capacity;
-        private _spriteTexture;
-        private _epsilon;
-        private _scene;
-        private _vertexData;
-        private _buffer;
-        private _vertexBuffers;
-        private _indexBuffer;
-        private _effectBase;
-        private _effectFog;
-        texture: Texture;
-        constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
-        private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
-        intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
-        render(): void;
-        dispose(): void;
-    }
-}
-
 declare module BABYLON.Internals {
 declare module BABYLON.Internals {
     class _AlphaState {
     class _AlphaState {
         private _isAlphaBlendDirty;
         private _isAlphaBlendDirty;
@@ -16384,24 +16315,93 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
-        readonly name: string;
-        private _zoomStopsAnimation;
-        private _idleRotationSpeed;
-        private _idleRotationWaitTime;
-        private _idleRotationSpinupTime;
-        /**
-        * Gets the flag that indicates if user zooming should stop animation.
-        */
-        /**
-        * Sets the flag that indicates if user zooming should stop animation.
-        */
-        zoomStopsAnimation: boolean;
-        /**
-        * Gets the default speed at which the camera rotates around the model.
-        */
+    class Sprite {
+        name: string;
+        position: Vector3;
+        color: Color4;
+        width: number;
+        height: number;
+        angle: number;
+        cellIndex: number;
+        invertU: number;
+        invertV: number;
+        disposeWhenFinishedAnimating: boolean;
+        animations: Animation[];
+        isPickable: boolean;
+        actionManager: ActionManager;
+        private _animationStarted;
+        private _loopAnimation;
+        private _fromIndex;
+        private _toIndex;
+        private _delay;
+        private _direction;
+        private _manager;
+        private _time;
+        private _onAnimationEnd;
+        size: number;
+        constructor(name: string, manager: SpriteManager);
+        playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
+        stopAnimation(): void;
+        _animate(deltaTime: number): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class SpriteManager {
+        name: string;
+        sprites: Sprite[];
+        renderingGroupId: number;
+        layerMask: number;
+        fogEnabled: boolean;
+        isPickable: boolean;
+        cellWidth: number;
+        cellHeight: number;
         /**
         /**
-        * Sets the default speed at which the camera rotates around the model.
+        * An event triggered when the manager is disposed.
+        * @type {BABYLON.Observable}
+        */
+        onDisposeObservable: Observable<SpriteManager>;
+        private _onDisposeObserver;
+        onDispose: () => void;
+        private _capacity;
+        private _spriteTexture;
+        private _epsilon;
+        private _scene;
+        private _vertexData;
+        private _buffer;
+        private _vertexBuffers;
+        private _indexBuffer;
+        private _effectBase;
+        private _effectFog;
+        texture: Texture;
+        constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
+        private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
+        intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
+        render(): void;
+        dispose(): void;
+    }
+}
+
+declare module BABYLON {
+    class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
+        readonly name: string;
+        private _zoomStopsAnimation;
+        private _idleRotationSpeed;
+        private _idleRotationWaitTime;
+        private _idleRotationSpinupTime;
+        /**
+        * Gets the flag that indicates if user zooming should stop animation.
+        */
+        /**
+        * Sets the flag that indicates if user zooming should stop animation.
+        */
+        zoomStopsAnimation: boolean;
+        /**
+        * Gets the default speed at which the camera rotates around the model.
+        */
+        /**
+        * Sets the default speed at which the camera rotates around the model.
         */
         */
         idleRotationSpeed: number;
         idleRotationSpeed: number;
         /**
         /**
@@ -16668,6 +16668,180 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
+    class VRCameraMetrics {
+        hResolution: number;
+        vResolution: number;
+        hScreenSize: number;
+        vScreenSize: number;
+        vScreenCenter: number;
+        eyeToScreenDistance: number;
+        lensSeparationDistance: number;
+        interpupillaryDistance: number;
+        distortionK: number[];
+        chromaAbCorrection: number[];
+        postProcessScaleFactor: number;
+        lensCenterOffset: number;
+        compensateDistortion: boolean;
+        readonly aspectRatio: number;
+        readonly aspectRatioFov: number;
+        readonly leftHMatrix: Matrix;
+        readonly rightHMatrix: Matrix;
+        readonly leftPreViewMatrix: Matrix;
+        readonly rightPreViewMatrix: Matrix;
+        static GetDefault(): VRCameraMetrics;
+    }
+}
+
+declare module BABYLON {
+    class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
+        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+    class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
+        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+    class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
+        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
+        getClassName(): string;
+    }
+}
+
+declare module BABYLON {
+    class VRExperienceHelper {
+        webVROptions: WebVROptions;
+        private _scene;
+        private _position;
+        private _btnVR;
+        private _webVRsupported;
+        private _webVRready;
+        private _webVRrequesting;
+        private _webVRpresenting;
+        private _fullscreenVRpresenting;
+        private _canvas;
+        private _webVRCamera;
+        private _vrDeviceOrientationCamera;
+        private _deviceOrientationCamera;
+        private _onKeyDown;
+        private _onVrDisplayPresentChange;
+        private _onVRDisplayChanged;
+        private _onVRRequestPresentStart;
+        private _onVRRequestPresentComplete;
+        onEnteringVR: () => void;
+        onExitingVR: () => void;
+        onControllerMeshLoaded: (controller: WebVRController) => void;
+        constructor(scene: Scene, webVROptions?: WebVROptions);
+        private _onDefaultMeshLoaded(webVRController);
+        private _onFullscreenChange();
+        private isInVRMode();
+        private onVrDisplayPresentChange();
+        private onVRDisplayChanged(eventArgs);
+        private updateButtonVisibility();
+        /**
+         * Attempt to enter VR. If a headset is connected and ready, will request present on that.
+         * Otherwise, will use the fullscreen API.
+         */
+        enterVR(): void;
+        /**
+         * Attempt to exit VR, or fullscreen.
+         */
+        exitVR(): void;
+        position: Vector3;
+        dispose(): void;
+        getClassName(): string;
+    }
+}
+
+declare var HMDVRDevice: any;
+declare var VRDisplay: any;
+declare var VRFrameData: any;
+declare module BABYLON {
+    /**
+     * This is a copy of VRPose.
+     * IMPORTANT!! The data is right-hand data.
+     * @export
+     * @interface DevicePose
+     */
+    interface DevicePose {
+        readonly position?: Float32Array;
+        readonly linearVelocity?: Float32Array;
+        readonly linearAcceleration?: Float32Array;
+        readonly orientation?: Float32Array;
+        readonly angularVelocity?: Float32Array;
+        readonly angularAcceleration?: Float32Array;
+    }
+    interface PoseControlled {
+        position: Vector3;
+        rotationQuaternion: Quaternion;
+        devicePosition?: Vector3;
+        deviceRotationQuaternion: Quaternion;
+        rawPose: Nullable<DevicePose>;
+        deviceScaleFactor: number;
+        updateFromDevice(poseData: DevicePose): void;
+    }
+    interface WebVROptions {
+        trackPosition?: boolean;
+        positionScale?: number;
+        displayName?: string;
+        controllerMeshes?: boolean;
+        defaultLightingOnControllers?: boolean;
+    }
+    class WebVRFreeCamera extends FreeCamera implements PoseControlled {
+        private webVROptions;
+        _vrDevice: any;
+        rawPose: Nullable<DevicePose>;
+        private _onVREnabled;
+        private _specsVersion;
+        private _attached;
+        private _frameData;
+        protected _descendants: Array<Node>;
+        devicePosition: Vector3;
+        deviceRotationQuaternion: Quaternion;
+        deviceScaleFactor: number;
+        controllers: Array<WebVRController>;
+        onControllersAttachedObservable: Observable<WebVRController[]>;
+        onControllerMeshLoadedObservable: Observable<WebVRController>;
+        rigParenting: boolean;
+        private _lightOnControllers;
+        constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
+        dispose(): void;
+        getControllerByName(name: string): Nullable<WebVRController>;
+        private _leftController;
+        readonly leftController: Nullable<WebVRController>;
+        private _rightController;
+        readonly rightController: Nullable<WebVRController>;
+        getForwardRay(length?: number): Ray;
+        _checkInputs(): void;
+        updateFromDevice(poseData: DevicePose): void;
+        /**
+         * WebVR's attach control will start broadcasting frames to the device.
+         * Note that in certain browsers (chrome for example) this function must be called
+         * within a user-interaction callback. Example:
+         * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
+         *
+         * @param {HTMLElement} element
+         * @param {boolean} [noPreventDefault]
+         *
+         * @memberOf WebVRFreeCamera
+         */
+        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
+        detachControl(element: HTMLElement): void;
+        getClassName(): string;
+        resetToCurrentRotation(): void;
+        _updateRigCameras(): void;
+        /**
+         * This function is called by the two RIG cameras.
+         * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
+         */
+        protected _getWebVRViewMatrix(): Matrix;
+        protected _getWebVRProjectionMatrix(): Matrix;
+        private _onGamepadConnectedObserver;
+        private _onGamepadDisconnectedObserver;
+        initControllers(): void;
+    }
+}
+
+declare module BABYLON {
     class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
     class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
         camera: ArcRotateCamera;
         camera: ArcRotateCamera;
         gamepad: Nullable<Gamepad>;
         gamepad: Nullable<Gamepad>;
@@ -16896,180 +17070,6 @@ declare module BABYLON {
 }
 }
 
 
 declare module BABYLON {
 declare module BABYLON {
-    class VRCameraMetrics {
-        hResolution: number;
-        vResolution: number;
-        hScreenSize: number;
-        vScreenSize: number;
-        vScreenCenter: number;
-        eyeToScreenDistance: number;
-        lensSeparationDistance: number;
-        interpupillaryDistance: number;
-        distortionK: number[];
-        chromaAbCorrection: number[];
-        postProcessScaleFactor: number;
-        lensCenterOffset: number;
-        compensateDistortion: boolean;
-        readonly aspectRatio: number;
-        readonly aspectRatioFov: number;
-        readonly leftHMatrix: Matrix;
-        readonly rightHMatrix: Matrix;
-        readonly leftPreViewMatrix: Matrix;
-        readonly rightPreViewMatrix: Matrix;
-        static GetDefault(): VRCameraMetrics;
-    }
-}
-
-declare module BABYLON {
-    class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
-        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-    class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
-        constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-    class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
-        constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
-        getClassName(): string;
-    }
-}
-
-declare module BABYLON {
-    class VRExperienceHelper {
-        webVROptions: WebVROptions;
-        private _scene;
-        private _position;
-        private _btnVR;
-        private _webVRsupported;
-        private _webVRready;
-        private _webVRrequesting;
-        private _webVRpresenting;
-        private _fullscreenVRpresenting;
-        private _canvas;
-        private _webVRCamera;
-        private _vrDeviceOrientationCamera;
-        private _deviceOrientationCamera;
-        private _onKeyDown;
-        private _onVrDisplayPresentChange;
-        private _onVRDisplayChanged;
-        private _onVRRequestPresentStart;
-        private _onVRRequestPresentComplete;
-        onEnteringVR: () => void;
-        onExitingVR: () => void;
-        onControllerMeshLoaded: (controller: WebVRController) => void;
-        constructor(scene: Scene, webVROptions?: WebVROptions);
-        private _onDefaultMeshLoaded(webVRController);
-        private _onFullscreenChange();
-        private isInVRMode();
-        private onVrDisplayPresentChange();
-        private onVRDisplayChanged(eventArgs);
-        private updateButtonVisibility();
-        /**
-         * Attempt to enter VR. If a headset is connected and ready, will request present on that.
-         * Otherwise, will use the fullscreen API.
-         */
-        enterVR(): void;
-        /**
-         * Attempt to exit VR, or fullscreen.
-         */
-        exitVR(): void;
-        position: Vector3;
-        dispose(): void;
-        getClassName(): string;
-    }
-}
-
-declare var HMDVRDevice: any;
-declare var VRDisplay: any;
-declare var VRFrameData: any;
-declare module BABYLON {
-    /**
-     * This is a copy of VRPose.
-     * IMPORTANT!! The data is right-hand data.
-     * @export
-     * @interface DevicePose
-     */
-    interface DevicePose {
-        readonly position?: Float32Array;
-        readonly linearVelocity?: Float32Array;
-        readonly linearAcceleration?: Float32Array;
-        readonly orientation?: Float32Array;
-        readonly angularVelocity?: Float32Array;
-        readonly angularAcceleration?: Float32Array;
-    }
-    interface PoseControlled {
-        position: Vector3;
-        rotationQuaternion: Quaternion;
-        devicePosition?: Vector3;
-        deviceRotationQuaternion: Quaternion;
-        rawPose: Nullable<DevicePose>;
-        deviceScaleFactor: number;
-        updateFromDevice(poseData: DevicePose): void;
-    }
-    interface WebVROptions {
-        trackPosition?: boolean;
-        positionScale?: number;
-        displayName?: string;
-        controllerMeshes?: boolean;
-        defaultLightingOnControllers?: boolean;
-    }
-    class WebVRFreeCamera extends FreeCamera implements PoseControlled {
-        private webVROptions;
-        _vrDevice: any;
-        rawPose: Nullable<DevicePose>;
-        private _onVREnabled;
-        private _specsVersion;
-        private _attached;
-        private _frameData;
-        protected _descendants: Array<Node>;
-        devicePosition: Vector3;
-        deviceRotationQuaternion: Quaternion;
-        deviceScaleFactor: number;
-        controllers: Array<WebVRController>;
-        onControllersAttachedObservable: Observable<WebVRController[]>;
-        onControllerMeshLoadedObservable: Observable<WebVRController>;
-        rigParenting: boolean;
-        private _lightOnControllers;
-        constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
-        dispose(): void;
-        getControllerByName(name: string): Nullable<WebVRController>;
-        private _leftController;
-        readonly leftController: Nullable<WebVRController>;
-        private _rightController;
-        readonly rightController: Nullable<WebVRController>;
-        getForwardRay(length?: number): Ray;
-        _checkInputs(): void;
-        updateFromDevice(poseData: DevicePose): void;
-        /**
-         * WebVR's attach control will start broadcasting frames to the device.
-         * Note that in certain browsers (chrome for example) this function must be called
-         * within a user-interaction callback. Example:
-         * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
-         *
-         * @param {HTMLElement} element
-         * @param {boolean} [noPreventDefault]
-         *
-         * @memberOf WebVRFreeCamera
-         */
-        attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
-        detachControl(element: HTMLElement): void;
-        getClassName(): string;
-        resetToCurrentRotation(): void;
-        _updateRigCameras(): void;
-        /**
-         * This function is called by the two RIG cameras.
-         * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
-         */
-        protected _getWebVRViewMatrix(): Matrix;
-        protected _getWebVRProjectionMatrix(): Matrix;
-        private _onGamepadConnectedObserver;
-        private _onGamepadDisconnectedObserver;
-        initControllers(): void;
-    }
-}
-
-declare module BABYLON {
     interface IOctreeContainer<T> {
     interface IOctreeContainer<T> {
         blocks: Array<OctreeBlock<T>>;
         blocks: Array<OctreeBlock<T>>;
     }
     }

+ 33 - 0
dist/preview release/inspector/package.json

@@ -0,0 +1,33 @@
+{
+    "author": {
+        "name": "David CATUHE"
+    },
+    "name": "babylonjs-inspector",
+    "description": "The Babylon.js inspector.",
+    "version": "3.1.0-beta1.0",
+    "repository": {
+        "type": "git",
+        "url": "https://github.com/BabylonJS/Babylon.js.git"
+    },
+    "main": "babylonjs.inspector.bundle.js",
+    "files": [
+        "babylonjs.inspector.bundle.js",
+        "readme.md",
+        "package.json"
+    ],
+    "keywords": [
+        "3D",
+        "javascript",
+        "html5",
+        "webgl",
+        "babylonjs",
+        "inspector"
+    ],
+    "license": "Apache-2.0",
+    "peerDependencies": {
+        "babylonjs": ">=3.1.0-alpha"
+    },
+    "engines": {
+        "node": "*"
+    }
+}

+ 34 - 0
dist/preview release/inspector/readme.md

@@ -0,0 +1,34 @@
+Babylon.js inspector module
+=====================
+
+For usage documentation please visit http://doc.babylonjs.com/how_to/debug_layer and search "inspector".
+
+# Installation instructions
+
+The inspector will be **automatically** (async) loaded when starting the debug layer, if not already included. So technically, nothing needs to be done!
+
+If you wish however to use a different version of the inspector or host it on your own, follow these instructions:
+
+## CDN
+
+The latest compiled js file is offered on our public CDN here:
+
+* https://preview.babylonjs.com/inspector/babylonjs.inspector.bundle.js
+
+## NPM
+
+To install using npm :
+
+```
+npm install --save babylonjs babylonjs-inspector
+```
+Afterwards it can be imported to the project using:
+
+```
+import * as BABYLON from 'babylonjs';
+import 'babylonjs-inspector';
+```
+
+This will create a global INSPECTOR variable that will be used bay BabylonJS
+
+Webpack is supported.

+ 34 - 0
dist/preview release/materialsLibrary/babylon.backgroundMaterial.d.ts

@@ -73,12 +73,45 @@ declare namespace BABYLON {
         protected _shadowLevel: float;
         protected _shadowLevel: float;
         shadowLevel: float;
         shadowLevel: float;
         /**
         /**
+         * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
+         * It is usually zero but might be interesting to modify according to your setup.
+         */
+        protected _sceneCenter: Vector3;
+        sceneCenter: Vector3;
+        /**
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps ensuring a nice transition when the camera goes under the ground.
          * This helps ensuring a nice transition when the camera goes under the ground.
          */
          */
         protected _opacityFresnel: boolean;
         protected _opacityFresnel: boolean;
         opacityFresnel: boolean;
         opacityFresnel: boolean;
         /**
         /**
+         * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
+         * This helps adding a mirror texture on the ground.
+         */
+        protected _reflectionFresnel: boolean;
+        reflectionFresnel: boolean;
+        /**
+         * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
+         * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
+         */
+        protected _reflectionFalloffDistance: number;
+        reflectionFalloffDistance: number;
+        /**
+         * This specifies the weight of the reflection against the background in case of reflection Fresnel.
+         */
+        protected _reflectionAmount: number;
+        reflectionAmount: number;
+        /**
+         * This specifies the weight of the reflection at grazing angle.
+         */
+        protected _reflectionReflectance0: number;
+        reflectionReflectance0: number;
+        /**
+         * This specifies the weight of the reflection at a perpendicular point of view.
+         */
+        protected _reflectionReflectance90: number;
+        reflectionReflectance90: number;
+        /**
          * Helps to directly use the maps channels instead of their level.
          * Helps to directly use the maps channels instead of their level.
          */
          */
         protected _useRGBColor: boolean;
         protected _useRGBColor: boolean;
@@ -170,6 +203,7 @@ declare namespace BABYLON {
          */
          */
         cameraColorCurves: Nullable<ColorCurves>;
         cameraColorCurves: Nullable<ColorCurves>;
         private _renderTargets;
         private _renderTargets;
+        private _reflectionControls;
         /**
         /**
          * constructor
          * constructor
          * @param name The name of the material
          * @param name The name of the material

File diff suppressed because it is too large
+ 74 - 3
dist/preview release/materialsLibrary/babylon.backgroundMaterial.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/materialsLibrary/babylon.backgroundMaterial.min.js


File diff suppressed because it is too large
+ 74 - 3
dist/preview release/materialsLibrary/babylonjs.materials.js


File diff suppressed because it is too large
+ 2 - 2
dist/preview release/materialsLibrary/babylonjs.materials.min.js


+ 34 - 0
dist/preview release/materialsLibrary/babylonjs.materials.module.d.ts

@@ -933,12 +933,45 @@ declare namespace BABYLON {
         protected _shadowLevel: float;
         protected _shadowLevel: float;
         shadowLevel: float;
         shadowLevel: float;
         /**
         /**
+         * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
+         * It is usually zero but might be interesting to modify according to your setup.
+         */
+        protected _sceneCenter: Vector3;
+        sceneCenter: Vector3;
+        /**
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps ensuring a nice transition when the camera goes under the ground.
          * This helps ensuring a nice transition when the camera goes under the ground.
          */
          */
         protected _opacityFresnel: boolean;
         protected _opacityFresnel: boolean;
         opacityFresnel: boolean;
         opacityFresnel: boolean;
         /**
         /**
+         * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
+         * This helps adding a mirror texture on the ground.
+         */
+        protected _reflectionFresnel: boolean;
+        reflectionFresnel: boolean;
+        /**
+         * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
+         * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
+         */
+        protected _reflectionFalloffDistance: number;
+        reflectionFalloffDistance: number;
+        /**
+         * This specifies the weight of the reflection against the background in case of reflection Fresnel.
+         */
+        protected _reflectionAmount: number;
+        reflectionAmount: number;
+        /**
+         * This specifies the weight of the reflection at grazing angle.
+         */
+        protected _reflectionReflectance0: number;
+        reflectionReflectance0: number;
+        /**
+         * This specifies the weight of the reflection at a perpendicular point of view.
+         */
+        protected _reflectionReflectance90: number;
+        reflectionReflectance90: number;
+        /**
          * Helps to directly use the maps channels instead of their level.
          * Helps to directly use the maps channels instead of their level.
          */
          */
         protected _useRGBColor: boolean;
         protected _useRGBColor: boolean;
@@ -1030,6 +1063,7 @@ declare namespace BABYLON {
          */
          */
         cameraColorCurves: Nullable<ColorCurves>;
         cameraColorCurves: Nullable<ColorCurves>;
         private _renderTargets;
         private _renderTargets;
+        private _reflectionControls;
         /**
         /**
          * constructor
          * constructor
          * @param name The name of the material
          * @param name The name of the material

+ 1 - 1
inspector/webpack.config.js

@@ -4,7 +4,7 @@ module.exports = {
         "../../dist/preview release/inspector/babylon.inspector.min.js"
         "../../dist/preview release/inspector/babylon.inspector.min.js"
     ],
     ],
     output: {
     output: {
-        libraryTarget: "var",
+        libraryTarget: "umd",
         library: "INSPECTOR",
         library: "INSPECTOR",
         umdNamedDefine: true
         umdNamedDefine: true
     },
     },

File diff suppressed because it is too large
+ 2 - 2
materialsLibrary/src/background/babylon.backgroundMaterial.js.include.fx


+ 87 - 0
materialsLibrary/src/background/babylon.backgroundMaterial.ts

@@ -36,6 +36,16 @@ namespace BABYLON {
         public REFLECTIONBLUR = false;
         public REFLECTIONBLUR = false;
 
 
         /**
         /**
+         * True if you want the material to fade to reflection at grazing angle.
+         */
+        public REFLECTIONFRESNEL = false;
+
+        /**
+         * True if you want the material to falloff as far as you move away from the scene center.
+         */
+        public REFLECTIONFALLOFF = false;
+
+        /**
          * False if the current Webgl implementation does not support the texture lod extension.
          * False if the current Webgl implementation does not support the texture lod extension.
          */
          */
         public TEXTURELODSUPPORT = false;
         public TEXTURELODSUPPORT = false;
@@ -213,6 +223,15 @@ namespace BABYLON {
         public shadowLevel: float = 0;
         public shadowLevel: float = 0;
 
 
         /**
         /**
+         * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
+         * It is usually zero but might be interesting to modify according to your setup.
+         */
+        @serializeAsVector3()
+        protected _sceneCenter: Vector3;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public sceneCenter: Vector3 = Vector3.Zero();
+
+        /**
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps specifying that the material is falling off to the sky box at grazing angle.
          * This helps ensuring a nice transition when the camera goes under the ground.
          * This helps ensuring a nice transition when the camera goes under the ground.
          */
          */
@@ -222,6 +241,48 @@ namespace BABYLON {
         public opacityFresnel: boolean = true;
         public opacityFresnel: boolean = true;
 
 
         /**
         /**
+         * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle. 
+         * This helps adding a mirror texture on the ground.
+         */
+        @serialize()
+        protected _reflectionFresnel: boolean;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public reflectionFresnel: boolean = false;
+
+        /**
+         * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
+         * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
+         */
+        @serialize()
+        protected _reflectionFalloffDistance: number;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public reflectionFalloffDistance: number = 0.0;
+
+        /**
+         * This specifies the weight of the reflection against the background in case of reflection Fresnel.
+         */
+        @serialize()
+        protected _reflectionAmount: number;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public reflectionAmount: number = 1.0;
+
+        /**
+         * This specifies the weight of the reflection at grazing angle.
+         */
+        @serialize()
+        protected _reflectionReflectance0: number;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public reflectionReflectance0: number = 0.05;
+
+        /**
+         * This specifies the weight of the reflection at a perpendicular point of view.
+         */
+        @serialize()
+        protected _reflectionReflectance90: number;
+        @expandToProperty("_markAllSubMeshesAsTexturesDirty")
+        public reflectionReflectance90: number = 0.5;
+
+        /**
          * Helps to directly use the maps channels instead of their level.
          * Helps to directly use the maps channels instead of their level.
          */
          */
         @serialize()
         @serialize()
@@ -399,6 +460,7 @@ namespace BABYLON {
 
 
         // Temp values kept as cache in the material.
         // Temp values kept as cache in the material.
         private _renderTargets = new SmartArray<RenderTargetTexture>(16);
         private _renderTargets = new SmartArray<RenderTargetTexture>(16);
+        private _reflectionControls = BABYLON.Vector4.Zero();
 
 
         /**
         /**
          * constructor
          * constructor
@@ -545,8 +607,23 @@ namespace BABYLON {
                                 defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
                                 defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
                                 break;
                                 break;
                         }
                         }
+
+                        if (this.reflectionFresnel) {
+                            defines.REFLECTIONFRESNEL = true;
+                            defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
+
+                            this._reflectionControls.x = this.reflectionAmount;
+                            this._reflectionControls.y = this.reflectionReflectance0;
+                            this._reflectionControls.z = this.reflectionReflectance90;
+                            this._reflectionControls.w = this.reflectionFalloffDistance;
+                        }
+                        else {
+                            defines.REFLECTIONFRESNEL = false;
+                            defines.REFLECTIONFALLOFF = false;
+                        }
                     } else {
                     } else {
                         defines.REFLECTION = false;
                         defines.REFLECTION = false;
+                        defines.REFLECTIONFALLOFF = false;
                         defines.REFLECTIONBLUR = false;
                         defines.REFLECTIONBLUR = false;
                         defines.REFLECTIONMAP_3D = false;
                         defines.REFLECTIONMAP_3D = false;
                         defines.REFLECTIONMAP_SPHERICAL = false;
                         defines.REFLECTIONMAP_SPHERICAL = false;
@@ -641,6 +718,8 @@ namespace BABYLON {
 
 
                         "shadowLevel", "alpha",
                         "shadowLevel", "alpha",
 
 
+                        "vBackgroundCenter", "vReflectionControl",
+
                         "vDiffuseInfos", "diffuseMatrix",
                         "vDiffuseInfos", "diffuseMatrix",
                 ];
                 ];
 
 
@@ -708,6 +787,9 @@ namespace BABYLON {
             this._uniformBuffer.addUniform("pointSize", 1);
             this._uniformBuffer.addUniform("pointSize", 1);
             this._uniformBuffer.addUniform("shadowLevel", 1);
             this._uniformBuffer.addUniform("shadowLevel", 1);
             this._uniformBuffer.addUniform("alpha", 1);
             this._uniformBuffer.addUniform("alpha", 1);
+            this._uniformBuffer.addUniform("vBackgroundCenter", 3);
+            this._uniformBuffer.addUniform("vReflectionControl", 4);
+        
             this._uniformBuffer.create();
             this._uniformBuffer.create();
         }
         }
 
 
@@ -819,6 +901,11 @@ namespace BABYLON {
                             this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
                             this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
                             this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
                             this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
                         }
                         }
+
+                        if (defines.REFLECTIONFRESNEL) {
+                            this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
+                            this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
+                        }
                     }
                     }
                 }
                 }
 
 

+ 109 - 73
materialsLibrary/src/background/background.fragment.fx

@@ -37,39 +37,39 @@ varying vec3 vNormalW;
 
 
 // Reflection
 // Reflection
 #ifdef REFLECTION
 #ifdef REFLECTION
-	#ifdef REFLECTIONMAP_3D
-		#define sampleReflection(s, c) textureCube(s, c)
-
-		uniform samplerCube reflectionSampler;
-		
-		#ifdef TEXTURELODSUPPORT
-			#define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
-		#else
-			uniform samplerCube reflectionSamplerLow;
-			uniform samplerCube reflectionSamplerHigh;
-		#endif
-	#else
-		#define sampleReflection(s, c) texture2D(s, c)
-
-		uniform sampler2D reflectionSampler;
-
-		#ifdef TEXTURELODSUPPORT
-			#define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
-		#else
-			uniform samplerCube reflectionSamplerLow;
-			uniform samplerCube reflectionSamplerHigh;
-		#endif
-	#endif
-
-	#ifdef REFLECTIONMAP_SKYBOX
-		varying vec3 vPositionUVW;
-	#else
-		#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
-			varying vec3 vDirectionW;
-		#endif
-	#endif
-
-	#include<reflectionFunction>
+    #ifdef REFLECTIONMAP_3D
+        #define sampleReflection(s, c) textureCube(s, c)
+
+        uniform samplerCube reflectionSampler;
+        
+        #ifdef TEXTURELODSUPPORT
+            #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)
+        #else
+            uniform samplerCube reflectionSamplerLow;
+            uniform samplerCube reflectionSamplerHigh;
+        #endif
+    #else
+        #define sampleReflection(s, c) texture2D(s, c)
+
+        uniform sampler2D reflectionSampler;
+
+        #ifdef TEXTURELODSUPPORT
+            #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)
+        #else
+            uniform samplerCube reflectionSamplerLow;
+            uniform samplerCube reflectionSamplerHigh;
+        #endif
+    #endif
+
+    #ifdef REFLECTIONMAP_SKYBOX
+        varying vec3 vPositionUVW;
+    #else
+        #if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
+            varying vec3 vDirectionW;
+        #endif
+    #endif
+
+    #include<reflectionFunction>
 #endif
 #endif
 
 
 // Forces linear space for image processing
 // Forces linear space for image processing
@@ -98,6 +98,17 @@ varying vec3 vNormalW;
 // Fog
 // Fog
 #include<fogFragmentDeclaration>
 #include<fogFragmentDeclaration>
 
 
+#ifdef REFLECTIONFRESNEL
+    #define FRESNEL_MAXIMUM_ON_ROUGH 0.25
+
+    vec3 fresnelSchlickEnvironmentGGX(float VdotN, vec3 reflectance0, vec3 reflectance90, float smoothness)
+    {
+        // Schlick fresnel approximation, extended with basic smoothness term so that rough surfaces do not approach reflectance90 at grazing angle
+        float weight = mix(FRESNEL_MAXIMUM_ON_ROUGH, 1.0, smoothness);
+        return reflectance0 + weight * (reflectance90 - reflectance0) * pow(clamp(1.0 - VdotN, 0., 1.), 5.0);
+    }
+#endif
+
 void main(void) {
 void main(void) {
 #include<clipPlaneFragment>
 #include<clipPlaneFragment>
 
 
@@ -124,23 +135,23 @@ void main(void) {
 #endif
 #endif
 
 
 // _____________________________ REFLECTION ______________________________________
 // _____________________________ REFLECTION ______________________________________
-vec3 environmentColor = vec3(1., 1., 1.);
+vec3 reflectionColor = vec3(1., 1., 1.);
 #ifdef REFLECTION
 #ifdef REFLECTION
-	vec3 reflectionVector = computeReflectionCoords(vec4(vPositionW, 1.0), normalW);
-	#ifdef REFLECTIONMAP_OPPOSITEZ
-		reflectionVector.z *= -1.0;
-	#endif
-
-	// _____________________________ 2D vs 3D Maps ________________________________
-	#ifdef REFLECTIONMAP_3D
-		vec3 reflectionCoords = reflectionVector;
-	#else
-		vec2 reflectionCoords = reflectionVector.xy;
-		#ifdef REFLECTIONMAP_PROJECTION
-			reflectionCoords /= reflectionVector.z;
-		#endif
-		reflectionCoords.y = 1.0 - reflectionCoords.y;
-	#endif
+    vec3 reflectionVector = computeReflectionCoords(vec4(vPositionW, 1.0), normalW);
+    #ifdef REFLECTIONMAP_OPPOSITEZ
+        reflectionVector.z *= -1.0;
+    #endif
+
+    // _____________________________ 2D vs 3D Maps ________________________________
+    #ifdef REFLECTIONMAP_3D
+        vec3 reflectionCoords = reflectionVector;
+    #else
+        vec2 reflectionCoords = reflectionVector.xy;
+        #ifdef REFLECTIONMAP_PROJECTION
+            reflectionCoords /= reflectionVector.z;
+        #endif
+        reflectionCoords.y = 1.0 - reflectionCoords.y;
+    #endif
 
 
     #ifdef REFLECTIONBLUR
     #ifdef REFLECTIONBLUR
         float reflectionLOD = vReflectionInfos.y;
         float reflectionLOD = vReflectionInfos.y;
@@ -148,20 +159,20 @@ vec3 environmentColor = vec3(1., 1., 1.);
         #ifdef TEXTURELODSUPPORT
         #ifdef TEXTURELODSUPPORT
             // Apply environment convolution scale/offset filter tuning parameters to the mipmap LOD selection
             // Apply environment convolution scale/offset filter tuning parameters to the mipmap LOD selection
             reflectionLOD = reflectionLOD * log2(vReflectionMicrosurfaceInfos.x) * vReflectionMicrosurfaceInfos.y + vReflectionMicrosurfaceInfos.z;
             reflectionLOD = reflectionLOD * log2(vReflectionMicrosurfaceInfos.x) * vReflectionMicrosurfaceInfos.y + vReflectionMicrosurfaceInfos.z;
-            environmentColor = sampleReflectionLod(reflectionSampler, reflectionCoords, reflectionLOD).rgb;
+            reflectionColor = sampleReflectionLod(reflectionSampler, reflectionCoords, reflectionLOD).rgb;
         #else
         #else
             float lodReflectionNormalized = clamp(reflectionLOD, 0., 1.);
             float lodReflectionNormalized = clamp(reflectionLOD, 0., 1.);
             float lodReflectionNormalizedDoubled = lodReflectionNormalized * 2.0;
             float lodReflectionNormalizedDoubled = lodReflectionNormalized * 2.0;
 
 
             vec3 reflectionSpecularMid = sampleReflection(reflectionSampler, reflectionCoords).rgb;
             vec3 reflectionSpecularMid = sampleReflection(reflectionSampler, reflectionCoords).rgb;
             if(lodReflectionNormalizedDoubled < 1.0){
             if(lodReflectionNormalizedDoubled < 1.0){
-                environmentColor = mix(
+                reflectionColor = mix(
                     sampleReflection(reflectionSamplerHigh, reflectionCoords).rgb,
                     sampleReflection(reflectionSamplerHigh, reflectionCoords).rgb,
                     reflectionSpecularMid,
                     reflectionSpecularMid,
                     lodReflectionNormalizedDoubled
                     lodReflectionNormalizedDoubled
                 );
                 );
             } else {
             } else {
-                environmentColor = mix(
+                reflectionColor = mix(
                     reflectionSpecularMid,
                     reflectionSpecularMid,
                     sampleReflection(reflectionSamplerLow, reflectionCoords).rgb,
                     sampleReflection(reflectionSamplerLow, reflectionCoords).rgb,
                     lodReflectionNormalizedDoubled - 1.0
                     lodReflectionNormalizedDoubled - 1.0
@@ -169,19 +180,20 @@ vec3 environmentColor = vec3(1., 1., 1.);
             }
             }
         #endif
         #endif
     #else
     #else
-        environmentColor = sampleReflection(reflectionSampler, reflectionCoords).rgb;
+        vec4 reflectionSample = sampleReflection(reflectionSampler, reflectionCoords);
+        reflectionColor = reflectionSample.rgb;
     #endif
     #endif
 
 
     #ifdef GAMMAREFLECTION
     #ifdef GAMMAREFLECTION
-        environmentColor = toLinearSpace(environmentColor.rgb);
+        reflectionColor = toLinearSpace(reflectionColor.rgb);
     #endif
     #endif
 
 
     // _____________________________ Levels _____________________________________
     // _____________________________ Levels _____________________________________
-    environmentColor *= vReflectionInfos.x;
+    reflectionColor *= vReflectionInfos.x;
 #endif
 #endif
 
 
-// _____________________________ Alpha Information _______________________________
-vec3 groundColor = vec3(1., 1., 1.);
+// _____________________________ Diffuse Information _______________________________
+vec3 diffuseColor = vec3(1., 1., 1.);
 float finalAlpha = alpha;
 float finalAlpha = alpha;
 #ifdef DIFFUSE
 #ifdef DIFFUSE
     vec4 diffuseMap = texture2D(diffuseSampler, vDiffuseUV);
     vec4 diffuseMap = texture2D(diffuseSampler, vDiffuseUV);
@@ -196,14 +208,18 @@ float finalAlpha = alpha;
         finalAlpha *= diffuseMap.a;
         finalAlpha *= diffuseMap.a;
     #endif
     #endif
 
 
-    groundColor = diffuseMap.rgb;
+    diffuseColor = diffuseMap.rgb;
 #endif
 #endif
 
 
-    // _____________________________ MIX ________________________________________
-    vec3 colorBase = environmentColor * groundColor;
+// _____________________________ MIX ________________________________________
+#ifdef REFLECTIONFRESNEL
+    vec3 colorBase = diffuseColor;
+#else
+    vec3 colorBase = reflectionColor * diffuseColor;
+#endif
     colorBase = max(colorBase, 0.0);
     colorBase = max(colorBase, 0.0);
 
 
-    // ___________________________ COMPOSE _______________________________________
+// ___________________________ COMPOSE _______________________________________
 #ifdef USERGBCOLOR
 #ifdef USERGBCOLOR
     vec3 finalColor = colorBase;
     vec3 finalColor = colorBase;
 #else
 #else
@@ -212,13 +228,27 @@ float finalAlpha = alpha;
     finalColor += colorBase.b * vTertiaryColor.rgb * vTertiaryColor.a;
     finalColor += colorBase.b * vTertiaryColor.rgb * vTertiaryColor.a;
 #endif
 #endif
 
 
-#ifdef SHADOWINUSE
-    finalColor = mix(finalColor * shadowLevel, finalColor, globalShadow);
+// ___________________________ FRESNELS _______________________________________
+#ifdef REFLECTIONFRESNEL
+    vec3 reflectionAmount = vReflectionControl.xxx;
+    vec3 reflectionReflectance0 = vReflectionControl.yyy;
+    vec3 reflectionReflectance90 = vReflectionControl.zzz;
+    float VdotN = dot(normalize(vEyePosition), normalW);
+
+    vec3 planarReflectionFresnel = fresnelSchlickEnvironmentGGX(clamp(VdotN, 0.0, 1.0), reflectionReflectance0, reflectionReflectance90, 1.0);
+    reflectionAmount *= planarReflectionFresnel;
+
+    #ifdef REFLECTIONFALLOFF
+        float reflectionDistanceFalloff = 1.0 - clamp(length(vPositionW.xyz - vBackgroundCenter) * vReflectionControl.w, 0.0, 1.0);
+        reflectionDistanceFalloff *= reflectionDistanceFalloff;
+        reflectionAmount *= reflectionDistanceFalloff;
+    #endif
+
+    finalColor = mix(finalColor, reflectionColor, clamp(reflectionAmount, 0., 1.));
 #endif
 #endif
 
 
 #ifdef OPACITYFRESNEL
 #ifdef OPACITYFRESNEL
-    // TODO. Change by camera forward Direction.
-    float viewAngleToFloor = dot(normalW, normalize(vEyePosition));
+    float viewAngleToFloor = dot(normalW, normalize(vEyePosition - vBackgroundCenter));
 
 
     // Fade out the floor plane as the angle between the floor and the camera tends to 0 (starting from startAngle)
     // Fade out the floor plane as the angle between the floor and the camera tends to 0 (starting from startAngle)
     const float startAngle = 0.1;
     const float startAngle = 0.1;
@@ -227,22 +257,28 @@ float finalAlpha = alpha;
     finalAlpha *= fadeFactor * fadeFactor;
     finalAlpha *= fadeFactor * fadeFactor;
 #endif
 #endif
 
 
-    vec4 color = vec4(finalColor, finalAlpha);
+// ___________________________ SHADOWS _______________________________________
+#ifdef SHADOWINUSE
+    finalColor = mix(finalColor * shadowLevel, finalColor, globalShadow);
+#endif
+
+// ___________________________ FINALIZE _______________________________________
+vec4 color = vec4(finalColor, finalAlpha);
 
 
 #include<fogFragment>
 #include<fogFragment>
 
 
 #ifdef IMAGEPROCESSINGPOSTPROCESS
 #ifdef IMAGEPROCESSINGPOSTPROCESS
-	// Sanitize output incase invalid normals or tangents have caused div by 0 or undefined behavior
-	// this also limits the brightness which helpfully reduces over-sparkling in bloom (native handles this in the bloom blur shader)
-	color.rgb = clamp(color.rgb, 0., 30.0);
+    // Sanitize output incase invalid normals or tangents have caused div by 0 or undefined behavior
+    // this also limits the brightness which helpfully reduces over-sparkling in bloom (native handles this in the bloom blur shader)
+    color.rgb = clamp(color.rgb, 0., 30.0);
 #else
 #else
-	// Alway run even to ensure going back to gamma space.
-	color = applyImageProcessing(color);
+    // Alway run even to ensure going back to gamma space.
+    color = applyImageProcessing(color);
 #endif
 #endif
 
 
 #ifdef PREMULTIPLYALPHA
 #ifdef PREMULTIPLYALPHA
-	// Convert to associative (premultiplied) format if needed.
-	color.rgb *= color.a;
+    // Convert to associative (premultiplied) format if needed.
+    color.rgb *= color.a;
 #endif
 #endif
 
 
     gl_FragColor = color;
     gl_FragColor = color;

+ 8 - 0
materialsLibrary/src/background/backgroundFragmentDeclaration.fx

@@ -12,4 +12,12 @@
     uniform vec2 vReflectionInfos;
     uniform vec2 vReflectionInfos;
     uniform mat4 reflectionMatrix;
     uniform mat4 reflectionMatrix;
     uniform vec3 vReflectionMicrosurfaceInfos;
     uniform vec3 vReflectionMicrosurfaceInfos;
+#endif
+
+#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
+    uniform vec3 vBackgroundCenter;
+#endif
+
+#ifdef REFLECTIONFRESNEL
+    uniform vec4 vReflectionControl;
 #endif
 #endif

+ 8 - 0
materialsLibrary/src/background/backgroundUboDeclaration.fx

@@ -14,6 +14,14 @@ uniform Material
 	uniform float pointSize;
 	uniform float pointSize;
 	uniform float shadowLevel;
 	uniform float shadowLevel;
 	uniform float alpha;
 	uniform float alpha;
+
+	#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)
+		uniform vec3 vBackgroundCenter;
+	#endif
+
+	#ifdef REFLECTIONFRESNEL
+		uniform vec4 vReflectionControl;
+	#endif
 };
 };
 
 
 uniform Scene {
 uniform Scene {

+ 57 - 18
materialsLibrary/test/addbackground.js

@@ -13,8 +13,21 @@ window.prepareBackgroundMaterial = function() {
     backgroundSkybox = BABYLON.Mesh.CreateBox("hdrSkyBox", 1000.0, scene);
     backgroundSkybox = BABYLON.Mesh.CreateBox("hdrSkyBox", 1000.0, scene);
 	backgroundSkybox.material = backSky;
 	backgroundSkybox.material = backSky;
 	backgroundSkybox.setEnabled(false);
 	backgroundSkybox.setEnabled(false);
+
+	var mirrorMesh = BABYLON.Mesh.CreateTorus("torus", 4, 2, 30, scene, false);
+	mirrorMesh.setEnabled(false);
+	mirrorMesh.position = new BABYLON.Vector3(0, 3, 0);
+	mirrorMesh.material = new BABYLON.StandardMaterial("", scene);
+	mirrorMesh.material.emissiveColor = BABYLON.Color3.Red();
+
+	var mirror = new BABYLON.MirrorTexture("mirror", {ratio: 0.3}, scene, true);
+	mirror.renderList = [mirrorMesh];
+	mirror.clearColor = new BABYLON.Color4(1, 1, 1, 0.0);
+	mirror.mirrorPlane = new BABYLON.Plane(0, -1.0, 0, 0.0);
+	mirror.adaptiveBlurKernel = 64;
 	
 	
 	registerRangeUI("background", "primaryColorR", 0, 1, function(value) {
 	registerRangeUI("background", "primaryColorR", 0, 1, function(value) {
+		mirror.clearColor.r = value;
 		back.primaryColor.r = value;
 		back.primaryColor.r = value;
 		backSky.primaryColor.r = value;
 		backSky.primaryColor.r = value;
 	}, function() {
 	}, function() {
@@ -22,6 +35,7 @@ window.prepareBackgroundMaterial = function() {
 	});
 	});
 
 
 	registerRangeUI("background", "primaryColorG", 0, 1, function(value) {
 	registerRangeUI("background", "primaryColorG", 0, 1, function(value) {
+		mirror.clearColor.g = value;
 		back.primaryColor.g = value;
 		back.primaryColor.g = value;
 		backSky.primaryColor.g = value;
 		backSky.primaryColor.g = value;
 	}, function() {
 	}, function() {
@@ -29,6 +43,7 @@ window.prepareBackgroundMaterial = function() {
 	});
 	});
 
 
 	registerRangeUI("background", "primaryColorB", 0, 1, function(value) {
 	registerRangeUI("background", "primaryColorB", 0, 1, function(value) {
+		mirror.clearColor.b = value;
 		back.primaryColor.b = value;
 		back.primaryColor.b = value;
 		backSky.primaryColor.b = value;
 		backSky.primaryColor.b = value;
 	}, function() {
 	}, function() {
@@ -70,39 +85,38 @@ window.prepareBackgroundMaterial = function() {
 		return back.secondaryLevel;
 		return back.secondaryLevel;
 	});
 	});
 
 
-	registerRangeUI("background", "thirdColorR", 0, 1, function(value) {
-		back.thirdColor.r = value;
-		backSky.thirdColor.r = value;
+	registerRangeUI("background", "tertiaryColorR", 0, 1, function(value) {
+		back.tertiaryColor.r = value;
+		backSky.tertiaryColor.r = value;
 	}, function() {
 	}, function() {
-		return back.thirdColor.r;
+		return back.tertiaryColor.r;
 	});
 	});
 
 
-	registerRangeUI("background", "thirdColorG", 0, 1, function(value) {
-		back.thirdColor.g = value;
-		backSky.thirdColor.g = value;
+	registerRangeUI("background", "tertiaryColorG", 0, 1, function(value) {
+		back.tertiaryColor.g = value;
+		backSky.tertiaryColor.g = value;
 	}, function() {
 	}, function() {
-		return back.thirdColor.g;
+		return back.tertiaryColor.g;
 	});
 	});
 
 
-	registerRangeUI("background", "thirdColorB", 0, 1, function(value) {
-		back.thirdColor.b = value;
-		backSky.thirdColor.b = value;
+	registerRangeUI("background", "tertiaryColorB", 0, 1, function(value) {
+		back.tertiaryColor.b = value;
+		backSky.tertiaryColor.b = value;
 	}, function() {
 	}, function() {
-		return back.thirdColor.b;
+		return back.tertiaryColor.b;
 	});
 	});
 
 
-	registerRangeUI("background", "thirdLevel", 0, 30, function(value) {
-		back.thirdLevel = value;		
-		backSky.thirdLevel = value;
+	registerRangeUI("background", "tertiaryLevel", 0, 30, function(value) {
+		back.tertiaryLevel = value;		
+		backSky.tertiaryLevel = value;
 	}, function() {
 	}, function() {
-		return back.thirdLevel;
+		return back.tertiaryLevel;
 	});
 	});
 
 
 	registerRangeUI("background", "reflectionBlur", 0, 1, function(value) {
 	registerRangeUI("background", "reflectionBlur", 0, 1, function(value) {
-		back.reflectionBlur = value;
 		backSky.reflectionBlur = value;
 		backSky.reflectionBlur = value;
 	}, function() {
 	}, function() {
-		return back.reflectionBlur;
+		return backSky.reflectionBlur;
 	});
 	});
 
 
 	registerRangeUI("background", "shadowLevel", 0, 1, function(value) {
 	registerRangeUI("background", "shadowLevel", 0, 1, function(value) {
@@ -118,6 +132,18 @@ window.prepareBackgroundMaterial = function() {
 		return back.alpha;
 		return back.alpha;
 	});
 	});
 
 
+	registerRangeUI("background", "mirrorAmount", 0, 10, function(value) {
+		back.reflectionAmount = value;
+	}, function() {
+		return back.reflectionAmount;
+	});
+
+	registerRangeUI("background", "mirrorFalloff", 0, 5, function(value) {
+		back.reflectionFalloffDistance = value;
+	}, function() {
+		return back.reflectionFalloffDistance;
+	});
+
 	registerButtonUI("background", "ToggleBackRGB", function() {
 	registerButtonUI("background", "ToggleBackRGB", function() {
 		back.useRGBColor = !back.useRGBColor;
 		back.useRGBColor = !back.useRGBColor;
 	});
 	});
@@ -126,6 +152,19 @@ window.prepareBackgroundMaterial = function() {
 		backSky.useRGBColor = !backSky.useRGBColor;
 		backSky.useRGBColor = !backSky.useRGBColor;
 	});
 	});
 
 
+	registerButtonUI("background", "ToggleMirror", function() {
+		if (back.reflectionFresnel) {
+			back.reflectionFresnel = false;
+			back.reflectionTexture = null;
+			mirrorMesh.setEnabled(false);
+		}
+		else {
+			back.reflectionFresnel = true;
+			back.reflectionTexture = mirror;
+			mirrorMesh.setEnabled(true);
+		}
+	});
+
 
 
 	return back;
 	return back;
 }
 }

+ 0 - 4
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -462,15 +462,11 @@
             impostor.object.position.copyFrom(impostor.physicsBody.position);
             impostor.object.position.copyFrom(impostor.physicsBody.position);
             if (impostor.object.rotationQuaternion) {
             if (impostor.object.rotationQuaternion) {
                 impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
                 impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
-                //impostor.object.rotationQuaternion.y *= -1;
-                //impostor.object.rotationQuaternion.z *= -1;
             }
             }
         }
         }
 
 
         public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {
         public setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion) {
             impostor.physicsBody.position.copy(newPosition);
             impostor.physicsBody.position.copy(newPosition);
-            //newRotation.y *= -1;
-            //newRotation.z *= -1;
             impostor.physicsBody.quaternion.copy(newRotation);
             impostor.physicsBody.quaternion.copy(newRotation);
         }
         }
 
 

+ 5 - 0
src/Physics/babylon.physicsImpostor.ts

@@ -404,6 +404,7 @@ module BABYLON {
 
 
             this.object.translate(this._deltaPosition, -1);
             this.object.translate(this._deltaPosition, -1);
             this._deltaRotationConjugated && this.object.rotationQuaternion && this.object.rotationQuaternion.multiplyToRef(this._deltaRotationConjugated, this.object.rotationQuaternion);
             this._deltaRotationConjugated && this.object.rotationQuaternion && this.object.rotationQuaternion.multiplyToRef(this._deltaRotationConjugated, this.object.rotationQuaternion);
+            this.object.computeWorldMatrix(false);
             if (this.object.parent && this.object.rotationQuaternion) {
             if (this.object.parent && this.object.rotationQuaternion) {
                 this.getParentsRotation();
                 this.getParentsRotation();
                 this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this._tmpQuat);
                 this._tmpQuat.multiplyToRef(this.object.rotationQuaternion, this._tmpQuat);
@@ -427,6 +428,10 @@ module BABYLON {
                 return;
                 return;
             }
             }
 
 
+            this._onAfterPhysicsStepCallbacks.forEach((func) => {
+                func(this);
+            });
+
             this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this);
             this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(this);
             // object has now its world rotation. needs to be converted to local.
             // object has now its world rotation. needs to be converted to local.
             if (this.object.parent && this.object.rotationQuaternion) {
             if (this.object.parent && this.object.rotationQuaternion) {