Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/danielitoCode/Spatial/llms.txt

Use this file to discover all available pages before exploring further.

Modifier3D is Spatial’s immutable transform chain — analogous to Compose’s Modifier but designed for 3D space. It is annotated @Immutable, so every operation returns a new Modifier3D instance rather than mutating the existing one. Chaining is therefore safe and composable. Under the hood, the chain is resolved into a column-major 4×4 model matrix (T × Rz × Ry × Rx × S order) before each frame is submitted to the render host.

Default

Modifier3D.Default is the zero-transform baseline — position at the world origin, no rotation, and a uniform scale of (1 m, 1 m, 1 m):
val Default = Modifier3D(
    position = Vec3Distance(0.meters, 0.meters, 0.meters),
    rotation = Rotation3D(),           // no rotation on any axis
    scale    = Vec3Distance(1.meters, 1.meters, 1.meters),
    size     = null,                   // falls back to scale
)
Start every element modifier with Modifier3D.Default and chain operations onto it.

Available Operations

position

Sets the element’s world-space position. Two overloads are available:
// Overload 1 — raw Float values (interpreted as meters)
fun position(x: Float, y: Float, z: Float): Modifier3D

// Overload 2 — typed Distance values (preferred)
fun position(x: Distance, y: Distance, z: Distance): Modifier3D

rotateX / rotateY / rotateZ

Rotates the element around the named world axis. The Angle type is constructed with the .deg extension:
fun rotateX(angle: Angle): Modifier3D
fun rotateY(angle: Angle): Modifier3D
fun rotateZ(angle: Angle): Modifier3D

scale

Multiplies the element’s size relative to its unit mesh dimensions:
fun scale(x: Distance, y: Distance, z: Distance): Modifier3D

size — uniform

Sets all three dimensions to the same absolute size in meters:
fun size(all: Distance): Modifier3D

size — non-uniform

Sets width, height, and depth independently:
fun size(width: Distance, height: Distance, depth: Distance): Modifier3D

Chaining

Chain calls left-to-right, starting from Modifier3D.Default. The order follows the model matrix composition (T × Rz × Ry × Rx × S), so rotation is applied before translation:
Element.Cube(
    modifier = Modifier3D.Default
        .rotateY(45f.deg)
        .size(2f.meters)
        .position(0f.meters, 0f.meters, (-5f).meters),
)
This places a 2 m cube 5 m in front of the camera, rotated 45° around the Y-axis.

Coordinate System

Spatial uses a standard right-handed coordinate system:
AxisDirection
+XRight
+YUp
+ZToward the viewer (out of the screen)
−ZInto the scene (away from the viewer)
Objects in front of the default camera position sit at negative Z. Use (-5f).meters, (-4f).meters, etc. for the Z component of position() so elements appear in the viewport.

size vs scale

size(...)scale(...)
SemanticsSets absolute world-space dimensions in metersMultiplies relative to the unit mesh
Example.size(2f.meters) → always 2 m.scale(2.meters, 2.meters, 2.meters) → 2× the mesh default
Use whenYou know the exact real-world dimensionsYou want proportional scaling relative to the base mesh
When size is set it overrides scale during model matrix resolution. If size is not set, scale is used instead.

Units Reference

Spatial uses two typed unit classes from the spatial-units module:
// Distance — constructed with .meters or .cm extension properties
val d: Distance = 1.5f.meters
val c: Distance = 50f.cm       // same as 0.5f.meters

// Angle — constructed with .deg extension property
val a: Angle = 45f.deg
  • Elements — apply Modifier3D to Element.Cube, Element.Sphere, and Element.Plane
  • Units — full reference for Distance and Angle typed units

Build docs developers (and LLMs) love