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 :
const cone = BABYLON.MeshBuilder.CreateCylinder("cone", options, scene); //scene is optional and defaults to the current scene
option | value | default value |
---|---|---|
option height | value (number) height of the cylinder | default value 2 |
option diameterTop | value (number) diameter of the top cap, can be zero to create a cone, overwrites the diameter option | default value 1 |
option diameterBottom | value (number) diameter of the bottom cap, can't be zero, overwrites the diameter option | default value 1 |
option diameter | value (number) diameter of both caps | default value 1 |
option tessellation | value (number) number of radial sides | default value 24 |
option subdivisions | value (number) number of rings | default value 1 |
option faceColors | value (Color4[]) array of 3 Color4, 0 : bottom cap, 1 : cylinder tube, 2 : top cap | default value Color4(1, 1, 1, 1) for each face |
option faceUV | value (Vector4[]) array of 3 Vector4, 0 : bottom cap, 1 : cylinder tube, 2 : top cap | default value UVs(0, 0, 1, 1) for each face |
option arc | value (number) ratio of the circumference between 0 and 1 | default value 1 |
option updatable | value (boolean) true if the mesh is updatable | default value false |
option sideOrientation | value (number) side orientation | default value DEFAULTSIDE |
option frontUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | default value Vector4(0,0, 1,1) |
option backUVs | value (Vector4) ONLY WHEN sideOrientation:BABYLON.Mesh.DOUBLESIDE set | default value Vector4(0,0, 1,1) |
Examples
Cylinder: Create a Cylinder Cone: Create a Cone Triangular Prism: Create a Triangular Prism Arc Create an Arc
Cylinder with faceUVs Create a Cylinder With Face UVs
Mesh
Usage :
const cylinder = BABYLON.Mesh.CreateCylinder("cylinder", height, diameterTop, diameterBottom, tessellation, subdivisions, scene);const cylinder = BABYLON.Mesh.CreateCylinder("cylinder", height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation); //optional parameters after scene