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 an @Immutable class that represents a chain of 3D transforms applied to an element. It follows an immutable-builder pattern: every method returns a new Modifier3D instance with the requested transform applied, leaving the original unchanged. This makes Modifier3D safe to share across recompositions and to store in remember blocks. The root package exports Modifier3D as a type alias of com.elitec.spatial_compose.modifier.Modifier3D, so a single import from com.elitec.spatial_compose is sufficient.

Import

import com.elitec.spatial_compose.Modifier3D

Default

val Default: Modifier3D
The canonical zero-transform instance available on the Modifier3D companion object. Position is (0m, 0m, 0m), rotation is zeroed on all axes, scale is (1m, 1m, 1m), and size is null (the renderer uses its own default mesh size). Start every modifier chain from Modifier3D.Default.

Methods

position

fun position(x: Float, y: Float, z: Float): Modifier3D
Shorthand overload that interprets the three Float arguments as metres. Internally calls the typed Distance overload with x.meters, y.meters, z.meters.
fun position(x: Distance, y: Distance, z: Distance): Modifier3D
Typed overload. Sets the world-space position of the element using explicit Distance values. Prefer this form when working with the spatial-units type-safe distance API.
x
Float | Distance
Position along the world X axis (positive = right).
y
Float | Distance
Position along the world Y axis (positive = up).
z
Float | Distance
Position along the world Z axis (positive = toward the viewer in a right-handed coordinate system; use negative values to place objects in front of a camera looking down −Z).

rotateX

fun rotateX(angle: Angle): Modifier3D
Applies a rotation around the local X axis. Replaces any previously set X rotation — rotations are stored per-axis and are not composed additively.
angle
Angle
Rotation angle. Use the deg or rad extension properties from spatial-units (e.g. 45f.deg).

rotateY

fun rotateY(angle: Angle): Modifier3D
Applies a rotation around the local Y axis (yaw). Use to spin an element horizontally.
angle
Angle
Rotation angle. Use 45f.deg for 45 degrees, for example.

rotateZ

fun rotateZ(angle: Angle): Modifier3D
Applies a rotation around the local Z axis (roll).
angle
Angle
Rotation angle.

scale

fun scale(x: Distance, y: Distance, z: Distance): Modifier3D
Sets the per-axis scale of the element in metres. The default scale is (1m, 1m, 1m). Scale and size are separate concerns: scale multiplies the mesh in object space, while size overrides the rendered bounding box dimensions.
x
Distance
Scale factor along the X axis.
y
Distance
Scale factor along the Y axis.
z
Distance
Scale factor along the Z axis.

size (uniform)

fun size(all: Distance): Modifier3D
Sets the rendered size of the element to a uniform value on all three axes. The all distance is applied identically to width, height, and depth.
all
Distance
Uniform size in all three dimensions. For example, 2f.meters produces a 2 × 2 × 2 metre bounding box.

size (per-axis)

fun size(width: Distance, height: Distance, depth: Distance): Modifier3D
Sets the rendered size of the element independently on each axis.
width
Distance
Size along the X axis.
height
Distance
Size along the Y axis.
depth
Distance
Size along the Z axis.

Internal Properties

These properties are internal and not part of the public API, but they are listed here for reference when reading the source or building tooling on top of the library.
PropertyTypeDescription
positionVec3DistanceWorld-space position as a typed three-component vector.
rotationRotation3DPer-axis rotation stored as a Rotation3D value.
scaleVec3DistancePer-axis scale vector; defaults to (1m, 1m, 1m).
sizeVec3Distance?Optional explicit bounding-box size; null means the renderer uses its mesh defaults.

Example

val modifier = Modifier3D.Default
    .size(2f.meters)
    .rotateY(45f.deg)
    .position(1f.meters, 0f.meters, (-5f).meters)
Each call in the chain creates a new Modifier3D — the pattern is identical to Jetpack Compose’s own Modifier builder. Because every instance is @Immutable, you can safely remember a Modifier3D across recompositions without worrying about mutation.
Use negative Z values to place objects in front of a typical scene camera. The default orbit camera in Spatial looks along the −Z axis, so objects at z = -4f.meters are 4 metres in front of the camera.

Build docs developers (and LLMs) love