API

Creating A Cylinder

Cylinder or Cone

The created cylinder has its flat sides parallel to the xz plane, with its origin at the center of the vertical line of symmetry. If you set diameterTop to zero, you get a cone instead of a cylinder. With different values for diameterTop and diameterBottom, you get a truncated cone.

MeshBuilder

Usage :

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const cone = MeshBuilder.CreateCylinder("cone", options, scene); //scene is optional and defaults to the current scene
optionvaluedefault value
height
(number) height of the cylinder
2
diameterTop
(number) diameter of the top cap, can be zero to create a cone, overwrites the diameter option
1
diameterBottom
(number) diameter of the bottom cap, can't be zero, overwrites the diameter option
1
diameter
(number) diameter of both caps
1
tessellation
(number) number of radial sides
24
subdivisions
(number) number of rings
1
faceColors
(Color4[]) array of 3 Color4, 0 : bottom cap, 1 : cylinder tube, 2 : top cap
Color4(1, 1, 1, 1) for each face
faceUV
(Vector4[]) array of 3 Vector4, 0 : bottom cap, 1 : cylinder tube, 2 : top cap
UVs(0, 0, 1, 1) for each face
arc
(number) ratio of the circumference between 0 and 1
1
hasRings
(boolean) makes the subdivisions independent from each other, so they become different faces
false
enclose
(boolean) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis
false
updatable
(boolean) true if the mesh is updatable
false
sideOrientation
(number) side orientation
DEFAULTSIDE
frontUVs
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set
Vector4(0,0, 1,1)
backUVs
(Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set
Vector4(0,0, 1,1)

Examples

Cylinder: Create a Cylinder

Cone: Create a Cone

Triangular Prism: Create a Triangular Prism

Arc Create an Arc

Cake Slice: Create a Cake Slice

can label and top

Cylinder with faceUVs Create a Cylinder With Face UVs

Mesh

Usage :

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const cylinder = MeshBuilder.CreateCylinder("cylinder", { height, diameterTop, diameterBottom, tessellation, subdivisions }, scene);