CameraNode

fun FilamentSceneScope.CameraNode(cameraState: CameraState, eyeOffset: Position = Position(0f), targetOffset: Position = Position(0f, 0f, -1f), up: Direction = Direction(0f, 1f, 0f))

Attaches a CameraState to the surrounding Group so the camera follows that group's world transform every frame — a declarative chase / first-person / mounted camera.

Place it inside a Group; the group's transform becomes the camera's reference frame. eyeOffset and targetOffset are expressed in that local space, so a third-person rig is just an eye behind-and-above the origin looking at the origin:

val cam = rememberCameraState()
val scene = rememberFilamentScene {
Group(position = carPosition, rotation = carRotation) {
GltfInstance(car)
CameraNode(cam, eyeOffset = Position(0f, 2f, -6f), targetOffset = Position(0f, 1f, 0f))
}
}
FilamentView(scene, cameraState = cam)

The camera itself still lives on the FilamentView this cameraState is passed to; this node only drives the state's eye/target/up. It has no effect until the group has a transform component (always true for Group) and the state is attached to a view.

Parameters

cameraState

The hoisted camera state to drive. Pass the same instance to a FilamentView.

eyeOffset

Camera position in the group's local space.

targetOffset

Look-at point in the group's local space.

up

Up direction in the group's local space.