CameraState
Hoisted, observable camera state. Create with rememberCameraState and pass to io.github.erkko68.filament.compose.FilamentView for full control over the camera.
All fields are observable androidx.compose.runtime.MutableState — read them inside a composable to subscribe to changes, or write them from anywhere on the main thread to drive the camera imperatively.
Read-only matrices (viewMatrix, projectionMatrix) reflect the underlying Filament camera and are valid only while the state is attached to a FilamentView.
val cameraState = rememberCameraState(initialEye = Position(0f, 2f, 5f))
FilamentView(scene = scene, cameraState = cameraState)
// Read the view matrix from anywhere
LaunchedEffect(cameraState.eye) {
val v = cameraState.viewMatrix // may be null until attached
}Properties
Distance from the camera to the plane of focus in world units, used by PostProcessing(depthOfField = …) to place the focal plane. Ignored without DoF.
Projection matrix (view→clip) computed by Filament. Null until this state is attached to a io.github.erkko68.filament.compose.FilamentView.
Per-axis projection scaling; LensScaling.Identity leaves the frustum as computed.
Off-axis lens shift; LensShift.None leaves the projection centred.
View matrix (world→view) computed by Filament. Null until this state is attached to a io.github.erkko68.filament.compose.FilamentView.