Prechádzať zdrojové kódy

Merge remote-tracking branch 'upstream/master' into motion-controller-profiles

Raanan Weber 5 rokov pred
rodič
commit
43fbb9fafa
83 zmenil súbory, kde vykonal 10885 pridanie a 13911 odobranie
  1. BIN
      Playground/textures/opacity.png
  2. 0 5
      Tools/Config/config.json
  3. 1 1
      Tools/Publisher/tasks/buildBabylonJSAndDependencies.js
  4. 96 307
      dist/preview release/babylon.d.ts
  5. 2 2
      dist/preview release/babylon.js
  6. 266 982
      dist/preview release/babylon.max.js
  7. 1 1
      dist/preview release/babylon.max.js.map
  8. 197 621
      dist/preview release/babylon.module.d.ts
  9. 96 404
      dist/preview release/documentation.d.ts
  10. 1 1
      dist/preview release/glTF2Interface/package.json
  11. 9337 7903
      dist/preview release/gltf_validator.js
  12. 2 2
      dist/preview release/gui/package.json
  13. 7 7
      dist/preview release/inspector/package.json
  14. 3 3
      dist/preview release/loaders/package.json
  15. 2 2
      dist/preview release/materialsLibrary/package.json
  16. 3 0
      dist/preview release/nodeEditor/babylon.nodeEditor.d.ts
  17. 2 2
      dist/preview release/nodeEditor/babylon.nodeEditor.js
  18. 37 3
      dist/preview release/nodeEditor/babylon.nodeEditor.max.js
  19. 1 1
      dist/preview release/nodeEditor/babylon.nodeEditor.max.js.map
  20. 6 0
      dist/preview release/nodeEditor/babylon.nodeEditor.module.d.ts
  21. 2 2
      dist/preview release/nodeEditor/package.json
  22. 1 1
      dist/preview release/package.json
  23. 1 1
      dist/preview release/packagesSizeBaseLine.json
  24. 2 2
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  25. 2 2
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  26. 0 655
      dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.js
  27. 0 1
      dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.js.map
  28. 0 16
      dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.min.js
  29. 0 97
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.d.ts
  30. 2 262
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.js
  31. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.js.map
  32. 2 2
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  33. 0 206
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.module.d.ts
  34. 2 2
      dist/preview release/postProcessesLibrary/package.json
  35. 2 2
      dist/preview release/proceduralTexturesLibrary/package.json
  36. 9 24
      dist/preview release/recast.js
  37. 3 3
      dist/preview release/serializers/package.json
  38. 197 621
      dist/preview release/viewer/babylon.module.d.ts
  39. 21 21
      dist/preview release/viewer/babylon.viewer.js
  40. 1 1
      dist/preview release/viewer/babylon.viewer.max.js
  41. 7 1
      dist/preview release/what's new.md
  42. 25 33
      loaders/src/glTF/glTFFileLoader.ts
  43. 12 0
      nodeEditor/src/diagram/display/inputDisplayManager.ts
  44. 9 1
      nodeEditor/src/diagram/graphCanvas.scss
  45. 10 0
      nodeEditor/src/diagram/graphCanvas.tsx
  46. 19 1
      nodeEditor/src/diagram/properties/gradientNodePropertyComponent.tsx
  47. 6 0
      nodeEditor/src/diagram/properties/gradientStepComponent.tsx
  48. 1 1
      package.json
  49. 1 14
      postProcessLibrary/index.html
  50. 1 2
      postProcessLibrary/src/index.ts
  51. 0 14
      postProcessLibrary/src/legacy/legacy-ocean.ts
  52. 0 1
      postProcessLibrary/src/ocean/index.ts
  53. 0 259
      postProcessLibrary/src/ocean/oceanPostProcess.fragment.fx
  54. 0 249
      postProcessLibrary/src/ocean/oceanPostProcess.ts
  55. 19 0
      src/Cameras/VR/vrExperienceHelper.ts
  56. 19 7
      src/Cameras/XR/features/WebXRAbstractFeature.ts
  57. 6 8
      src/Cameras/XR/features/WebXRAnchorSystem.ts
  58. 7 5
      src/Cameras/XR/features/WebXRBackgroundRemover.ts
  59. 20 11
      src/Cameras/XR/features/WebXRControllerPointerSelection.ts
  60. 3 5
      src/Cameras/XR/features/WebXRControllerTeleportation.ts
  61. 3 8
      src/Cameras/XR/features/WebXRHitTestLegacy.ts
  62. 3 5
      src/Cameras/XR/features/WebXRPlaneDetector.ts
  63. 4 9
      src/Cameras/XR/webXRCamera.ts
  64. 6 1
      src/Cameras/XR/webXRExperienceHelper.ts
  65. 53 7
      src/Cameras/XR/webXRFeaturesManager.ts
  66. 7 6
      src/Cameras/XR/webXRSessionManager.ts
  67. 5 4
      src/Engines/thinEngine.ts
  68. 91 927
      src/Lights/Shadows/cascadedShadowGenerator.ts
  69. 163 123
      src/Lights/Shadows/shadowGenerator.ts
  70. 0 8
      src/Lights/Shadows/shadowGeneratorSceneComponent.ts
  71. 4 0
      src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts
  72. 2 0
      src/Materials/Node/Blocks/colorSplitterBlock.ts
  73. 2 0
      src/Materials/Node/Blocks/vectorSplitterBlock.ts
  74. 3 0
      src/Materials/Node/nodeMaterialBlock.ts
  75. 6 1
      src/Materials/Node/nodeMaterialBlockConnectionPoint.ts
  76. 4 0
      src/Materials/shaderMaterial.ts
  77. 3 2
      src/Meshes/Builders/linesBuilder.ts
  78. 4 10
      src/Meshes/mesh.ts
  79. 3 12
      src/Meshes/subMesh.ts
  80. 8 5
      src/Meshes/trailMesh.ts
  81. 36 0
      src/Meshes/transformNode.ts
  82. 1 1
      src/Navigation/INavigationEngine.ts
  83. 1 1
      src/Navigation/Plugins/recastJSPlugin.ts

BIN
Playground/textures/opacity.png


+ 0 - 5
Tools/Config/config.json

@@ -263,11 +263,6 @@
                 "output": "babylon.digitalRainPostProcess.min.js",
                 "entry": "./legacy/legacy-digitalRain.ts",
                 "preventLoadLibrary": true
-            },
-            {
-                "output": "babylon.oceanPostProcess.min.js",
-                "entry": "./legacy/legacy-ocean.ts",
-                "preventLoadLibrary": true
             }
         ],
         "build": {

+ 1 - 1
Tools/Publisher/tasks/buildBabylonJSAndDependencies.js

@@ -8,7 +8,7 @@ const colorConsole = require("../../NodeHelpers/colorConsole");
  */
 function buildBabylonJSAndDependencies() {
     colorConsole.log("Running gulp compilation");
-    let exec = shelljs.exec("gulp typescript-all", {
+    let exec = shelljs.exec("gulp --max-old-space-size=8192 typescript-all", {
         cwd: path.resolve(__dirname, "../../Gulp/")
     });
     if (exec.code) {

+ 96 - 307
dist/preview release/babylon.d.ts

@@ -9470,6 +9470,10 @@ declare module BABYLON {
      */
     export class ShadowGenerator implements IShadowGenerator {
         /**
+         * Name of the shadow generator class
+         */
+        static CLASSNAME: string;
+        /**
          * Shadow generator mode None: no filtering applied.
          */
         static readonly FILTER_NONE: number;
@@ -9559,7 +9563,7 @@ declare module BABYLON {
          * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
          */
         onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
-        private _bias;
+        protected _bias: number;
         /**
          * Gets the bias: offset applied on the depth preventing acnea (in light direction).
          */
@@ -9568,7 +9572,7 @@ declare module BABYLON {
          * Sets the bias: offset applied on the depth preventing acnea (in light direction).
          */
         set bias(bias: number);
-        private _normalBias;
+        protected _normalBias: number;
         /**
          * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
          */
@@ -9577,7 +9581,7 @@ declare module BABYLON {
          * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
          */
         set normalBias(normalBias: number);
-        private _blurBoxOffset;
+        protected _blurBoxOffset: number;
         /**
          * Gets the blur box offset: offset applied during the blur pass.
          * Only useful if useKernelBlur = false
@@ -9588,7 +9592,7 @@ declare module BABYLON {
          * Only useful if useKernelBlur = false
          */
         set blurBoxOffset(value: number);
-        private _blurScale;
+        protected _blurScale: number;
         /**
          * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
          * 2 means half of the size.
@@ -9599,7 +9603,7 @@ declare module BABYLON {
          * 2 means half of the size.
          */
         set blurScale(value: number);
-        private _blurKernel;
+        protected _blurKernel: number;
         /**
          * Gets the blur kernel: kernel size of the blur pass.
          * Only useful if useKernelBlur = true
@@ -9610,7 +9614,7 @@ declare module BABYLON {
          * Only useful if useKernelBlur = true
          */
         set blurKernel(value: number);
-        private _useKernelBlur;
+        protected _useKernelBlur: boolean;
         /**
          * Gets whether the blur pass is a kernel blur (if true) or box blur.
          * Only useful in filtered mode (useBlurExponentialShadowMap...)
@@ -9621,7 +9625,7 @@ declare module BABYLON {
          * Only useful in filtered mode (useBlurExponentialShadowMap...)
          */
         set useKernelBlur(value: boolean);
-        private _depthScale;
+        protected _depthScale: number;
         /**
          * Gets the depth scale used in ESM mode.
          */
@@ -9631,7 +9635,8 @@ declare module BABYLON {
          * This can override the scale stored on the light.
          */
         set depthScale(value: number);
-        private _filter;
+        protected _validateFilter(filter: number): number;
+        protected _filter: number;
         /**
          * Gets the current mode of the shadow generator (normal, PCF, ESM...).
          * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
@@ -9694,7 +9699,7 @@ declare module BABYLON {
          * Sets the current filter to "PCF" (percentage closer filtering).
          */
         set usePercentageCloserFiltering(value: boolean);
-        private _filteringQuality;
+        protected _filteringQuality: number;
         /**
          * Gets the PCF or PCSS Quality.
          * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
@@ -9713,7 +9718,7 @@ declare module BABYLON {
          * Sets the current filter to "PCSS" (contact hardening).
          */
         set useContactHardeningShadow(value: boolean);
-        private _contactHardeningLightSizeUVRatio;
+        protected _contactHardeningLightSizeUVRatio: number;
         /**
          * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
          * Using a ratio helps keeping shape stability independently of the map size.
@@ -9734,7 +9739,7 @@ declare module BABYLON {
          * Only valid if useContactHardeningShadow is true.
          */
         set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
-        private _darkness;
+        protected _darkness: number;
         /** Gets or sets the actual darkness of a shadow */
         get darkness(): number;
         set darkness(value: number);
@@ -9750,7 +9755,7 @@ declare module BABYLON {
          * @returns the shadow generator allowing fluent coding.
          */
         setDarkness(darkness: number): ShadowGenerator;
-        private _transparencyShadow;
+        protected _transparencyShadow: boolean;
         /** Gets or sets the ability to have transparent shadow  */
         get transparencyShadow(): boolean;
         set transparencyShadow(value: boolean);
@@ -9760,8 +9765,8 @@ declare module BABYLON {
          * @returns the shadow generator allowing fluent coding
          */
         setTransparencyShadow(transparent: boolean): ShadowGenerator;
-        private _shadowMap;
-        private _shadowMap2;
+        protected _shadowMap: Nullable<RenderTargetTexture>;
+        protected _shadowMap2: Nullable<RenderTargetTexture>;
         /**
          * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
          * @returns The render target texture if present otherwise, null
@@ -9793,10 +9798,9 @@ declare module BABYLON {
         removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
         /**
          * Controls the extent to which the shadows fade out at the edge of the frustum
-         * Used only by directionals and spots
          */
         frustumEdgeFalloff: number;
-        private _light;
+        protected _light: IShadowLight;
         /**
          * Returns the associated light object.
          * @returns the light generating the shadow
@@ -9808,26 +9812,26 @@ declare module BABYLON {
          * It might on the other hand introduce peter panning.
          */
         forceBackFacesOnly: boolean;
-        private _scene;
-        private _lightDirection;
-        private _effect;
-        private _viewMatrix;
-        private _projectionMatrix;
-        private _transformMatrix;
-        private _cachedPosition;
-        private _cachedDirection;
-        private _cachedDefines;
-        private _currentRenderID;
-        private _boxBlurPostprocess;
-        private _kernelBlurXPostprocess;
-        private _kernelBlurYPostprocess;
-        private _blurPostProcesses;
-        private _mapSize;
-        private _currentFaceIndex;
-        private _currentFaceIndexCache;
-        private _textureType;
-        private _defaultTextureMatrix;
-        private _storedUniqueId;
+        protected _scene: Scene;
+        protected _lightDirection: Vector3;
+        protected _effect: Effect;
+        protected _viewMatrix: Matrix;
+        protected _projectionMatrix: Matrix;
+        protected _transformMatrix: Matrix;
+        protected _cachedPosition: Vector3;
+        protected _cachedDirection: Vector3;
+        protected _cachedDefines: string;
+        protected _currentRenderID: number;
+        protected _boxBlurPostprocess: Nullable<PostProcess>;
+        protected _kernelBlurXPostprocess: Nullable<PostProcess>;
+        protected _kernelBlurYPostprocess: Nullable<PostProcess>;
+        protected _blurPostProcesses: PostProcess[];
+        protected _mapSize: number;
+        protected _currentFaceIndex: number;
+        protected _currentFaceIndexCache: number;
+        protected _textureType: number;
+        protected _defaultTextureMatrix: Matrix;
+        protected _storedUniqueId: Nullable<number>;
         /** @hidden */
         static _SceneComponentInitialization: (scene: Scene) => void;
         /**
@@ -9840,12 +9844,14 @@ declare module BABYLON {
          * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
          */
         constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
-        private _initializeGenerator;
-        private _initializeShadowMap;
-        private _initializeBlurRTTAndPostProcesses;
-        private _renderForShadowMap;
-        private _renderSubMeshForShadowMap;
-        private _applyFilterValues;
+        protected _initializeGenerator(): void;
+        protected _createTargetRenderTexture(): void;
+        protected _initializeShadowMap(): void;
+        protected _initializeBlurRTTAndPostProcesses(): void;
+        protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
+        protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
+        protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
+        protected _applyFilterValues(): void;
         /**
          * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
          * @param onCompiled Callback triggered at the and of the effects compilation
@@ -9862,6 +9868,7 @@ declare module BABYLON {
         forceCompilationAsync(options?: Partial<{
             useInstances: boolean;
         }>): Promise<void>;
+        protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
         /**
          * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
          * @param subMesh The submesh we want to render in the shadow map
@@ -9893,8 +9900,8 @@ declare module BABYLON {
          * Cube and 2D textures for instance.
          */
         recreateShadowMap(): void;
-        private _disposeBlurPostProcesses;
-        private _disposeRTTandPostProcesses;
+        protected _disposeBlurPostProcesses(): void;
+        protected _disposeRTTandPostProcesses(): void;
         /**
          * Disposes the ShadowGenerator.
          * Returns nothing.
@@ -9909,9 +9916,10 @@ declare module BABYLON {
          * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
          * @param parsedShadowGenerator The JSON object to parse
          * @param scene The scene to create the shadow map for
+         * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
          * @returns The parsed shadow generator
          */
-        static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
+        static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
     }
 }
 declare module BABYLON {
@@ -31240,7 +31248,8 @@ declare module BABYLON {
          */
         updateArrayBuffer(data: Float32Array): void;
         private _vertexAttribPointer;
-        private _bindIndexBufferWithCache;
+        /** @hidden */
+        _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
         private _bindVertexBuffersAttributes;
         /**
          * Records a vertex array object
@@ -44053,6 +44062,14 @@ declare module BABYLON {
          * Should the selection mesh be displayed (The ring at the end of the laser pointer)
          */
         displaySelectionMesh: boolean;
+        /**
+         * Disable lighting on the laser pointer (so it will always be visible)
+         */
+        disablePointerLighting: boolean;
+        /**
+         * Disable lighting on the selection mesh (so it will always be visible)
+         */
+        disableSelectionMeshLighting: boolean;
         private static _idCounter;
         private _tmpRay;
         private _controllers;
@@ -44250,6 +44267,7 @@ declare module BABYLON {
          * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
          * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
          * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
+         * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
          * * When updating an instance, remember that only point positions can change, not the number of points
          * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
          * @param name defines the name of the mesh
@@ -44265,6 +44283,7 @@ declare module BABYLON {
             dashNb?: number;
             updatable?: boolean;
             instance?: LinesMesh;
+            useVertexAlpha?: boolean;
         }, scene?: Nullable<Scene>): LinesMesh;
     }
 }
@@ -44878,6 +44897,11 @@ declare module BABYLON {
          */
         setLaserColor(color: Color3, pickedColor?: Color3): void;
         /**
+         * Set lighting enabled / disabled on the laser pointer of both controllers
+         * @param enabled should the lighting be enabled on the laser pointer
+         */
+        setLaserLightingState(enabled?: boolean): void;
+        /**
          * Permanently set new colors for the gaze pointer
          * @param color the new gaze color
          * @param pickedColor the new gaze color when picked mesh detected
@@ -54275,12 +54299,12 @@ declare module BABYLON {
      * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
      * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
      */
-    export class CascadedShadowGenerator implements IShadowGenerator {
+    export class CascadedShadowGenerator extends ShadowGenerator {
         private static readonly frustumCornersNDCSpace;
         /**
          * Name of the CSM class
          */
-        static readonly CLASSNAME: string;
+        static CLASSNAME: string;
         /**
          * Defines the default number of cascades used by the CSM.
          */
@@ -54293,175 +54317,11 @@ declare module BABYLON {
          * Defines the maximum number of cascades used by the CSM.
          */
         static readonly MAX_CASCADES_COUNT: number;
-        /**
-         * Shadow generator mode None: no filtering applied.
-         */
-        static readonly FILTER_NONE: number;
-        /**
-         * Shadow generator mode PCF: Percentage Closer Filtering
-         * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
-         * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
-         */
-        static readonly FILTER_PCF: number;
-        /**
-         * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
-         * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
-         * Contact Hardening
-         */
-        static readonly FILTER_PCSS: number;
-        /**
-         * Reserved for PCF and PCSS
-         * Highest Quality.
-         *
-         * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
-         *
-         * Execute PCSS with 32 taps blocker search and 64 taps PCF.
-         */
-        static readonly QUALITY_HIGH: number;
-        /**
-         * Reserved for PCF and PCSS
-         * Good tradeoff for quality/perf cross devices
-         *
-         * Execute PCF on a 3*3 kernel.
-         *
-         * Execute PCSS with 16 taps blocker search and 32 taps PCF.
-         */
-        static readonly QUALITY_MEDIUM: number;
-        /**
-         * Reserved for PCF and PCSS
-         * The lowest quality but the fastest.
-         *
-         * Execute PCF on a 1*1 kernel.
-         *
-         * Execute PCSS with 16 taps blocker search and 16 taps PCF.
-         */
-        static readonly QUALITY_LOW: number;
-        private static readonly _CLEARONE;
-        /**
-         * Observable triggered before the shadow is rendered. Can be used to update internal effect state
-         */
-        onBeforeShadowMapRenderObservable: Observable<Effect>;
-        /**
-         * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
-         */
-        onAfterShadowMapRenderObservable: Observable<Effect>;
-        /**
-         * Observable triggered before a mesh is rendered in the shadow map.
-         * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
-         */
-        onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
-        /**
-         * Observable triggered after a mesh is rendered in the shadow map.
-         * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
-         */
-        onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
-        private _bias;
-        /**
-         * Gets the bias: offset applied on the depth preventing acnea (in light direction).
-         */
-        get bias(): number;
-        /**
-         * Sets the bias: offset applied on the depth preventing acnea (in light direction).
-         */
-        set bias(bias: number);
-        private _normalBias;
-        /**
-         * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
-         */
-        get normalBias(): number;
-        /**
-         * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
-         */
-        set normalBias(normalBias: number);
-        private _filter;
-        /**
-         * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
-         * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
-         */
-        get filter(): number;
-        /**
-         * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
-         * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
-         */
-        set filter(value: number);
-        /**
-         * Gets if the current filter is set to "PCF" (percentage closer filtering).
-         */
-        get usePercentageCloserFiltering(): boolean;
-        /**
-         * Sets the current filter to "PCF" (percentage closer filtering).
-         */
-        set usePercentageCloserFiltering(value: boolean);
-        private _filteringQuality;
-        /**
-         * Gets the PCF or PCSS Quality.
-         * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
-         */
-        get filteringQuality(): number;
-        /**
-         * Sets the PCF or PCSS Quality.
-         * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
-         */
-        set filteringQuality(filteringQuality: number);
-        /**
-         * Gets if the current filter is set to "PCSS" (contact hardening).
-         */
-        get useContactHardeningShadow(): boolean;
-        /**
-         * Sets the current filter to "PCSS" (contact hardening).
-         */
-        set useContactHardeningShadow(value: boolean);
-        private _contactHardeningLightSizeUVRatio;
-        /**
-         * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
-         * Using a ratio helps keeping shape stability independently of the map size.
-         *
-         * It does not account for the light projection as it was having too much
-         * instability during the light setup or during light position changes.
-         *
-         * Only valid if useContactHardeningShadow is true.
-         */
-        get contactHardeningLightSizeUVRatio(): number;
-        /**
-         * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
-         * Using a ratio helps keeping shape stability independently of the map size.
-         *
-         * It does not account for the light projection as it was having too much
-         * instability during the light setup or during light position changes.
-         *
-         * Only valid if useContactHardeningShadow is true.
-         */
-        set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
-        private _darkness;
-        /** Gets or sets the actual darkness of a shadow */
-        get darkness(): number;
-        set darkness(value: number);
-        /**
-         * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
-         * 0 means strongest and 1 would means no shadow.
-         * @returns the darkness.
-         */
-        getDarkness(): number;
-        /**
-         * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
-         * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
-         * @returns the shadow generator allowing fluent coding.
-         */
-        setDarkness(darkness: number): CascadedShadowGenerator;
+        protected _validateFilter(filter: number): number;
         /**
          * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
          */
         penumbraDarkness: number;
-        private _transparencyShadow;
-        /** Gets or sets the ability to have transparent shadow  */
-        get transparencyShadow(): boolean;
-        set transparencyShadow(value: boolean);
-        /**
-         * Sets the ability to have transparent shadow (boolean).
-         * @param transparent True if transparent else False
-         * @returns the shadow generator allowing fluent coding
-         */
-        setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
         private _numCascades;
         /**
          * Gets or set the number of cascades used by the CSM.
@@ -54473,13 +54333,7 @@ declare module BABYLON {
          * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
          */
         stabilizeCascades: boolean;
-        private _shadowMap;
-        /**
-         * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
-         * @returns The render target texture if present otherwise, null
-         */
-        getShadowMap(): Nullable<RenderTargetTexture>;
-        protected _freezeShadowCastersBoundingInfo: boolean;
+        private _freezeShadowCastersBoundingInfo;
         private _freezeShadowCastersBoundingInfoObservable;
         /**
          * Enables or disables the shadow casters bounding info computation.
@@ -54517,39 +54371,9 @@ declare module BABYLON {
         get maxDistance(): number;
         /**
          * Gets the class name of that object
-         * @returns "ShadowGenerator"
+         * @returns "CascadedShadowGenerator"
          */
         getClassName(): string;
-        /**
-         * Helper function to add a mesh and its descendants to the list of shadow casters.
-         * @param mesh Mesh to add
-         * @param includeDescendants boolean indicating if the descendants should be added. Default to true
-         * @returns the Shadow Generator itself
-         */
-        addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
-        /**
-         * Helper function to remove a mesh and its descendants from the list of shadow casters
-         * @param mesh Mesh to remove
-         * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
-         * @returns the Shadow Generator itself
-         */
-        removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
-        /**
-         * Controls the extent to which the shadows fade out at the edge of the frustum
-         */
-        frustumEdgeFalloff: number;
-        private _light;
-        /**
-         * Returns the associated light object.
-         * @returns the light generating the shadow
-         */
-        getLight(): DirectionalLight;
-        /**
-         * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
-         * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
-         * It might on the other hand introduce peter panning.
-         */
-        forceBackFacesOnly: boolean;
         private _cascadeMinExtents;
         private _cascadeMaxExtents;
         /**
@@ -54564,17 +54388,8 @@ declare module BABYLON {
          * @returns the maximum cascade extents
          */
         getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
-        private _scene;
-        private _lightDirection;
-        private _effect;
         private _cascades;
-        private _cachedDirection;
-        private _cachedDefines;
-        private _mapSize;
         private _currentLayer;
-        private _textureType;
-        private _defaultTextureMatrix;
-        private _storedUniqueId;
         private _viewSpaceFrustumsZ;
         private _viewMatrices;
         private _projectionMatrices;
@@ -54642,6 +54457,12 @@ declare module BABYLON {
          * @returns the cascade projection matrix
          */
         getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
+        /**
+         * Gets the transformation matrix corresponding to a given cascade
+         * @param cascadeNum cascade to retrieve the transformation matrix from
+         * @returns the cascade transformation matrix
+         */
+        getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
         private _depthRenderer;
         /**
          * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
@@ -54681,13 +54502,6 @@ declare module BABYLON {
          */
         splitFrustum(): void;
         private _splitFrustum;
-        /**
-         * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
-         * (eq to view projection * shadow projection matrices)
-         * @param cascadeIndex index number of the cascaded shadow map
-         * @returns The transform matrix used to create the CSM shadow map
-         */
-        getCSMTransformMatrix(cascadeIndex: number): Matrix;
         private _computeMatrices;
         private _computeFrustumInWorldSpace;
         private _computeCascadeFrustum;
@@ -54703,34 +54517,11 @@ declare module BABYLON {
          * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
          */
         constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
-        private _initializeGenerator;
-        private _initializeShadowMap;
-        private _renderForShadowMap;
-        private _renderSubMeshForShadowMap;
-        private _applyFilterValues;
-        /**
-         * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
-         * @param onCompiled Callback triggered at the and of the effects compilation
-         * @param options Sets of optional options forcing the compilation with different modes
-         */
-        forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
-            useInstances: boolean;
-        }>): void;
-        /**
-         * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
-         * @param options Sets of optional options forcing the compilation with different modes
-         * @returns A promise that resolves when the compilation completes
-         */
-        forceCompilationAsync(options?: Partial<{
-            useInstances: boolean;
-        }>): Promise<void>;
-        /**
-         * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
-         * @param subMesh The submesh we want to render in the shadow map
-         * @param useInstances Defines wether will draw in the map using instances
-         * @returns true if ready otherwise, false
-         */
-        isReady(subMesh: SubMesh, useInstances: boolean): boolean;
+        protected _initializeGenerator(): void;
+        protected _createTargetRenderTexture(): void;
+        protected _initializeShadowMap(): void;
+        protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
+        protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
         /**
          * Prepare all the defines in a material relying on a shadow map at the specified light index.
          * @param defines Defines of the material we want to update
@@ -54751,12 +54542,6 @@ declare module BABYLON {
          */
         getTransformMatrix(): Matrix;
         /**
-         * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
-         * Cube and 2D textures for instance.
-         */
-        recreateShadowMap(): void;
-        private _disposeRTT;
-        /**
          * Disposes the ShadowGenerator.
          * Returns nothing.
          */
@@ -54772,7 +54557,7 @@ declare module BABYLON {
          * @param scene The scene to create the shadow map for
          * @returns The parsed shadow generator
          */
-        static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
+        static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
     }
 }
 declare module BABYLON {
@@ -57738,6 +57523,8 @@ declare module BABYLON {
         private _isFinalMerger;
         private _isInput;
         protected _isUnique: boolean;
+        /** Gets or sets a boolean indicating that only one input can be connected at a time */
+        inputsAreExclusive: boolean;
         /** @hidden */
         _codeVariableName: string;
         /** @hidden */
@@ -58165,6 +57952,8 @@ declare module BABYLON {
          */
         get associatedVariableName(): string;
         set associatedVariableName(value: string);
+        /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
+        get innerType(): NodeMaterialBlockConnectionPointTypes;
         /**
          * Gets or sets the connection point type (default is float)
          */
@@ -60616,13 +60405,13 @@ declare module BABYLON {
         /**
          * @constructor
          * @param name The value used by scene.getMeshByName() to do a lookup.
-         * @param generator The mesh to generate a trail.
+         * @param generator The mesh or transform node to generate a trail.
          * @param scene The scene to add this mesh to.
          * @param diameter Diameter of trailing mesh. Default is 1.
          * @param length Length of trailing mesh. Default is 60.
          * @param autoStart Automatically start trailing mesh. Default true.
          */
-        constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
+        constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
         /**
          * "TrailMesh"
          * @returns "TrailMesh"
@@ -60647,7 +60436,7 @@ declare module BABYLON {
          * @param newGenerator use new generator object for cloned trail mesh
          * @returns a new mesh
          */
-        clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
+        clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
         /**
          * Serializes this trail mesh
          * @param serializationObject object to write serialization to
@@ -61980,7 +61769,7 @@ declare module BABYLON {
          * @param meshes array of all the geometry used to compute the navigatio mesh
          * @param parameters bunch of parameters used to filter geometry
          */
-        createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
+        createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
         /**
          * Create a navigation mesh debug mesh
          * @param scene is where the mesh will be added
@@ -62244,7 +62033,7 @@ declare module BABYLON {
          * @param meshes array of all the geometry used to compute the navigatio mesh
          * @param parameters bunch of parameters used to filter geometry
          */
-        createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
+        createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
         /**
          * Create a navigation mesh debug mesh
          * @param scene is where the mesh will be added

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/babylon.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 266 - 982
dist/preview release/babylon.max.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/babylon.max.js.map


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 197 - 621
dist/preview release/babylon.module.d.ts


+ 96 - 404
dist/preview release/documentation.d.ts

@@ -9470,6 +9470,10 @@ declare module BABYLON {
      */
     export class ShadowGenerator implements IShadowGenerator {
         /**
+         * Name of the shadow generator class
+         */
+        static CLASSNAME: string;
+        /**
          * Shadow generator mode None: no filtering applied.
          */
         static readonly FILTER_NONE: number;
@@ -9559,7 +9563,7 @@ declare module BABYLON {
          * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
          */
         onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
-        private _bias;
+        protected _bias: number;
         /**
          * Gets the bias: offset applied on the depth preventing acnea (in light direction).
          */
@@ -9568,7 +9572,7 @@ declare module BABYLON {
          * Sets the bias: offset applied on the depth preventing acnea (in light direction).
          */
         set bias(bias: number);
-        private _normalBias;
+        protected _normalBias: number;
         /**
          * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
          */
@@ -9577,7 +9581,7 @@ declare module BABYLON {
          * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
          */
         set normalBias(normalBias: number);
-        private _blurBoxOffset;
+        protected _blurBoxOffset: number;
         /**
          * Gets the blur box offset: offset applied during the blur pass.
          * Only useful if useKernelBlur = false
@@ -9588,7 +9592,7 @@ declare module BABYLON {
          * Only useful if useKernelBlur = false
          */
         set blurBoxOffset(value: number);
-        private _blurScale;
+        protected _blurScale: number;
         /**
          * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
          * 2 means half of the size.
@@ -9599,7 +9603,7 @@ declare module BABYLON {
          * 2 means half of the size.
          */
         set blurScale(value: number);
-        private _blurKernel;
+        protected _blurKernel: number;
         /**
          * Gets the blur kernel: kernel size of the blur pass.
          * Only useful if useKernelBlur = true
@@ -9610,7 +9614,7 @@ declare module BABYLON {
          * Only useful if useKernelBlur = true
          */
         set blurKernel(value: number);
-        private _useKernelBlur;
+        protected _useKernelBlur: boolean;
         /**
          * Gets whether the blur pass is a kernel blur (if true) or box blur.
          * Only useful in filtered mode (useBlurExponentialShadowMap...)
@@ -9621,7 +9625,7 @@ declare module BABYLON {
          * Only useful in filtered mode (useBlurExponentialShadowMap...)
          */
         set useKernelBlur(value: boolean);
-        private _depthScale;
+        protected _depthScale: number;
         /**
          * Gets the depth scale used in ESM mode.
          */
@@ -9631,7 +9635,8 @@ declare module BABYLON {
          * This can override the scale stored on the light.
          */
         set depthScale(value: number);
-        private _filter;
+        protected _validateFilter(filter: number): number;
+        protected _filter: number;
         /**
          * Gets the current mode of the shadow generator (normal, PCF, ESM...).
          * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
@@ -9694,7 +9699,7 @@ declare module BABYLON {
          * Sets the current filter to "PCF" (percentage closer filtering).
          */
         set usePercentageCloserFiltering(value: boolean);
-        private _filteringQuality;
+        protected _filteringQuality: number;
         /**
          * Gets the PCF or PCSS Quality.
          * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
@@ -9713,7 +9718,7 @@ declare module BABYLON {
          * Sets the current filter to "PCSS" (contact hardening).
          */
         set useContactHardeningShadow(value: boolean);
-        private _contactHardeningLightSizeUVRatio;
+        protected _contactHardeningLightSizeUVRatio: number;
         /**
          * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
          * Using a ratio helps keeping shape stability independently of the map size.
@@ -9734,7 +9739,7 @@ declare module BABYLON {
          * Only valid if useContactHardeningShadow is true.
          */
         set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
-        private _darkness;
+        protected _darkness: number;
         /** Gets or sets the actual darkness of a shadow */
         get darkness(): number;
         set darkness(value: number);
@@ -9750,7 +9755,7 @@ declare module BABYLON {
          * @returns the shadow generator allowing fluent coding.
          */
         setDarkness(darkness: number): ShadowGenerator;
-        private _transparencyShadow;
+        protected _transparencyShadow: boolean;
         /** Gets or sets the ability to have transparent shadow  */
         get transparencyShadow(): boolean;
         set transparencyShadow(value: boolean);
@@ -9760,8 +9765,8 @@ declare module BABYLON {
          * @returns the shadow generator allowing fluent coding
          */
         setTransparencyShadow(transparent: boolean): ShadowGenerator;
-        private _shadowMap;
-        private _shadowMap2;
+        protected _shadowMap: Nullable<RenderTargetTexture>;
+        protected _shadowMap2: Nullable<RenderTargetTexture>;
         /**
          * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
          * @returns The render target texture if present otherwise, null
@@ -9793,10 +9798,9 @@ declare module BABYLON {
         removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
         /**
          * Controls the extent to which the shadows fade out at the edge of the frustum
-         * Used only by directionals and spots
          */
         frustumEdgeFalloff: number;
-        private _light;
+        protected _light: IShadowLight;
         /**
          * Returns the associated light object.
          * @returns the light generating the shadow
@@ -9808,26 +9812,26 @@ declare module BABYLON {
          * It might on the other hand introduce peter panning.
          */
         forceBackFacesOnly: boolean;
-        private _scene;
-        private _lightDirection;
-        private _effect;
-        private _viewMatrix;
-        private _projectionMatrix;
-        private _transformMatrix;
-        private _cachedPosition;
-        private _cachedDirection;
-        private _cachedDefines;
-        private _currentRenderID;
-        private _boxBlurPostprocess;
-        private _kernelBlurXPostprocess;
-        private _kernelBlurYPostprocess;
-        private _blurPostProcesses;
-        private _mapSize;
-        private _currentFaceIndex;
-        private _currentFaceIndexCache;
-        private _textureType;
-        private _defaultTextureMatrix;
-        private _storedUniqueId;
+        protected _scene: Scene;
+        protected _lightDirection: Vector3;
+        protected _effect: Effect;
+        protected _viewMatrix: Matrix;
+        protected _projectionMatrix: Matrix;
+        protected _transformMatrix: Matrix;
+        protected _cachedPosition: Vector3;
+        protected _cachedDirection: Vector3;
+        protected _cachedDefines: string;
+        protected _currentRenderID: number;
+        protected _boxBlurPostprocess: Nullable<PostProcess>;
+        protected _kernelBlurXPostprocess: Nullable<PostProcess>;
+        protected _kernelBlurYPostprocess: Nullable<PostProcess>;
+        protected _blurPostProcesses: PostProcess[];
+        protected _mapSize: number;
+        protected _currentFaceIndex: number;
+        protected _currentFaceIndexCache: number;
+        protected _textureType: number;
+        protected _defaultTextureMatrix: Matrix;
+        protected _storedUniqueId: Nullable<number>;
         /** @hidden */
         static _SceneComponentInitialization: (scene: Scene) => void;
         /**
@@ -9840,12 +9844,14 @@ declare module BABYLON {
          * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
          */
         constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
-        private _initializeGenerator;
-        private _initializeShadowMap;
-        private _initializeBlurRTTAndPostProcesses;
-        private _renderForShadowMap;
-        private _renderSubMeshForShadowMap;
-        private _applyFilterValues;
+        protected _initializeGenerator(): void;
+        protected _createTargetRenderTexture(): void;
+        protected _initializeShadowMap(): void;
+        protected _initializeBlurRTTAndPostProcesses(): void;
+        protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
+        protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
+        protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
+        protected _applyFilterValues(): void;
         /**
          * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
          * @param onCompiled Callback triggered at the and of the effects compilation
@@ -9862,6 +9868,7 @@ declare module BABYLON {
         forceCompilationAsync(options?: Partial<{
             useInstances: boolean;
         }>): Promise<void>;
+        protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
         /**
          * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
          * @param subMesh The submesh we want to render in the shadow map
@@ -9893,8 +9900,8 @@ declare module BABYLON {
          * Cube and 2D textures for instance.
          */
         recreateShadowMap(): void;
-        private _disposeBlurPostProcesses;
-        private _disposeRTTandPostProcesses;
+        protected _disposeBlurPostProcesses(): void;
+        protected _disposeRTTandPostProcesses(): void;
         /**
          * Disposes the ShadowGenerator.
          * Returns nothing.
@@ -9909,9 +9916,10 @@ declare module BABYLON {
          * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
          * @param parsedShadowGenerator The JSON object to parse
          * @param scene The scene to create the shadow map for
+         * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
          * @returns The parsed shadow generator
          */
-        static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
+        static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
     }
 }
 declare module BABYLON {
@@ -31240,7 +31248,8 @@ declare module BABYLON {
          */
         updateArrayBuffer(data: Float32Array): void;
         private _vertexAttribPointer;
-        private _bindIndexBufferWithCache;
+        /** @hidden */
+        _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
         private _bindVertexBuffersAttributes;
         /**
          * Records a vertex array object
@@ -44053,6 +44062,14 @@ declare module BABYLON {
          * Should the selection mesh be displayed (The ring at the end of the laser pointer)
          */
         displaySelectionMesh: boolean;
+        /**
+         * Disable lighting on the laser pointer (so it will always be visible)
+         */
+        disablePointerLighting: boolean;
+        /**
+         * Disable lighting on the selection mesh (so it will always be visible)
+         */
+        disableSelectionMeshLighting: boolean;
         private static _idCounter;
         private _tmpRay;
         private _controllers;
@@ -44250,6 +44267,7 @@ declare module BABYLON {
          * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
          * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
          * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
+         * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
          * * When updating an instance, remember that only point positions can change, not the number of points
          * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
          * @param name defines the name of the mesh
@@ -44265,6 +44283,7 @@ declare module BABYLON {
             dashNb?: number;
             updatable?: boolean;
             instance?: LinesMesh;
+            useVertexAlpha?: boolean;
         }, scene?: Nullable<Scene>): LinesMesh;
     }
 }
@@ -44878,6 +44897,11 @@ declare module BABYLON {
          */
         setLaserColor(color: Color3, pickedColor?: Color3): void;
         /**
+         * Set lighting enabled / disabled on the laser pointer of both controllers
+         * @param enabled should the lighting be enabled on the laser pointer
+         */
+        setLaserLightingState(enabled?: boolean): void;
+        /**
          * Permanently set new colors for the gaze pointer
          * @param color the new gaze color
          * @param pickedColor the new gaze color when picked mesh detected
@@ -54275,12 +54299,12 @@ declare module BABYLON {
      * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
      * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
      */
-    export class CascadedShadowGenerator implements IShadowGenerator {
+    export class CascadedShadowGenerator extends ShadowGenerator {
         private static readonly frustumCornersNDCSpace;
         /**
          * Name of the CSM class
          */
-        static readonly CLASSNAME: string;
+        static CLASSNAME: string;
         /**
          * Defines the default number of cascades used by the CSM.
          */
@@ -54293,175 +54317,11 @@ declare module BABYLON {
          * Defines the maximum number of cascades used by the CSM.
          */
         static readonly MAX_CASCADES_COUNT: number;
-        /**
-         * Shadow generator mode None: no filtering applied.
-         */
-        static readonly FILTER_NONE: number;
-        /**
-         * Shadow generator mode PCF: Percentage Closer Filtering
-         * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
-         * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
-         */
-        static readonly FILTER_PCF: number;
-        /**
-         * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
-         * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
-         * Contact Hardening
-         */
-        static readonly FILTER_PCSS: number;
-        /**
-         * Reserved for PCF and PCSS
-         * Highest Quality.
-         *
-         * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
-         *
-         * Execute PCSS with 32 taps blocker search and 64 taps PCF.
-         */
-        static readonly QUALITY_HIGH: number;
-        /**
-         * Reserved for PCF and PCSS
-         * Good tradeoff for quality/perf cross devices
-         *
-         * Execute PCF on a 3*3 kernel.
-         *
-         * Execute PCSS with 16 taps blocker search and 32 taps PCF.
-         */
-        static readonly QUALITY_MEDIUM: number;
-        /**
-         * Reserved for PCF and PCSS
-         * The lowest quality but the fastest.
-         *
-         * Execute PCF on a 1*1 kernel.
-         *
-         * Execute PCSS with 16 taps blocker search and 16 taps PCF.
-         */
-        static readonly QUALITY_LOW: number;
-        private static readonly _CLEARONE;
-        /**
-         * Observable triggered before the shadow is rendered. Can be used to update internal effect state
-         */
-        onBeforeShadowMapRenderObservable: Observable<Effect>;
-        /**
-         * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
-         */
-        onAfterShadowMapRenderObservable: Observable<Effect>;
-        /**
-         * Observable triggered before a mesh is rendered in the shadow map.
-         * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
-         */
-        onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
-        /**
-         * Observable triggered after a mesh is rendered in the shadow map.
-         * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
-         */
-        onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
-        private _bias;
-        /**
-         * Gets the bias: offset applied on the depth preventing acnea (in light direction).
-         */
-        get bias(): number;
-        /**
-         * Sets the bias: offset applied on the depth preventing acnea (in light direction).
-         */
-        set bias(bias: number);
-        private _normalBias;
-        /**
-         * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
-         */
-        get normalBias(): number;
-        /**
-         * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
-         */
-        set normalBias(normalBias: number);
-        private _filter;
-        /**
-         * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
-         * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
-         */
-        get filter(): number;
-        /**
-         * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
-         * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
-         */
-        set filter(value: number);
-        /**
-         * Gets if the current filter is set to "PCF" (percentage closer filtering).
-         */
-        get usePercentageCloserFiltering(): boolean;
-        /**
-         * Sets the current filter to "PCF" (percentage closer filtering).
-         */
-        set usePercentageCloserFiltering(value: boolean);
-        private _filteringQuality;
-        /**
-         * Gets the PCF or PCSS Quality.
-         * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
-         */
-        get filteringQuality(): number;
-        /**
-         * Sets the PCF or PCSS Quality.
-         * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
-         */
-        set filteringQuality(filteringQuality: number);
-        /**
-         * Gets if the current filter is set to "PCSS" (contact hardening).
-         */
-        get useContactHardeningShadow(): boolean;
-        /**
-         * Sets the current filter to "PCSS" (contact hardening).
-         */
-        set useContactHardeningShadow(value: boolean);
-        private _contactHardeningLightSizeUVRatio;
-        /**
-         * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
-         * Using a ratio helps keeping shape stability independently of the map size.
-         *
-         * It does not account for the light projection as it was having too much
-         * instability during the light setup or during light position changes.
-         *
-         * Only valid if useContactHardeningShadow is true.
-         */
-        get contactHardeningLightSizeUVRatio(): number;
-        /**
-         * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
-         * Using a ratio helps keeping shape stability independently of the map size.
-         *
-         * It does not account for the light projection as it was having too much
-         * instability during the light setup or during light position changes.
-         *
-         * Only valid if useContactHardeningShadow is true.
-         */
-        set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
-        private _darkness;
-        /** Gets or sets the actual darkness of a shadow */
-        get darkness(): number;
-        set darkness(value: number);
-        /**
-         * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
-         * 0 means strongest and 1 would means no shadow.
-         * @returns the darkness.
-         */
-        getDarkness(): number;
-        /**
-         * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
-         * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
-         * @returns the shadow generator allowing fluent coding.
-         */
-        setDarkness(darkness: number): CascadedShadowGenerator;
+        protected _validateFilter(filter: number): number;
         /**
          * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
          */
         penumbraDarkness: number;
-        private _transparencyShadow;
-        /** Gets or sets the ability to have transparent shadow  */
-        get transparencyShadow(): boolean;
-        set transparencyShadow(value: boolean);
-        /**
-         * Sets the ability to have transparent shadow (boolean).
-         * @param transparent True if transparent else False
-         * @returns the shadow generator allowing fluent coding
-         */
-        setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
         private _numCascades;
         /**
          * Gets or set the number of cascades used by the CSM.
@@ -54473,13 +54333,7 @@ declare module BABYLON {
          * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
          */
         stabilizeCascades: boolean;
-        private _shadowMap;
-        /**
-         * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
-         * @returns The render target texture if present otherwise, null
-         */
-        getShadowMap(): Nullable<RenderTargetTexture>;
-        protected _freezeShadowCastersBoundingInfo: boolean;
+        private _freezeShadowCastersBoundingInfo;
         private _freezeShadowCastersBoundingInfoObservable;
         /**
          * Enables or disables the shadow casters bounding info computation.
@@ -54517,39 +54371,9 @@ declare module BABYLON {
         get maxDistance(): number;
         /**
          * Gets the class name of that object
-         * @returns "ShadowGenerator"
+         * @returns "CascadedShadowGenerator"
          */
         getClassName(): string;
-        /**
-         * Helper function to add a mesh and its descendants to the list of shadow casters.
-         * @param mesh Mesh to add
-         * @param includeDescendants boolean indicating if the descendants should be added. Default to true
-         * @returns the Shadow Generator itself
-         */
-        addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
-        /**
-         * Helper function to remove a mesh and its descendants from the list of shadow casters
-         * @param mesh Mesh to remove
-         * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
-         * @returns the Shadow Generator itself
-         */
-        removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
-        /**
-         * Controls the extent to which the shadows fade out at the edge of the frustum
-         */
-        frustumEdgeFalloff: number;
-        private _light;
-        /**
-         * Returns the associated light object.
-         * @returns the light generating the shadow
-         */
-        getLight(): DirectionalLight;
-        /**
-         * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
-         * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
-         * It might on the other hand introduce peter panning.
-         */
-        forceBackFacesOnly: boolean;
         private _cascadeMinExtents;
         private _cascadeMaxExtents;
         /**
@@ -54564,17 +54388,8 @@ declare module BABYLON {
          * @returns the maximum cascade extents
          */
         getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
-        private _scene;
-        private _lightDirection;
-        private _effect;
         private _cascades;
-        private _cachedDirection;
-        private _cachedDefines;
-        private _mapSize;
         private _currentLayer;
-        private _textureType;
-        private _defaultTextureMatrix;
-        private _storedUniqueId;
         private _viewSpaceFrustumsZ;
         private _viewMatrices;
         private _projectionMatrices;
@@ -54642,6 +54457,12 @@ declare module BABYLON {
          * @returns the cascade projection matrix
          */
         getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
+        /**
+         * Gets the transformation matrix corresponding to a given cascade
+         * @param cascadeNum cascade to retrieve the transformation matrix from
+         * @returns the cascade transformation matrix
+         */
+        getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
         private _depthRenderer;
         /**
          * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
@@ -54681,13 +54502,6 @@ declare module BABYLON {
          */
         splitFrustum(): void;
         private _splitFrustum;
-        /**
-         * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
-         * (eq to view projection * shadow projection matrices)
-         * @param cascadeIndex index number of the cascaded shadow map
-         * @returns The transform matrix used to create the CSM shadow map
-         */
-        getCSMTransformMatrix(cascadeIndex: number): Matrix;
         private _computeMatrices;
         private _computeFrustumInWorldSpace;
         private _computeCascadeFrustum;
@@ -54703,34 +54517,11 @@ declare module BABYLON {
          * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
          */
         constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
-        private _initializeGenerator;
-        private _initializeShadowMap;
-        private _renderForShadowMap;
-        private _renderSubMeshForShadowMap;
-        private _applyFilterValues;
-        /**
-         * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
-         * @param onCompiled Callback triggered at the and of the effects compilation
-         * @param options Sets of optional options forcing the compilation with different modes
-         */
-        forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
-            useInstances: boolean;
-        }>): void;
-        /**
-         * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
-         * @param options Sets of optional options forcing the compilation with different modes
-         * @returns A promise that resolves when the compilation completes
-         */
-        forceCompilationAsync(options?: Partial<{
-            useInstances: boolean;
-        }>): Promise<void>;
-        /**
-         * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
-         * @param subMesh The submesh we want to render in the shadow map
-         * @param useInstances Defines wether will draw in the map using instances
-         * @returns true if ready otherwise, false
-         */
-        isReady(subMesh: SubMesh, useInstances: boolean): boolean;
+        protected _initializeGenerator(): void;
+        protected _createTargetRenderTexture(): void;
+        protected _initializeShadowMap(): void;
+        protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
+        protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
         /**
          * Prepare all the defines in a material relying on a shadow map at the specified light index.
          * @param defines Defines of the material we want to update
@@ -54751,12 +54542,6 @@ declare module BABYLON {
          */
         getTransformMatrix(): Matrix;
         /**
-         * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
-         * Cube and 2D textures for instance.
-         */
-        recreateShadowMap(): void;
-        private _disposeRTT;
-        /**
          * Disposes the ShadowGenerator.
          * Returns nothing.
          */
@@ -54772,7 +54557,7 @@ declare module BABYLON {
          * @param scene The scene to create the shadow map for
          * @returns The parsed shadow generator
          */
-        static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
+        static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
     }
 }
 declare module BABYLON {
@@ -57738,6 +57523,8 @@ declare module BABYLON {
         private _isFinalMerger;
         private _isInput;
         protected _isUnique: boolean;
+        /** Gets or sets a boolean indicating that only one input can be connected at a time */
+        inputsAreExclusive: boolean;
         /** @hidden */
         _codeVariableName: string;
         /** @hidden */
@@ -58165,6 +57952,8 @@ declare module BABYLON {
          */
         get associatedVariableName(): string;
         set associatedVariableName(value: string);
+        /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
+        get innerType(): NodeMaterialBlockConnectionPointTypes;
         /**
          * Gets or sets the connection point type (default is float)
          */
@@ -60616,13 +60405,13 @@ declare module BABYLON {
         /**
          * @constructor
          * @param name The value used by scene.getMeshByName() to do a lookup.
-         * @param generator The mesh to generate a trail.
+         * @param generator The mesh or transform node to generate a trail.
          * @param scene The scene to add this mesh to.
          * @param diameter Diameter of trailing mesh. Default is 1.
          * @param length Length of trailing mesh. Default is 60.
          * @param autoStart Automatically start trailing mesh. Default true.
          */
-        constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
+        constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
         /**
          * "TrailMesh"
          * @returns "TrailMesh"
@@ -60647,7 +60436,7 @@ declare module BABYLON {
          * @param newGenerator use new generator object for cloned trail mesh
          * @returns a new mesh
          */
-        clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
+        clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
         /**
          * Serializes this trail mesh
          * @param serializationObject object to write serialization to
@@ -61980,7 +61769,7 @@ declare module BABYLON {
          * @param meshes array of all the geometry used to compute the navigatio mesh
          * @param parameters bunch of parameters used to filter geometry
          */
-        createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
+        createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
         /**
          * Create a navigation mesh debug mesh
          * @param scene is where the mesh will be added
@@ -62244,7 +62033,7 @@ declare module BABYLON {
          * @param meshes array of all the geometry used to compute the navigatio mesh
          * @param parameters bunch of parameters used to filter geometry
          */
-        createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
+        createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
         /**
          * Create a navigation mesh debug mesh
          * @param scene is where the mesh will be added
@@ -79061,103 +78850,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /** @hidden */
-    export var oceanPostProcessPixelShader: {
-        name: string;
-        shader: string;
-    };
-}
-declare module BABYLON {
-    /**
-     * Option available in the Ocean Post Process.
-     */
-    export interface IOceanPostProcessOptions {
-        /**
-         * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        reflectionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-        /**
-         * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        refractionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-    }
-    /**
-     * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
-     *
-     * Simmply add it to your scene and let the nerd that lives in you have fun.
-     * Example usage:
-     *  var pp = new OceanPostProcess("myOcean", camera);
-     *  pp.reflectionEnabled = true;
-     *  pp.refractionEnabled = true;
-     */
-    export class OceanPostProcess extends BABYLON.PostProcess {
-        /**
-         * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
-         */
-        get reflectionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time reflection is enabled on the ocean.
-         * Is set to true, the reflection mirror texture will be used as reflection texture.
-         */
-        set reflectionEnabled(enabled: boolean);
-        /**
-         * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
-         */
-        get refractionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time refraction is enabled on the ocean.
-         * Is set to true, the refraction render target texture will be used as refraction texture.
-         */
-        set refractionEnabled(enabled: boolean);
-        /**
-         * Gets wether or not the post-processes is supported by the running hardware.
-         * This requires draw buffer supports.
-         */
-        get isSupported(): boolean;
-        /**
-         * This is the reflection mirror texture used to display reflections on the ocean.
-         * By default, render list is empty.
-         */
-        reflectionTexture: BABYLON.MirrorTexture;
-        /**
-         * This is the refraction render target texture used to display refraction on the ocean.
-         * By default, render list is empty.
-         */
-        refractionTexture: BABYLON.RenderTargetTexture;
-        private _time;
-        private _cameraRotation;
-        private _cameraViewMatrix;
-        private _reflectionEnabled;
-        private _refractionEnabled;
-        private _geometryRenderer;
-        /**
-         * Instantiates a new Ocean Post Process.
-         * @param name the name to give to the postprocess.
-         * @camera the camera to apply the post process to.
-         * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
-         */
-        constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
-        /**
-         * Returns the appropriate defines according to the current configuration.
-         */
-        private _getDefines;
-        /**
-         * Computes the current camera rotation as the shader requires a camera rotation.
-         */
-        private _computeCameraRotation;
-    }
-}
-declare module BABYLON {
-    /** @hidden */
     export var brickProceduralTexturePixelShader: {
         name: string;
         shader: string;

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

@@ -1,7 +1,7 @@
 {
     "name": "babylonjs-gltf2interface",
     "description": "A typescript declaration of babylon's gltf2 inteface.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 9337 - 7903
dist/preview release/gltf_validator.js


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

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-gui",
     "description": "The Babylon.js GUI library is an extension you can use to generate interactive user interface. It is build on top of the DynamicTexture.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

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

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-inspector",
     "description": "The Babylon.js inspector.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -29,12 +29,12 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20",
-        "babylonjs-gui": "4.1.0-beta.20",
-        "babylonjs-loaders": "4.1.0-beta.20",
-        "babylonjs-materials": "4.1.0-beta.20",
-        "babylonjs-serializers": "4.1.0-beta.20",
-        "babylonjs-gltf2interface": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22",
+        "babylonjs-gui": "4.1.0-beta.22",
+        "babylonjs-loaders": "4.1.0-beta.22",
+        "babylonjs-materials": "4.1.0-beta.22",
+        "babylonjs-serializers": "4.1.0-beta.22",
+        "babylonjs-gltf2interface": "4.1.0-beta.22"
     },
     "devDependencies": {
         "@types/react": "~16.7.3",

+ 3 - 3
dist/preview release/loaders/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-loaders",
     "description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,8 +28,8 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs-gltf2interface": "4.1.0-beta.20",
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs-gltf2interface": "4.1.0-beta.22",
+        "babylonjs": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

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

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-materials",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

+ 3 - 0
dist/preview release/nodeEditor/babylon.nodeEditor.d.ts

@@ -786,6 +786,7 @@ declare module NODEEDITOR {
         lineIndex: number;
         onDelete: () => void;
         onUpdateStep: () => void;
+        onCheckForReOrder: () => void;
     }
     export class GradientStepComponent extends React.Component<IGradientStepComponentProps, {
         gradient: number;
@@ -793,6 +794,7 @@ declare module NODEEDITOR {
         constructor(props: IGradientStepComponentProps);
         updateColor(color: string): void;
         updateStep(gradient: number): void;
+        onPointerUp(): void;
         render(): JSX.Element;
     }
 }
@@ -812,6 +814,7 @@ declare module NODEEDITOR {
         forceRebuild(): void;
         deleteStep(step: BABYLON.GradientBlockColorStep): void;
         addNewStep(): void;
+        checkForReOrder(): void;
         render(): JSX.Element;
     }
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/nodeEditor/babylon.nodeEditor.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 37 - 3
dist/preview release/nodeEditor/babylon.nodeEditor.max.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/nodeEditor/babylon.nodeEditor.max.js.map


+ 6 - 0
dist/preview release/nodeEditor/babylon.nodeEditor.module.d.ts

@@ -968,6 +968,7 @@ declare module "babylonjs-node-editor/diagram/properties/gradientStepComponent"
         lineIndex: number;
         onDelete: () => void;
         onUpdateStep: () => void;
+        onCheckForReOrder: () => void;
     }
     export class GradientStepComponent extends React.Component<IGradientStepComponentProps, {
         gradient: number;
@@ -975,6 +976,7 @@ declare module "babylonjs-node-editor/diagram/properties/gradientStepComponent"
         constructor(props: IGradientStepComponentProps);
         updateColor(color: string): void;
         updateStep(gradient: number): void;
+        onPointerUp(): void;
         render(): JSX.Element;
     }
 }
@@ -998,6 +1000,7 @@ declare module "babylonjs-node-editor/diagram/properties/gradientNodePropertyCom
         forceRebuild(): void;
         deleteStep(step: GradientBlockColorStep): void;
         addNewStep(): void;
+        checkForReOrder(): void;
         render(): JSX.Element;
     }
 }
@@ -2349,6 +2352,7 @@ declare module NODEEDITOR {
         lineIndex: number;
         onDelete: () => void;
         onUpdateStep: () => void;
+        onCheckForReOrder: () => void;
     }
     export class GradientStepComponent extends React.Component<IGradientStepComponentProps, {
         gradient: number;
@@ -2356,6 +2360,7 @@ declare module NODEEDITOR {
         constructor(props: IGradientStepComponentProps);
         updateColor(color: string): void;
         updateStep(gradient: number): void;
+        onPointerUp(): void;
         render(): JSX.Element;
     }
 }
@@ -2375,6 +2380,7 @@ declare module NODEEDITOR {
         forceRebuild(): void;
         deleteStep(step: BABYLON.GradientBlockColorStep): void;
         addNewStep(): void;
+        checkForReOrder(): void;
         render(): JSX.Element;
     }
 }

+ 2 - 2
dist/preview release/nodeEditor/package.json

@@ -4,14 +4,14 @@
     },
     "name": "babylonjs-node-editor",
     "description": "The Babylon.js node material editor.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
     },
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22"
     },
     "files": [
         "babylon.nodeEditor.max.js.map",

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

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

+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"thinEngineOnly":112345,"engineOnly":148455,"sceneOnly":502488,"minGridMaterial":633280,"minStandardMaterial":773307}
+{"thinEngineOnly":112368,"engineOnly":148478,"sceneOnly":502443,"minGridMaterial":633238,"minStandardMaterial":773265}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 655
dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 1
dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.js.map


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 0 - 16
dist/preview release/postProcessesLibrary/babylon.oceanPostProcess.min.js


+ 0 - 97
dist/preview release/postProcessesLibrary/babylonjs.postProcess.d.ts

@@ -209,101 +209,4 @@ declare module BABYLON {
          */
         constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
     }
-}
-declare module BABYLON {
-    /** @hidden */
-    export var oceanPostProcessPixelShader: {
-        name: string;
-        shader: string;
-    };
-}
-declare module BABYLON {
-    /**
-     * Option available in the Ocean Post Process.
-     */
-    export interface IOceanPostProcessOptions {
-        /**
-         * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        reflectionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-        /**
-         * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        refractionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-    }
-    /**
-     * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
-     *
-     * Simmply add it to your scene and let the nerd that lives in you have fun.
-     * Example usage:
-     *  var pp = new OceanPostProcess("myOcean", camera);
-     *  pp.reflectionEnabled = true;
-     *  pp.refractionEnabled = true;
-     */
-    export class OceanPostProcess extends BABYLON.PostProcess {
-        /**
-         * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
-         */
-        get reflectionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time reflection is enabled on the ocean.
-         * Is set to true, the reflection mirror texture will be used as reflection texture.
-         */
-        set reflectionEnabled(enabled: boolean);
-        /**
-         * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
-         */
-        get refractionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time refraction is enabled on the ocean.
-         * Is set to true, the refraction render target texture will be used as refraction texture.
-         */
-        set refractionEnabled(enabled: boolean);
-        /**
-         * Gets wether or not the post-processes is supported by the running hardware.
-         * This requires draw buffer supports.
-         */
-        get isSupported(): boolean;
-        /**
-         * This is the reflection mirror texture used to display reflections on the ocean.
-         * By default, render list is empty.
-         */
-        reflectionTexture: BABYLON.MirrorTexture;
-        /**
-         * This is the refraction render target texture used to display refraction on the ocean.
-         * By default, render list is empty.
-         */
-        refractionTexture: BABYLON.RenderTargetTexture;
-        private _time;
-        private _cameraRotation;
-        private _cameraViewMatrix;
-        private _reflectionEnabled;
-        private _refractionEnabled;
-        private _geometryRenderer;
-        /**
-         * Instantiates a new Ocean Post Process.
-         * @param name the name to give to the postprocess.
-         * @camera the camera to apply the post process to.
-         * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
-         */
-        constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
-        /**
-         * Returns the appropriate defines according to the current configuration.
-         */
-        private _getDefines;
-        /**
-         * Computes the current camera rotation as the shader requires a camera rotation.
-         */
-        private _computeCameraRotation;
-    }
 }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 262
dist/preview release/postProcessesLibrary/babylonjs.postProcess.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.js.map


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 2 - 2
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


+ 0 - 206
dist/preview release/postProcessesLibrary/babylonjs.postProcess.module.d.ts

@@ -228,115 +228,9 @@ declare module "babylonjs-post-process/digitalRain/digitalRainPostProcess" {
 declare module "babylonjs-post-process/digitalRain/index" {
     export * from "babylonjs-post-process/digitalRain/digitalRainPostProcess";
 }
-declare module "babylonjs-post-process/ocean/oceanPostProcess.fragment" {
-    /** @hidden */
-    export var oceanPostProcessPixelShader: {
-        name: string;
-        shader: string;
-    };
-}
-declare module "babylonjs-post-process/ocean/oceanPostProcess" {
-    import { TargetCamera } from "babylonjs/Cameras/targetCamera";
-    import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
-    import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
-    import { PostProcess } from "babylonjs/PostProcesses/postProcess";
-    import "babylonjs-post-process/ocean/oceanPostProcess.fragment";
-    /**
-     * Option available in the Ocean Post Process.
-     */
-    export interface IOceanPostProcessOptions {
-        /**
-         * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        reflectionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-        /**
-         * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        refractionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-    }
-    /**
-     * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
-     *
-     * Simmply add it to your scene and let the nerd that lives in you have fun.
-     * Example usage:
-     *  var pp = new OceanPostProcess("myOcean", camera);
-     *  pp.reflectionEnabled = true;
-     *  pp.refractionEnabled = true;
-     */
-    export class OceanPostProcess extends PostProcess {
-        /**
-         * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
-         */
-        get reflectionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time reflection is enabled on the ocean.
-         * Is set to true, the reflection mirror texture will be used as reflection texture.
-         */
-        set reflectionEnabled(enabled: boolean);
-        /**
-         * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
-         */
-        get refractionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time refraction is enabled on the ocean.
-         * Is set to true, the refraction render target texture will be used as refraction texture.
-         */
-        set refractionEnabled(enabled: boolean);
-        /**
-         * Gets wether or not the post-processes is supported by the running hardware.
-         * This requires draw buffer supports.
-         */
-        get isSupported(): boolean;
-        /**
-         * This is the reflection mirror texture used to display reflections on the ocean.
-         * By default, render list is empty.
-         */
-        reflectionTexture: MirrorTexture;
-        /**
-         * This is the refraction render target texture used to display refraction on the ocean.
-         * By default, render list is empty.
-         */
-        refractionTexture: RenderTargetTexture;
-        private _time;
-        private _cameraRotation;
-        private _cameraViewMatrix;
-        private _reflectionEnabled;
-        private _refractionEnabled;
-        private _geometryRenderer;
-        /**
-         * Instantiates a new Ocean Post Process.
-         * @param name the name to give to the postprocess.
-         * @camera the camera to apply the post process to.
-         * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
-         */
-        constructor(name: string, camera: TargetCamera, options?: IOceanPostProcessOptions);
-        /**
-         * Returns the appropriate defines according to the current configuration.
-         */
-        private _getDefines;
-        /**
-         * Computes the current camera rotation as the shader requires a camera rotation.
-         */
-        private _computeCameraRotation;
-    }
-}
-declare module "babylonjs-post-process/ocean/index" {
-    export * from "babylonjs-post-process/ocean/oceanPostProcess";
-}
 declare module "babylonjs-post-process/index" {
     export * from "babylonjs-post-process/asciiArt/index";
     export * from "babylonjs-post-process/digitalRain/index";
-    export * from "babylonjs-post-process/ocean/index";
 }
 declare module "babylonjs-post-process/legacy/legacy-asciiArt" {
     export * from "babylonjs-post-process/asciiArt/index";
@@ -344,9 +238,6 @@ declare module "babylonjs-post-process/legacy/legacy-asciiArt" {
 declare module "babylonjs-post-process/legacy/legacy-digitalRain" {
     export * from "babylonjs-post-process/digitalRain/index";
 }
-declare module "babylonjs-post-process/legacy/legacy-ocean" {
-    export * from "babylonjs-post-process/ocean/index";
-}
 declare module "babylonjs-post-process/legacy/legacy" {
     export * from "babylonjs-post-process/index";
 }
@@ -564,101 +455,4 @@ declare module BABYLON {
          */
         constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
     }
-}
-declare module BABYLON {
-    /** @hidden */
-    export var oceanPostProcessPixelShader: {
-        name: string;
-        shader: string;
-    };
-}
-declare module BABYLON {
-    /**
-     * Option available in the Ocean Post Process.
-     */
-    export interface IOceanPostProcessOptions {
-        /**
-         * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        reflectionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-        /**
-         * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-         */
-        refractionSize?: number | {
-            width: number;
-            height: number;
-        } | {
-            ratio: number;
-        };
-    }
-    /**
-     * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
-     *
-     * Simmply add it to your scene and let the nerd that lives in you have fun.
-     * Example usage:
-     *  var pp = new OceanPostProcess("myOcean", camera);
-     *  pp.reflectionEnabled = true;
-     *  pp.refractionEnabled = true;
-     */
-    export class OceanPostProcess extends BABYLON.PostProcess {
-        /**
-         * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
-         */
-        get reflectionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time reflection is enabled on the ocean.
-         * Is set to true, the reflection mirror texture will be used as reflection texture.
-         */
-        set reflectionEnabled(enabled: boolean);
-        /**
-         * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
-         */
-        get refractionEnabled(): boolean;
-        /**
-         * Sets weither or not the real-time refraction is enabled on the ocean.
-         * Is set to true, the refraction render target texture will be used as refraction texture.
-         */
-        set refractionEnabled(enabled: boolean);
-        /**
-         * Gets wether or not the post-processes is supported by the running hardware.
-         * This requires draw buffer supports.
-         */
-        get isSupported(): boolean;
-        /**
-         * This is the reflection mirror texture used to display reflections on the ocean.
-         * By default, render list is empty.
-         */
-        reflectionTexture: BABYLON.MirrorTexture;
-        /**
-         * This is the refraction render target texture used to display refraction on the ocean.
-         * By default, render list is empty.
-         */
-        refractionTexture: BABYLON.RenderTargetTexture;
-        private _time;
-        private _cameraRotation;
-        private _cameraViewMatrix;
-        private _reflectionEnabled;
-        private _refractionEnabled;
-        private _geometryRenderer;
-        /**
-         * Instantiates a new Ocean Post Process.
-         * @param name the name to give to the postprocess.
-         * @camera the camera to apply the post process to.
-         * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
-         */
-        constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
-        /**
-         * Returns the appropriate defines according to the current configuration.
-         */
-        private _getDefines;
-        /**
-         * Computes the current camera rotation as the shader requires a camera rotation.
-         */
-        private _computeCameraRotation;
-    }
 }

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

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-post-process",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

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

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-procedural-textures",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 9 - 24
dist/preview release/recast.js


+ 3 - 3
dist/preview release/serializers/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-serializers",
     "description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.",
-    "version": "4.1.0-beta.20",
+    "version": "4.1.0-beta.22",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,8 +28,8 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.1.0-beta.20",
-        "babylonjs-gltf2interface": "4.1.0-beta.20"
+        "babylonjs": "4.1.0-beta.22",
+        "babylonjs-gltf2interface": "4.1.0-beta.22"
     },
     "engines": {
         "node": "*"

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 197 - 621
dist/preview release/viewer/babylon.module.d.ts


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 21 - 21
dist/preview release/viewer/babylon.viewer.js


Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


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

@@ -59,6 +59,7 @@
 - Added `RenderTargetTexture.getCustomRenderList` to overload the render list at rendering time (and possibly for each layer (2DArray) / face (Cube)) ([Popov72](https://github.com/Popov72))
 - Make sure all properties of CascadedShadowMap class are serialized/parsed ([Popov72](https://github.com/Popov72))
 - Added `textures/opacity.png` file to the Playground ([Popov72](https://github.com/Popov72))
+- Refactored the shadow generators code ([Popov72](https://github.com/Popov72))
 
 ### Engine
 
@@ -111,6 +112,8 @@
 - Added absolute scaling and rotation getters ([haroldma](https://github.com/haroldma))
 - Added `BILLBOARDMODE_USE_POSITION` flag to billboards allowing use of camera positioning instead of orientation for mesh rotation ([delaneyj](https://github.com/delaneyj))
 - Added accessor functions for `SubMesh._materialDefines` ([Popov72](https://github.com/Popov72))
+- Generator type used in `TrailMesh` constructor is now `TransformNode` instead of `AbstrachMesh` ([Popov72](https://github.com/Popov72))
+- Added the `useVertexAlpha` options to `MeshBuilder.CreateDashedLines` ([Popov72](https://github.com/Popov72))
 
 ### Physics
 
@@ -137,6 +140,7 @@
 - Added support for 8 bone influences to glTF loader ([zeux](https://github.com/zeux))
 - Added support for animations import from separate files ([noalak](https://github.com/noalak/))
 - Use web workers to validate glTF to avoid blocking the main thread. ([bghgary](https://github.com/bghgary))
+- Update glTF validator to 2.0.0-dev.3.1. ([bghgary](https://github.com/bghgary))
 
 ### Materials
 
@@ -189,13 +193,14 @@
 - WebXR teleportation can now be disabled after initialized or before created ([RaananW](https://github.com/RaananW/))
 - New Features Manager for WebXR features ([RaananW](https://github.com/RaananW/))
 - New features - Plane detection, Hit Test, Background remover ([RaananW](https://github.com/RaananW/))
-- Camera's API is Babylon-conform (position, rotationQuaternion, world matrix, direction etc') ([#7239](https://github.com/BabylonJS/Babylon.js/issues/7239)) ([RaananW](https://github.com/RaananW/))
+- XR Camera's API is Babylon-conform (position, rotationQuaternion, world matrix, direction etc') ([#7239](https://github.com/BabylonJS/Babylon.js/issues/7239)) ([RaananW](https://github.com/RaananW/))
 - XR Input now using standard profiles and completely separated from the gamepad class ([#7348](https://github.com/BabylonJS/Babylon.js/issues/7348)) ([RaananW](https://github.com/RaananW/))
 - Teleportation and controller selection are now WebXR features. ([#7290](https://github.com/BabylonJS/Babylon.js/issues/7290)) ([RaananW](https://github.com/RaananW/))
 - Teleportation allows selecting direction before teleporting when using thumbstick or touchpad. ([#7290](https://github.com/BabylonJS/Babylon.js/issues/7290)) ([RaananW](https://github.com/RaananW/))
 - It is now possible to force a certain profile type for the controllers ([#7348](https://github.com/BabylonJS/Babylon.js/issues/7375)) ([RaananW](https://github.com/RaananW/))
 - WebXR camera is initialized on the first frame ([#7389](https://github.com/BabylonJS/Babylon.js/issues/7389)) ([RaananW](https://github.com/RaananW/))
 - Selection has gaze mode (which can be forced) and touch-screen support ([#7395](https://github.com/BabylonJS/Babylon.js/issues/7395)) ([RaananW](https://github.com/RaananW/))
+- Laser pointers can be excluded from lighting influence so that they are always visible in both WebXR and WebVR ([#7323](https://github.com/BabylonJS/Babylon.js/issues/7323)) ([RaananW](https://github.com/RaananW/))
 
 ### Ray
 
@@ -307,3 +312,4 @@
 - The glTF2 exporter extension no longer ignores childless empty nodes.([drigax](https://github.com/drigax))
 - Default culling strategy changed to CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY ([Deltakosh](https://github.com/deltakosh/))
 - `MaterialHelper.BindLight` and `MaterialHelper.BindLights` do not need the usePhysicalLight anymore ([Sebavan](https://github.com/sebavan/))
+- `Mesh.bakeTransformIntoVertices` now preserves child world-space transforms([drigax](https://github.com/drigax))

+ 25 - 33
loaders/src/glTF/glTFFileLoader.ts

@@ -486,7 +486,10 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
                     readAsync: (byteOffset: number, byteLength: number) => {
                         return new Promise<ArrayBufferView>((resolve, reject) => {
                             fileRequests.push(scene._requestFile(url, (data, webRequest) => {
-                                dataBuffer.byteLength = Number(webRequest!.getResponseHeader("Content-Range")!.split("/")[1]);
+                                const contentRange = webRequest!.getResponseHeader("Content-Range");
+                                if (contentRange) {
+                                    dataBuffer.byteLength = Number(contentRange.split("/")[1]);
+                                }
                                 resolve(new Uint8Array(data as ArrayBuffer));
                             }, onProgress, true, true, (error) => {
                                 reject(error);
@@ -727,18 +730,18 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
             }
 
             const length = dataReader.readUint32();
-            if (length !== dataReader.buffer.byteLength) {
+            if (dataReader.buffer.byteLength != 0 && length !== dataReader.buffer.byteLength) {
                 throw new Error(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);
             }
 
             let unpacked: Promise<IGLTFLoaderData>;
             switch (version) {
                 case 1: {
-                    unpacked = this._unpackBinaryV1Async(dataReader);
+                    unpacked = this._unpackBinaryV1Async(dataReader, length);
                     break;
                 }
                 case 2: {
-                    unpacked = this._unpackBinaryV2Async(dataReader);
+                    unpacked = this._unpackBinaryV2Async(dataReader, length);
                     break;
                 }
                 default: {
@@ -752,7 +755,7 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
         });
     }
 
-    private _unpackBinaryV1Async(dataReader: DataReader): Promise<IGLTFLoaderData> {
+    private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {
         const ContentFormat = {
             JSON: 0
         };
@@ -764,7 +767,7 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
             throw new Error(`Unexpected content format: ${contentFormat}`);
         }
 
-        const bodyLength = dataReader.buffer.byteLength - dataReader.byteOffset;
+        const bodyLength = length - dataReader.byteOffset;
 
         const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };
         if (bodyLength !== 0) {
@@ -778,37 +781,26 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
         return Promise.resolve(data);
     }
 
-    private _unpackBinaryV2Async(dataReader: DataReader): Promise<IGLTFLoaderData> {
+    private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {
         const ChunkFormat = {
             JSON: 0x4E4F534A,
             BIN: 0x004E4942
         };
 
-        // Read the JSON chunk header.
-        const chunkLength = dataReader.readUint32();
-        const chunkFormat = dataReader.readUint32();
-        if (chunkFormat !== ChunkFormat.JSON) {
-            throw new Error("First chunk format is not JSON");
-        }
+        const data: IGLTFLoaderData = { json: {}, bin: null };
 
-        // Bail if there are no other chunks.
-        if (dataReader.byteOffset + chunkLength === dataReader.buffer.byteLength) {
-            return dataReader.loadAsync(chunkLength).then(() => {
-                return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
-            });
-        }
+        const readAsync = (): Promise<IGLTFLoaderData> => {
+            const chunkLength = dataReader.readUint32();
+            const chunkFormat = dataReader.readUint32();
 
-        // Read the JSON chunk and the length and type of the next chunk.
-        return dataReader.loadAsync(chunkLength + 8).then(() => {
-            const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };
-
-            const readAsync = (): Promise<IGLTFLoaderData> => {
-                const chunkLength = dataReader.readUint32();
-                const chunkFormat = dataReader.readUint32();
+            const finalChunk = (dataReader.byteOffset + chunkLength + 8 > length);
 
+            // Read the chunk and (if available) the length and type of the next chunk.
+            return dataReader.loadAsync(finalChunk ? chunkLength : chunkLength + 8).then(() => {
                 switch (chunkFormat) {
                     case ChunkFormat.JSON: {
-                        throw new Error("Unexpected JSON chunk");
+                        data.json = this._parseJson(dataReader.readString(chunkLength));
+                        break;
                     }
                     case ChunkFormat.BIN: {
                         const startByteOffset = dataReader.byteOffset;
@@ -826,15 +818,15 @@ export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISc
                     }
                 }
 
-                if (dataReader.byteOffset !== dataReader.buffer.byteLength) {
-                    return dataReader.loadAsync(8).then(readAsync);
+                if (finalChunk) {
+                    return data;
                 }
 
-                return Promise.resolve(data);
-            };
+                return readAsync();
+            });
+        };
 
-            return readAsync();
-        });
+        return readAsync();
     }
 
     private static _parseVersion(version: string): Nullable<{ major: number, minor: number }> {

+ 12 - 0
nodeEditor/src/diagram/display/inputDisplayManager.ts

@@ -62,6 +62,8 @@ export class InputDisplayManager implements IDisplayManager {
     public updatePreviewContent(block: NodeMaterialBlock, contentArea: HTMLDivElement): void {
         let value = "";
         let inputBlock = block as InputBlock;
+        let isFat = false;
+        let smallFont = false;
 
         if (inputBlock.isAttribute) {
             value = "mesh." + inputBlock.name;
@@ -75,6 +77,7 @@ export class InputDisplayManager implements IDisplayManager {
                     break;
                 case NodeMaterialSystemValues.WorldViewProjection:
                     value = "World x View x Projection";
+                    isFat = true;
                     break;
                 case NodeMaterialSystemValues.View:
                     value = "View";
@@ -113,6 +116,7 @@ export class InputDisplayManager implements IDisplayManager {
                     value = `(${vec3Value.x.toFixed(2)}, ${vec3Value.y.toFixed(2)}, ${vec3Value.z.toFixed(2)})`;
                     break;
                 case NodeMaterialBlockConnectionPointTypes.Vector4:
+                    smallFont = true;
                     let vec4Value = inputBlock.value as Vector4
                     value = `(${vec4Value.x.toFixed(2)}, ${vec4Value.y.toFixed(2)}, ${vec4Value.z.toFixed(2)}, ${vec4Value.w.toFixed(2)})`;
                     break;                        
@@ -121,5 +125,13 @@ export class InputDisplayManager implements IDisplayManager {
 
         contentArea.innerHTML = value;
         contentArea.classList.add("input-block");
+
+        if (isFat) {
+            contentArea.classList.add("fat");
+        }
+
+        if (smallFont) {
+            contentArea.classList.add("small-font");
+        }
     }
 }

+ 9 - 1
nodeEditor/src/diagram/graphCanvas.scss

@@ -221,7 +221,7 @@
             height: 100%;  
             overflow: visible; 
             pointer-events: none;
-            z-index: 1;
+            z-index: 2;
             
             .link {
                 stroke-width: 4px;    
@@ -357,6 +357,14 @@
                         font-size: 18px;
                         font-weight: bold;
                         margin: 0 10px;
+
+                        &.fat {
+                            height: 54px;
+                        }
+
+                        &.small-font {                            
+                            font-size: 17px;
+                        }
                     }
 
                     &.output-block {

+ 10 - 0
nodeEditor/src/diagram/graphCanvas.tsx

@@ -712,6 +712,16 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
             });
         }
 
+        if (pointB.ownerBlock.inputsAreExclusive) { // Disconnect all inputs if block has exclusive inputs
+            pointB.ownerBlock.inputs.forEach(i => {
+                let links = nodeB.getLinksForConnectionPoint(i);
+
+                links.forEach(link => {
+                    link.dispose();
+                });
+            })
+        }
+
         pointA.connectTo(pointB);
         this.connectPorts(pointA, pointB);
 

+ 19 - 1
nodeEditor/src/diagram/properties/gradientNodePropertyComponent.tsx

@@ -41,6 +41,23 @@ export class GradientPropertyTabComponent extends React.Component<IPropertyCompo
         this.forceUpdate();
     }
 
+    checkForReOrder() {
+        let gradientBlock = this.props.block as GradientBlock;
+        gradientBlock.colorSteps.sort((a, b) => {
+            if (a.step === b.step) {
+                return 0;
+            }
+
+            if (a.step > b.step) {
+                return 1;
+            }
+
+            return -1;
+        });
+
+        this.forceUpdate();
+    }
+
     render() {
         let gradientBlock = this.props.block as GradientBlock;
       
@@ -53,8 +70,9 @@ export class GradientPropertyTabComponent extends React.Component<IPropertyCompo
                         gradientBlock.colorSteps.map((c, i) => {
                             return (
                                 <GradientStepComponent globalState={this.props.globalState} 
+                                onCheckForReOrder={() => this.checkForReOrder()}
                                 onUpdateStep={() => this.forceRebuild()}
-                                key={c.step} lineIndex={i} step={c} onDelete={() => this.deleteStep(c)}/>
+                                key={"step-" + i} lineIndex={i} step={c} onDelete={() => this.deleteStep(c)}/>
                             )
                         })
                     }

+ 6 - 0
nodeEditor/src/diagram/properties/gradientStepComponent.tsx

@@ -11,6 +11,7 @@ interface IGradientStepComponentProps {
     lineIndex: number;
     onDelete: () => void;
     onUpdateStep: () => void;
+    onCheckForReOrder: () => void;
 }
 
 export class GradientStepComponent extends React.Component<IGradientStepComponentProps, {gradient: number}> {
@@ -36,6 +37,10 @@ export class GradientStepComponent extends React.Component<IGradientStepComponen
         this.props.onUpdateStep();
     }
 
+    onPointerUp() {
+        this.props.onCheckForReOrder();
+    }
+
     render() {
         let step = this.props.step;
 
@@ -50,6 +55,7 @@ export class GradientStepComponent extends React.Component<IGradientStepComponen
                 </div>
                 <div className="step-slider">
                     <input className="range" type="range" step={0.01} min={0} max={1.0} value={step.step}
+                        onPointerUp={evt => this.onPointerUp()}
                         onChange={evt => this.updateStep(parseFloat(evt.target.value))} />
                 </div>
                 <div className="gradient-delete" onClick={() => this.props.onDelete()}>

+ 1 - 1
package.json

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

+ 1 - 14
postProcessLibrary/index.html

@@ -91,27 +91,18 @@
 			// Post-processes
 			var aaPostProcess = new BABYLON.AsciiArtPostProcess("AsciiArt", camera);
 			var drPostProcess = new BABYLON.DigitalRainPostProcess("AsciiArt", camera);
-
-			var oceanPostProcess = new BABYLON.OceanPostProcess("Ocean", camera);
-			if (oceanPostProcess.isSupported) {
-				oceanPostProcess.refractionTexture.renderList = scene.meshes;
-				oceanPostProcess.reflectionTexture.renderList = scene.meshes;
-				oceanPostProcess.reflectionEnabled = oceanPostProcess.refractionEnabled = true;
-			}
 			
 			//camera.detachPostProcess(aaPostProcess);
 			camera.detachPostProcess(drPostProcess);
-			camera.detachPostProcess(oceanPostProcess);
 
 			var gui = new dat.GUI();
 			var options = {
 				postProcess: "asciiArt"
 			}
 
-			gui.add(options, 'postProcess', ['asciiArt', 'digitalRain', 'ocean']).onFinishChange(function () {
+			gui.add(options, 'postProcess', ['asciiArt', 'digitalRain']).onFinishChange(function () {
 				camera.detachPostProcess(aaPostProcess);
 				camera.detachPostProcess(drPostProcess);
-				camera.detachPostProcess(oceanPostProcess);
 
 				skybox.setEnabled(false);
 
@@ -122,10 +113,6 @@
 					case "digitalRain":
 						camera.attachPostProcess(drPostProcess);
 						break;
-					case "ocean":
-						camera.attachPostProcess(oceanPostProcess);
-						skybox.setEnabled(true);
-						break;
 				}
 			});
 		}

+ 1 - 2
postProcessLibrary/src/index.ts

@@ -1,3 +1,2 @@
 export * from "./asciiArt";
-export * from "./digitalRain";
-export * from "./ocean";
+export * from "./digitalRain";

+ 0 - 14
postProcessLibrary/src/legacy/legacy-ocean.ts

@@ -1,14 +0,0 @@
-import * as postProcessLibrary from "../ocean/index";
-
-/**
- * This is the entry point for the UMD module.
- * The entry point for a future ESM package should be index.ts
- */
-var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
-if (typeof globalObject !== "undefined") {
-    for (var key in postProcessLibrary) {
-        (<any>globalObject).BABYLON[key] = (<any>postProcessLibrary)[key];
-    }
-}
-
-export * from "../ocean/index";

+ 0 - 1
postProcessLibrary/src/ocean/index.ts

@@ -1 +0,0 @@
-export * from "./oceanPostProcess";

+ 0 - 259
postProcessLibrary/src/ocean/oceanPostProcess.fragment.fx

@@ -1,259 +0,0 @@
-/*
- * "Seascape" by Alexander Alekseev aka TDM - 2014
- * Babylon.js integration by luaacro https://twitter.com/Luaacro
- * License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
- * Contact: tdmaav@gmail.com
- */
-
-// Uniforms
-uniform sampler2D textureSampler;
-uniform sampler2D positionSampler;
-
-#ifdef REFLECTION_ENABLED
-uniform sampler2D reflectionSampler;
-#endif
-#ifdef REFRACTION_ENABLED
-uniform sampler2D refractionSampler;
-#endif
-
-uniform float time;
-uniform vec2 resolution;
-uniform vec3 cameraRotation;
-uniform vec3 cameraPosition;
-
-// Varyings
-varying vec2 vUV;
-
-// Constants
-const int NUM_STEPS = 8;
-const float PI	 	= 3.141592;
-const float EPSILON	= 1e-3;
-#define EPSILON_NRM (0.1 / resolution.x)
-
-// Sea
-const int ITER_GEOMETRY = 8;
-const int ITER_FRAGMENT = 5;
-const float SEA_HEIGHT = 0.6;
-const float SEA_CHOPPY = 4.0;
-const float SEA_SPEED = 0.8;
-const float SEA_FREQ = 0.16;
-const vec3 SEA_BASE = vec3(0.1,0.19,0.22);
-const vec3 SEA_WATER_COLOR = vec3(0.8,0.9,0.6);
-#define SEA_TIME (1.0 + time * SEA_SPEED)
-const mat2 octave_m = mat2(1.6,1.2,-1.2,1.6);
-
-// Math
-mat3 fromEuler(vec3 ang)
-{
-	vec2 a1 = vec2(sin(ang.x),cos(ang.x));
-    vec2 a2 = vec2(sin(ang.y),cos(ang.y));
-    vec2 a3 = vec2(sin(ang.z),cos(ang.z));
-    mat3 m;
-    m[0] = vec3(a1.y*a3.y+a1.x*a2.x*a3.x,a1.y*a2.x*a3.x+a3.y*a1.x,-a2.y*a3.x);
-	m[1] = vec3(-a2.y*a1.x,a1.y*a2.y,a2.x);
-	m[2] = vec3(a3.y*a1.x*a2.x+a1.y*a3.x,a1.x*a3.x-a1.y*a3.y*a2.x,a2.y*a3.y);
-	return m;
-}
-
-float hash( vec2 p )
-{
-	float h = dot(p,vec2(127.1,311.7));	
-    return fract(sin(h)*43758.5453123);
-}
-
-float noise( in vec2 p )
-{
-    vec2 i = floor( p );
-    vec2 f = fract( p );	
-	vec2 u = f*f*(3.0-2.0*f);
-    return -1.0+2.0*mix( mix( hash( i + vec2(0.0,0.0) ), 
-                     hash( i + vec2(1.0,0.0) ), u.x),
-                mix( hash( i + vec2(0.0,1.0) ), 
-                     hash( i + vec2(1.0,1.0) ), u.x), u.y);
-}
-
-// Lighting
-float diffuse(vec3 n,vec3 l,float p)
-{
-    return pow(dot(n,l) * 0.4 + 0.6,p);
-}
-
-float specular(vec3 n,vec3 l,vec3 e,float s)
-{
-    float nrm = (s + 8.0) / (PI * 8.0);
-    return pow(max(dot(reflect(e,n),l),0.0),s) * nrm;
-}
-
-// Sea
-float sea_octave(vec2 uv, float choppy)
-{
-    uv += noise(uv);        
-    vec2 wv = 1.0-abs(sin(uv));
-    vec2 swv = abs(cos(uv));    
-    wv = mix(wv,swv,wv);
-    return pow(1.0-pow(wv.x * wv.y,0.65),choppy);
-}
-
-float map(vec3 p)
-{
-    float freq = SEA_FREQ;
-    float amp = SEA_HEIGHT;
-    float choppy = SEA_CHOPPY;
-    vec2 uv = p.xz; uv.x *= 0.75;
-    
-    float d, h = 0.0;    
-    for(int i = 0; i < ITER_GEOMETRY; i++)
-    {
-    	d = sea_octave((uv+SEA_TIME)*freq,choppy);
-    	d += sea_octave((uv-SEA_TIME)*freq,choppy);
-        h += d * amp;        
-    	uv *= octave_m; freq *= 1.9; amp *= 0.22;
-        choppy = mix(choppy,1.0,0.2);
-    }
-    return p.y - h;
-}
-
-float map_detailed(vec3 p)
-{
-    float freq = SEA_FREQ;
-    float amp = SEA_HEIGHT;
-    float choppy = SEA_CHOPPY;
-    vec2 uv = p.xz; uv.x *= 0.75;
-    
-    float d, h = 0.0;    
-    for(int i = 0; i < ITER_FRAGMENT; i++)
-    {
-    	d = sea_octave((uv+SEA_TIME)*freq,choppy);
-    	d += sea_octave((uv-SEA_TIME)*freq,choppy);
-        h += d * amp;        
-    	uv *= octave_m; freq *= 1.9; amp *= 0.22;
-        choppy = mix(choppy,1.0,0.2);
-    }
-    return p.y - h;
-}
-
-vec3 getSeaColor(vec3 p, vec3 n, vec3 l, vec3 eye, vec3 dist)
-{
-    float fresnel = clamp(1.0 - dot(n, -eye), 0.0, 1.0);
-    fresnel = pow(fresnel, 3.0) * 0.65;
-
-    #if defined(REFLECTION_ENABLED) || defined(REFRACTION_ENABLED)
-    vec2 reflectionUv = vec2(vUV.x, vUV.y + normalize(n).y);
-    #endif
-
-    #ifdef REFLECTION_ENABLED
-    vec3 reflected = texture2D(reflectionSampler, reflectionUv).rgb * (1.0 - fresnel);
-    #else
-    vec3 eyeNormal = reflect(eye, n);
-    eyeNormal.y = max(eyeNormal.y,0.0);
-    vec3 reflected = vec3(pow(1.0-eyeNormal.y,2.0), 1.0-eyeNormal.y, 0.6+(1.0-eyeNormal.y)*0.4);
-    #endif
-
-    #ifdef REFRACTION_ENABLED
-    vec3 refracted = SEA_BASE + diffuse(n, l, 80.0) * SEA_WATER_COLOR * 0.12;
-    refracted += (texture2D(refractionSampler, reflectionUv).rgb * fresnel);
-    #else
-    vec3 refracted = SEA_BASE + diffuse(n, l, 80.0) * SEA_WATER_COLOR * 0.12;
-    #endif
-
-    vec3 color = mix(refracted, reflected, fresnel);
-    
-    float atten = max(1.0 - dot(dist, dist) * 0.001, 0.0);
-    color += SEA_WATER_COLOR * (p.y - SEA_HEIGHT) * 0.18 * atten;
-    
-    color += vec3(specular(n,l,eye,60.0));
-    
-    return color;
-}
-
-// Tracing
-vec3 getNormal(vec3 p, float eps)
-{
-    vec3 n;
-    n.y = map_detailed(p);    
-    n.x = map_detailed(vec3(p.x+eps,p.y,p.z)) - n.y;
-    n.z = map_detailed(vec3(p.x,p.y,p.z+eps)) - n.y;
-    n.y = eps;
-    return normalize(n);
-}
-
-float heightMapTracing(vec3 ori, vec3 dir, out vec3 p)
-{
-    float tm = 0.0;
-    float tx = 1000.0;    
-    float hx = map(ori + dir * tx);
-    if(hx > 0.0) return tx;   
-    float hm = map(ori + dir * tm);    
-    float tmid = 0.0;
-    for(int i = 0; i < NUM_STEPS; i++)
-    {
-        tmid = mix(tm,tx, hm/(hm-hx));                   
-        p = ori + dir * tmid;                   
-    	float hmid = map(p);
-        if(hmid < 0.0)
-        {
-        	tx = tmid;
-            hx = hmid;
-        }
-        else
-        {
-            tm = tmid;
-            hm = hmid;
-        }
-    }
-    return tmid;
-}
-
-// Main
-void main()
-{
-    #ifdef NOT_SUPPORTED
-    // Just work as a pass through
-    gl_FragColor = texture2D(textureSampler, vUV);
-    #else
-	vec2 uv = vUV;
-    uv = uv * 2.0 - 1.0;
-    uv.x *= resolution.x / resolution.y;
-    
-    // ray
-    vec3 ang = vec3(cameraRotation.z, cameraRotation.x, cameraRotation.y);
-    vec3 ori = vec3(cameraPosition.x, cameraPosition.y, -cameraPosition.z);
-
-    vec3 dir = normalize(vec3(uv.xy, -3.0));
-    dir = normalize(dir) * fromEuler(ang);
-    
-    // Tracing
-    vec3 p;
-    heightMapTracing(ori, dir, p);
-    vec3 dist = p - ori;
-
-    vec3 n = getNormal(p, dot(dist, dist) * EPSILON_NRM);
-    vec3 light = normalize(vec3(0.0, 1.0, 0.8));
-    
-    // Color
-    float seaFact = clamp(max(ori.y, 0.0), 0.0, 1.0);
-    vec3 position = texture2D(positionSampler, vUV).rgb;
-    vec3 baseColor = texture2D(textureSampler, vUV).rgb;
-
-    vec3 color = baseColor;
-
-    if (max(position.y, 0.0) < p.y)
-    {
-        // Sea above
-        color = mix(
-            baseColor,
-            getSeaColor(p, n, light, dir, dist),
-            pow(smoothstep(0.0, -0.05, dir.y), 0.3)
-        ) * seaFact;
-    }
-
-    color = mix(
-        color,
-        baseColor * SEA_BASE + diffuse(n, n, 80.0) * SEA_WATER_COLOR * 0.12,
-        1.0 - seaFact
-    );
-
-    // post
-    gl_FragColor = vec4(pow(color, vec3(0.75)), 1.0);
-    #endif
-}

+ 0 - 249
postProcessLibrary/src/ocean/oceanPostProcess.ts

@@ -1,249 +0,0 @@
-import { TargetCamera } from "babylonjs/Cameras/targetCamera";
-import { Texture } from "babylonjs/Materials/Textures/texture";
-import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
-import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
-import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
-import { Effect } from "babylonjs/Materials/effect";
-import { PostProcess } from "babylonjs/PostProcesses/postProcess";
-import { Vector2, Vector3, Plane, Matrix, Epsilon } from "babylonjs/Maths/math";
-import { Nullable } from "babylonjs/types";
-
-import "./oceanPostProcess.fragment";
-
-/**
- * Option available in the Ocean Post Process.
- */
-export interface IOceanPostProcessOptions {
-    /**
-     * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-     */
-    reflectionSize?: number | { width: number; height: number } | { ratio: number };
-    /**
-     * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
-     */
-    refractionSize?: number | { width: number; height: number } | { ratio: number };
-}
-
-/**
- * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
- *
- * Simmply add it to your scene and let the nerd that lives in you have fun.
- * Example usage:
- *  var pp = new OceanPostProcess("myOcean", camera);
- *  pp.reflectionEnabled = true;
- *  pp.refractionEnabled = true;
- */
-export class OceanPostProcess extends PostProcess {
-
-    /**
-     * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
-     */
-    public get reflectionEnabled(): boolean {
-        return this._reflectionEnabled;
-    }
-
-    /**
-     * Sets weither or not the real-time reflection is enabled on the ocean.
-     * Is set to true, the reflection mirror texture will be used as reflection texture.
-     */
-    public set reflectionEnabled(enabled: boolean) {
-        if (this._reflectionEnabled === enabled) {
-            return;
-        }
-
-        this._reflectionEnabled = enabled;
-        this.updateEffect(this._getDefines());
-
-        // Remove or add custom render target
-        const customRenderTargets = this.getCamera().getScene().customRenderTargets;
-        if (!enabled) {
-            const index = customRenderTargets.indexOf(this.reflectionTexture);
-            if (index !== -1) {
-                customRenderTargets.splice(index, 1);
-            }
-        } else {
-            customRenderTargets.push(this.reflectionTexture);
-        }
-    }
-
-    /**
-     * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
-     */
-    public get refractionEnabled(): boolean {
-        return this._refractionEnabled;
-    }
-
-    /**
-     * Sets weither or not the real-time refraction is enabled on the ocean.
-     * Is set to true, the refraction render target texture will be used as refraction texture.
-     */
-    public set refractionEnabled(enabled: boolean) {
-        if (this._refractionEnabled === enabled) {
-            return;
-        }
-
-        this._refractionEnabled = enabled;
-        this.updateEffect(this._getDefines());
-
-        // Remove or add custom render target
-        const customRenderTargets = this.getCamera().getScene().customRenderTargets;
-        if (!enabled) {
-            const index = customRenderTargets.indexOf(this.refractionTexture);
-            if (index !== -1) {
-                customRenderTargets.splice(index, 1);
-            }
-        } else {
-            customRenderTargets.push(this.refractionTexture);
-        }
-    }
-
-    /**
-     * Gets wether or not the post-processes is supported by the running hardware.
-     * This requires draw buffer supports.
-     */
-    public get isSupported(): boolean {
-        return this._geometryRenderer !== null && this._geometryRenderer.isSupported;
-    }
-
-    /**
-     * This is the reflection mirror texture used to display reflections on the ocean.
-     * By default, render list is empty.
-     */
-    public reflectionTexture: MirrorTexture;
-    /**
-     * This is the refraction render target texture used to display refraction on the ocean.
-     * By default, render list is empty.
-     */
-    public refractionTexture: RenderTargetTexture;
-
-    private _time: number = 0;
-    private _cameraRotation: Vector3 = Vector3.Zero();
-    private _cameraViewMatrix: Matrix = Matrix.Identity();
-    private _reflectionEnabled: boolean = false;
-    private _refractionEnabled: boolean = false;
-    private _geometryRenderer: Nullable<GeometryBufferRenderer>;
-
-    /**
-     * Instantiates a new Ocean Post Process.
-     * @param name the name to give to the postprocess.
-     * @camera the camera to apply the post process to.
-     * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
-     */
-    constructor(name: string, camera: TargetCamera, options: IOceanPostProcessOptions = { }) {
-        super(name,
-            "oceanPostProcess",
-            ["time", "resolution", "cameraPosition", "cameraRotation"],
-            ["positionSampler", "reflectionSampler", "refractionSampler"],
-            {
-                width: camera.getEngine().getRenderWidth(),
-                height: camera.getEngine().getRenderHeight()
-            },
-            camera,
-            Texture.TRILINEAR_SAMPLINGMODE,
-            camera.getEngine(),
-            true);
-
-        // Get geometry shader
-        this._geometryRenderer = camera.getScene().enableGeometryBufferRenderer(1.0);
-        if (this._geometryRenderer && this._geometryRenderer.isSupported) {
-            // Eanble position buffer
-            this._geometryRenderer.enablePosition = true;
-
-            // Create mirror textures
-            this.reflectionTexture = new MirrorTexture("oceanPostProcessReflection", options.reflectionSize || { width: 512, height: 512 }, camera.getScene());
-            this.reflectionTexture.mirrorPlane = Plane.FromPositionAndNormal(Vector3.Zero(), new Vector3(0, -1, 0));
-
-            this.refractionTexture = new RenderTargetTexture("oceanPostProcessRefraction", options.refractionSize || { width: 512, height: 512 }, camera.getScene());
-        } else {
-            this.updateEffect("#define NOT_SUPPORTED\n");
-        }
-
-        // On apply the post-process
-        this.onApply = (effect: Effect) => {
-            if (!this._geometryRenderer || !this._geometryRenderer.isSupported) {
-                return;
-            }
-
-            const engine = camera.getEngine();
-            const scene = camera.getScene();
-
-            this._time += engine.getDeltaTime() * 0.001;
-            effect.setFloat("time", this._time);
-
-            effect.setVector2("resolution", new Vector2(engine.getRenderWidth(), engine.getRenderHeight()));
-
-            if (scene) {
-                // Position
-                effect.setVector3("cameraPosition", camera.globalPosition);
-
-                // Rotation
-                this._computeCameraRotation(camera);
-                effect.setVector3("cameraRotation", this._cameraRotation);
-
-                // Samplers
-                effect.setTexture("positionSampler", this._geometryRenderer.getGBuffer().textures[2]);
-
-                if (this._reflectionEnabled) {
-                    effect.setTexture("reflectionSampler", this.reflectionTexture);
-                }
-                if (this._refractionEnabled) {
-                    effect.setTexture("refractionSampler", this.refractionTexture);
-                }
-            }
-        };
-    }
-
-    /**
-     * Returns the appropriate defines according to the current configuration.
-     */
-    private _getDefines(): string {
-        const defines: string[] = [];
-
-        if (this._reflectionEnabled) {
-            defines.push("#define REFLECTION_ENABLED");
-        }
-
-        if (this._refractionEnabled) {
-            defines.push("#define REFRACTION_ENABLED");
-        }
-
-        return defines.join("\n");
-    }
-
-    /**
-     * Computes the current camera rotation as the shader requires a camera rotation.
-     */
-    private _computeCameraRotation(camera: TargetCamera): void {
-        camera.upVector.normalize();
-        const target = camera.getTarget();
-        camera._initialFocalDistance = target.subtract(camera.position).length();
-        if (camera.position.z === target.z) {
-            camera.position.z += Epsilon;
-        }
-
-        const direction = target.subtract(camera.position);
-        camera._viewMatrix.invertToRef(this._cameraViewMatrix);
-
-        this._cameraRotation.x = Math.atan(this._cameraViewMatrix.m[6] / this._cameraViewMatrix.m[10]);
-
-        if (direction.x >= 0.0) {
-            this._cameraRotation.y = (-Math.atan(direction.z / direction.x) + Math.PI / 2.0);
-        } else {
-            this._cameraRotation.y = (-Math.atan(direction.z / direction.x) - Math.PI / 2.0);
-        }
-
-        this._cameraRotation.z = 0;
-
-        if (isNaN(this._cameraRotation.x)) {
-            this._cameraRotation.x = 0;
-        }
-
-        if (isNaN(this._cameraRotation.y)) {
-            this._cameraRotation.y = 0;
-        }
-
-        if (isNaN(this._cameraRotation.z)) {
-            this._cameraRotation.z = 0;
-        }
-    }
-}

+ 19 - 0
src/Cameras/VR/vrExperienceHelper.ts

@@ -254,6 +254,11 @@ class VRExperienceHelperControllerGazer extends VRExperienceHelperGazer {
     }
 
     /** @hidden */
+    public _setLaserPointerLightingDisabled(disabled: boolean) {
+        (<StandardMaterial>this._laserPointer.material).disableLighting = disabled;
+    }
+
+    /** @hidden */
     public _setLaserPointerParent(mesh: AbstractMesh) {
         var makeNotPick = (root: AbstractMesh) => {
             root.isPickable = false;
@@ -2228,6 +2233,20 @@ export class VRExperienceHelper {
     }
 
     /**
+     * Set lighting enabled / disabled on the laser pointer of both controllers
+     * @param enabled should the lighting be enabled on the laser pointer
+     */
+    public setLaserLightingState(enabled: boolean = true) {
+        if (this._leftController) {
+            this._leftController._setLaserPointerLightingDisabled(!enabled);
+
+        }
+        if (this._rightController) {
+            this._rightController._setLaserPointerLightingDisabled(!enabled);
+        }
+    }
+
+    /**
      * Permanently set new colors for the gaze pointer
      * @param color the new gaze color
      * @param pickedColor the new gaze color when picked mesh detected

+ 19 - 7
src/Cameras/XR/features/WebXRAbstractFeature.ts

@@ -15,7 +15,6 @@ export abstract class WebXRAbstractFeature implements IWebXRFeature {
      * @param _xrSessionManager the xr session manager for this feature
      */
     constructor(protected _xrSessionManager: WebXRSessionManager) {
-
     }
 
     private _attached: boolean = false;
@@ -32,14 +31,28 @@ export abstract class WebXRAbstractFeature implements IWebXRFeature {
     }
 
     /**
+     * Should auto-attach be disabled?
+     */
+    public disableAutoAttach: boolean = false;
+
+    /**
      * attach this feature
      *
+     * @param force should attachment be forced (even when already attached)
      * @returns true if successful, false is failed or already attached
      */
-    public attach(): boolean {
-        if (this.attached) {
-            return false;
+    public attach(force?: boolean): boolean {
+        if (!force) {
+            if (this.attached) {
+                return false;
+            }
+        } else {
+            if (this.attached) {
+                // detach first, to be sure
+                this.detach();
+            }
         }
+
         this._attached = true;
         this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable, (frame) => this._onXRFrame(frame));
         return true;
@@ -52,6 +65,7 @@ export abstract class WebXRAbstractFeature implements IWebXRFeature {
      */
     public detach(): boolean {
         if (!this._attached) {
+            this.disableAutoAttach = true;
             return false;
         }
         this._attached = false;
@@ -72,9 +86,7 @@ export abstract class WebXRAbstractFeature implements IWebXRFeature {
      * This function will not execute after the feature is detached.
      * @param _xrFrame the current frame
      */
-    protected _onXRFrame(_xrFrame: XRFrame): void {
-        // no-op
-    }
+    protected abstract _onXRFrame(_xrFrame: XRFrame): void;
 
     /**
      * This is used to register callbacks that will automatically be removed when detach is called.

+ 6 - 8
src/Cameras/XR/features/WebXRAnchorSystem.ts

@@ -1,4 +1,4 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { WebXRFeatureName } from '../webXRFeaturesManager';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Matrix } from '../../../Maths/math.vector';
@@ -7,8 +7,6 @@ import { WebXRPlaneDetector } from './WebXRPlaneDetector';
 import { WebXRHitTestLegacy } from './WebXRHitTestLegacy';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-anchor-system";
-
 /**
  * Configuration options of the anchor system
  */
@@ -54,12 +52,12 @@ let anchorIdProvider = 0;
  * will use the frame to create an anchor and not the session or a detected plane
  * For further information see https://github.com/immersive-web/anchors/
  */
-export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRAnchorSystem extends WebXRAbstractFeature {
 
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.ANCHOR_SYSTEM;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.
@@ -262,6 +260,6 @@ export class WebXRAnchorSystem extends WebXRAbstractFeature implements IWebXRFea
 }
 
 //register the plugin
-WebXRFeaturesManager.AddWebXRFeature(WebXRAnchorSystem.Name, (xrSessionManager, options) => {
-    return () => new WebXRAnchorSystem(xrSessionManager, options);
-}, WebXRAnchorSystem.Version);
+// WebXRFeaturesManager.AddWebXRFeature(WebXRAnchorSystem.Name, (xrSessionManager, options) => {
+//     return () => new WebXRAnchorSystem(xrSessionManager, options);
+// }, WebXRAnchorSystem.Version);

+ 7 - 5
src/Cameras/XR/features/WebXRBackgroundRemover.ts

@@ -1,11 +1,9 @@
-import { WebXRFeaturesManager, IWebXRFeature } from "../webXRFeaturesManager";
+import { WebXRFeaturesManager, WebXRFeatureName } from "../webXRFeaturesManager";
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { AbstractMesh } from '../../../Meshes/abstractMesh';
 import { Observable } from '../../../Misc/observable';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-background-remover";
-
 /**
  * Options interface for the background remover plugin
  */
@@ -37,12 +35,12 @@ export interface IWebXRBackgroundRemoverOptions {
 /**
  * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  */
-export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRBackgroundRemover extends WebXRAbstractFeature {
 
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.BACKGROUND_REMOVER;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.
@@ -128,6 +126,10 @@ export class WebXRBackgroundRemover extends WebXRAbstractFeature implements IWeb
         super.dispose();
         this.onBackgroundStateChangedObservable.clear();
     }
+
+    protected _onXRFrame(_xrFrame: XRFrame) {
+        // no-op
+    }
 }
 
 //register the plugin

+ 20 - 11
src/Cameras/XR/features/WebXRControllerPointerSelection.ts

@@ -1,4 +1,4 @@
-import { WebXRFeaturesManager, IWebXRFeature } from "../webXRFeaturesManager";
+import { WebXRFeaturesManager, WebXRFeatureName } from "../webXRFeaturesManager";
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { AbstractMesh } from '../../../Meshes/abstractMesh';
 import { Observer } from '../../../Misc/observable';
@@ -17,8 +17,6 @@ import { Ray } from '../../../Culling/ray';
 import { PickingInfo } from '../../../Collisions/pickingInfo';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-controller-pointer-selection";
-
 /**
  * Options interface for the pointer selection module
  */
@@ -62,12 +60,12 @@ export interface IWebXRControllerPointerSelectionOptions {
 /**
  * A module that will enable pointer selection for motion controllers of XR Input Sources
  */
-export class WebXRControllerPointerSelection extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
 
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.POINTER_SELECTION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.
@@ -78,19 +76,19 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature implem
     /**
      * This color will be set to the laser pointer when selection is triggered
      */
-    public laserPointerPickedColor: Color3 = new Color3(0.7, 0.7, 0.7);
+    public laserPointerPickedColor: Color3 = new Color3(0.9, 0.9, 0.9);
     /**
      * This color will be applied to the selection ring when selection is triggered
      */
-    public selectionMeshPickedColor: Color3 = new Color3(0.7, 0.7, 0.7);
+    public selectionMeshPickedColor: Color3 = new Color3(0.3, 0.3, 1.0);
     /**
      * default color of the selection ring
      */
-    public selectionMeshDefaultColor: Color3 = new Color3(0.5, 0.5, 0.5);
+    public selectionMeshDefaultColor: Color3 = new Color3(0.8, 0.8, 0.8);
     /**
      * Default color of the laser pointer
      */
-    public lasterPointerDefaultColor: Color3 = new Color3(0.5, 0.5, 0.5);
+    public lasterPointerDefaultColor: Color3 = new Color3(0.7, 0.7, 0.7);
 
     /**
      * Should the laser pointer be displayed
@@ -101,6 +99,16 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature implem
      */
     public displaySelectionMesh: boolean = true;
 
+    /**
+     * Disable lighting on the laser pointer (so it will always be visible)
+     */
+    public disablePointerLighting: boolean = true;
+
+    /**
+     * Disable lighting on the selection mesh (so it will always be visible)
+     */
+    public disableSelectionMeshLighting: boolean = true;
+
     private static _idCounter = 0;
 
     private _tmpRay = new Ray(new Vector3(), new Vector3());
@@ -371,8 +379,9 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature implem
                     (<StandardMaterial>controllerData.selectionMesh.material).emissiveColor = this.selectionMeshDefaultColor;
                     (<StandardMaterial>controllerData.laserPointer.material).emissiveColor = this.lasterPointerDefaultColor;
                 }
-
                 controllerData.laserPointer.isVisible = this.displayLaserPointer;
+                (<StandardMaterial>controllerData.laserPointer.material).disableLighting = this.disablePointerLighting;
+                (<StandardMaterial>controllerData.selectionMesh.material).disableLighting = this.disableSelectionMeshLighting;
 
                 if (controllerData.pick) {
                     this._scene.simulatePointerMove(controllerData.pick, { pointerId: controllerData.id });
@@ -423,7 +432,7 @@ export class WebXRControllerPointerSelection extends WebXRAbstractFeature implem
         laserPointer.parent = xrController.pointer;
         let laserPointerMaterial = new StandardMaterial("laserPointerMat", this._scene);
         laserPointerMaterial.emissiveColor = this.lasterPointerDefaultColor;
-        laserPointerMaterial.alpha = 0.6;
+        laserPointerMaterial.alpha = 0.7;
         laserPointer.material = laserPointerMaterial;
         laserPointer.rotation.x = Math.PI / 2;
         this._updatePointerDistance(laserPointer, 1);

+ 3 - 5
src/Cameras/XR/features/WebXRControllerTeleportation.ts

@@ -1,4 +1,4 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { IWebXRFeature, WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { Observer } from '../../../Misc/observable';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Nullable } from '../../../types';
@@ -22,8 +22,6 @@ import { Curve3 } from '../../../Maths/math.path';
 import { LinesBuilder } from '../../../Meshes/Builders/linesBuilder';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-controller-teleportation";
-
 /**
  * The options container for the teleportation module
  */
@@ -85,11 +83,11 @@ export interface IWebXRTeleportationOptions {
  * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  * the input of the attached controllers.
  */
-export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.TELEPORTATION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 3 - 8
src/Cameras/XR/features/WebXRHitTestLegacy.ts

@@ -1,15 +1,10 @@
-import { IWebXRFeature, WebXRFeaturesManager } from '../webXRFeaturesManager';
+import { WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Vector3, Matrix } from '../../../Maths/math.vector';
 import { TransformNode } from '../../../Meshes/transformNode';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-/**
- * name of module (can be reused with other versions)
- */
-const WebXRHitTestModuleName = "xr-hit-test";
-
 // the plugin is registered at the end of the file
 
 /**
@@ -45,12 +40,12 @@ export interface IWebXRHitResult {
  * Hit test (or raycasting) is used to interact with the real world.
  * For further information read here - https://github.com/immersive-web/hit-test
  */
-export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRHitTestLegacy extends WebXRAbstractFeature {
 
     /**
      * The module's name
      */
-    public static readonly Name = WebXRHitTestModuleName;
+    public static readonly Name = WebXRFeatureName.HIT_TEST;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 3 - 5
src/Cameras/XR/features/WebXRPlaneDetector.ts

@@ -1,12 +1,10 @@
-import { WebXRFeaturesManager, IWebXRFeature } from '../webXRFeaturesManager';
+import { WebXRFeaturesManager, WebXRFeatureName } from '../webXRFeaturesManager';
 import { TransformNode } from '../../../Meshes/transformNode';
 import { WebXRSessionManager } from '../webXRSessionManager';
 import { Observable } from '../../../Misc/observable';
 import { Vector3, Matrix } from '../../../Maths/math.vector';
 import { WebXRAbstractFeature } from './WebXRAbstractFeature';
 
-const Name = "xr-plane-detector";
-
 /**
  * Options used in the plane detector module
  */
@@ -47,12 +45,12 @@ let planeIdProvider = 0;
  * The plane detector is used to detect planes in the real world when in AR
  * For more information see https://github.com/immersive-web/real-world-geometry/
  */
-export class WebXRPlaneDetector extends WebXRAbstractFeature implements IWebXRFeature {
+export class WebXRPlaneDetector extends WebXRAbstractFeature {
 
     /**
      * The module's name
      */
-    public static readonly Name = Name;
+    public static readonly Name = WebXRFeatureName.PLANE_DETECTION;
     /**
      * The (Babylon) version of this module.
      * This is an integer representing the implementation version.

+ 4 - 9
src/Cameras/XR/webXRCamera.ts

@@ -12,11 +12,6 @@ import { Viewport } from '../../Maths/math.viewport';
  */
 export class WebXRCamera extends FreeCamera {
 
-    /**
-     * Is the camera in debug mode. Used when using an emulator
-     */
-    public debugMode = false;
-
     private _firstFrame = false;
     private _referencedPosition: Vector3 = new Vector3();
     private _referenceQuaternion: Quaternion = Quaternion.Identity();
@@ -78,7 +73,10 @@ export class WebXRCamera extends FreeCamera {
      * @param otherCamera the non-vr camera to copy the transformation from
      * @param resetToBaseReferenceSpace should XR reset to the base reference space
      */
-    public setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace: boolean = true) {
+    public setTransformationFromNonVRCamera(otherCamera: Camera = this.getScene().activeCamera!, resetToBaseReferenceSpace: boolean = true) {
+        if (!otherCamera || otherCamera === this) {
+            return;
+        }
         const mat = otherCamera.computeWorldMatrix();
         mat.decompose(undefined, this.rotationQuaternion, this.position);
         // set the ground level
@@ -250,9 +248,6 @@ export class WebXRCamera extends FreeCamera {
                 currentRig.viewport.x = viewport.x / width;
                 currentRig.viewport.y = viewport.y / height;
             }
-            if (this.debugMode) {
-                this._updateForDualEyeDebugging();
-            }
 
             // Set cameras to render to the session's render target
             currentRig.outputRenderTarget = this._xrSessionManager.getRenderTargetTextureForEye(view.eye);

+ 6 - 1
src/Cameras/XR/webXRExperienceHelper.ts

@@ -23,6 +23,9 @@ export class WebXRExperienceHelper implements IDisposable {
     public state: WebXRState = WebXRState.NOT_IN_XR;
 
     private _setState(val: WebXRState) {
+        if (this.state === val) {
+            return;
+        }
         this.state = val;
         this.onStateChangedObservable.notifyObservers(this.state);
     }
@@ -63,6 +66,7 @@ export class WebXRExperienceHelper implements IDisposable {
             helper._supported = true;
             return helper;
         }).catch((e) => {
+            helper._setState(WebXRState.NOT_IN_XR);
             helper.dispose();
             throw e;
         });
@@ -110,7 +114,7 @@ export class WebXRExperienceHelper implements IDisposable {
         return this.sessionManager.isSessionSupportedAsync(sessionMode).then(() => {
             return this.sessionManager.initializeSessionAsync(sessionMode, sessionCreationOptions);
         }).then(() => {
-            return this.sessionManager.setReferenceSpaceAsync(referenceSpaceType);
+            return this.sessionManager.setReferenceSpaceTypeAsync(referenceSpaceType);
         }).then(() => {
             return renderTarget.initializeXRLayerAsync(this.sessionManager.session);
         }).then(() => {
@@ -154,6 +158,7 @@ export class WebXRExperienceHelper implements IDisposable {
         }).catch((e: any) => {
             console.log(e);
             console.log(e.message);
+            this._setState(WebXRState.NOT_IN_XR);
             throw (e);
         });
     }

+ 53 - 7
src/Cameras/XR/webXRFeaturesManager.ts

@@ -10,12 +10,17 @@ export interface IWebXRFeature extends IDisposable {
      */
     attached: boolean;
     /**
+     * Should auto-attach be disabled?
+     */
+    disableAutoAttach: boolean;
+    /**
      * Attach the feature to the session
      * Will usually be called by the features manager
      *
+     * @param force should attachment be forced (even when already attached)
      * @returns true if successful.
      */
-    attach(): boolean;
+    attach(force?: boolean): boolean;
     /**
      * Detach the feature from the session
      * Will usually be called by the features manager
@@ -26,6 +31,36 @@ export interface IWebXRFeature extends IDisposable {
 }
 
 /**
+ * A list of the currently available features without referencing them
+ */
+export class WebXRFeatureName {
+    /**
+     * The name of the hit test feature
+     */
+    public static HIT_TEST = "xr-hit-test";
+    /**
+     * The name of the anchor system feature
+     */
+    public static ANCHOR_SYSTEM = "xr-anchor-system";
+    /**
+     * The name of the background remover feature
+     */
+    public static BACKGROUND_REMOVER = "xr-background-remover";
+    /**
+     * The name of the pointer selection feature
+     */
+    public static POINTER_SELECTION = "xr-controller-pointer-selection";
+    /**
+     * The name of the teleportation feature
+     */
+    public static TELEPORTATION = "xr-controller-teleportation";
+    /**
+     * The name of the plane detection feature
+     */
+    public static PLANE_DETECTION = "xr-plane-detection";
+}
+
+/**
  * Defining the constructor of a feature. Used to register the modules.
  */
 export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
@@ -139,7 +174,7 @@ export class WebXRFeaturesManager implements IDisposable {
         this._xrSessionManager.onXRSessionInit.add(() => {
             this.getEnabledFeatures().forEach((featureName) => {
                 const feature = this._features[featureName];
-                if (feature.enabled && !feature.featureImplementation.attached) {
+                if (feature.enabled && !feature.featureImplementation.attached && !feature.featureImplementation.disableAutoAttach) {
                     this.attachFeature(featureName);
                 }
             });
@@ -171,12 +206,18 @@ export class WebXRFeaturesManager implements IDisposable {
         const name = typeof featureName === 'string' ? featureName : featureName.Name;
         let versionToLoad = 0;
         if (typeof version === 'string') {
+            if (!version) {
+                throw new Error(`Error in provided version - ${name} (${version})`);
+            }
             if (version === 'stable') {
                 versionToLoad = WebXRFeaturesManager.GetStableVersionOfFeature(name);
             } else if (version === 'latest') {
                 versionToLoad = WebXRFeaturesManager.GetLatestVersionOfFeature(name);
+            } else {
+                // try loading the number the string represents
+                versionToLoad = +version;
             }
-            if (versionToLoad === -1) {
+            if (versionToLoad === -1 || isNaN(versionToLoad)) {
                 throw new Error(`feature not found - ${name} (${version})`);
             }
         } else {
@@ -201,10 +242,15 @@ export class WebXRFeaturesManager implements IDisposable {
             version: versionToLoad
         };
 
-        // if session started already, request and enable
-        if (this._xrSessionManager.session && !feature.featureImplementation.attached && attachIfPossible) {
-            // enable feature
-            this.attachFeature(name);
+        if (attachIfPossible) {
+            // if session started already, request and enable
+            if (this._xrSessionManager.session && !feature.featureImplementation.attached) {
+                // enable feature
+                this.attachFeature(name);
+            }
+        } else {
+            // disable auto-attach when session starts
+            this._features[name].featureImplementation.disableAutoAttach = true;
         }
 
         return this._features[name].featureImplementation;

+ 7 - 6
src/Cameras/XR/webXRSessionManager.ts

@@ -139,17 +139,18 @@ export class WebXRSessionManager implements IDisposable {
 
             // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
             this.session.addEventListener("end", () => {
+                const engine = this.scene.getEngine();
                 this._sessionEnded = true;
                 // Remove render target texture and notify frame obervers
                 this._rttProvider = null;
 
                 // Restore frame buffer to avoid clear on xr framebuffer after session end
-                this.scene.getEngine().restoreDefaultFramebuffer();
+                engine.restoreDefaultFramebuffer();
 
                 // Need to restart render loop as after the session is ended the last request for new frame will never call callback
-                this.scene.getEngine().customAnimationFrameRequester = null;
+                engine.customAnimationFrameRequester = null;
                 this.onXRSessionEnded.notifyObservers(null);
-                this.scene.getEngine()._renderLoop();
+                engine._renderLoop();
             }, { once: true });
             return this.session;
         });
@@ -157,11 +158,11 @@ export class WebXRSessionManager implements IDisposable {
 
     /**
      * Sets the reference space on the xr session
-     * @param referenceSpace space to set
+     * @param referenceSpaceType space to set
      * @returns a promise that will resolve once the reference space has been set
      */
-    public setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType = "local-floor"): Promise<XRReferenceSpace> {
-        return this.session.requestReferenceSpace(referenceSpace).then((referenceSpace: XRReferenceSpace) => {
+    public setReferenceSpaceTypeAsync(referenceSpaceType: XRReferenceSpaceType = "local-floor"): Promise<XRReferenceSpace> {
+        return this.session.requestReferenceSpace(referenceSpaceType).then((referenceSpace: XRReferenceSpace) => {
             return referenceSpace;
         }, (rejectionReason) => {
             Logger.Error("XR.requestReferenceSpace failed for the following reason: ");

+ 5 - 4
src/Engines/thinEngine.ts

@@ -132,14 +132,14 @@ export class ThinEngine {
      */
     // Not mixed with Version for tooling purpose.
     public static get NpmPackage(): string {
-        return "babylonjs@4.1.0-beta.20";
+        return "babylonjs@4.1.0-beta.22";
     }
 
     /**
      * Returns the current version of the framework
      */
     public static get Version(): string {
-        return "4.1.0-beta.20";
+        return "4.1.0-beta.22";
     }
 
     /**
@@ -1590,7 +1590,8 @@ export class ThinEngine {
         }
     }
 
-    private _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void {
+    /** @hidden */
+    public _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void {
         if (indexBuffer == null) {
             return;
         }
@@ -3141,7 +3142,7 @@ export class ThinEngine {
             this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(wrapV), texture);
             texture._cachedWrapV = wrapV;
         }
-        if (wrapR) {
+        if ((texture.is2DArray || texture.is3D) && wrapR) {
             this._setTextureParameterInteger(target, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(wrapR), texture);
             texture._cachedWrapR = wrapR;
         }

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 91 - 927
src/Lights/Shadows/cascadedShadowGenerator.ts


+ 163 - 123
src/Lights/Shadows/shadowGenerator.ts

@@ -135,6 +135,12 @@ export interface IShadowGenerator {
  * Documentation: https://doc.babylonjs.com/babylon101/shadows
  */
 export class ShadowGenerator implements IShadowGenerator {
+
+    /**
+     * Name of the shadow generator class
+     */
+    public static CLASSNAME = "ShadowGenerator";
+
     /**
      * Shadow generator mode None: no filtering applied.
      */
@@ -232,7 +238,7 @@ export class ShadowGenerator implements IShadowGenerator {
      */
     public onAfterShadowMapRenderMeshObservable = new Observable<Mesh>();
 
-    private _bias = 0.00005;
+    protected _bias = 0.00005;
     /**
      * Gets the bias: offset applied on the depth preventing acnea (in light direction).
      */
@@ -246,7 +252,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._bias = bias;
     }
 
-    private _normalBias = 0;
+    protected _normalBias = 0;
     /**
      * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
      */
@@ -260,7 +266,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._normalBias = normalBias;
     }
 
-    private _blurBoxOffset = 1;
+    protected _blurBoxOffset = 1;
     /**
      * Gets the blur box offset: offset applied during the blur pass.
      * Only useful if useKernelBlur = false
@@ -281,7 +287,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._disposeBlurPostProcesses();
     }
 
-    private _blurScale = 2;
+    protected _blurScale = 2;
     /**
      * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
      * 2 means half of the size.
@@ -302,7 +308,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._disposeBlurPostProcesses();
     }
 
-    private _blurKernel = 1;
+    protected _blurKernel = 1;
     /**
      * Gets the blur kernel: kernel size of the blur pass.
      * Only useful if useKernelBlur = true
@@ -323,7 +329,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._disposeBlurPostProcesses();
     }
 
-    private _useKernelBlur = false;
+    protected _useKernelBlur = false;
     /**
      * Gets whether the blur pass is a kernel blur (if true) or box blur.
      * Only useful in filtered mode (useBlurExponentialShadowMap...)
@@ -344,7 +350,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._disposeBlurPostProcesses();
     }
 
-    private _depthScale: number;
+    protected _depthScale: number;
     /**
      * Gets the depth scale used in ESM mode.
      */
@@ -359,7 +365,11 @@ export class ShadowGenerator implements IShadowGenerator {
         this._depthScale = value;
     }
 
-    private _filter = ShadowGenerator.FILTER_NONE;
+    protected _validateFilter(filter: number): number {
+        return filter;
+    }
+
+    protected _filter = ShadowGenerator.FILTER_NONE;
     /**
      * Gets the current mode of the shadow generator (normal, PCF, ESM...).
      * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
@@ -372,6 +382,8 @@ export class ShadowGenerator implements IShadowGenerator {
      * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
      */
     public set filter(value: number) {
+        value = this._validateFilter(value);
+
         // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
         if (this._light.needCube()) {
             if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
@@ -417,11 +429,13 @@ export class ShadowGenerator implements IShadowGenerator {
      * Sets the current filter to Poisson Sampling.
      */
     public set usePoissonSampling(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_POISSONSAMPLING);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
             return;
         }
 
-        this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
     /**
@@ -434,10 +448,12 @@ export class ShadowGenerator implements IShadowGenerator {
      * Sets the current filter is to ESM.
      */
     public set useExponentialShadowMap(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
     /**
@@ -450,10 +466,12 @@ export class ShadowGenerator implements IShadowGenerator {
      * Gets if the current filter is set to filtered  ESM.
      */
     public set useBlurExponentialShadowMap(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
     /**
@@ -468,10 +486,12 @@ export class ShadowGenerator implements IShadowGenerator {
      * exponential to prevent steep falloff artifacts).
      */
     public set useCloseExponentialShadowMap(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
     /**
@@ -486,10 +506,12 @@ export class ShadowGenerator implements IShadowGenerator {
      * exponential to prevent steep falloff artifacts).
      */
     public set useBlurCloseExponentialShadowMap(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
     /**
@@ -502,13 +524,15 @@ export class ShadowGenerator implements IShadowGenerator {
      * Sets the current filter to "PCF" (percentage closer filtering).
      */
     public set usePercentageCloserFiltering(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_PCF);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
-    private _filteringQuality = ShadowGenerator.QUALITY_HIGH;
+    protected _filteringQuality = ShadowGenerator.QUALITY_HIGH;
     /**
      * Gets the PCF or PCSS Quality.
      * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
@@ -542,13 +566,15 @@ export class ShadowGenerator implements IShadowGenerator {
      * Sets the current filter to "PCSS" (contact hardening).
      */
     public set useContactHardeningShadow(value: boolean) {
+        let filter = this._validateFilter(ShadowGenerator.FILTER_PCSS);
+
         if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
             return;
         }
-        this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
+        this.filter = (value ? filter : ShadowGenerator.FILTER_NONE);
     }
 
-    private _contactHardeningLightSizeUVRatio = 0.1;
+    protected _contactHardeningLightSizeUVRatio = 0.1;
     /**
      * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
      * Using a ratio helps keeping shape stability independently of the map size.
@@ -574,7 +600,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
     }
 
-    private _darkness = 0;
+    protected _darkness = 0;
 
     /** Gets or sets the actual darkness of a shadow */
     public get darkness() {
@@ -611,7 +637,7 @@ export class ShadowGenerator implements IShadowGenerator {
         return this;
     }
 
-    private _transparencyShadow = false;
+    protected _transparencyShadow = false;
 
     /** Gets or sets the ability to have transparent shadow  */
     public get transparencyShadow() {
@@ -632,8 +658,9 @@ export class ShadowGenerator implements IShadowGenerator {
         return this;
     }
 
-    private _shadowMap: Nullable<RenderTargetTexture>;
-    private _shadowMap2: Nullable<RenderTargetTexture>;
+    protected _shadowMap: Nullable<RenderTargetTexture>;
+    protected _shadowMap2: Nullable<RenderTargetTexture>;
+
     /**
      * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
      * @returns The render target texture if present otherwise, null
@@ -641,6 +668,7 @@ export class ShadowGenerator implements IShadowGenerator {
     public getShadowMap(): Nullable<RenderTargetTexture> {
         return this._shadowMap;
     }
+
     /**
      * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
      * @returns The render target texture if the shadow map is present otherwise, null
@@ -658,7 +686,7 @@ export class ShadowGenerator implements IShadowGenerator {
      * @returns "ShadowGenerator"
      */
     public getClassName(): string {
-        return "ShadowGenerator";
+        return ShadowGenerator.CLASSNAME;
     }
 
     /**
@@ -713,11 +741,10 @@ export class ShadowGenerator implements IShadowGenerator {
 
     /**
      * Controls the extent to which the shadows fade out at the edge of the frustum
-     * Used only by directionals and spots
      */
     public frustumEdgeFalloff = 0;
 
-    private _light: IShadowLight;
+    protected _light: IShadowLight;
     /**
      * Returns the associated light object.
      * @returns the light generating the shadow
@@ -733,28 +760,28 @@ export class ShadowGenerator implements IShadowGenerator {
      */
     public forceBackFacesOnly = false;
 
-    private _scene: Scene;
-    private _lightDirection = Vector3.Zero();
-
-    private _effect: Effect;
-
-    private _viewMatrix = Matrix.Zero();
-    private _projectionMatrix = Matrix.Zero();
-    private _transformMatrix = Matrix.Zero();
-    private _cachedPosition: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-    private _cachedDirection: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
-    private _cachedDefines: string;
-    private _currentRenderID: number;
-    private _boxBlurPostprocess: Nullable<PostProcess>;
-    private _kernelBlurXPostprocess: Nullable<PostProcess>;
-    private _kernelBlurYPostprocess: Nullable<PostProcess>;
-    private _blurPostProcesses: PostProcess[];
-    private _mapSize: number;
-    private _currentFaceIndex = 0;
-    private _currentFaceIndexCache = 0;
-    private _textureType: number;
-    private _defaultTextureMatrix = Matrix.Identity();
-    private _storedUniqueId: Nullable<number>;
+    protected _scene: Scene;
+    protected _lightDirection = Vector3.Zero();
+
+    protected _effect: Effect;
+
+    protected _viewMatrix = Matrix.Zero();
+    protected _projectionMatrix = Matrix.Zero();
+    protected _transformMatrix = Matrix.Zero();
+    protected _cachedPosition: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+    protected _cachedDirection: Vector3 = new Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
+    protected _cachedDefines: string;
+    protected _currentRenderID: number;
+    protected _boxBlurPostprocess: Nullable<PostProcess>;
+    protected _kernelBlurXPostprocess: Nullable<PostProcess>;
+    protected _kernelBlurYPostprocess: Nullable<PostProcess>;
+    protected _blurPostProcesses: PostProcess[];
+    protected _mapSize: number;
+    protected _currentFaceIndex = 0;
+    protected _currentFaceIndexCache = 0;
+    protected _textureType: number;
+    protected _defaultTextureMatrix = Matrix.Identity();
+    protected _storedUniqueId: Nullable<number>;
 
     /** @hidden */
     public static _SceneComponentInitialization: (scene: Scene) => void = (_) => {
@@ -807,13 +834,12 @@ export class ShadowGenerator implements IShadowGenerator {
         this._applyFilterValues();
     }
 
-    private _initializeGenerator(): void {
+    protected _initializeGenerator(): void {
         this._light._markMeshesAsLightDirty();
         this._initializeShadowMap();
     }
 
-    private _initializeShadowMap(): void {
-        // Render target
+    protected _createTargetRenderTexture(): void {
         let engine = this._scene.getEngine();
         if (engine.webGLVersion > 1) {
             this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube(), undefined, false, false);
@@ -822,6 +848,15 @@ export class ShadowGenerator implements IShadowGenerator {
         else {
             this._shadowMap = new RenderTargetTexture(this._light.name + "_shadowMap", this._mapSize, this._scene, false, true, this._textureType, this._light.needCube());
         }
+    }
+
+    protected _initializeShadowMap(): void {
+        this._createTargetRenderTexture();
+
+        if (this._shadowMap === null) {
+            return;
+        }
+
         this._shadowMap.wrapU = Texture.CLAMP_ADDRESSMODE;
         this._shadowMap.wrapV = Texture.CLAMP_ADDRESSMODE;
         this._shadowMap.anisotropicFilteringLevel = 1;
@@ -832,6 +867,11 @@ export class ShadowGenerator implements IShadowGenerator {
             this._shadowMap.uniqueId = this._storedUniqueId;
         }
 
+        // Custom render function.
+        this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
+
+        let engine = this._scene.getEngine();
+
         // Record Face Index before render.
         this._shadowMap.onBeforeRenderObservable.add((faceIndex: number) => {
             this._currentFaceIndex = faceIndex;
@@ -840,9 +880,6 @@ export class ShadowGenerator implements IShadowGenerator {
             }
         });
 
-        // Custom render function.
-        this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
-
         // Blur if required afer render.
         this._shadowMap.onAfterUnbindObservable.add(() => {
             if (this._filter === ShadowGenerator.FILTER_PCF) {
@@ -873,6 +910,7 @@ export class ShadowGenerator implements IShadowGenerator {
             }
         });
 
+        // Recreate on resize.
         this._shadowMap.onResizeObservable.add((RTT) => {
             this._storedUniqueId = this._shadowMap!.uniqueId;
             this._mapSize = RTT.getRenderSize();
@@ -881,7 +919,7 @@ export class ShadowGenerator implements IShadowGenerator {
         });
     }
 
-    private _initializeBlurRTTAndPostProcesses(): void {
+    protected _initializeBlurRTTAndPostProcesses(): void {
         var engine = this._scene.getEngine();
         var targetSize = this._mapSize / this.blurScale;
 
@@ -925,7 +963,7 @@ export class ShadowGenerator implements IShadowGenerator {
         }
     }
 
-    private _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void {
+    protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void {
         var index: number;
         let engine = this._scene.getEngine();
 
@@ -953,7 +991,10 @@ export class ShadowGenerator implements IShadowGenerator {
         }
     }
 
-    private _renderSubMeshForShadowMap(subMesh: SubMesh): void {
+    protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void {
+    }
+
+    protected _renderSubMeshForShadowMap(subMesh: SubMesh): void {
         var mesh = subMesh.getRenderingMesh();
         var scene = this._scene;
         var engine = scene.getEngine();
@@ -1023,6 +1064,8 @@ export class ShadowGenerator implements IShadowGenerator {
             // Morph targets
             MaterialHelper.BindMorphTargetParameters(mesh, this._effect);
 
+            this._bindCustomEffectForRenderSubMeshForShadowMap(subMesh, this._effect);
+
             if (this.forceBackFacesOnly) {
                 engine.setState(true, 0, false, true);
             }
@@ -1051,7 +1094,7 @@ export class ShadowGenerator implements IShadowGenerator {
         }
     }
 
-    private _applyFilterValues(): void {
+    protected _applyFilterValues(): void {
         if (!this._shadowMap) {
             return;
         }
@@ -1136,6 +1179,9 @@ export class ShadowGenerator implements IShadowGenerator {
         });
     }
 
+    protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void {
+    }
+
     /**
      * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
      * @param subMesh The submesh we want to render in the shadow map
@@ -1244,6 +1290,8 @@ export class ShadowGenerator implements IShadowGenerator {
             }
         }
 
+        this._isReadyCustomDefines(defines, subMesh, useInstances);
+
         // Get correct effect
         var join = defines.join("\n");
         if (this._cachedDefines !== join) {
@@ -1336,7 +1384,7 @@ export class ShadowGenerator implements IShadowGenerator {
             }
             // else default to high.
         }
-        if (this.usePercentageCloserFiltering) {
+        else if (this.usePercentageCloserFiltering) {
             defines["SHADOWPCF" + lightIndex] = true;
             if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
                 defines["SHADOWLOWQUALITY" + lightIndex] = true;
@@ -1368,19 +1416,19 @@ export class ShadowGenerator implements IShadowGenerator {
      * @param effect The effect we are binfing the information for
      */
     public bindShadowLight(lightIndex: string, effect: Effect): void {
-        var light = this._light;
-        var scene = this._scene;
+        const light = this._light;
+        const scene = this._scene;
 
         if (!scene.shadowsEnabled || !light.shadowEnabled) {
             return;
         }
 
-        let camera = scene.activeCamera;
+        const camera = scene.activeCamera;
         if (!camera) {
             return;
         }
 
-        let shadowMap = this.getShadowMap();
+        const shadowMap = this.getShadowMap();
 
         if (!shadowMap) {
             return;
@@ -1479,7 +1527,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._shadowMap!.renderList = renderList;
     }
 
-    private _disposeBlurPostProcesses(): void {
+    protected _disposeBlurPostProcesses(): void {
         if (this._shadowMap2) {
             this._shadowMap2.dispose();
             this._shadowMap2 = null;
@@ -1503,7 +1551,7 @@ export class ShadowGenerator implements IShadowGenerator {
         this._blurPostProcesses = [];
     }
 
-    private _disposeRTTandPostProcesses(): void {
+    protected _disposeRTTandPostProcesses(): void {
         if (this._shadowMap) {
             this._shadowMap.dispose();
             this._shadowMap = null;
@@ -1542,30 +1590,29 @@ export class ShadowGenerator implements IShadowGenerator {
             return serializationObject;
         }
 
+        serializationObject.className = this.getClassName();
         serializationObject.lightId = this._light.id;
         serializationObject.mapSize = shadowMap.getRenderSize();
+        serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
+        serializationObject.darkness = this.getDarkness();
+        serializationObject.transparencyShadow = this._transparencyShadow;
+        serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
+        serializationObject.bias = this.bias;
+        serializationObject.normalBias = this.normalBias;
+        serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
+        serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
+        serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
+        serializationObject.filteringQuality = this.filteringQuality;
         serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
         serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
         serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
         serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
         serializationObject.usePoissonSampling = this.usePoissonSampling;
-        serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
         serializationObject.depthScale = this.depthScale;
-        serializationObject.darkness = this.getDarkness();
         serializationObject.blurBoxOffset = this.blurBoxOffset;
         serializationObject.blurKernel = this.blurKernel;
         serializationObject.blurScale = this.blurScale;
         serializationObject.useKernelBlur = this.useKernelBlur;
-        serializationObject.transparencyShadow = this._transparencyShadow;
-        serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
-
-        serializationObject.bias = this.bias;
-        serializationObject.normalBias = this.normalBias;
-
-        serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
-        serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
-        serializationObject.filteringQuality = this.filteringQuality;
-        serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
 
         serializationObject.renderList = [];
         if (shadowMap.renderList) {
@@ -1583,11 +1630,12 @@ export class ShadowGenerator implements IShadowGenerator {
      * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
      * @param parsedShadowGenerator The JSON object to parse
      * @param scene The scene to create the shadow map for
+     * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
      * @returns The parsed shadow generator
      */
-    public static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator {
+    public static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator {
         var light = <IShadowLight>scene.getLightByID(parsedShadowGenerator.lightId);
-        var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
+        var shadowGenerator = constr ? constr(parsedShadowGenerator.mapSize, light) : new ShadowGenerator(parsedShadowGenerator.mapSize, light);
         var shadowMap = shadowGenerator.getShadowMap();
 
         for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
@@ -1603,42 +1651,56 @@ export class ShadowGenerator implements IShadowGenerator {
             });
         }
 
-        if (parsedShadowGenerator.usePoissonSampling) {
-            shadowGenerator.usePoissonSampling = true;
+        shadowGenerator.forceBackFacesOnly = !!parsedShadowGenerator.forceBackFacesOnly;
+
+        if (parsedShadowGenerator.darkness !== undefined) {
+            shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
         }
-        else if (parsedShadowGenerator.useExponentialShadowMap) {
-            shadowGenerator.useExponentialShadowMap = true;
+
+        if (parsedShadowGenerator.transparencyShadow) {
+            shadowGenerator.setTransparencyShadow(true);
         }
-        else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
-            shadowGenerator.useBlurExponentialShadowMap = true;
+
+        if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
+            shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
         }
-        else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
-            shadowGenerator.useCloseExponentialShadowMap = true;
+
+        if (parsedShadowGenerator.bias !== undefined) {
+            shadowGenerator.bias = parsedShadowGenerator.bias;
         }
-        else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
-            shadowGenerator.useBlurCloseExponentialShadowMap = true;
+
+        if (parsedShadowGenerator.normalBias !== undefined) {
+            shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
         }
-        else if (parsedShadowGenerator.usePercentageCloserFiltering) {
+
+        if (parsedShadowGenerator.usePercentageCloserFiltering) {
             shadowGenerator.usePercentageCloserFiltering = true;
-        }
-        else if (parsedShadowGenerator.useContactHardeningShadow) {
+        } else if (parsedShadowGenerator.useContactHardeningShadow) {
             shadowGenerator.useContactHardeningShadow = true;
+        } else if (parsedShadowGenerator.usePoissonSampling) {
+            shadowGenerator.usePoissonSampling = true;
+        } else if (parsedShadowGenerator.useExponentialShadowMap) {
+            shadowGenerator.useExponentialShadowMap = true;
+        } else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
+            shadowGenerator.useBlurExponentialShadowMap = true;
+        } else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
+            shadowGenerator.useCloseExponentialShadowMap = true;
+        } else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
+            shadowGenerator.useBlurCloseExponentialShadowMap = true;
+        } else
+        // Backward compat
+        if (parsedShadowGenerator.useVarianceShadowMap) {
+            shadowGenerator.useExponentialShadowMap = true;
+        } else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
+            shadowGenerator.useBlurExponentialShadowMap = true;
         }
 
-        if (parsedShadowGenerator.filteringQuality) {
-            shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
-        }
-
-        if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
+        if (parsedShadowGenerator.contactHardeningLightSizeUVRatio !== undefined) {
             shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
         }
 
-        // Backward compat
-        else if (parsedShadowGenerator.useVarianceShadowMap) {
-            shadowGenerator.useExponentialShadowMap = true;
-        }
-        else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
-            shadowGenerator.useBlurExponentialShadowMap = true;
+        if (parsedShadowGenerator.filteringQuality !== undefined) {
+            shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
         }
 
         if (parsedShadowGenerator.depthScale) {
@@ -1661,28 +1723,6 @@ export class ShadowGenerator implements IShadowGenerator {
             shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
         }
 
-        if (parsedShadowGenerator.bias !== undefined) {
-            shadowGenerator.bias = parsedShadowGenerator.bias;
-        }
-
-        if (parsedShadowGenerator.normalBias !== undefined) {
-            shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
-        }
-
-        if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
-            shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
-        }
-
-        if (parsedShadowGenerator.darkness) {
-            shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
-        }
-
-        if (parsedShadowGenerator.transparencyShadow) {
-            shadowGenerator.setTransparencyShadow(true);
-        }
-
-        shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
-
         return shadowGenerator;
     }
 }

+ 0 - 8
src/Lights/Shadows/shadowGeneratorSceneComponent.ts

@@ -127,11 +127,3 @@ ShadowGenerator._SceneComponentInitialization = (scene: Scene) => {
         scene._addComponent(component);
     }
 };
-
-CascadedShadowGenerator._SceneComponentInitialization = (scene: Scene) => {
-    let component = scene._getComponent(SceneComponentConstants.NAME_SHADOWGENERATOR);
-    if (!component) {
-        component = new ShadowGeneratorSceneComponent(scene);
-        scene._addComponent(component);
-    }
-};

+ 4 - 0
src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts

@@ -215,6 +215,10 @@ export class MorphTargetsBlock extends NodeMaterialBlock {
                 if (hasTangents) {
                     state.attributes.push(VertexBuffer.TangentKind + index);
                 }
+
+                if (hasUVs) {
+                    state.attributes.push(VertexBuffer.UVKind + "_" + index);
+                }
             }
         }
     }

+ 2 - 0
src/Materials/Node/Blocks/colorSplitterBlock.ts

@@ -25,6 +25,8 @@ export class ColorSplitterBlock extends NodeMaterialBlock {
         this.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float);
         this.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float);
         this.registerOutput("a", NodeMaterialBlockConnectionPointTypes.Float);
+
+        this.inputsAreExclusive = true;
     }
 
     /**

+ 2 - 0
src/Materials/Node/Blocks/vectorSplitterBlock.ts

@@ -27,6 +27,8 @@ export class VectorSplitterBlock extends NodeMaterialBlock {
         this.registerOutput("y", NodeMaterialBlockConnectionPointTypes.Float);
         this.registerOutput("z", NodeMaterialBlockConnectionPointTypes.Float);
         this.registerOutput("w", NodeMaterialBlockConnectionPointTypes.Float);
+
+        this.inputsAreExclusive = true;
     }
 
     /**

+ 3 - 0
src/Materials/Node/nodeMaterialBlock.ts

@@ -24,6 +24,9 @@ export class NodeMaterialBlock {
     private _isInput = false;
     protected _isUnique = false;
 
+    /** Gets or sets a boolean indicating that only one input can be connected at a time */
+    public inputsAreExclusive = false;
+
     /** @hidden */
     public _codeVariableName = "";
 

+ 6 - 1
src/Materials/Node/nodeMaterialBlockConnectionPoint.ts

@@ -91,6 +91,11 @@ export class NodeMaterialConnectionPoint {
         this._associatedVariableName = value;
     }
 
+    /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
+    public get innerType() {
+        return this._type;
+    }
+
     /**
      * Gets or sets the connection point type (default is float)
      */
@@ -330,7 +335,7 @@ export class NodeMaterialConnectionPoint {
             }
         }
 
-        if (this.type !== connectionPoint.type && connectionPoint.type !== NodeMaterialBlockConnectionPointTypes.AutoDetect) {
+        if (this.type !== connectionPoint.type && connectionPoint.innerType !== NodeMaterialBlockConnectionPointTypes.AutoDetect) {
             // Equivalents
             switch (this.type) {
                 case NodeMaterialBlockConnectionPointTypes.Vector3: {

+ 4 - 0
src/Materials/shaderMaterial.ts

@@ -651,6 +651,10 @@ export class ShaderMaterial extends Material {
                 }
             }
 
+            if (this.getScene().activeCamera && this._options.uniforms.indexOf("cameraPosition") !== -1) {
+                this._effect.setVector3("cameraPosition", this.getScene().activeCamera!.globalPosition);
+            }
+
             // Bones
             MaterialHelper.BindBonesParameters(mesh, this._effect);
 

+ 3 - 2
src/Meshes/Builders/linesBuilder.ts

@@ -202,6 +202,7 @@ export class LinesBuilder {
      * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
      * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
      * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines
+     * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
      * * When updating an instance, remember that only point positions can change, not the number of points
      * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
      * @param name defines the name of the mesh
@@ -210,7 +211,7 @@ export class LinesBuilder {
      * @returns the dashed line mesh
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
      */
-    public static CreateDashedLines(name: string, options: { points: Vector3[], dashSize?: number, gapSize?: number, dashNb?: number, updatable?: boolean, instance?: LinesMesh }, scene: Nullable<Scene> = null): LinesMesh {
+    public static CreateDashedLines(name: string, options: { points: Vector3[], dashSize?: number, gapSize?: number, dashNb?: number, updatable?: boolean, instance?: LinesMesh, useVertexAlpha?: boolean }, scene: Nullable<Scene> = null): LinesMesh {
         var points = options.points;
         var instance = options.instance;
         var gapSize = options.gapSize || 1;
@@ -264,7 +265,7 @@ export class LinesBuilder {
             return instance;
         }
         // dashed lines creation
-        var dashedLines = new LinesMesh(name, scene);
+        var dashedLines = new LinesMesh(name, scene, null, undefined, undefined, undefined, options.useVertexAlpha);
         var vertexData = VertexData.CreateDashedLines(options);
         vertexData.applyToMesh(dashedLines, options.updatable);
 

+ 4 - 10
src/Meshes/mesh.ts

@@ -1504,7 +1504,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
         const onlyForInstances = isInIntermediateRendering ? this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate : this._internalAbstractMeshDataInfo._onlyForInstances;
         let batchCache = this._instanceDataStorage.batchCache;
         batchCache.mustReturn = false;
-        batchCache.renderSelf[subMeshId] = !onlyForInstances && this.isEnabled() && this.isVisible;
+        batchCache.renderSelf[subMeshId] = isReplacementMode || (!onlyForInstances && this.isEnabled() && this.isVisible);
         batchCache.visibleInstances[subMeshId] = null;
 
         if (this._instanceDataStorage.visibleInstances && !isReplacementMode) {
@@ -2151,18 +2151,12 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
      * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
      * Note that, under the hood, this method sets a new VertexBuffer each call.
      * @see http://doc.babylonjs.com/resources/baking_transformations
+     * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
      * @returns the current mesh
      */
-    public bakeCurrentTransformIntoVertices(): Mesh {
+    public bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren : boolean = true): Mesh {
         this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
-        this.scaling.copyFromFloats(1, 1, 1);
-        this.position.copyFromFloats(0, 0, 0);
-        this.rotation.copyFromFloats(0, 0, 0);
-        //only if quaternion is already set
-        if (this.rotationQuaternion) {
-            this.rotationQuaternion = Quaternion.Identity();
-        }
-        this._worldMatrix = Matrix.Identity();
+        this.resetLocalMatrix(bakeIndependenlyOfChildren);
         return this;
     }
 

+ 3 - 12
src/Meshes/subMesh.ts

@@ -474,18 +474,9 @@ export class SubMesh extends BaseSubMesh implements ICullable {
             const indexB = indices[index + 1];
             const indexC = indices[index + 2];
 
-            if (checkStopper) {
-                if (indexA === 0xFFFFFFFF) {
-                    continue;
-                }
-                if (indexB === 0xFFFFFFFF) {
-                    index += 1;
-                    continue;
-                }
-                if (indexC === 0xFFFFFFFF) {
-                    index += 2;
-                    continue;
-                }
+            if (checkStopper && indexC === 0xFFFFFFFF) {
+                index += 2;
+                continue;
             }
 
             var p0 = positions[indexA];

+ 8 - 5
src/Meshes/trailMesh.ts

@@ -6,12 +6,13 @@ import { Scene } from "../scene";
 import { Vector3 } from "../Maths/math.vector";
 import { VertexBuffer } from "../Meshes/buffer";
 import { VertexData } from "../Meshes/mesh.vertexData";
+import { TransformNode } from "../Meshes/transformNode";
 
 /**
  * Class used to create a trail following a mesh
  */
 export class TrailMesh extends Mesh {
-    private _generator: AbstractMesh;
+    private _generator: TransformNode;
     private _autoStart: boolean;
     private _running: boolean;
     private _diameter: number;
@@ -24,13 +25,13 @@ export class TrailMesh extends Mesh {
     /**
      * @constructor
      * @param name The value used by scene.getMeshByName() to do a lookup.
-     * @param generator The mesh to generate a trail.
+     * @param generator The mesh or transform node to generate a trail.
      * @param scene The scene to add this mesh to.
      * @param diameter Diameter of trailing mesh. Default is 1.
      * @param length Length of trailing mesh. Default is 60.
      * @param autoStart Automatically start trailing mesh. Default true.
      */
-    constructor(name: string, generator: AbstractMesh, scene: Scene, diameter: number = 1, length: number = 60, autoStart: boolean = true) {
+    constructor(name: string, generator: TransformNode, scene: Scene, diameter: number = 1, length: number = 60, autoStart: boolean = true) {
         super(name, scene);
 
         this._running = false;
@@ -61,8 +62,10 @@ export class TrailMesh extends Mesh {
         let normals: Array<number> = [];
         let indices: Array<number> = [];
         let meshCenter = Vector3.Zero();
-        if (this._generator._boundingInfo) {
+        if (this._generator instanceof AbstractMesh && this._generator._boundingInfo) {
             meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
+        } else {
+            meshCenter = this._generator.position;
         }
         let alpha: number = 2 * Math.PI / this._sectionPolygonPointsCount;
         for (let i: number = 0; i < this._sectionPolygonPointsCount; i++) {
@@ -185,7 +188,7 @@ export class TrailMesh extends Mesh {
      * @param newGenerator use new generator object for cloned trail mesh
      * @returns a new mesh
      */
-    public clone(name: string = "", newGenerator: AbstractMesh): TrailMesh {
+    public clone(name: string = "", newGenerator: TransformNode): TrailMesh {
         return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
     }
 

+ 36 - 0
src/Meshes/transformNode.ts

@@ -1168,6 +1168,42 @@ export class TransformNode extends Node {
         return this._worldMatrix;
     }
 
+    /**
+     * Resets this nodeTransform's local matrix to Matrix.Identity().
+     * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
+     */
+    public resetLocalMatrix(independentOfChildren : boolean = true): void
+    {
+        this.computeWorldMatrix();
+        if (independentOfChildren) {
+            let children = this.getChildren();
+            for (let i = 0; i < children.length; ++i) {
+                let child = children[i] as TransformNode;
+                if (child) {
+                    child.computeWorldMatrix();
+                    let bakedMatrix = TmpVectors.Matrix[0];
+                    child._localMatrix.multiplyToRef(this._localMatrix, bakedMatrix);
+                    let tmpRotationQuaternion = TmpVectors.Quaternion[0];
+                    bakedMatrix.decompose(child.scaling, tmpRotationQuaternion, child.position);
+                    if (child.rotationQuaternion) {
+                        child.rotationQuaternion = tmpRotationQuaternion;
+                    } else {
+                        tmpRotationQuaternion.toEulerAnglesToRef(child.rotation);
+                    }
+                }
+            }
+        }
+        this.scaling.copyFromFloats(1, 1, 1);
+        this.position.copyFromFloats(0, 0, 0);
+        this.rotation.copyFromFloats(0, 0, 0);
+
+        //only if quaternion is already set
+        if (this.rotationQuaternion) {
+            this.rotationQuaternion = Quaternion.Identity();
+        }
+        this._worldMatrix = Matrix.Identity();
+    }
+
     protected _afterComputeWorldMatrix(): void {
     }
 

+ 1 - 1
src/Navigation/INavigationEngine.ts

@@ -17,7 +17,7 @@ export interface INavigationEnginePlugin {
      * @param meshes array of all the geometry used to compute the navigatio mesh
      * @param parameters bunch of parameters used to filter geometry
      */
-    createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
+    createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
 
     /**
      * Create a navigation mesh debug mesh

+ 1 - 1
src/Navigation/Plugins/recastJSPlugin.ts

@@ -52,7 +52,7 @@ export class RecastJSPlugin implements INavigationEnginePlugin {
      * @param meshes array of all the geometry used to compute the navigatio mesh
      * @param parameters bunch of parameters used to filter geometry
      */
-    createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void {
+    createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void {
         const rc = new this.bjsRECAST.rcConfig();
         rc.cs = parameters.cs;
         rc.ch = parameters.ch;