Transforms API
Complete reference for spatial transform operations. Transforms modify the position, orientation, and scale of shapes without changing their underlying geometry.
Translation
Move shapes in 3D space. Translation shifts the shape's position without affecting its orientation or size.
translate(x, y, z)
Move a shape by the specified offset in all three dimensions simultaneously.
| Parameter | Type | Description |
|---|---|---|
| x | float | Offset along X axis (positive = right) |
| y | float | Offset along Y axis (positive = up) |
| z | float | Offset along Z axis (positive = forward) |
// Move a sphere to position (1, 2, 0.5)
sphere(0.3).translate(1.0, 2.0, 0.5)
// Create a diagonal arrangement
let a = cube(0.2);
let b = cube(0.2).translate(0.5, 0.5, 0.5);
let c = cube(0.2).translate(1.0, 1.0, 1.0);
a.union(b).union(c)translate_x(distance)
Move a shape along the X axis only.
| Parameter | Type | Description |
|---|---|---|
| distance | float | Offset along X axis |
// Position gear teeth around a hub
let tooth = box3(0.1, 0.15, 0.08).translate_x(0.5);
tooth.repeat_polar(12)translate_y(distance)
Move a shape along the Y axis only (vertical).
| Parameter | Type | Description |
|---|---|---|
| distance | float | Offset along Y axis (positive = up) |
// Stack rings on a barrel
let ring_top = torus(0.5, 0.08).translate_y(0.4);
let ring_bot = torus(0.5, 0.08).translate_y(-0.4);
cylinder(0.5, 1.0)
.smooth_union(ring_top, 0.05)
.smooth_union(ring_bot, 0.05)translate_z(distance)
Move a shape along the Z axis only (depth).
| Parameter | Type | Description |
|---|---|---|
| distance | float | Offset along Z axis (positive = forward) |
// Create depth layers
let front = sphere(0.3).translate_z(0.5);
let back = sphere(0.3).translate_z(-0.5);
front.union(back)Rotation
Rotate shapes around the coordinate axes. Use the deg() helper to specify
angles in degrees, or pass radians directly.
rotate_x(angle)
Rotate around the X axis (pitch). Positive angles rotate counterclockwise when looking down the positive X axis.
| Parameter | Type | Description |
|---|---|---|
| angle | float | Rotation angle in radians (use deg() for degrees) |
// Tilt a cylinder 45 degrees forward
cylinder(0.3, 1.0).rotate_x(deg(45))
// Lay a capsule flat
capsule(0.2, 0.8).rotate_x(deg(90))rotate_y(angle)
Rotate around the Y axis (yaw). Positive angles rotate counterclockwise when looking down from above.
| Parameter | Type | Description |
|---|---|---|
| angle | float | Rotation angle in radians (use deg() for degrees) |
// Rotate a box 30 degrees around vertical axis
box3(0.5, 0.3, 0.2).rotate_y(deg(30))
// Create a fan pattern manually
let blade = box3(0.1, 0.02, 0.4).translate_z(0.3);
let b1 = blade;
let b2 = blade.rotate_y(deg(90));
let b3 = blade.rotate_y(deg(180));
let b4 = blade.rotate_y(deg(270));
b1.union(b2).union(b3).union(b4)rotate_z(angle)
Rotate around the Z axis (roll). Positive angles rotate counterclockwise when looking toward the camera.
| Parameter | Type | Description |
|---|---|---|
| angle | float | Rotation angle in radians (use deg() for degrees) |
// Tilt a shape 45 degrees
box3(0.4, 0.1, 0.4).rotate_z(deg(45))
// Diamond orientation
cube(0.4).rotate_z(deg(45)).rotate_x(deg(45))Tip: Rotation order matters! rotate_x().rotate_y() produces
different results than rotate_y().rotate_x(). When combining rotations,
apply them from right to left (last rotation applied first in the chain is performed first
in world space).
Scale
Resize shapes uniformly or along specific axes. Scaling is applied from the shape's origin.
scale(factor)
Uniformly scale a shape in all dimensions. Values greater than 1 enlarge, values between 0 and 1 shrink.
| Parameter | Type | Description |
|---|---|---|
| factor | float | Scale multiplier (1.0 = no change) |
// Double the size of a sphere
sphere(0.3).scale(2.0)
// Create nested shells at different scales
let s1 = sphere(0.5).shell(0.02);
let s2 = sphere(0.5).scale(0.7).shell(0.02);
let s3 = sphere(0.5).scale(0.4).shell(0.02);
s1.union(s2).union(s3)scale_xyz(x, y, z)
Scale a shape non-uniformly along each axis independently. Useful for stretching or squashing shapes.
| Parameter | Type | Description |
|---|---|---|
| x | float | Scale factor along X axis |
| y | float | Scale factor along Y axis |
| z | float | Scale factor along Z axis |
// Flatten a sphere into a disc
sphere(0.5).scale_xyz(1.0, 0.2, 1.0)
// Stretch a cube into a beam
cube(0.3).scale_xyz(0.5, 3.0, 0.5)Note: Non-uniform scaling can distort SDF distance calculations,
which may affect boolean operations and surface quality. For precise work, prefer
using primitives with the correct proportions (like ellipsoid instead of
a scaled sphere).
Mirror
Reflect shapes across coordinate planes. Mirror operations flip the shape to the opposite side of the specified plane, replacing the original.
mirror_x()
Mirror across the YZ plane (flip left/right). Points with positive X become negative X.
// Flip a shape to the opposite side
sphere(0.3).translate_x(0.5).mirror_x()
// Result: sphere at x = -0.5mirror_y()
Mirror across the XZ plane (flip up/down). Points with positive Y become negative Y.
// Flip a shape vertically
cone(0.3, 0.6).translate_y(0.3).mirror_y()
// Result: cone pointing up, positioned below originmirror_z()
Mirror across the XY plane (flip front/back). Points with positive Z become negative Z.
// Flip a shape in depth
box3(0.2, 0.2, 0.4).translate_z(0.3).mirror_z()
// Result: box at z = -0.3Symmetry
Create symmetric shapes by mirroring and combining with the original. Unlike mirror operations, symmetry keeps both the original and the mirrored copy.
symmetry_x()
Create left/right symmetry across the YZ plane. Equivalent to shape.union(shape.mirror_x()).
// Create a symmetric shape from one side
sphere(0.3).translate_x(0.5).symmetry_x()
// Result: two spheres at x = 0.5 and x = -0.5
// Build half a model, then mirror it
let half = box3(0.2, 0.3, 0.1).translate_x(0.3);
let detail = sphere(0.1).translate(0.4, 0.1, 0.0);
half.union(detail).symmetry_x()symmetry_y()
Create top/bottom symmetry across the XZ plane. Equivalent to shape.union(shape.mirror_y()).
// Create vertical symmetry
cone(0.3, 0.5).translate_y(0.25).symmetry_y()
// Result: double cone (diamond shape)symmetry_z()
Create front/back symmetry across the XY plane. Equivalent to shape.union(shape.mirror_z()).
// Create depth symmetry
box3(0.3, 0.2, 0.1).translate_z(0.2).symmetry_z()
// Result: boxes at z = 0.2 and z = -0.2Workflow tip: Symmetry operations are powerful for character and
mechanical modeling. Design one half of your model, then use symmetry_x() to complete it. This ensures perfect symmetry and halves your modeling work.
Math Helpers
Utility functions for angle conversion and common mathematical constants.
deg(degrees)
Convert degrees to radians. All rotation functions expect radians, so use this helper for more intuitive angle specification.
| Parameter | Type | Description |
|---|---|---|
| degrees | float | Angle in degrees |
Returns: Angle in radians
// Common rotations
cube(0.3).rotate_y(deg(45)) // 45 degrees
cube(0.3).rotate_y(deg(90)) // Quarter turn
cube(0.3).rotate_y(deg(180)) // Half turn
cube(0.3).rotate_y(deg(360)) // Full turn (same as original)rad(radians)
Identity function for radians (included for API consistency). Returns the input unchanged.
| Parameter | Type | Description |
|---|---|---|
| radians | float | Angle in radians |
// Using radians directly
cube(0.3).rotate_y(rad(PI / 4)) // Same as deg(45)
cube(0.3).rotate_y(PI / 2) // Also works without rad()PI, TAU
Mathematical constants for angle calculations.
| Constant | Value | Description |
|---|---|---|
| PI | 3.14159... | Half turn in radians (180 degrees) |
| TAU | 6.28318... | Full turn in radians (360 degrees, equals 2 * PI) |
// Using constants for rotations
cube(0.3).rotate_y(PI) // Half turn (180 deg)
cube(0.3).rotate_y(TAU) // Full turn (360 deg)
cube(0.3).rotate_y(PI / 4) // Eighth turn (45 deg)
cube(0.3).rotate_y(TAU / 6) // Sixth turn (60 deg)Transform Order
Transforms are applied in the order they are chained. The result can vary significantly based on order:
Translate then Rotate
// Orbits around origin
sphere(0.2)
.translate_x(1.0)
.rotate_y(deg(45))Shape moves to x=1, then rotates around origin (orbiting motion).
Rotate then Translate
// Rotates in place, then moves
sphere(0.2)
.rotate_y(deg(45))
.translate_x(1.0)Shape rotates around its center, then moves along world X axis.