Class MeshBuilder
Hierarchy
- MeshBuilder
Index
Methods
- Create
Box - Create
Capsule - Create
Cylinder - Create
Dashed Lines - Create
Decal - Create
Disc - Create
Ground - Create
Ground From Height Map - Create
Ico Sphere - Create
Lathe - Create
Line System - Create
Lines - Create
Plane - Create
Polygon - Create
Polyhedron - Create
Ribbon - Create
Sphere - Create
Tiled Box - Create
Tiled Ground - Create
Tiled Plane - Create
Torus - Create
Torus Knot - Create
Tube - Extrude
Polygon - Extrude
Shape - Extrude
Shape Custom
Methods
Static Create BoxSearch playground for CreateBox
-
Creates a box mesh
- The parameter
size
sets the size (float) of each box side (default 1) - You can set some different box dimensions by using the parameters
width
,height
anddepth
(all by default have the same value ofsize
) - You can set different colors and different images to each box side by using the parameters
faceColors
(an array of 6 Color3 elements) andfaceUV
(an array of 6 Vector4 elements) - Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
- You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; bottomBaseAt?: number; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; height?: number; sideOrientation?: number; size?: number; topBaseAt?: number; updatable?: boolean; width?: number; wrap?: boolean }
defines the options used to create the mesh
-
Optional backUVs?: Vector4
-
Optional bottom
Base At?: number -
Optional depth?: number
-
Optional face
Colors?: Color4[] -
Optional faceUV?: Vector4[]
-
Optional frontUVs?: Vector4
-
Optional height?: number
-
Optional side
Orientation?: number -
Optional size?: number
-
Optional top
Base At?: number -
Optional updatable?: boolean
-
Optional width?: number
-
Optional wrap?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the box mesh
- The parameter
Static Create CapsuleSearch playground for CreateCapsule
-
Creates a Capsule Mesh
Parameters
-
name: string
defines the name of the mesh.
-
Optional options: ICreateCapsuleOptions
the constructors options used to shape the mesh.
-
Optional scene: Nullable<Scene>
defines the scene the mesh is scoped to.
Returns Mesh
the capsule mesh
-
Static Create CylinderSearch playground for CreateCylinder
-
Creates a cylinder or a cone mesh
- The parameter
height
sets the height size (float) of the cylinder/cone (float, default 2). - The parameter
diameter
sets the diameter of the top and bottom cap at once (float, default 1). - The parameters
diameterTop
anddiameterBottom
overwrite the parameterdiameter
and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter "diameterBottom" can't be zero. - The parameter
tessellation
sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance. - The parameter
subdivisions
sets the number of rings along the cylinder height (positive integer, default 1). - The parameter
hasRings
(boolean, default false) makes the subdivisions independent from each other, so they become different faces. - The parameter
enclose
(boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis. - The parameter
cap
sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default). - The parameter
arc
(float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder. - You can set different colors and different images to each box side by using the parameters
faceColors
(an array of n Color3 elements) andfaceUV
(an array of n Vector4 elements). - The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3
- Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
- Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17
- Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.
- If
enclose
is false, a ring surface is one element. - If
enclose
is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces. - Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
- You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { arc?: number; backUVs?: Vector4; cap?: number; diameter?: number; diameterBottom?: number; diameterTop?: number; enclose?: boolean; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; hasRings?: boolean; height?: number; sideOrientation?: number; subdivisions?: number; tessellation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional arc?: number
-
Optional backUVs?: Vector4
-
Optional cap?: number
-
Optional diameter?: number
-
Optional diameter
Bottom?: number -
Optional diameter
Top?: number -
Optional enclose?: boolean
-
Optional face
Colors?: Color4[] -
Optional faceUV?: Vector4[]
-
Optional frontUVs?: Vector4
-
Optional has
Rings?: boolean -
Optional height?: number
-
Optional side
Orientation?: number -
Optional subdivisions?: number
-
Optional tessellation?: number
-
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the cylinder mesh
- The parameter
Static Create Dashed LinesSearch playground for CreateDashedLines
-
Creates a dashed line mesh
- A dashed line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
- Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
- The parameter
points
is an array successive Vector3 - The parameter
dashNb
is the intended total number of dashes (positive integer, default 200) - The parameter
dashSize
is the size of the dashes relatively the dash number (positive float, default 3) - The parameter
gapSize
is the size of the gap between two successive dashes relatively the dash number (positive float, default 1) - The optional parameter
instance
is an instance of an existing LineMesh object to be updated with the passedpoints
parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines - When updating an instance, remember that only point positions can change, not the number of points
- The mesh can be set to updatable with the boolean parameter
updatable
(default false) if its internal geometry is supposed to change once created
Parameters
-
name: string
defines the name of the mesh
-
options: { dashNb?: number; dashSize?: number; gapSize?: number; instance?: LinesMesh; points: Vector3[]; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns LinesMesh
the dashed line mesh
Static Create DecalSearch playground for CreateDecal
-
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- The parameter
position
(Vector3, default(0, 0, 0)
) sets the position of the decal in World coordinates - The parameter
normal
(Vector3, defaultVector3.Up
) sets the normal of the mesh where the decal is applied onto in World coordinates - The parameter
size
(Vector3, default(1, 1, 1)
) sets the decal scaling - The parameter
angle
(float in radian, default 0) sets the angle to rotate the decal
Parameters
-
name: string
defines the name of the mesh
-
sourceMesh: AbstractMesh
defines the mesh where the decal must be applied
-
options: { angle?: number; normal?: Vector3; position?: Vector3; size?: Vector3 }
defines the options used to create the mesh
Returns Mesh
the decal mesh
- The parameter
Static Create DiscSearch playground for CreateDisc
-
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
tessellation
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 - You can create an unclosed polygon with the parameter
arc
(positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { arc?: number; backUVs?: Vector4; frontUVs?: Vector4; radius?: number; sideOrientation?: number; tessellation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the plane polygonal mesh
- The parameter
Static Create GroundSearch playground for CreateGround
-
Creates a ground mesh
- The parameters
width
andheight
(floats, default 1) set the width and height sizes of the ground - The parameter
subdivisions
(positive integer) sets the number of subdivisions per side - 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: { height?: number; subdivisions?: number; subdivisionsX?: number; subdivisionsY?: number; updatable?: boolean; width?: number }
defines the options used to create the mesh
-
Optional height?: number
-
Optional subdivisions?: number
-
Optional subdivisionsX?: number
-
Optional subdivisionsY?: number
-
Optional updatable?: boolean
-
Optional width?: number
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the ground mesh
- The parameters
Static Create Ground From Height MapSearch playground for CreateGroundFromHeightMap
-
Creates a ground mesh from a height map
- The parameter
url
sets the URL of the height map image resource. - The parameters
width
andheight
(positive floats, default 10) set the ground width and height sizes. - The parameter
subdivisions
(positive integer, default 1) sets the number of subdivision per side. - The parameter
minHeight
(float, default 0) is the minimum altitude on the ground. - The parameter
maxHeight
(float, default 1) is the maximum altitude on the ground. - The parameter
colorFilter
(optional Color3, default (0.3, 0.59, 0.11) ) is the filter to apply to the image pixel colors to compute the height. - The parameter
onReady
is a javascript callback function that will be called once the mesh is just built (the height map download can last some time). - The parameter
alphaFilter
will filter any data where the alpha channel is below this value, defaults 0 (all data visible) - 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
-
url: string
defines the url to the height map
-
options: { alphaFilter?: number; colorFilter?: Color3; height?: number; maxHeight?: number; minHeight?: number; onReady?: (mesh: GroundMesh) => void; subdivisions?: number; updatable?: boolean; width?: number }
defines the options used to create the mesh
-
Optional alpha
Filter?: number -
Optional color
Filter?: Color3 -
Optional height?: number
-
Optional max
Height?: number -
Optional min
Height?: number -
Optional on
Ready?: (mesh: GroundMesh) => void -
-
Parameters
-
mesh: GroundMesh
Returns void
-
-
-
-
Optional subdivisions?: number
-
Optional updatable?: boolean
-
Optional width?: number
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns GroundMesh
the ground mesh
- The parameter
Static Create Ico SphereSearch playground for CreateIcoSphere
-
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 ofradius
) - The parameter
subdivisions
sets the number of subdivisions (postive 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 : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; flat?: boolean; frontUVs?: Vector4; radius?: number; radiusX?: number; radiusY?: number; radiusZ?: number; sideOrientation?: number; subdivisions?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the icosahedron mesh
- The parameter
Static Create LatheSearch playground for CreateLathe
-
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 parameter
shape
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 - The parameter
radius
(positive float, default 1) is the radius value of the lathe - The parameter
tessellation
(positive integer, default 64) is the side number of the lathe - The parameter
clip
(positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides - The parameter
arc
(positive float, default 1) is the ratio of the lathe. 0.5 builds for instance half a lathe, so an opened shape - The parameter
closed
(boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc" - The parameter
cap
sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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 optional parameter
invertUV
(boolean, default false) swaps in the geometry the U and V coordinates to apply a texture - 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: { arc?: number; backUVs?: Vector4; cap?: number; clip?: number; closed?: boolean; frontUVs?: Vector4; invertUV?: boolean; radius?: number; shape: Vector3[]; sideOrientation?: number; tessellation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional arc?: number
-
Optional backUVs?: Vector4
-
Optional cap?: number
-
Optional clip?: number
-
Optional closed?: boolean
-
Optional frontUVs?: Vector4
-
Optional invertUV?: boolean
-
Optional radius?: number
-
shape: Vector3[]
-
Optional side
Orientation?: number -
Optional tessellation?: number
-
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the lathe mesh
- The parameter
Static Create Line SystemSearch playground for CreateLineSystem
-
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
- Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
- The parameter
lines
is an array of lines, each line being an array of successive Vector3 - The optional parameter
instance
is an instance of an existing LineSystem object to be updated with the passedlines
parameter - The optional parameter
colors
is an array of line colors, each line colors being an array of successive Color4, one per line point - The optional parameter
useVertexAlpha
is to be set tofalse
(defaulttrue
) when you don't need the alpha blending (faster) - Updating a simple Line mesh, you just need to update every line in the
lines
array : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines - When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
- 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 new line system
-
options: { colors?: Nullable<Color4[][]>; instance?: Nullable<LinesMesh>; lines: Vector3[][]; updatable?: boolean; useVertexAlpha?: boolean }
defines the options used to create the line system
-
scene: Nullable<Scene>
defines the hosting scene
Returns LinesMesh
a new line system mesh
Static Create LinesSearch playground for CreateLines
-
Creates a line mesh A line mesh is considered as a parametric shape since it has no predefined original shape. Its shape is determined by the passed array of points as an input parameter
- Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
- The parameter
points
is an array successive Vector3 - The optional parameter
instance
is an instance of an existing LineMesh object to be updated with the passedpoints
parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#lines-and-dashedlines - The optional parameter
colors
is an array of successive Color4, one per line point - The optional parameter
useVertexAlpha
is to be set tofalse
(defaulttrue
) when you don't need alpha blending (faster) - When updating an instance, remember that only point positions can change, not the number of points
- The mesh can be set to updatable with the boolean parameter
updatable
(default false) if its internal geometry is supposed to change once created
Parameters
-
name: string
defines the name of the new line system
-
options: { colors?: Color4[]; instance?: Nullable<LinesMesh>; points: Vector3[]; updatable?: boolean; useVertexAlpha?: boolean }
defines the options used to create the line system
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns LinesMesh
a new line mesh
Static Create PlaneSearch playground for CreatePlane
-
Creates a plane mesh
- The parameter
size
sets the size (float) of both sides of the plane at once (default 1) - You can set some different plane dimensions by using the parameters
width
andheight
(both by default have the same value ofsize
) - The parameter
sourcePlane
is a Plane instance. It builds a mesh plane from a Math plane - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; frontUVs?: Vector4; height?: number; sideOrientation?: number; size?: number; sourcePlane?: Plane; updatable?: boolean; width?: number }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the plane mesh
- The parameter
Static Create PolygonSearch playground for CreatePolygon
-
Creates a polygon mesh 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 parameter
updatable
(default false) if its internal geometry is supposed to change once created - 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) - Remember you can only change the shape positions, not their number when updating a polygon
Parameters
-
name: string
defines the name of the mesh
-
options: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
-
Optional earcutInjection: any
can be used to inject your own earcut reference
Returns Mesh
the polygon mesh
- The parameter
Static Create PolyhedronSearch playground for CreatePolyhedron
-
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
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 : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; custom?: any; faceColors?: Color4[]; faceUV?: Vector4[]; flat?: boolean; frontUVs?: Vector4; sideOrientation?: number; size?: number; sizeX?: number; sizeY?: number; sizeZ?: number; type?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional backUVs?: Vector4
-
Optional custom?: any
-
Optional face
Colors?: Color4[] -
Optional faceUV?: Vector4[]
-
Optional flat?: boolean
-
Optional frontUVs?: Vector4
-
Optional side
Orientation?: number -
Optional size?: number
-
Optional sizeX?: number
-
Optional sizeY?: number
-
Optional sizeZ?: number
-
Optional type?: number
-
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the polyhedron mesh
- The parameter
Static Create RibbonSearch playground for CreateRibbon
-
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
closeArray
(boolean, default false) creates a seam between the first and the last paths of the path array - The parameter
closePath
(boolean, default false) creates a seam between the first and the last points of each path of the path array - The parameter
offset
(positive integer, default : rounded half size of the pathArray length), is taken in account only if thepathArray
is containing a single path - It's the offset to join the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11
- The optional parameter
instance
is an instance of an existing Ribbon object to be updated with the passedpathArray
parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#ribbon - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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 optional parameter
invertUV
(boolean, default false) swaps in the geometry the U and V coordinates to apply a texture - The parameter
uvs
is an optional flat array ofVector2
to update/set each ribbon vertex with its own custom UV values instead of the computed ones - The parameters
colors
is an optional flat array ofColor4
to set/update each ribbon vertex with its own custom color values - Note that if you use the parameters
uvs
orcolors
, the passed arrays must be populated with the right number of elements, it is to say the number of ribbon vertices. Remember that if you setclosePath
totrue
, there's one extra vertex per path in the geometry - Moreover, you can use the parameter
color
withinstance
(to update the ribbon), only if you previously used it at creation time - 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: { backUVs?: Vector4; closeArray?: boolean; closePath?: boolean; colors?: Color4[]; frontUVs?: Vector4; instance?: Mesh; invertUV?: boolean; offset?: number; pathArray: Vector3[][]; sideOrientation?: number; updatable?: boolean; uvs?: Vector2[] }
defines the options used to create the mesh
-
Optional backUVs?: Vector4
-
Optional close
Array?: boolean -
Optional close
Path?: boolean -
Optional colors?: Color4[]
-
Optional frontUVs?: Vector4
-
Optional instance?: Mesh
-
Optional invertUV?: boolean
-
Optional offset?: number
-
path
Array: Vector3[][] -
Optional side
Orientation?: number -
Optional updatable?: boolean
-
Optional uvs?: Vector2[]
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the ribbon mesh
- The parameter
Static Create SphereSearch playground for CreateSphere
-
Creates a sphere mesh
- The parameter
diameter
sets the diameter size (float) of the sphere (default 1) - You can set some different sphere dimensions, for instance to build an ellipsoid, by using the parameters
diameterX
,diameterY
anddiameterZ
(all by default have the same value ofdiameter
) - The parameter
segments
sets the sphere number of horizontal stripes (positive integer, default 32) - You can create an unclosed sphere with the parameter
arc
(positive float, default 1), valued between 0 and 1, what is the ratio of the circumference (latitude) : 2 x PI x ratio - You can create an unclosed sphere on its height with the parameter
slice
(positive float, default1), valued between 0 and 1, what is the height ratio (longitude) - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { arc?: number; backUVs?: Vector4; diameter?: number; diameterX?: number; diameterY?: number; diameterZ?: number; frontUVs?: Vector4; segments?: number; sideOrientation?: number; slice?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional arc?: number
-
Optional backUVs?: Vector4
-
Optional diameter?: number
-
Optional diameterX?: number
-
Optional diameterY?: number
-
Optional diameterZ?: number
-
Optional frontUVs?: Vector4
-
Optional segments?: number
-
Optional side
Orientation?: number -
Optional slice?: number
-
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the sphere mesh
- The parameter
Static Create Tiled BoxSearch playground for CreateTiledBox
-
Creates a tiled box mesh
- faceTiles sets the pattern, tile size and number of tiles for a face
- 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: { alignHorizontal?: number; alignVertical?: number; depth: number; faceColors?: Color4[]; faceUV?: Vector4[]; height?: number; pattern?: number; sideOrientation?: number; size?: number; tileHeight?: number; tileSize?: number; tileWidth?: number; updatable?: boolean; width?: number }
defines the options used to create the mesh
-
Optional align
Horizontal?: number -
Optional align
Vertical?: number -
depth: number
-
Optional face
Colors?: Color4[] -
Optional faceUV?: Vector4[]
-
Optional height?: number
-
Optional pattern?: number
-
Optional side
Orientation?: number -
Optional size?: number
-
Optional tile
Height?: number -
Optional tile
Size?: number -
Optional tile
Width?: number -
Optional updatable?: boolean
-
Optional width?: number
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the tiled box mesh
Static Create Tiled GroundSearch playground for CreateTiledGround
-
Creates a tiled ground mesh
- The parameters
xmin
andxmax
(floats, default -1 and 1) set the ground minimum and maximum X coordinates - The parameters
zmin
andzmax
(floats, default -1 and 1) set the ground minimum and maximum Z coordinates - The parameter
subdivisions
is a javascript 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 tile - The parameter
precision
is a javascript 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 tile - 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: { precision?: { h: number; w: number }; subdivisions?: { h: number; w: number }; updatable?: boolean; xmax: number; xmin: number; zmax: number; zmin: number }
defines the options used to create the mesh
-
Optional precision?: { h: number; w: number }
-
h: number
-
w: number
-
-
Optional subdivisions?: { h: number; w: number }
-
h: number
-
w: number
-
-
Optional updatable?: boolean
-
xmax: number
-
xmin: number
-
zmax: number
-
zmin: number
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the tiled ground mesh
- The parameters
Static Create Tiled PlaneSearch playground for CreateTiledPlane
-
Creates a tiled plane mesh
- You can set a limited pattern arrangement with the tiles
- You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { alignHorizontal?: number; alignVertical?: number; backUVs?: Vector4; frontUVs?: Vector4; height?: number; pattern?: number; sideOrientation?: number; size?: number; tileHeight?: number; tileSize?: number; tileWidth?: number; updatable?: boolean; width?: number }
defines the options used to create the mesh
-
Optional align
Horizontal?: number -
Optional align
Vertical?: number -
Optional backUVs?: Vector4
-
Optional frontUVs?: Vector4
-
Optional height?: number
-
Optional pattern?: number
-
Optional side
Orientation?: number -
Optional size?: number
-
Optional tile
Height?: number -
Optional tile
Size?: number -
Optional tile
Width?: number -
Optional updatable?: boolean
-
Optional width?: number
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the plane mesh
Static Create TorusSearch playground for CreateTorus
-
Creates a torus mesh
- The parameter
diameter
sets the diameter size (float) of the torus (default 1) - The parameter
thickness
sets the diameter size of the tube of the torus (float, default 0.5) - The parameter
tessellation
sets the number of torus sides (postive integer, default 16) - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; diameter?: number; frontUVs?: Vector4; sideOrientation?: number; tessellation?: number; thickness?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the torus mesh
- The parameter
Static Create Torus KnotSearch playground for CreateTorusKnot
-
Creates a torus knot mesh
- The parameter
radius
sets the global radius size (float) of the torus knot (default 2) - The parameter
radialSegments
sets the number of sides on each tube segments (positive integer, default 32) - The parameter
tubularSegments
sets the number of tubes to decompose the knot into (positive integer, default 32) - The parameters
p
andq
are the number of windings on each axis (positive integers, default 2 and 3) - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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: { backUVs?: Vector4; frontUVs?: Vector4; p?: number; q?: number; radialSegments?: number; radius?: number; sideOrientation?: number; tube?: number; tubularSegments?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the torus knot mesh
- The parameter
Static Create TubeSearch playground for CreateTube
-
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 parameter
path
is a required array of successive Vector3. It is the curve used as the axis of the tube - The parameter
radius
(positive float, default 1) sets the tube radius size - The parameter
tessellation
(positive float, default 64) is the number of sides on the tubular surface - The parameter
radiusFunction
(javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameterradius
- This function is called on each point of the tube path and is passed the index
i
of the i-th point and the distance of this point from the first point of the path. It must return a radius value (positive float) - The parameter
arc
(positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc - The parameter
cap
sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL - The optional parameter
instance
is an instance of an existing Tube object to be updated with the passedpathArray
parameter : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#tube - You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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 optional parameter
invertUV
(boolean, default false) swaps in the geometry the U and V coordinates to apply a texture - 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: { arc?: number; backUVs?: Vector4; cap?: number; frontUVs?: Vector4; instance?: Mesh; invertUV?: boolean; path: Vector3[]; radius?: number; radiusFunction?: (i: number, distance: number) => number; sideOrientation?: number; tessellation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional arc?: number
-
Optional backUVs?: Vector4
-
Optional cap?: number
-
Optional frontUVs?: Vector4
-
Optional instance?: Mesh
-
Optional invertUV?: boolean
-
path: Vector3[]
-
Optional radius?: number
-
Optional radius
Function?: (i: number, distance: number) => number -
-
Parameters
-
i: number
-
distance: number
Returns number
-
-
-
-
Optional side
Orientation?: number -
Optional tessellation?: number
-
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the tube mesh
- The parameter
Static Extrude PolygonSearch playground for ExtrudePolygon
-
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) andfaceUV
(an array of 3 Vector4 elements)
Parameters
-
name: string
defines the name of the mesh
-
options: { backUVs?: Vector4; depth?: number; faceColors?: Color4[]; faceUV?: Vector4[]; frontUVs?: Vector4; holes?: Vector3[][]; shape: Vector3[]; sideOrientation?: number; updatable?: boolean; wrap?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
-
Optional earcutInjection: any
can be used to inject your own earcut reference
Returns Mesh
the polygon mesh
- You can set different colors and different images to the top, bottom and extruded side by using the parameters
Static Extrude ShapeSearch playground for ExtrudeShape
-
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.
- The parameter
shape
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. - The parameter
path
is a required array of successive Vector3. This is the axis curve the shape is extruded along. - The parameter
rotation
(float, default 0 radians) 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. - The parameter
scale
(float, default 1) is the value to scale the shape. - The parameter
cap
sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL - The optional parameter
instance
is an instance of an existing ExtrudedShape object to be updated with the passedshape
,path
,scale
orrotation
parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape - Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
- You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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 optional parameter
invertUV
(boolean, default false) swaps in the geometry the U and V coordinates to apply a texture. - 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: { backUVs?: Vector4; cap?: number; frontUVs?: Vector4; instance?: Mesh; invertUV?: boolean; path: Vector3[]; rotation?: number; scale?: number; shape: Vector3[]; sideOrientation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the extruded shape mesh
- The parameter
Static Extrude Shape CustomSearch playground for ExtrudeShapeCustom
-
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.
- The parameter
shape
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. - The parameter
path
is a required array of successive Vector3. This is the axis curve the shape is extruded along. - The parameter
rotationFunction
(JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path - It must returns a float value that will be the rotation in radians applied to the shape on each path point.
- The parameter
scaleFunction
(JS function) is a custom Javascript function called on each path point. This function is passed the position i of the point in the path and the distance of this point from the begining of the path - It must returns a float value that will be the scale value applied to the shape on each path point
- The parameter
ribbonClosePath
(boolean, default false) forces the extrusion underlying ribbon to close all the paths in itspathArray
- The parameter
ribbonCloseArray
(boolean, default false) forces the extrusion underlying ribbon to close itspathArray
- The parameter
cap
sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL - The optional parameter
instance
is an instance of an existing ExtrudedShape object to be updated with the passedshape
,path
,scale
orrotation
parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape - Remember you can only change the shape or path point positions, not their number when updating an extruded shape
- You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.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 optional parameter
invertUV
(boolean, default false) swaps in the geometry the U and V coordinates to apply a texture - 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: { backUVs?: Vector4; cap?: number; frontUVs?: Vector4; instance?: Mesh; invertUV?: boolean; path: Vector3[]; ribbonCloseArray?: boolean; ribbonClosePath?: boolean; rotationFunction?: any; scaleFunction?: any; shape: Vector3[]; sideOrientation?: number; updatable?: boolean }
defines the options used to create the mesh
-
Optional backUVs?: Vector4
-
Optional cap?: number
-
Optional frontUVs?: Vector4
-
Optional instance?: Mesh
-
Optional invertUV?: boolean
-
path: Vector3[]
-
Optional ribbon
Close Array?: boolean -
Optional ribbon
Close Path?: boolean -
Optional rotation
Function?: any -
Optional scale
Function?: any -
shape: Vector3[]
-
Optional side
Orientation?: number -
Optional updatable?: boolean
-
-
Optional scene: Nullable<Scene>
defines the hosting scene
Returns Mesh
the custom extruded shape mesh
- The parameter
Class containing static functions to help procedurally build meshes