Group

fun FilamentSceneScope.Group(position: Position = Position(0f), rotation: Rotation = Rotation.Identity, scale: Scale = Scale(1f), pivot: Position = Position(0f), visible: Boolean = true, onCreate: EntityScope.() -> Unit = {}, onTap: (Position) -> Unit? = null, content: @Composable FilamentSceneScope.() -> Unit)

Groups child scene composables under a single transform. Everything declared inside content is parented to a hidden transform entity, so moving/rotating/scaling the Group moves the whole assembly as a unit. Children's own position/rotation/scale become local to the group, and groups themselves nest cleanly inside other groups.

Group(position = Position(2f, 0f, 0f), rotation = bodyRotation) {
Cube(material = body, size = 1.5f)
Cylinder(material = wheel, position = Position( 0.6f, -0.4f, 0f), radius = 0.2f, height = 0.1f)
Cylinder(material = wheel, position = Position(-0.6f, -0.4f, 0f), radius = 0.2f, height = 0.1f)
}

Note: a light inside a Group is parented like any other child, so the group's translation moves it, and (by default) the typed lights re-aim their direction by the group's rotation each frame (followGroupRotation). Pass followGroupRotation = false to keep a light's aim fixed in world space while it still translates with the group.

Parameters

position

World-space position of the group's pivot (or local-space if this Group is itself nested inside another Group).

rotation

Rotation applied to the whole group.

scale

Scale applied to the whole group.

pivot

Mesh-space pivot point that rotation/scale revolve around.

visible

Whether the whole subtree is in the scene. False removes every child renderable and light (cheaply, keeping entities and state alive) — a show/hide toggle for the group.

onCreate

Runs once when the group's transform entity is created, with the entity and engine in scope (EntityScope).

onTap

Called when a tap hits anything inside content that has no onTap of its own, with the world point it hit — one handler for a whole assembly.

content

Scene composables placed under this group's transform.