Operations API

Boolean operations, modifiers, and repetition methods.

Boolean Operations

union

method

Combines two shapes.

sdf.union(other: Sdf) -> Sdf
sphere(0.5).union(cube(0.4))

subtract

method

Subtracts one shape from another.

sdf.subtract(other: Sdf) -> Sdf
sphere(0.5).subtract(cube(0.4))

intersect

method

Keeps only the overlapping region of two shapes.

sdf.intersect(other: Sdf) -> Sdf
sphere(0.5).intersect(cube(0.4))

smooth_union

method

Combines two shapes with a smooth blend.

sdf.smooth_union(other: Sdf, k: f64) -> Sdf
sphere(0.5).smooth_union(cube(0.4), 0.1)

smooth_subtract

method

Subtracts one shape from another with smooth edges.

sdf.smooth_subtract(other: Sdf, k: f64) -> Sdf
sphere(0.5).smooth_subtract(cube(0.4), 0.05)

smooth_intersect

method

Intersects two shapes with smooth edges.

sdf.smooth_intersect(other: Sdf, k: f64) -> Sdf
sphere(0.5).smooth_intersect(cube(0.4), 0.05)

xor

method

Keeps non-overlapping regions from two shapes.

sdf.xor(other: Sdf) -> Sdf
sphere(0.5).xor(cube(0.4))

Modifiers And Repetition

shell

method

Keeps only a shell around the surface.

sdf.shell(thickness: f64) -> Sdf
sphere(0.5).shell(0.05)

hollow

alias

Alias for shell.

sdf.hollow(thickness: f64) -> Sdf
sphere(0.5).hollow(0.05)

Alias for shell.

round

method

Rounds the surface outward by a radius.

sdf.round(radius: f64) -> Sdf
cube(0.5).round(0.05)

onion

method

Creates repeated shell layers.

sdf.onion(thickness: f64) -> Sdf
sphere(0.5).onion(0.05)

elongate

method

Stretches the shape along each axis.

sdf.elongate(x: f64, y: f64, z: f64) -> Sdf
sphere(0.3).elongate(0.2, 0.0, 0.0)

twist

method

Twists the shape around the Y axis.

sdf.twist(amount: f64) -> Sdf
box3(0.5, 1.0, 0.1).twist(2.0)

bend

method

Bends the shape along the X axis.

sdf.bend(amount: f64) -> Sdf
box3(1.0, 0.2, 0.2).bend(0.5)

displace

method

Adds noise-based displacement to the surface.

sdf.displace(amount: f64, frequency: f64) -> Sdf
sphere(0.5).displace(0.05, 10.0)

repeat

method

Repeats the shape infinitely in a grid.

sdf.repeat(sx: f64, sy: f64, sz: f64) -> Sdf
sphere(0.2).repeat(1.0, 1.0, 1.0)

repeat_limited

method

Repeats the shape in a bounded grid.

sdf.repeat_limited(sx: f64, sy: f64, sz: f64, cx: f64, cy: f64, cz: f64) -> Sdf
sphere(0.2).repeat_limited(0.5, 0.5, 0.5, 3.0, 3.0, 3.0)

repeat_polar

method

Repeats the shape radially around the Y axis.

sdf.repeat_polar(count: i64) -> Sdf
sphere(0.2).translate_x(0.5).repeat_polar(6)