Cube

fun FilamentSceneScope.Cube(material: MaterialInstance, position: Position = Position(0f), rotation: Quaternion = Quaternion(), scale: Scale = Scale(1f), pivot: Position = Position(0f), size: Float = 1.0f, onCreate: (Entity) -> 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. Use rememberMaterial + rememberMaterialInstance to construct one.

position

World-space position of the pivot point.

rotation

World-space rotation as a quaternion.

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.

onCreate

Receives the renderable entity ID once the cube is added to the scene. Use it to register the cube with view.pick callbacks or other entity-keyed maps.