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 radii must be > 0.
MeshBuilder
Usage :
import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";const capsule = MeshBuilder.CreateCapsule("ribbon", options, scene); //scene is optional and defaults to the current scene| option | value | default value |
|---|---|---|
| orientation? | (Vector3) Direction of the capsule on creation. | Vector3.Up |
| subdivisions | (number) Number of sub-segments on the tube section of the capsule running parallel to orientation. | 2 |
| tessellation | (number) Number of cylindrical segments on the capsule. | 16 |
| height | (number) Height or length of the capsule. | 1 |
| radius | (number) Radius of the capsule. | 0.25 |
| capSubdivisions | (number) Number of sub-segments on the cap sections of the capsule running parallel to orientation. | 6 |
| radiusTop? | (number) Override for the top radius. | |
| radiusBottom? | (number) Override for the bottom radius. | |
| topCapSubdivisions? | (number) Override for the top capSubdivisions. | |
| bottomCapSubdivisions? | (number) Override for the bottom capSubdivisions. |
Examples
Default capsule: Create a Default Capsule
Different cap subdivisions: Create a Capsule With Subdivisions
Forward orientation: Create a Capsule With Forward Orientation
Different radii: Create a Capsule With Different Radii
Mesh
import { Mesh } from "@babylonjs/core/Meshes/mesh";const capsule = Mesh.CreateCapsule("ribbon", options, scene); //scene is optional and defaults to the current sceneThe same form as for MeshBuilder.