natiny.mesh.capsule
Lua
natiny.mesh.capsule([radius [, height [, segments [, rings]]]]) -> mesh
Builds a one-part capsule standing upright along Y and centred on the origin:
a cylindrical side closed by a hemisphere at each end. The generated mesh has
normals and UV coordinates but no texture.
Parameters
| Name |
Type |
Default |
Description |
radius |
number |
0.5 |
Radius of the side and of both hemispheres |
height |
number |
radius * 4 |
Total height end to end, hemispheres included |
segments |
integer |
32 |
Meridians around Y; values below 3 are clamped |
rings |
integer |
8 |
Rings per hemisphere; values below 1 are clamped |
Returns
| Type |
Description |
number |
Mesh handle |
Example
Lua
local capsule = natiny.mesh.capsule(0.4, 1.8)
local player = natiny.model.create()
natiny.model.set_mesh(player, capsule)
Notes
- A
height at or below 2 * radius produces a sphere: the side is clamped to
zero height rather than inverted, and the band that would draw it is skipped.