Operations API

Complete reference for boolean operations, smooth blends, and modifiers.

Boolean Operations

Combine shapes using standard constructive solid geometry (CSG) operations.

.union()

Combines two shapes together (logical OR).

shape.union(other: Sdf) -> Sdf
// Combine a sphere and cube
sphere(0.5).union(cube(0.7))

.subtract()

Removes one shape from another (A minus B).

shape.subtract(other: Sdf) -> Sdf
// Cut a hole in a cube
cube(1.0).subtract(sphere(0.7))

.intersect()

Keeps only the overlapping region of two shapes (logical AND).

shape.intersect(other: Sdf) -> Sdf
// Keep only where sphere and cube overlap
sphere(0.6).intersect(cube(0.8))

Smooth Operations

Blend shapes together with organic, filleted transitions. The k parameter controls the blend radius.

The k parameter (blend radius)

  • k = 0.01 - Barely visible blend
  • k = 0.05 - Subtle fillet
  • k = 0.1 - Noticeable blend
  • k = 0.2+ - Organic, blobby appearance

.smooth_union()

Blends two shapes together with a smooth transition.

shape.smooth_union(other: Sdf, k: f64) -> Sdf
ParameterTypeDescription
otherSdfShape to blend with
kf64Blend radius (larger = softer)
// Organic blob from two spheres
let a = sphere(0.4);
let b = sphere(0.4).translate_x(0.5);
a.smooth_union(b, 0.2)

.smooth_subtract()

Subtracts with a filleted edge instead of a sharp cut.

shape.smooth_subtract(other: Sdf, k: f64) -> Sdf
// Soft-edged cavity
cube(1.0).smooth_subtract(sphere(0.6), 0.1)

.smooth_intersect()

Intersection with filleted edges where shapes meet.

shape.smooth_intersect(other: Sdf, k: f64) -> Sdf
// Rounded intersection
sphere(0.6).smooth_intersect(cube(0.8), 0.1)

Surface Modifiers

Transform the surface or volume of shapes.

.shell() / .hollow()

Makes a shape hollow with specified wall thickness. Both methods are equivalent.

shape.shell(thickness: f64) -> Sdf
shape.hollow(thickness: f64) -> Sdf
ParameterTypeDescription
thicknessf64Wall thickness
// Hollow sphere with 0.05 thick walls
sphere(0.5).shell(0.05)

.round()

Rounds all edges and corners of a shape.

shape.round(radius: f64) -> Sdf
ParameterTypeDescription
radiusf64Rounding radius
// Cube with rounded corners
cube(1.0).round(0.1)

.onion()

Creates concentric shells like an onion.

shape.onion(thickness: f64) -> Sdf
ParameterTypeDescription
thicknessf64Spacing between shells
// Concentric spherical shells
sphere(0.5).onion(0.1)

.elongate()

Stretches a shape by inserting flat sections along each axis.

shape.elongate(x: f64, y: f64, z: f64) -> Sdf
ParameterTypeDescription
xf64Elongation along X axis
yf64Elongation along Y axis
zf64Elongation along Z axis
// Stretched sphere (capsule-like)
sphere(0.3).elongate(0.5, 0.0, 0.0)

Deformations

Warp and bend shapes in space.

.twist()

Twists a shape around the Y axis progressively along its height.

shape.twist(amount: f64) -> Sdf
ParameterTypeDescription
amountf64Twist per unit height (radians)
// Twisted column
box3(0.3, 2.0, 0.3).twist(2.0)

.bend()

Bends a shape around the Y axis.

shape.bend(amount: f64) -> Sdf
ParameterTypeDescription
amountf64Bend curvature amount
// Curved bar
box3(2.0, 0.2, 0.3).bend(1.0)

Repetition

Create patterns by repeating shapes.

.repeat()

Infinitely repeats a shape with the given spacing. Use with caution - creates infinite geometry.

shape.repeat(sx: f64, sy: f64, sz: f64) -> Sdf
ParameterTypeDescription
sxf64Spacing along X axis
syf64Spacing along Y axis
szf64Spacing along Z axis
// Infinite grid of spheres
sphere(0.2).repeat(1.0, 1.0, 1.0)

.repeat_limited()

Creates a finite grid of copies with specified count per axis.

shape.repeat_limited(sx: f64, sy: f64, sz: f64, cx: f64, cy: f64, cz: f64) -> Sdf
ParameterTypeDescription
sx, sy, szf64Spacing between copies
cx, cy, czf64Number of copies per axis
// 3x3x3 grid of spheres
sphere(0.1).repeat_limited(0.3, 0.3, 0.3, 3.0, 3.0, 3.0)

.repeat_polar()

Repeats a shape in a circular pattern around the Y axis.

shape.repeat_polar(count: i64) -> Sdf
ParameterTypeDescription
counti64Number of copies around circle
// Gear teeth pattern
let tooth = box3(0.1, 0.5, 0.1).translate_x(0.5);
tooth.repeat_polar(8)