Namespace Mesh
Index
Functions
- Create
Box - Create
Capsule - Create
Cylinder - Create
Dashed Lines - Create
Decal - Create
Disc - Create
Ground - Create
Ground From Height Map - Create
Hemisphere - Create
Ico Sphere - Create
Lathe - Create
Lines - Create
Plane - Create
Polygon - Create
Polyhedron - Create
Ribbon - Create
Sphere - Create
Tiled Ground - Create
Torus - Create
Torus Knot - Create
Tube - Extend
To Goldberg - Extrude
Polygon - Extrude
Shape - Extrude
Shape Custom
Functions
Create Box
Parameters
name: string
defines the name of the mesh to create
size: number
sets the size (float) of each box side (default 1)
scene: Nullable<Scene>
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Capsule
Creates a Capsule Mesh
Parameters
name: string
defines the name of the mesh.
options: ICreateCapsuleOptions
the constructors options used to shape the mesh.
scene: Scene
defines the scene the mesh is scoped to.
Returns Mesh
the capsule mesh
Create Cylinder
Creates a cylinder or a cone mesh.
Parameters
name: string
defines the name of the mesh to create
height: number
sets the height size (float) of the cylinder/cone (float, default 2)
diameterTop: number
set the top cap diameter (floats, default 1)
diameterBottom: number
set the bottom cap diameter (floats, default 1). This value can't be zero
tessellation: number
sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
subdivisions: any
sets the number of rings along the cylinder height (positive integer, default 1)
Optional scene: Scene
defines the hosting scene
Optional updatable: any
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Dashed Lines
Creates a dashed line mesh.
Parameters
name: string
defines the name of the mesh to create
points: Vector3[]
is an array successive Vector3
dashSize: number
is the size of the dashes relatively the dash number (positive float, default 3)
gapSize: number
is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
dashNb: number
is the intended total number of dashes (positive integer, default 200)
scene: Nullable<Scene>
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional instance: LinesMesh
is an instance of an existing LineMesh object to be updated with the passed
points
parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
Returns LinesMesh
a new Mesh
Create Decal
Creates a decal mesh. . A decal is a mesh usually applied as a model onto the surface of another mesh
Parameters
name: string
defines the name of the mesh
sourceMesh: AbstractMesh
defines the mesh receiving the decal
position: Vector3
sets the position of the decal in world coordinates
normal: Vector3
sets the normal of the mesh where the decal is applied onto in world coordinates
size: Vector3
sets the decal scaling
angle: number
sets the angle to rotate the decal
Returns Mesh
a new Mesh
Create Disc
Creates a plane polygonal mesh. By default, this is a disc.
Parameters
name: string
defines the name of the mesh to create
radius: number
sets the radius size (float) of the polygon (default 0.5)
tessellation: number
sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
scene: Nullable<Scene>
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Ground
Creates a ground mesh.
Parameters
name: string
defines the name of the mesh to create
width: number
set the width of the ground
height: number
set the height of the ground
subdivisions: number
sets the number of subdivisions per side
Optional scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Returns Mesh
a new Mesh
Create Ground From Height Map
Creates a ground mesh from a height map.
Parameters
name: string
defines the name of the mesh to create
url: string
sets the URL of the height map image resource
width: number
set the ground width size
height: number
set the ground height size
subdivisions: number
sets the number of subdivision per side
minHeight: number
is the minimum altitude on the ground
maxHeight: number
is the maximum altitude on the ground
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional onReady: ((mesh: GroundMesh) => void)
is a callback function that will be called once the mesh is built (the height map download can last some time)
Parameters
mesh: GroundMesh
Returns void
Optional alphaFilter: number
will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
Returns GroundMesh
a new Mesh
Create Hemisphere
Creates a hemisphere mesh.
Parameters
name: string
defines the name of the mesh to create
segments: number
sets the sphere number of horizontal stripes (positive integer, default 32)
diameter: number
sets the diameter size (float) of the sphere (default 1)
Optional scene: Scene
defines the hosting scene
Returns Mesh
a new Mesh
Create Ico Sphere
Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
- The parameter
radius
sets the radius size (float) of the icosphere (default 1) - You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters
radiusX
,radiusY
andradiusZ
(all by default have the same value thanradius
) - The parameter
subdivisions
sets the number of subdivisions (positive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size - The parameter
flat
(boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface - You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
- If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters
frontUVs
andbackUVs
(Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation - The mesh can be set to updatable with the boolean parameter
updatable
(default false) if its internal geometry is supposed to change once created
Parameters
name: string
defines the name of the mesh
options: { flat?: boolean; radius?: number; sideOrientation?: number; subdivisions?: number; updatable?: boolean }
defines the options used to create the mesh
Optional flat?: boolean
Optional radius?: number
Optional side
Orientation?: number Optional subdivisions?: number
Optional updatable?: boolean
scene: Scene
defines the hosting scene
Returns Mesh
a new Mesh
- The parameter
Create Lathe
Creates lathe mesh. The lathe is a shape with a symmetry axis : a 2D model shape is rotated around this axis to design the lathe.
Parameters
name: string
defines the name of the mesh to create
shape: Vector3[]
is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
radius: number
is the radius value of the lathe
tessellation: number
is the side number of the lathe.
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Lines
Creates a line mesh..
Parameters
name: string
defines the name of the mesh to create
points: Vector3[]
is an array successive Vector3
scene: Nullable<Scene>
defines the hosting scene
updatable: boolean
defines if the mesh must be flagged as updatable
Optional instance: Nullable<LinesMesh>
is an instance of an existing LineMesh object to be updated with the passed
points
parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
Returns LinesMesh
a new Mesh
Create Plane
Creates a plane mesh.
Parameters
name: string
defines the name of the mesh to create
size: number
sets the size (float) of both sides of the plane at once (default 1)
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Polygon
Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh. The parameter
shape
is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors. You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE The mesh can be set to updatable with the boolean parameterupdatable
(default false) if its internal geometry is supposed to change once created. Remember you can only change the shape positions, not their number when updating a polygon.Parameters
name: string
defines the name of the mesh to create
shape: Vector3[]
is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
scene: Scene
defines the hosting scene
Optional holes: Vector3[][]
is a required array of arrays of successive Vector3 used to defines holes in the polygon
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional earcutInjection: any
can be used to inject your own earcut reference
Returns Mesh
a new Mesh
Create Polyhedron
Creates a polyhedron mesh. .
- The parameter
type
(positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embedded types. Please refer to the type sheet in the tutorial to choose the wanted type - The parameter
size
(positive float, default 1) sets the polygon size - You can overwrite the
size
on each dimension bu using the parameterssizeX
,sizeY
orsizeZ
(positive floats, default tosize
value) - You can build other polyhedron types than the 15 embbeded ones by setting the parameter
custom
(polyhedronObject
, default null). If you set the parametercustom
, this overwrittes the parametertype
- A
polyhedronObject
is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron - You can set the color and the UV of each side of the polyhedron with the parameters
faceColors
(Color4, default(1, 1, 1, 1)
) and faceUV (Vector4, default(0, 0, 1, 1)
) - To understand how to set
faceUV
orfaceColors
, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors - The parameter
flat
(boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case,faceColors
andfaceUV
are ignored - You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
- If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters
frontUVs
andbackUVs
(Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation - The mesh can be set to updatable with the boolean parameter
updatable
(default false) if its internal geometry is supposed to change once created
Parameters
name: string
defines the name of the mesh to create
options: { custom?: any; faceColors?: Color4[]; faceUV?: Vector4[]; sideOrientation?: number; size?: number; sizeX?: number; sizeY?: number; sizeZ?: number; type?: number; updatable?: boolean }
defines the options used to create the mesh
scene: Scene
defines the hosting scene
Returns Mesh
a new Mesh
- The parameter
Create Ribbon
Creates a ribbon mesh.
Parameters
name: string
defines the name of the mesh to create
pathArray: Vector3[][]
is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
closeArray: boolean
creates a seam between the first and the last paths of the path array (default is false)
closePath: boolean
creates a seam between the first and the last points of each path of the path array
offset: number
is taken in account only if the
pathArray
is containing a single pathOptional scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional instance: Mesh
defines an instance of an existing Ribbon object to be updated with the passed
pathArray
parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
Returns Mesh
a new Mesh
Create Sphere
Creates a sphere mesh.
Parameters
name: string
defines the name of the mesh to create
segments: number
sets the sphere number of horizontal stripes (positive integer, default 32)
diameter: number
sets the diameter size (float) of the sphere (default 1)
Optional scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Tiled Ground
Creates a tiled ground mesh.
Parameters
name: string
defines the name of the mesh to create
xmin: number
set the ground minimum X coordinate
zmin: number
set the ground minimum Y coordinate
xmax: number
set the ground maximum X coordinate
zmax: number
set the ground maximum Z coordinate
subdivisions: { h: number; w: number }
is an object
{w: positive integer, h: positive integer}
(default{w: 6, h: 6}
).w
andh
are the numbers of subdivisions on the ground width and height. Each subdivision is called a tileh: number
w: number
precision: { h: number; w: number }
is an object
{w: positive integer, h: positive integer}
(default{w: 2, h: 2}
).w
andh
are the numbers of subdivisions on the ground width and height of each tileh: number
w: number
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Returns Mesh
a new Mesh
Create Torus
Creates a torus mesh.
Parameters
name: string
defines the name of the mesh to create
diameter: number
sets the diameter size (float) of the torus (default 1)
thickness: number
sets the diameter size of the tube of the torus (float, default 0.5)
tessellation: number
sets the number of torus sides (positive integer, default 16)
Optional scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Torus Knot
Creates a torus knot mesh.
Parameters
name: string
defines the name of the mesh to create
radius: number
sets the global radius size (float) of the torus knot (default 2)
tube: number
sets the diameter size of the tube of the torus (float, default 0.5)
radialSegments: number
sets the number of sides on each tube segments (positive integer, default 32)
tubularSegments: number
sets the number of tubes to decompose the knot into (positive integer, default 32)
p: number
the number of windings on X axis (positive integers, default 2)
q: number
the number of windings on Y axis (positive integers, default 3)
Optional scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Returns Mesh
a new Mesh
Create Tube
Creates a tube mesh. The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
Parameters
name: string
defines the name of the mesh to create
path: Vector3[]
is a required array of successive Vector3. It is the curve used as the axis of the tube
radius: number
sets the tube radius size
tessellation: number
is the number of sides on the tubular surface
radiusFunction: ((i: number, distance: number) => number)
is a custom function. If it is not null, it overrides the parameter
radius
. This function is called on each point of the tube path and is passed the indexi
of the i-th point and the distance of this point from the first point of the pathParameters
i: number
distance: number
Returns number
cap: number
sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional instance: Mesh
is an instance of an existing Tube object to be updated with the passed
pathArray
parameter (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
Returns Mesh
a new Mesh
Extend To Goldberg
Extrude Polygon
Creates an extruded polygon mesh, with depth in the Y direction..
Parameters
name: string
defines the name of the mesh to create
shape: Vector3[]
is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
depth: number
defines the height of extrusion
scene: Scene
defines the hosting scene
Optional holes: Vector3[][]
is a required array of arrays of successive Vector3 used to defines holes in the polygon
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional earcutInjection: any
can be used to inject your own earcut reference
Returns Mesh
a new Mesh
Extrude Shape
Creates an extruded shape mesh. The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
Parameters
name: string
defines the name of the mesh to create
shape: Vector3[]
is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
path: Vector3[]
is a required array of successive Vector3. This is the axis curve the shape is extruded along
scale: number
is the value to scale the shape
rotation: number
is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
cap: number
sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
scene: Nullable<Scene>
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional instance: Mesh
is an instance of an existing ExtrudedShape object to be updated with the passed
shape
,path
,scale
orrotation
parameters (https://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
Returns Mesh
a new Mesh
Extrude Shape Custom
Creates an custom extruded shape mesh. The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
Parameters
name: string
defines the name of the mesh to create
shape: Vector3[]
is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
path: Vector3[]
is a required array of successive Vector3. This is the axis curve the shape is extruded along
scaleFunction: Nullable<((i: number, distance: number) => number)>
is a custom Javascript function called on each path point
rotationFunction: Nullable<((i: number, distance: number) => number)>
is a custom Javascript function called on each path point
ribbonCloseArray: boolean
forces the extrusion underlying ribbon to close all the paths in its
pathArray
ribbonClosePath: boolean
forces the extrusion underlying ribbon to close its
pathArray
cap: number
sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
scene: Scene
defines the hosting scene
Optional updatable: boolean
defines if the mesh must be flagged as updatable
Optional sideOrientation: number
defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
Optional instance: Mesh
is an instance of an existing ExtrudedShape object to be updated with the passed
shape
,path
,scale
orrotation
parameters (https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
Returns Mesh
a new Mesh
Creates a box mesh.
Please use MeshBuilder instead