Cube

fun FilamentSceneScope.Cube(material: MaterialInstance?, position: Position = Position(0f), rotation: Rotation = Rotation.Identity, scale: Scale = Scale(1f), pivot: Position = Position(0f), size: Float = 1.0f, visible: Boolean = true, castShadows: Boolean = true, receiveShadows: Boolean = true, onCreate: EntityScope.() -> Unit = {})

A unit cube centered on the origin (in mesh space). Six faces, 24 vertices (4 per face so normals and UVs are not shared across edges), 12 triangles.

Each face's UV maps the full 0..1 square. The cube is sized via size (full edge length).

Parameters

material

The material to apply to every face, or null while it is still loading (nothing renders until it arrives). Use rememberMaterial + rememberMaterialInstance.

position

World-space position of the pivot point.

rotation

World-space rotation. Build one with Rotation.axisAngle/Rotation.euler.

scale

Per-axis scale applied after size.

pivot

Point in mesh space that rotation/scale revolve around and that ends up at position. Defaults to the cube centre.

size

Edge length in mesh space. The mesh is rebuilt when this changes.

visible

Whether this renderable is in the scene. False removes it from the scene (cheaply, keeping the entity alive) — a show/hide toggle without losing state.

castShadows

Whether the cube casts shadows onto other renderables. On by default.

receiveShadows

Whether the cube receives shadows cast by others. On by default.

onCreate

Runs once when the cube enters the scene, with the renderable entity and engine in scope (EntityScope). Use it to register the cube with view.pick callbacks or other entity-keyed maps.