Creating A Capsule

Capsule

Requires BJS version 4.2+ The created capsule has its origin at the center of the capsule. The height minus the sum of the top and bottom radius must be > 0.

MeshBuilder

Usage :

const capsule = BABYLON.MeshBuilder.CreateCapsule("ribbon", options, scene); //scene is optional and defaults to the current scene
optionvaluedefault value
option
orientation?
value
(Vector3) Direction of the capsule upon inception.
default value
Vector3.Up
option
subdivisions
value
(number) Number of sub segments on the tube section of the capsule running parallel to orientation.
default value
2
option
tessellation
value
(number) Number of cylindrical segments on the capsule.
default value
16
option
height
value
(number) Height or length of the capsule.
default value
1
option
radius
value
(number) Radius of the capsule.
default value
0.25
option
capSubdivisions
value
(number) Number of sub segments on the cap sections of the capsule running parallel to orientation.
default value
6
option
radiusTop?
value
(number) Overwrite for the top radius.
default value
 
option
radiusBottom?
value
(number) Overwrite for the bottom radius.
default value
 
option
topCapSubdivisions?
value
(number) Overwrite for the top capSubdivisions.
default value
 
option
bottomCapSubdivisions?
value
(number) Overwrite for the bottom capSubdivisions.
default value
 

Examples

Default capsule: Create a Default Capsule
Different cap subdivisions: Create a Capsule With Subdivisions Forward orientation: Create a Capsule With Foreward Orientation Different radii: Create a Capsule With Different Radii

Mesh

const capsule = BABYLON.Mesh.CreateCapsule("ribbon", options, scene); //scene is optional and defaults to the current scene

The same form as for MeshBuilder