Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

Sebastien Vandenberghe 6 years ago
parent
commit
083e4fb5a2

+ 25 - 25
Playground/babylon.d.txt

@@ -34845,7 +34845,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -38544,7 +38544,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -38574,7 +38574,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -41783,7 +41783,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -47432,7 +47432,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -48962,7 +48962,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -48983,7 +48983,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49024,7 +49024,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49069,7 +49069,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49103,7 +49103,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49193,7 +49193,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -49243,7 +49243,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -49324,7 +49324,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -49347,7 +49347,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -49374,7 +49374,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -49520,7 +49520,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -49554,7 +49554,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -49578,7 +49578,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -49597,7 +49597,7 @@ declare module BABYLON {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -49625,7 +49625,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -49655,7 +49655,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -49680,7 +49680,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -49701,7 +49701,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -49739,7 +49739,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -49773,7 +49773,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal

+ 25 - 25
dist/preview release/babylon.d.ts

@@ -35453,7 +35453,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -39169,7 +39169,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -39199,7 +39199,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -42445,7 +42445,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -48114,7 +48114,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -49651,7 +49651,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -49672,7 +49672,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49713,7 +49713,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49758,7 +49758,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49792,7 +49792,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -49882,7 +49882,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -49932,7 +49932,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -50013,7 +50013,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -50036,7 +50036,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -50063,7 +50063,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -50209,7 +50209,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -50243,7 +50243,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -50267,7 +50267,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -50286,7 +50286,7 @@ declare module BABYLON {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -50314,7 +50314,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -50344,7 +50344,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -50369,7 +50369,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -50390,7 +50390,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -50428,7 +50428,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -50462,7 +50462,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal

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


+ 48 - 3
dist/preview release/babylon.max.js

@@ -699,7 +699,7 @@ var ActionEvent = /** @class */ (function () {
      */
      */
     ActionEvent.CreateNew = function (source, evt, additionalData) {
     ActionEvent.CreateNew = function (source, evt, additionalData) {
         var scene = source.getScene();
         var scene = source.getScene();
-        return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
+        return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
     };
     };
     /**
     /**
      * Helper function to auto-create an ActionEvent from a source sprite
      * Helper function to auto-create an ActionEvent from a source sprite
@@ -28347,9 +28347,14 @@ var PhysicsViewer = /** @class */ (function () {
         return wireframeOver;
         return wireframeOver;
     };
     };
     PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
     PhysicsViewer.prototype._getDebugMesh = function (impostor, targetMesh) {
+        var _this = this;
         if (!this._utilityLayer) {
         if (!this._utilityLayer) {
             return null;
             return null;
         }
         }
+        // Only create child impostor debug meshes when evaluating the parent
+        if (targetMesh && targetMesh.parent && targetMesh.parent.physicsImpostor) {
+            return null;
+        }
         var mesh = null;
         var mesh = null;
         var utilityLayerScene = this._utilityLayer.utilityLayerScene;
         var utilityLayerScene = this._utilityLayer.utilityLayerScene;
         switch (impostor.type) {
         switch (impostor.type) {
@@ -28369,6 +28374,16 @@ var PhysicsViewer = /** @class */ (function () {
                     mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
                     mesh = this._getDebugMeshMesh(targetMesh, utilityLayerScene);
                 }
                 }
                 break;
                 break;
+            case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_6__["PhysicsImpostor"].NoImpostor:
+                if (targetMesh) {
+                    // Handle compound impostors
+                    var childMeshes = targetMesh.getChildMeshes().filter(function (c) { return c.physicsImpostor ? 1 : 0; });
+                    childMeshes.forEach(function (m) {
+                        var a = _this._getDebugBoxMesh(utilityLayerScene);
+                        a.parent = m;
+                    });
+                }
+                break;
         }
         }
         return mesh;
         return mesh;
     };
     };
@@ -82534,6 +82549,8 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
 /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
 /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
 /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
 /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
 /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
+/* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
+
 
 
 
 
 
 
@@ -82808,6 +82825,7 @@ var GroundBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      */
      */
     GroundBuilder.CreateTiledGround = function (name, options, scene) {
     GroundBuilder.CreateTiledGround = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
         var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
         vertexData.applyToMesh(tiledGround, options.updatable);
         vertexData.applyToMesh(tiledGround, options.updatable);
@@ -82833,6 +82851,7 @@ var GroundBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      */
      */
     GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
     GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
+        if (scene === void 0) { scene = null; }
         var width = options.width || 10.0;
         var width = options.width || 10.0;
         var height = options.height || 10.0;
         var height = options.height || 10.0;
         var subdivisions = options.subdivisions || 1 | 0;
         var subdivisions = options.subdivisions || 1 | 0;
@@ -82842,6 +82861,7 @@ var GroundBuilder = /** @class */ (function () {
         var alphaFilter = options.alphaFilter || 0.0;
         var alphaFilter = options.alphaFilter || 0.0;
         var updatable = options.updatable;
         var updatable = options.updatable;
         var onReady = options.onReady;
         var onReady = options.onReady;
+        scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
         var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
         var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
         ground._subdivisionsX = subdivisions;
         ground._subdivisionsX = subdivisions;
         ground._subdivisionsY = subdivisions;
         ground._subdivisionsY = subdivisions;
@@ -83228,6 +83248,7 @@ var IcoSphereBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      */
      */
     IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
     IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         sphere._originalBuilderSideOrientation = options.sideOrientation;
         sphere._originalBuilderSideOrientation = options.sideOrientation;
@@ -83380,6 +83401,7 @@ var LatheBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      */
      */
     LatheBuilder.CreateLathe = function (name, options, scene) {
     LatheBuilder.CreateLathe = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
         var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
         var closed = (options.closed === undefined) ? true : options.closed;
         var closed = (options.closed === undefined) ? true : options.closed;
         var shape = options.shape;
         var shape = options.shape;
@@ -83795,6 +83817,7 @@ var PlaneBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      */
      */
     PlaneBuilder.CreatePlane = function (name, options, scene) {
     PlaneBuilder.CreatePlane = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
         var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         plane._originalBuilderSideOrientation = options.sideOrientation;
         plane._originalBuilderSideOrientation = options.sideOrientation;
@@ -83828,6 +83851,8 @@ __webpack_require__.r(__webpack_exports__);
 /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
 /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
 /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
 /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
 /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
 /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
+/* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
+
 
 
 
 
 
 
@@ -83929,6 +83954,7 @@ var PolygonBuilder = /** @class */ (function () {
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
     PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
     PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
+        if (scene === void 0) { scene = null; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         var shape = options.shape;
         var shape = options.shape;
@@ -83943,7 +83969,7 @@ var PolygonBuilder = /** @class */ (function () {
         if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
         if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
             contours.pop();
             contours.pop();
         }
         }
-        var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
+        var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene, earcutInjection);
         for (var hNb = 0; hNb < holes.length; hNb++) {
         for (var hNb = 0; hNb < holes.length; hNb++) {
             hole = [];
             hole = [];
             for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
             for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
@@ -83968,6 +83994,7 @@ var PolygonBuilder = /** @class */ (function () {
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
     PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
     PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
+        if (scene === void 0) { scene = null; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
     };
     };
@@ -84142,6 +84169,7 @@ var PolyhedronBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      */
      */
     PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
     PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
         polyhedron._originalBuilderSideOrientation = options.sideOrientation;
         polyhedron._originalBuilderSideOrientation = options.sideOrientation;
@@ -84659,6 +84687,7 @@ var ShapeBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      */
      */
     ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
     ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var path = options.path;
         var path = options.path;
         var shape = options.shape;
         var shape = options.shape;
         var scaleFunction = options.scaleFunction || (function () { return 1; });
         var scaleFunction = options.scaleFunction || (function () { return 1; });
@@ -85192,6 +85221,7 @@ var TubeBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      */
      */
     TubeBuilder.CreateTube = function (name, options, scene) {
     TubeBuilder.CreateTube = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         var path = options.path;
         var path = options.path;
         var instance = options.instance;
         var instance = options.instance;
         var radius = 1.0;
         var radius = 1.0;
@@ -95874,6 +95904,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
      * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
      */
      */
     MeshBuilder.CreateSphere = function (name, options, scene) {
     MeshBuilder.CreateSphere = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
         return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
     };
     };
     /**
     /**
@@ -95910,6 +95941,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      */
      */
     MeshBuilder.CreateIcoSphere = function (name, options, scene) {
     MeshBuilder.CreateIcoSphere = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
         return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
     };
     };
     /**
     /**
@@ -95967,6 +95999,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
      * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
      */
      */
     MeshBuilder.CreateCylinder = function (name, options, scene) {
     MeshBuilder.CreateCylinder = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
         return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
     };
     };
     /**
     /**
@@ -95984,6 +96017,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#torus
      * @see https://doc.babylonjs.com/how_to/set_shapes#torus
      */
      */
     MeshBuilder.CreateTorus = function (name, options, scene) {
     MeshBuilder.CreateTorus = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
         return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
     };
     };
     /**
     /**
@@ -96002,6 +96036,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see  https://doc.babylonjs.com/how_to/set_shapes#torus-knot
      * @see  https://doc.babylonjs.com/how_to/set_shapes#torus-knot
      */
      */
     MeshBuilder.CreateTorusKnot = function (name, options, scene) {
     MeshBuilder.CreateTorusKnot = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
         return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
     };
     };
     /**
     /**
@@ -96116,6 +96151,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      */
      */
     MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
     MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
         return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
     };
     };
     /**
     /**
@@ -96139,6 +96175,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      */
      */
     MeshBuilder.CreateLathe = function (name, options, scene) {
     MeshBuilder.CreateLathe = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
         return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
     };
     };
     /**
     /**
@@ -96156,6 +96193,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      */
      */
     MeshBuilder.CreatePlane = function (name, options, scene) {
     MeshBuilder.CreatePlane = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
         return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
     };
     };
     /**
     /**
@@ -96170,6 +96208,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground
      */
      */
     MeshBuilder.CreateGround = function (name, options, scene) {
     MeshBuilder.CreateGround = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
     };
     };
     /**
     /**
@@ -96186,6 +96225,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      */
      */
     MeshBuilder.CreateTiledGround = function (name, options, scene) {
     MeshBuilder.CreateTiledGround = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
     };
     };
     /**
     /**
@@ -96208,6 +96248,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      */
      */
     MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
     MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
         return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
     };
     };
     /**
     /**
@@ -96225,6 +96266,7 @@ var MeshBuilder = /** @class */ (function () {
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
     MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
     MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
+        if (scene === void 0) { scene = null; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
         return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
     };
     };
@@ -96239,6 +96281,7 @@ var MeshBuilder = /** @class */ (function () {
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
     MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
     MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
+        if (scene === void 0) { scene = null; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         if (earcutInjection === void 0) { earcutInjection = earcut; }
         return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
         return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
     };
     };
@@ -96265,6 +96308,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      */
      */
     MeshBuilder.CreateTube = function (name, options, scene) {
     MeshBuilder.CreateTube = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
         return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
     };
     };
     /**
     /**
@@ -96287,6 +96331,7 @@ var MeshBuilder = /** @class */ (function () {
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      */
      */
     MeshBuilder.CreatePolyhedron = function (name, options, scene) {
     MeshBuilder.CreatePolyhedron = function (name, options, scene) {
+        if (scene === void 0) { scene = null; }
         return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
         return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
     };
     };
     /**
     /**
@@ -96784,7 +96829,7 @@ var QuadraticErrorSimplification = /** @class */ (function () {
                         newUVsData.push(uvs[(originalOffset * 2)]);
                         newUVsData.push(uvs[(originalOffset * 2)]);
                         newUVsData.push(uvs[(originalOffset * 2) + 1]);
                         newUVsData.push(uvs[(originalOffset * 2) + 1]);
                     }
                     }
-                    else if (colorsData && colorsData.length) {
+                    if (colorsData && colorsData.length) {
                         newColorsData.push(colorsData[(originalOffset * 4)]);
                         newColorsData.push(colorsData[(originalOffset * 4)]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 1]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 1]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 2]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 2]);

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 57 - 50
dist/preview release/babylon.module.d.ts

@@ -36374,6 +36374,7 @@ declare module "babylonjs/Meshes/Builders/planeBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector4, Plane } from "babylonjs/Maths/math";
     import { Vector4, Plane } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -36401,7 +36402,7 @@ declare module "babylonjs/Meshes/Builders/planeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
 declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
@@ -40363,6 +40364,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
     import { Color3 } from "babylonjs/Maths/math";
     import { Color3 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { GroundMesh } from "babylonjs/Meshes/groundMesh";
     import { GroundMesh } from "babylonjs/Meshes/groundMesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -40413,7 +40415,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -40443,7 +40445,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/torusBuilder" {
 declare module "babylonjs/Meshes/Builders/torusBuilder" {
@@ -44002,6 +44004,7 @@ declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Color4, Vector4 } from "babylonjs/Maths/math";
     import { Color4, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -44039,7 +44042,7 @@ declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Gizmos/scaleGizmo" {
 declare module "babylonjs/Gizmos/scaleGizmo" {
@@ -50131,7 +50134,7 @@ declare module "babylonjs/Meshes/Builders/shapeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -51793,6 +51796,7 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51821,7 +51825,7 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -51842,13 +51846,14 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/latheBuilder" {
 declare module "babylonjs/Meshes/Builders/latheBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51886,10 +51891,11 @@ declare module "babylonjs/Meshes/Builders/latheBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/tubeBuilder" {
 declare module "babylonjs/Meshes/Builders/tubeBuilder" {
+    import { Nullable } from "babylonjs/types";
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
@@ -51934,13 +51940,14 @@ declare module "babylonjs/Meshes/Builders/tubeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
 declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector4 } from "babylonjs/Maths/math";
     import { Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51971,7 +51978,7 @@ declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/decalBuilder" {
 declare module "babylonjs/Meshes/Builders/decalBuilder" {
@@ -52071,7 +52078,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -52121,7 +52128,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -52202,7 +52209,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -52225,7 +52232,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -52252,7 +52259,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -52398,7 +52405,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -52432,7 +52439,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -52456,7 +52463,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -52475,7 +52482,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -52503,7 +52510,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -52533,7 +52540,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -52558,7 +52565,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -52579,7 +52586,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -52617,7 +52624,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -52651,7 +52658,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
@@ -94885,7 +94892,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -98601,7 +98608,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -98631,7 +98638,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -101877,7 +101884,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -107546,7 +107553,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -109083,7 +109090,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -109104,7 +109111,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109145,7 +109152,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109190,7 +109197,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109224,7 +109231,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109314,7 +109321,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -109364,7 +109371,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -109445,7 +109452,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -109468,7 +109475,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -109495,7 +109502,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -109641,7 +109648,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -109675,7 +109682,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -109699,7 +109706,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -109718,7 +109725,7 @@ declare module BABYLON {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -109746,7 +109753,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -109776,7 +109783,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -109801,7 +109808,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -109822,7 +109829,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -109860,7 +109867,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -109894,7 +109901,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal

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

@@ -1 +1 @@
-{"engineOnly":308951,"sceneOnly":510918,"minGridMaterial":634687,"minStandardMaterial":758506}
+{"engineOnly":308951,"sceneOnly":510921,"minGridMaterial":634690,"minStandardMaterial":758509}

+ 57 - 50
dist/preview release/viewer/babylon.module.d.ts

@@ -36374,6 +36374,7 @@ declare module "babylonjs/Meshes/Builders/planeBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector4, Plane } from "babylonjs/Maths/math";
     import { Vector4, Plane } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -36401,7 +36402,7 @@ declare module "babylonjs/Meshes/Builders/planeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
 declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
@@ -40363,6 +40364,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
     import { Color3 } from "babylonjs/Maths/math";
     import { Color3 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { GroundMesh } from "babylonjs/Meshes/groundMesh";
     import { GroundMesh } from "babylonjs/Meshes/groundMesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -40413,7 +40415,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -40443,7 +40445,7 @@ declare module "babylonjs/Meshes/Builders/groundBuilder" {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/torusBuilder" {
 declare module "babylonjs/Meshes/Builders/torusBuilder" {
@@ -44002,6 +44004,7 @@ declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Color4, Vector4 } from "babylonjs/Maths/math";
     import { Color4, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -44039,7 +44042,7 @@ declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Gizmos/scaleGizmo" {
 declare module "babylonjs/Gizmos/scaleGizmo" {
@@ -50131,7 +50134,7 @@ declare module "babylonjs/Meshes/Builders/shapeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -51793,6 +51796,7 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51821,7 +51825,7 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -51842,13 +51846,14 @@ declare module "babylonjs/Meshes/Builders/polygonBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/latheBuilder" {
 declare module "babylonjs/Meshes/Builders/latheBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51886,10 +51891,11 @@ declare module "babylonjs/Meshes/Builders/latheBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/tubeBuilder" {
 declare module "babylonjs/Meshes/Builders/tubeBuilder" {
+    import { Nullable } from "babylonjs/types";
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Vector3, Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
@@ -51934,13 +51940,14 @@ declare module "babylonjs/Meshes/Builders/tubeBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
 declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
     import { Scene } from "babylonjs/scene";
     import { Scene } from "babylonjs/scene";
     import { Vector4 } from "babylonjs/Maths/math";
     import { Vector4 } from "babylonjs/Maths/math";
     import { Mesh } from "babylonjs/Meshes/mesh";
     import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Nullable } from "babylonjs/types";
     /**
     /**
      * Class containing static functions to help procedurally build meshes
      * Class containing static functions to help procedurally build meshes
      */
      */
@@ -51971,7 +51978,7 @@ declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module "babylonjs/Meshes/Builders/decalBuilder" {
 declare module "babylonjs/Meshes/Builders/decalBuilder" {
@@ -52071,7 +52078,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -52121,7 +52128,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -52202,7 +52209,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -52225,7 +52232,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -52252,7 +52259,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -52398,7 +52405,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -52432,7 +52439,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -52456,7 +52463,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -52475,7 +52482,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -52503,7 +52510,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -52533,7 +52540,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -52558,7 +52565,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -52579,7 +52586,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -52617,7 +52624,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -52651,7 +52658,7 @@ declare module "babylonjs/Meshes/meshBuilder" {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
@@ -94885,7 +94892,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -98601,7 +98608,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -98631,7 +98638,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -101877,7 +101884,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -107546,7 +107553,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         private static _ExtrudeShapeGeneric;
         private static _ExtrudeShapeGeneric;
     }
     }
 }
 }
@@ -109083,7 +109090,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -109104,7 +109111,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109145,7 +109152,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109190,7 +109197,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109224,7 +109231,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
     }
     }
 }
 }
 declare module BABYLON {
 declare module BABYLON {
@@ -109314,7 +109321,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane polygonal mesh.  By default, this is a disc
          * Creates a plane polygonal mesh.  By default, this is a disc
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
          * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
@@ -109364,7 +109371,7 @@ declare module BABYLON {
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * Creates a ribbon mesh. The ribbon is a parametric shape.  It has no predefined shape. Its final shape will depend on the input parameters
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
          * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
@@ -109445,7 +109452,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus mesh
          * Creates a torus mesh
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
          * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
@@ -109468,7 +109475,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a torus knot mesh
          * Creates a torus knot mesh
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
          * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
@@ -109495,7 +109502,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
          * * A line system mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of lines as an input parameter
@@ -109641,7 +109648,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates lathe mesh.
          * Creates lathe mesh.
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
          * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
@@ -109675,7 +109682,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             cap?: number;
             cap?: number;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a plane mesh
          * Creates a plane mesh
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
          * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
@@ -109699,7 +109706,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             updatable?: boolean;
             updatable?: boolean;
             sourcePlane?: Plane;
             sourcePlane?: Plane;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh
          * Creates a ground mesh
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
          * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
@@ -109718,7 +109725,7 @@ declare module BABYLON {
             subdivisionsX?: number;
             subdivisionsX?: number;
             subdivisionsY?: number;
             subdivisionsY?: number;
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: any): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a tiled ground mesh
          * Creates a tiled ground mesh
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
          * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
@@ -109746,7 +109753,7 @@ declare module BABYLON {
                 h: number;
                 h: number;
             };
             };
             updatable?: boolean;
             updatable?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a ground mesh from a height map
          * Creates a ground mesh from a height map
          * * The parameter `url` sets the URL of the height map image resource.
          * * The parameter `url` sets the URL of the height map image resource.
@@ -109776,7 +109783,7 @@ declare module BABYLON {
             alphaFilter?: number;
             alphaFilter?: number;
             updatable?: boolean;
             updatable?: boolean;
             onReady?: (mesh: GroundMesh) => void;
             onReady?: (mesh: GroundMesh) => void;
-        }, scene: Scene): GroundMesh;
+        }, scene?: Nullable<Scene>): GroundMesh;
         /**
         /**
          * Creates a polygon mesh
          * Creates a polygon mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
          * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
@@ -109801,7 +109808,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * Creates an extruded polygon mesh, with depth in the Y direction.
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
          * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)
@@ -109822,7 +109829,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene, earcutInjection?: any): Mesh;
+        }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
         /**
         /**
          * Creates a tube mesh.
          * Creates a tube mesh.
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
          * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
@@ -109860,7 +109867,7 @@ declare module BABYLON {
             backUVs?: Vector4;
             backUVs?: Vector4;
             instance?: Mesh;
             instance?: Mesh;
             invertUV?: boolean;
             invertUV?: boolean;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a polyhedron mesh
          * Creates a polyhedron mesh
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
          * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
@@ -109894,7 +109901,7 @@ declare module BABYLON {
             sideOrientation?: number;
             sideOrientation?: number;
             frontUVs?: Vector4;
             frontUVs?: Vector4;
             backUVs?: Vector4;
             backUVs?: Vector4;
-        }, scene: Scene): Mesh;
+        }, scene?: Nullable<Scene>): Mesh;
         /**
         /**
          * Creates a decal mesh.
          * Creates a decal mesh.
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal
          * A decal is a mesh usually applied as a model onto the surface of another mesh. So don't forget the parameter `sourceMesh` depicting the decal

+ 4 - 4
dist/preview release/viewer/babylon.viewer.d.ts

@@ -197,11 +197,11 @@ declare module BabylonViewer {
                 * Mainly used for help and errors
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the overlay screen.
                 * Hide the overlay screen.
                 */
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * show the viewer (in case it was hidden)
                 * show the viewer (in case it was hidden)
                 *
                 *
@@ -218,11 +218,11 @@ declare module BabylonViewer {
                 * Show the loading screen.
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 * The loading screen can be configured using the configuration object
                 */
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the loading screen
                 * Hide the loading screen
                 */
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
     }

File diff suppressed because it is too large
+ 12 - 12
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 4 - 4
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -230,11 +230,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Mainly used for help and errors
                 * Mainly used for help and errors
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 * @param subScreen the name of the subScreen. Those can be defined in the configuration object
                 */
                 */
-            showOverlayScreen(subScreen: string): Promise<string> | Promise<Template>;
+            showOverlayScreen(subScreen: string): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the overlay screen.
                 * Hide the overlay screen.
                 */
                 */
-            hideOverlayScreen(): Promise<string> | Promise<Template>;
+            hideOverlayScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * show the viewer (in case it was hidden)
                 * show the viewer (in case it was hidden)
                 *
                 *
@@ -251,11 +251,11 @@ declare module 'babylonjs-viewer/viewer/defaultViewer' {
                 * Show the loading screen.
                 * Show the loading screen.
                 * The loading screen can be configured using the configuration object
                 * The loading screen can be configured using the configuration object
                 */
                 */
-            showLoadingScreen(): Promise<string> | Promise<Template>;
+            showLoadingScreen(): Promise<Template> | Promise<string>;
             /**
             /**
                 * Hide the loading screen
                 * Hide the loading screen
                 */
                 */
-            hideLoadingScreen(): Promise<string> | Promise<Template>;
+            hideLoadingScreen(): Promise<Template> | Promise<string>;
             dispose(): void;
             dispose(): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
             protected _onConfigurationLoaded(configuration: ViewerConfiguration): void;
     }
     }

+ 4 - 0
dist/preview release/what's new.md

@@ -135,6 +135,8 @@
 - Added customShaderNameResolve to PBRMaterialBase to allow subclasses to specify custom shader information [MackeyK24](https://github.com/mackeyk24))
 - Added customShaderNameResolve to PBRMaterialBase to allow subclasses to specify custom shader information [MackeyK24](https://github.com/mackeyk24))
 - Added PBRCustomMaterial to material library to allow easy subclassing of PBR materials [MackeyK24](https://github.com/mackeyk24))
 - Added PBRCustomMaterial to material library to allow easy subclassing of PBR materials [MackeyK24](https://github.com/mackeyk24))
 - Added `auto-exposure` support in `StandardRenderingPipeline` when `HDR` is enabled ([julien-moreau](https://github.com/julien-moreau))
 - Added `auto-exposure` support in `StandardRenderingPipeline` when `HDR` is enabled ([julien-moreau](https://github.com/julien-moreau))
+- Added `Matrix.RotationAlignToRef` method to obtain rotation matrix from one vector to another ([sable](https://github.com/thscott))
+- ArcRotateCamera will now cache the necessary matrices when modifying its upVector, instead of calculating them each time they're needed ([sable](https://github.com/thscott))
 
 
 ### OBJ Loader
 ### OBJ Loader
 - Add color vertex support (not part of standard) ([brianzinn](https://github.com/brianzinn))
 - Add color vertex support (not part of standard) ([brianzinn](https://github.com/brianzinn))
@@ -219,6 +221,8 @@
 - Fix `mesh.visibility` not working properly when certain material properties are set that changes the interpretation of alpha (e.g. refraction, specular over alpha, etc.) ([bghgary](https://github.com/bghgary))
 - Fix `mesh.visibility` not working properly when certain material properties are set that changes the interpretation of alpha (e.g. refraction, specular over alpha, etc.) ([bghgary](https://github.com/bghgary))
 - Fix material and texture leak when loading/removing GLTF/obj/babylon files with AssetContainer ([TrevorDev](https://github.com/TrevorDev))
 - Fix material and texture leak when loading/removing GLTF/obj/babylon files with AssetContainer ([TrevorDev](https://github.com/TrevorDev))
 - Avoid exception when removing impostor during cannon world step ([TrevorDev](https://github.com/TrevorDev))
 - Avoid exception when removing impostor during cannon world step ([TrevorDev](https://github.com/TrevorDev))
+- Fix ArcRotateCamera divide by zero error (when looking along up axis) in rebuildAnglesAndRadius ([sable](https://github.com/thscott))
+- Fix ArcRotateCamera rebuildAnglesAndRadius when upVector modified ([sable](https://github.com/thscott))
 
 
 ### Core Engine
 ### Core Engine
 - Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))
 - Fixed a bug with `mesh.alwaysSelectAsActiveMesh` preventing layerMask to be taken in account ([Deltakosh](https://github.com/deltakosh))

+ 1 - 1
package.json

@@ -106,4 +106,4 @@
         "xhr2": "^0.1.4",
         "xhr2": "^0.1.4",
         "xmlbuilder": "8.2.2"
         "xmlbuilder": "8.2.2"
     }
     }
-}
+}

+ 1 - 1
src/Actions/actionEvent.ts

@@ -59,7 +59,7 @@ export class ActionEvent implements IActionEvent {
      */
      */
     public static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent {
     public static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent {
         var scene = source.getScene();
         var scene = source.getScene();
-        return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
+        return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer || source, evt, additionalData);
     }
     }
 
 
     /**
     /**

+ 52 - 19
src/Cameras/arcRotateCamera.ts

@@ -74,6 +74,45 @@ export class ArcRotateCamera extends TargetCamera {
         this.setPosition(newPosition);
         this.setPosition(newPosition);
     }
     }
 
 
+    @serializeAsVector3("upVector")
+    protected _upVector = Vector3.Up();
+
+    protected _upToYMatrix: Matrix;
+    protected _YToUpMatrix: Matrix;
+
+    /**
+     * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
+     * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
+     * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
+     */
+    set upVector(vec: Vector3) {
+        if (!this._upToYMatrix) {
+            this._YToUpMatrix = new Matrix();
+            this._upToYMatrix = new Matrix();
+
+            this._upVector = Vector3.Zero();
+        }
+
+        vec.normalize();
+        this._upVector.copyFrom(vec);
+        this.setMatUp();
+    }
+
+    get upVector() {
+        return this._upVector;
+    }
+
+    /**
+     * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
+     */
+    public setMatUp() {
+        // from y-up to custom-up (used in _getViewMatrix)
+        Matrix.RotationAlignToRef(Vector3.UpReadOnly, this._upVector, this._YToUpMatrix);
+
+        // from custom-up to y-up (used in rebuildAnglesAndRadius)
+        Matrix.RotationAlignToRef(this._upVector, Vector3.UpReadOnly, this._upToYMatrix);
+    }
+
     /**
     /**
      * Current inertia value on the longitudinal axis.
      * Current inertia value on the longitudinal axis.
      * The bigger this number the longer it will take for the camera to stop.
      * The bigger this number the longer it will take for the camera to stop.
@@ -574,8 +613,6 @@ export class ArcRotateCamera extends TargetCamera {
     protected _targetBoundingCenter: Nullable<Vector3>;
     protected _targetBoundingCenter: Nullable<Vector3>;
 
 
     private _computationVector: Vector3 = Vector3.Zero();
     private _computationVector: Vector3 = Vector3.Zero();
-    private _tempAxisVector: Vector3;
-    private _tempAxisRotationMatrix: Matrix;
 
 
     /**
     /**
      * Instantiates a new ArcRotateCamera in a given scene
      * Instantiates a new ArcRotateCamera in a given scene
@@ -859,6 +896,12 @@ export class ArcRotateCamera extends TargetCamera {
      */
      */
     public rebuildAnglesAndRadius(): void {
     public rebuildAnglesAndRadius(): void {
         this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
         this._position.subtractToRef(this._getTargetPosition(), this._computationVector);
+
+        // need to rotate to Y up equivalent if up vector not Axis.Y
+        if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
+            Vector3.TransformCoordinatesToRef(this._computationVector, this._upToYMatrix, this._computationVector);
+        }
+
         this.radius = this._computationVector.length();
         this.radius = this._computationVector.length();
 
 
         if (this.radius === 0) {
         if (this.radius === 0) {
@@ -866,7 +909,11 @@ export class ArcRotateCamera extends TargetCamera {
         }
         }
 
 
         // Alpha
         // Alpha
-        this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+        if (this._computationVector.x === 0 && this._computationVector.z === 0) {
+            this.alpha = Math.PI / 2; // avoid division by zero when looking along up axis, and set to acos(0)
+        } else {
+            this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
+        }
 
 
         if (this._computationVector.z < 0) {
         if (this._computationVector.z < 0) {
             this.alpha = 2 * Math.PI - this.alpha;
             this.alpha = 2 * Math.PI - this.alpha;
@@ -942,22 +989,8 @@ export class ArcRotateCamera extends TargetCamera {
         this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
         this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
 
 
         // Rotate according to up vector
         // Rotate according to up vector
-        if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
-
-            if (!this._tempAxisVector) {
-                this._tempAxisVector = new Vector3();
-                this._tempAxisRotationMatrix = new Matrix();
-            }
-
-            Vector3.CrossToRef(Vector3.Up(), this.upVector, this._tempAxisVector);
-            this._tempAxisVector.normalize();
-
-            let angle = Math.acos(Vector3.Dot(Vector3.UpReadOnly, this.upVector));
-
-            Matrix.RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
-
-            this._tempAxisVector.copyFrom(this._computationVector);
-            Vector3.TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
+        if (this._upVector.x !== 0 || this._upVector.y !== 1.0 || this._upVector.z !== 0) {
+            Vector3.TransformCoordinatesToRef(this._computationVector, this._YToUpMatrix, this._computationVector);
         }
         }
 
 
         target.addToRef(this._computationVector, this._newPosition);
         target.addToRef(this._computationVector, this._newPosition);

+ 23 - 0
src/Debug/physicsViewer.ts

@@ -11,6 +11,7 @@ import { StandardMaterial } from "../Materials/standardMaterial";
 import { IPhysicsEnginePlugin } from "../Physics/IPhysicsEngine";
 import { IPhysicsEnginePlugin } from "../Physics/IPhysicsEngine";
 import { PhysicsImpostor } from "../Physics/physicsImpostor";
 import { PhysicsImpostor } from "../Physics/physicsImpostor";
 import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
 import { UtilityLayerRenderer } from "../Rendering/utilityLayerRenderer";
+import { CylinderBuilder } from '../Meshes/Builders/cylinderBuilder';
 
 
 /**
 /**
      * Used to show the physics impostor around the specific mesh
      * Used to show the physics impostor around the specific mesh
@@ -32,6 +33,7 @@ export class PhysicsViewer {
 
 
     private _debugBoxMesh: Mesh;
     private _debugBoxMesh: Mesh;
     private _debugSphereMesh: Mesh;
     private _debugSphereMesh: Mesh;
+    private _debugCylinderMesh: Mesh;
     private _debugMaterial: StandardMaterial;
     private _debugMaterial: StandardMaterial;
     private _debugMeshMeshes = new Array<Mesh>();
     private _debugMeshMeshes = new Array<Mesh>();
 
 
@@ -196,6 +198,17 @@ export class PhysicsViewer {
         return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
         return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
     }
     }
 
 
+    private _getDebugCylinderMesh(scene: Scene): AbstractMesh {
+        if (!this._debugCylinderMesh) {
+            this._debugCylinderMesh = CylinderBuilder.CreateCylinder('physicsBodyCylinderViewMesh', { diameterTop: 1, diameterBottom: 1, height: 1 }, scene);
+            this._debugCylinderMesh.rotationQuaternion = Quaternion.Identity();
+            this._debugCylinderMesh.material = this._getDebugMaterial(scene);
+            this._debugCylinderMesh.setEnabled(false);
+        }
+
+        return this._debugCylinderMesh.createInstance('physicsBodyBoxViewInstance');
+    }
+
     private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {
     private _getDebugMeshMesh(mesh: Mesh, scene: Scene): AbstractMesh {
         var wireframeOver = new Mesh(mesh.name, scene, null, mesh);
         var wireframeOver = new Mesh(mesh.name, scene, null, mesh);
         wireframeOver.position = Vector3.Zero();
         wireframeOver.position = Vector3.Zero();
@@ -247,6 +260,13 @@ export class PhysicsViewer {
                     });
                     });
                 }
                 }
                 break;
                 break;
+            case PhysicsImpostor.CylinderImpostor:
+                mesh = this._getDebugCylinderMesh(utilityLayerScene);
+                var bi = impostor.object.getBoundingInfo();
+                mesh.scaling.x = bi.boundingBox.maximum.x - bi.boundingBox.minimum.x;
+                mesh.scaling.y = bi.boundingBox.maximum.y - bi.boundingBox.minimum.y;
+                mesh.scaling.z = bi.boundingBox.maximum.z - bi.boundingBox.minimum.z;
+                break;
         }
         }
         return mesh;
         return mesh;
     }
     }
@@ -264,6 +284,9 @@ export class PhysicsViewer {
         if (this._debugSphereMesh) {
         if (this._debugSphereMesh) {
             this._debugSphereMesh.dispose();
             this._debugSphereMesh.dispose();
         }
         }
+        if (this._debugCylinderMesh) {
+            this._debugCylinderMesh.dispose();
+        }
         if (this._debugMaterial) {
         if (this._debugMaterial) {
             this._debugMaterial.dispose();
             this._debugMaterial.dispose();
         }
         }

+ 21 - 0
src/Maths/math.ts

@@ -5477,6 +5477,27 @@ export class Matrix {
     }
     }
 
 
     /**
     /**
+     * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
+     * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
+     * @param from defines the vector to align
+     * @param to defines the vector to align to
+     * @param result defines the target matrix
+     */
+    public static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void {
+        const v = Vector3.Cross(to, from);
+        const c = Vector3.Dot(to, from);
+        const k = 1 / (1 + c);
+
+        const m = result._m;
+        m[0]  = v.x * v.x * k + c;   m[1]  = v.y * v.x * k - v.z; m[2]  = v.z * v.x * k + v.y; m[3]  = 0;
+        m[4]  = v.x * v.y * k + v.z; m[5]  = v.y * v.y * k + c;   m[6]  = v.z * v.y * k - v.x; m[7]  = 0;
+        m[8]  = v.x * v.z * k - v.y; m[9]  = v.y * v.z * k + v.x; m[10] = v.z * v.z * k + c;   m[11] = 0;
+        m[12] = 0;               m[13] = 0;               m[14] = 0;               m[15] = 1;
+
+        result._markAsUpdated();
+    }
+
+    /**
      * Creates a rotation matrix
      * Creates a rotation matrix
      * @param yaw defines the yaw angle in radians (Y axis)
      * @param yaw defines the yaw angle in radians (Y axis)
      * @param pitch defines the pitch angle in radians (X axis)
      * @param pitch defines the pitch angle in radians (X axis)

+ 7 - 3
src/Meshes/Builders/groundBuilder.ts

@@ -4,6 +4,8 @@ import { Mesh, _CreationDataStorage } from "../mesh";
 import { VertexData } from "../mesh.vertexData";
 import { VertexData } from "../mesh.vertexData";
 import { GroundMesh } from "../groundMesh";
 import { GroundMesh } from "../groundMesh";
 import { Tools } from "../../Misc/tools";
 import { Tools } from "../../Misc/tools";
+import { Nullable } from '../../types';
+import { EngineStore } from '../../Engines/engineStore';
 
 
 VertexData.CreateGround = function(options: { width?: number, height?: number, subdivisions?: number, subdivisionsX?: number, subdivisionsY?: number }): VertexData {
 VertexData.CreateGround = function(options: { width?: number, height?: number, subdivisions?: number, subdivisionsX?: number, subdivisionsY?: number }): VertexData {
     var indices = [];
     var indices = [];
@@ -324,7 +326,7 @@ export class GroundBuilder {
      * @returns the tiled ground mesh
      * @returns the tiled ground mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      */
      */
-    public static CreateTiledGround(name: string, options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; }, updatable?: boolean }, scene: Scene): Mesh {
+    public static CreateTiledGround(name: string, options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; }, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         var tiledGround = new Mesh(name, scene);
         var tiledGround = new Mesh(name, scene);
 
 
         var vertexData = VertexData.CreateTiledGround(options);
         var vertexData = VertexData.CreateTiledGround(options);
@@ -353,7 +355,7 @@ export class GroundBuilder {
      * @see https://doc.babylonjs.com/babylon101/height_map
      * @see https://doc.babylonjs.com/babylon101/height_map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      */
      */
-    public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, colorFilter?: Color3, alphaFilter?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Scene): GroundMesh {
+    public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, colorFilter?: Color3, alphaFilter?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Nullable<Scene> = null): GroundMesh {
         var width = options.width || 10.0;
         var width = options.width || 10.0;
         var height = options.height || 10.0;
         var height = options.height || 10.0;
         var subdivisions = options.subdivisions || 1 | 0;
         var subdivisions = options.subdivisions || 1 | 0;
@@ -364,6 +366,8 @@ export class GroundBuilder {
         var updatable = options.updatable;
         var updatable = options.updatable;
         var onReady = options.onReady;
         var onReady = options.onReady;
 
 
+        scene = scene || EngineStore.LastCreatedScene!;
+
         var ground = new GroundMesh(name, scene);
         var ground = new GroundMesh(name, scene);
         ground._subdivisionsX = subdivisions;
         ground._subdivisionsX = subdivisions;
         ground._subdivisionsY = subdivisions;
         ground._subdivisionsY = subdivisions;
@@ -385,7 +389,7 @@ export class GroundBuilder {
                 throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
                 throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
             }
             }
 
 
-            if (scene.isDisposed) {
+            if (scene!.isDisposed) {
                 return;
                 return;
             }
             }
 
 

+ 2 - 1
src/Meshes/Builders/icoSphereBuilder.ts

@@ -2,6 +2,7 @@ import { Scene } from "../../scene";
 import { Vector4, Vector3, Vector2 } from "../../Maths/math";
 import { Vector4, Vector3, Vector2 } from "../../Maths/math";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { VertexData } from "../mesh.vertexData";
 import { VertexData } from "../mesh.vertexData";
+import { Nullable } from '../../types';
 
 
 VertexData.CreateIcoSphere = function(options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
 VertexData.CreateIcoSphere = function(options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
     var sideOrientation = options.sideOrientation || VertexData.DEFAULTSIDE;
     var sideOrientation = options.sideOrientation || VertexData.DEFAULTSIDE;
@@ -283,7 +284,7 @@ export class IcoSphereBuilder {
      * @returns the icosahedron mesh
      * @returns the icosahedron mesh
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      */
      */
-    public static CreateIcoSphere(name: string, options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Scene): Mesh {
+    public static CreateIcoSphere(name: string, options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         var sphere = new Mesh(name, scene);
         var sphere = new Mesh(name, scene);
 
 
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);

+ 2 - 1
src/Meshes/Builders/latheBuilder.ts

@@ -2,6 +2,7 @@ import { Scene } from "../../scene";
 import { Vector3, Vector4 } from "../../Maths/math";
 import { Vector3, Vector4 } from "../../Maths/math";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { RibbonBuilder } from "./ribbonBuilder";
 import { RibbonBuilder } from "./ribbonBuilder";
+import { Nullable } from '../../types';
 
 
 Mesh.CreateLathe = (name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh => {
 Mesh.CreateLathe = (name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh => {
     var options = {
     var options = {
@@ -39,7 +40,7 @@ export class LatheBuilder {
      * @returns the lathe mesh
      * @returns the lathe mesh
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      */
      */
-    public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, clip?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, cap?: number, invertUV?: boolean }, scene: Scene): Mesh {
+    public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, clip?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, cap?: number, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         var arc: number = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
         var arc: number = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
         var closed: boolean = (options.closed === undefined) ? true : options.closed;
         var closed: boolean = (options.closed === undefined) ? true : options.closed;
         var shape = options.shape;
         var shape = options.shape;

+ 2 - 1
src/Meshes/Builders/planeBuilder.ts

@@ -2,6 +2,7 @@ import { Scene } from "../../scene";
 import { Vector4, Plane } from "../../Maths/math";
 import { Vector4, Plane } from "../../Maths/math";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { VertexData } from "../mesh.vertexData";
 import { VertexData } from "../mesh.vertexData";
+import { Nullable } from '../../types';
 
 
 VertexData.CreatePlane = function(options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
 VertexData.CreatePlane = function(options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
     var indices = [];
     var indices = [];
@@ -86,7 +87,7 @@ export class PlaneBuilder {
      * @returns the plane mesh
      * @returns the plane mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      */
      */
-    public static CreatePlane(name: string, options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean, sourcePlane?: Plane }, scene: Scene): Mesh {
+    public static CreatePlane(name: string, options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean, sourcePlane?: Plane }, scene: Nullable<Scene> = null): Mesh {
         var plane = new Mesh(name, scene);
         var plane = new Mesh(name, scene);
 
 
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);

+ 5 - 4
src/Meshes/Builders/polygonBuilder.ts

@@ -3,8 +3,9 @@ import { Vector3, Vector2, Color4, Vector4 } from "../../Maths/math";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { VertexData } from "../mesh.vertexData";
 import { VertexData } from "../mesh.vertexData";
 import { PolygonMeshBuilder } from "../polygonMesh";
 import { PolygonMeshBuilder } from "../polygonMesh";
-import { FloatArray, IndicesArray } from "../../types";
+import { FloatArray, IndicesArray, Nullable } from "../../types";
 import { VertexBuffer } from "../../Meshes/buffer";
 import { VertexBuffer } from "../../Meshes/buffer";
+import { EngineStore } from '../../Engines/engineStore';
 
 
 declare var earcut: any;
 declare var earcut: any;
 
 
@@ -109,7 +110,7 @@ export class PolygonBuilder {
      * @param earcutInjection can be used to inject your own earcut reference
      * @param earcutInjection can be used to inject your own earcut reference
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
-    public static CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, }, scene: Scene, earcutInjection = earcut): Mesh {
+    public static CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
         var shape = options.shape;
         var shape = options.shape;
         var holes = options.holes || [];
         var holes = options.holes || [];
@@ -125,7 +126,7 @@ export class PolygonBuilder {
             contours.pop();
             contours.pop();
         }
         }
 
 
-        var polygonTriangulation = new PolygonMeshBuilder(name, contours, scene, earcutInjection);
+        var polygonTriangulation = new PolygonMeshBuilder(name, contours, scene || EngineStore.LastCreatedScene!, earcutInjection);
         for (var hNb = 0; hNb < holes.length; hNb++) {
         for (var hNb = 0; hNb < holes.length; hNb++) {
             hole = [];
             hole = [];
             for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
             for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
@@ -151,7 +152,7 @@ export class PolygonBuilder {
      * @param earcutInjection can be used to inject your own earcut reference
      * @param earcutInjection can be used to inject your own earcut reference
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
-    public static ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Scene, earcutInjection = earcut): Mesh {
+    public static ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
     }
     }
 }
 }

+ 2 - 1
src/Meshes/Builders/polyhedronBuilder.ts

@@ -2,6 +2,7 @@ import { Scene } from "../../scene";
 import { Color4, Vector4 } from "../../Maths/math";
 import { Color4, Vector4 } from "../../Maths/math";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { Mesh, _CreationDataStorage } from "../mesh";
 import { VertexData } from "../mesh.vertexData";
 import { VertexData } from "../mesh.vertexData";
+import { Nullable } from '../../types';
 
 
 VertexData.CreatePolyhedron = function(options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
 VertexData.CreatePolyhedron = function(options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }): VertexData {
     // provided polyhedron types :
     // provided polyhedron types :
@@ -160,7 +161,7 @@ export class PolyhedronBuilder {
      * @returns the polyhedron mesh
      * @returns the polyhedron mesh
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      */
      */
-    public static CreatePolyhedron(name: string, options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Scene): Mesh {
+    public static CreatePolyhedron(name: string, options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
         var polyhedron = new Mesh(name, scene);
         var polyhedron = new Mesh(name, scene);
 
 
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
         options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);

+ 1 - 1
src/Meshes/Builders/shapeBuilder.ts

@@ -100,7 +100,7 @@ export class ShapeBuilder {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      */
      */
-    public static ExtrudeShapeCustom(name: string, options: { shape: Vector3[], path: Vector3[], scaleFunction?: any, rotationFunction?: any, ribbonCloseArray?: boolean, ribbonClosePath?: boolean, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Scene): Mesh {
+    public static ExtrudeShapeCustom(name: string, options: { shape: Vector3[], path: Vector3[], scaleFunction?: any, rotationFunction?: any, ribbonCloseArray?: boolean, ribbonClosePath?: boolean, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         var path = options.path;
         var path = options.path;
         var shape = options.shape;
         var shape = options.shape;
         var scaleFunction = options.scaleFunction || (() => { return 1; });
         var scaleFunction = options.scaleFunction || (() => { return 1; });

+ 1 - 1
src/Meshes/Builders/tubeBuilder.ts

@@ -45,7 +45,7 @@ export class TubeBuilder {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      */
      */
-    public static CreateTube(name: string, options: { path: Vector3[], radius?: number, tessellation?: number, radiusFunction?: { (i: number, distance: number): number; }, cap?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Scene): Mesh {
+    public static CreateTube(name: string, options: { path: Vector3[], radius?: number, tessellation?: number, radiusFunction?: { (i: number, distance: number): number; }, cap?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         var path = options.path;
         var path = options.path;
         var instance = options.instance;
         var instance = options.instance;
         var radius = 1.0;
         var radius = 1.0;

+ 15 - 15
src/Meshes/meshBuilder.ts

@@ -65,7 +65,7 @@ export class MeshBuilder {
      * @returns the sphere mesh
      * @returns the sphere mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
      * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
      */
      */
-    public static CreateSphere(name: string, options: { segments?: number, diameter?: number, diameterX?: number, diameterY?: number, diameterZ?: number, arc?: number, slice?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: any): Mesh {
+    public static CreateSphere(name: string, options: { segments?: number, diameter?: number, diameterX?: number, diameterY?: number, diameterZ?: number, arc?: number, slice?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return SphereBuilder.CreateSphere(name, options, scene);
         return SphereBuilder.CreateSphere(name, options, scene);
     }
     }
 
 
@@ -102,7 +102,7 @@ export class MeshBuilder {
      * @returns the icosahedron mesh
      * @returns the icosahedron mesh
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
      */
      */
-    public static CreateIcoSphere(name: string, options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Scene): Mesh {
+    public static CreateIcoSphere(name: string, options: { radius?: number, radiusX?: number, radiusY?: number, radiusZ?: number, flat?: boolean, subdivisions?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
         return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
     }
     }
 
 
@@ -160,7 +160,7 @@ export class MeshBuilder {
      * @returns the cylinder mesh
      * @returns the cylinder mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
      * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
      */
      */
-    public static CreateCylinder(name: string, options: { height?: number, diameterTop?: number, diameterBottom?: number, diameter?: number, tessellation?: number, subdivisions?: number, arc?: number, faceColors?: Color4[], faceUV?: Vector4[], updatable?: boolean, hasRings?: boolean, enclose?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: any): Mesh {
+    public static CreateCylinder(name: string, options: { height?: number, diameterTop?: number, diameterBottom?: number, diameter?: number, tessellation?: number, subdivisions?: number, arc?: number, faceColors?: Color4[], faceUV?: Vector4[], updatable?: boolean, hasRings?: boolean, enclose?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
         return CylinderBuilder.CreateCylinder(name, options, scene);
         return CylinderBuilder.CreateCylinder(name, options, scene);
     }
     }
 
 
@@ -178,7 +178,7 @@ export class MeshBuilder {
      * @returns the torus mesh
      * @returns the torus mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#torus
      * @see https://doc.babylonjs.com/how_to/set_shapes#torus
      */
      */
-    public static CreateTorus(name: string, options: { diameter?: number, thickness?: number, tessellation?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: any): Mesh {
+    public static CreateTorus(name: string, options: { diameter?: number, thickness?: number, tessellation?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
         return TorusBuilder.CreateTorus(name, options, scene);
         return TorusBuilder.CreateTorus(name, options, scene);
     }
     }
 
 
@@ -197,7 +197,7 @@ export class MeshBuilder {
      * @returns the torus knot mesh
      * @returns the torus knot mesh
      * @see  https://doc.babylonjs.com/how_to/set_shapes#torus-knot
      * @see  https://doc.babylonjs.com/how_to/set_shapes#torus-knot
      */
      */
-    public static CreateTorusKnot(name: string, options: { radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: any): Mesh {
+    public static CreateTorusKnot(name: string, options: { radius?: number, tube?: number, radialSegments?: number, tubularSegments?: number, p?: number, q?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
         return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
         return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
     }
     }
 
 
@@ -313,7 +313,7 @@ export class MeshBuilder {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
      */
      */
-    public static ExtrudeShapeCustom(name: string, options: { shape: Vector3[], path: Vector3[], scaleFunction?: any, rotationFunction?: any, ribbonCloseArray?: boolean, ribbonClosePath?: boolean, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Scene): Mesh {
+    public static ExtrudeShapeCustom(name: string, options: { shape: Vector3[], path: Vector3[], scaleFunction?: any, rotationFunction?: any, ribbonCloseArray?: boolean, ribbonClosePath?: boolean, cap?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
         return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
     }
     }
 
 
@@ -337,7 +337,7 @@ export class MeshBuilder {
      * @returns the lathe mesh
      * @returns the lathe mesh
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
      */
      */
-    public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, clip?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, cap?: number, invertUV?: boolean }, scene: Scene): Mesh {
+    public static CreateLathe(name: string, options: { shape: Vector3[], radius?: number, tessellation?: number, clip?: number, arc?: number, closed?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, cap?: number, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return LatheBuilder.CreateLathe(name, options, scene);
         return LatheBuilder.CreateLathe(name, options, scene);
     }
     }
 
 
@@ -355,7 +355,7 @@ export class MeshBuilder {
      * @returns the plane mesh
      * @returns the plane mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      * @see https://doc.babylonjs.com/how_to/set_shapes#plane
      */
      */
-    public static CreatePlane(name: string, options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean, sourcePlane?: Plane }, scene: Scene): Mesh {
+    public static CreatePlane(name: string, options: { size?: number, width?: number, height?: number, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, updatable?: boolean, sourcePlane?: Plane }, scene: Nullable<Scene> = null): Mesh {
         return PlaneBuilder.CreatePlane(name, options, scene);
         return PlaneBuilder.CreatePlane(name, options, scene);
     }
     }
 
 
@@ -370,7 +370,7 @@ export class MeshBuilder {
      * @returns the ground mesh
      * @returns the ground mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground
      */
      */
-    public static CreateGround(name: string, options: { width?: number, height?: number, subdivisions?: number, subdivisionsX?: number, subdivisionsY?: number, updatable?: boolean }, scene: any): Mesh {
+    public static CreateGround(name: string, options: { width?: number, height?: number, subdivisions?: number, subdivisionsX?: number, subdivisionsY?: number, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return GroundBuilder.CreateGround(name, options, scene);
         return GroundBuilder.CreateGround(name, options, scene);
     }
     }
 
 
@@ -387,7 +387,7 @@ export class MeshBuilder {
      * @returns the tiled ground mesh
      * @returns the tiled ground mesh
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
      */
      */
-    public static CreateTiledGround(name: string, options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; }, updatable?: boolean }, scene: Scene): Mesh {
+    public static CreateTiledGround(name: string, options: { xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: { w: number; h: number; }, precision?: { w: number; h: number; }, updatable?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return GroundBuilder.CreateTiledGround(name, options, scene);
         return GroundBuilder.CreateTiledGround(name, options, scene);
     }
     }
 
 
@@ -410,7 +410,7 @@ export class MeshBuilder {
      * @see https://doc.babylonjs.com/babylon101/height_map
      * @see https://doc.babylonjs.com/babylon101/height_map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
      */
      */
-    public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, colorFilter?: Color3, alphaFilter?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Scene): GroundMesh {
+    public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, colorFilter?: Color3, alphaFilter?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Nullable<Scene> = null): GroundMesh {
         return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
         return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
     }
     }
 
 
@@ -428,7 +428,7 @@ export class MeshBuilder {
      * @param earcutInjection can be used to inject your own earcut reference
      * @param earcutInjection can be used to inject your own earcut reference
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
-    public static CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, }, scene: Scene, earcutInjection = earcut): Mesh {
+    public static CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
         return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
     }
     }
 
 
@@ -442,7 +442,7 @@ export class MeshBuilder {
      * @param earcutInjection can be used to inject your own earcut reference
      * @param earcutInjection can be used to inject your own earcut reference
      * @returns the polygon mesh
      * @returns the polygon mesh
      */
      */
-    public static ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Scene, earcutInjection = earcut): Mesh {
+    public static ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {
         return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
         return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
     }
     }
 
 
@@ -468,7 +468,7 @@ export class MeshBuilder {
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/parametric_shapes
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      * @see https://doc.babylonjs.com/how_to/set_shapes#tube
      */
      */
-    public static CreateTube(name: string, options: { path: Vector3[], radius?: number, tessellation?: number, radiusFunction?: { (i: number, distance: number): number; }, cap?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Scene): Mesh {
+    public static CreateTube(name: string, options: { path: Vector3[], radius?: number, tessellation?: number, radiusFunction?: { (i: number, distance: number): number; }, cap?: number, arc?: number, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, instance?: Mesh, invertUV?: boolean }, scene: Nullable<Scene> = null): Mesh {
         return TubeBuilder.CreateTube(name, options, scene);
         return TubeBuilder.CreateTube(name, options, scene);
     }
     }
 
 
@@ -491,7 +491,7 @@ export class MeshBuilder {
      * @returns the polyhedron mesh
      * @returns the polyhedron mesh
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
      */
      */
-    public static CreatePolyhedron(name: string, options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Scene): Mesh {
+    public static CreatePolyhedron(name: string, options: { type?: number, size?: number, sizeX?: number, sizeY?: number, sizeZ?: number, custom?: any, faceUV?: Vector4[], faceColors?: Color4[], flat?: boolean, updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4 }, scene: Nullable<Scene> = null): Mesh {
         return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
         return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
     }
     }
 
 

+ 3 - 1
src/Meshes/meshSimplification.ts

@@ -575,7 +575,9 @@ class QuadraticErrorSimplification implements ISimplifier {
                     if (uvs && uvs.length) {
                     if (uvs && uvs.length) {
                         newUVsData.push(uvs[(originalOffset * 2)]);
                         newUVsData.push(uvs[(originalOffset * 2)]);
                         newUVsData.push(uvs[(originalOffset * 2) + 1]);
                         newUVsData.push(uvs[(originalOffset * 2) + 1]);
-                    } else if (colorsData && colorsData.length) {
+                    }
+
+                    if (colorsData && colorsData.length) {
                         newColorsData.push(colorsData[(originalOffset * 4)]);
                         newColorsData.push(colorsData[(originalOffset * 4)]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 1]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 1]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 2]);
                         newColorsData.push(colorsData[(originalOffset * 4) + 2]);

+ 3 - 0
src/Physics/Plugins/ammoJSPlugin.ts

@@ -856,6 +856,9 @@ export class AmmoJSPlugin implements IPhysicsEnginePlugin {
             meshChildren.forEach((childMesh) => {
             meshChildren.forEach((childMesh) => {
                 var childImpostor = childMesh.getPhysicsImpostor();
                 var childImpostor = childMesh.getPhysicsImpostor();
                 if (childImpostor) {
                 if (childImpostor) {
+                    if (childImpostor.type == PhysicsImpostor.MeshImpostor) {
+                        throw "A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";
+                    }
                     var shape = this._createShape(childImpostor);
                     var shape = this._createShape(childImpostor);
 
 
                     // Position needs to be scaled based on parent's scaling
                     // Position needs to be scaled based on parent's scaling