Primitives API

Complete reference for all primitive shapes.

sphere

Creates a sphere centered at the origin.

sphere(radius: f64) -> Sdf
ParameterTypeDescription
radiusf64Radius of the sphere
sphere(0.5)

cube

Creates a cube with equal sides, centered at the origin.

cube(size: f64) -> Sdf
ParameterTypeDescription
sizef64Length 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
ParameterTypeDescription
widthf64Full width along X axis
heightf64Full height along Y axis
depthf64Full 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
ParameterTypeDescription
widthf64Full width along X axis
heightf64Full height along Y axis
depthf64Full depth along Z axis
radiusf64Corner 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
ParameterTypeDescription
radiusf64Radius of the cylinder
heightf64Full 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
ParameterTypeDescription
radiusf64Radius of the capsule body and caps
heightf64Total 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
ParameterTypeDescription
major_radiusf64Distance from center to tube center
minor_radiusf64Radius 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
ParameterTypeDescription
radiusf64Radius of the base
heightf64Height 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
ParameterTypeDescription
rxf64Radius along X axis
ryf64Radius along Y axis
rzf64Radius 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
ParameterTypeDescription
sizef64Size 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
ParameterTypeDescription
radiusf64Circumradius of the hexagon
heightf64Full 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
ParameterTypeDescription
widthf64Base width of the triangle
heightf64Height 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
ParameterTypeDescription
nxf64X component of normal (auto-normalized)
nyf64Y component of normal (auto-normalized)
nzf64Z component of normal (auto-normalized)
offsetf64Distance 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() -> Sdf

Equivalent to plane(0.0, 1.0, 0.0, 0.0)

ground_plane()