# Creating A Capsule

> Learn how to create a capsule in Babylon.js.

Source: https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/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 :
```javascript
const capsule = BABYLON.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: [Playground: Create a Default Capsule](https://playground.babylonjs.com/#CL6HZ0) - Simple example of creating a default capsule.  
Different cap subdivisions: [Playground: Create a Capsule With Subdivisions](https://playground.babylonjs.com/#CL6HZ0#1) - Simple example of creating a capsule with subdivisions.
Forward orientation: [Playground: Create a Capsule With Forward Orientation](https://playground.babylonjs.com/#CL6HZ0#2) - Simple example of creating a capsule with forward orientation.
Different radii: [Playground: Create a Capsule With Different Radii](https://playground.babylonjs.com/#CL6HZ0#3) - Simple example of creating a capsule with different radii.

## Mesh
```javascript
const capsule = BABYLON.Mesh.CreateCapsule("ribbon", options, scene);  //scene is optional and defaults to the current scene
```
The same form as for *MeshBuilder*.
