Primitives API
Complete reference for all primitive shapes.
sphere
Creates a sphere centered at the origin.
sphere(radius: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| radius | f64 | Radius of the sphere |
sphere(0.5)cube
Creates a cube with equal sides, centered at the origin.
cube(size: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| size | f64 | Length of each edge |
cube(1.0)box3
Creates a rectangular box with different dimensions per axis, centered at the origin.
box3(width: f64, height: f64, depth: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| width | f64 | Full width along X axis |
| height | f64 | Full height along Y axis |
| depth | f64 | Full depth along Z axis |
box3(1.0, 0.5, 0.3)rounded_box
Creates a rectangular box with rounded edges and corners.
rounded_box(width: f64, height: f64, depth: f64, radius: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| width | f64 | Full width along X axis |
| height | f64 | Full height along Y axis |
| depth | f64 | Full depth along Z axis |
| radius | f64 | Corner rounding radius |
rounded_box(1.0, 0.5, 0.3, 0.1)cylinder
Creates a cylinder aligned along the Y axis, centered at the origin.
cylinder(radius: f64, height: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| radius | f64 | Radius of the cylinder |
| height | f64 | Full height of the cylinder |
cylinder(0.4, 1.0)capsule
Creates a pill-shaped primitive (cylinder with hemispherical caps), aligned along Y axis.
capsule(radius: f64, height: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| radius | f64 | Radius of the capsule body and caps |
| height | f64 | Total height including caps |
capsule(0.3, 0.8)torus
Creates a donut shape lying in the XZ plane, centered at the origin.
torus(major_radius: f64, minor_radius: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| major_radius | f64 | Distance from center to tube center |
| minor_radius | f64 | Radius of the tube itself |
torus(0.5, 0.15)cone
Creates a cone with its tip at the origin, opening upward along the Y axis.
cone(radius: f64, height: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| radius | f64 | Radius of the base |
| height | f64 | Height of the cone |
cone(0.5, 1.0)ellipsoid
Creates a stretched sphere with different radii per axis.
ellipsoid(rx: f64, ry: f64, rz: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| rx | f64 | Radius along X axis |
| ry | f64 | Radius along Y axis |
| rz | f64 | Radius along Z axis |
ellipsoid(0.6, 0.4, 0.3)octahedron
Creates an 8-faced platonic solid (diamond shape), centered at the origin.
octahedron(size: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| size | f64 | Size of the octahedron |
octahedron(0.6)hex_prism
Creates a hexagonal prism (6-sided column), aligned along the Y axis.
hex_prism(radius: f64, height: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| radius | f64 | Circumradius of the hexagon |
| height | f64 | Full height of the prism |
hex_prism(0.4, 0.8)tri_prism
Creates a triangular prism, aligned along the Y axis.
tri_prism(width: f64, height: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| width | f64 | Base width of the triangle |
| height | f64 | Height of the prism |
tri_prism(0.5, 0.8)plane
Creates an infinite plane defined by a normal vector and offset from the origin.
plane(nx: f64, ny: f64, nz: f64, offset: f64) -> Sdf| Parameter | Type | Description |
|---|---|---|
| nx | f64 | X component of normal (auto-normalized) |
| ny | f64 | Y component of normal (auto-normalized) |
| nz | f64 | Z component of normal (auto-normalized) |
| offset | f64 | Distance from origin along normal |
// Horizontal plane at y=0
plane(0.0, 1.0, 0.0, 0.0)ground_plane
Convenience function for a horizontal ground plane at y=0.
ground_plane() -> SdfEquivalent to plane(0.0, 1.0, 0.0, 0.0)
ground_plane()