FilamentViewState

Hoisted handle to a FilamentView's live Filament objects. Create with rememberFilamentViewState, pass to a FilamentView, and use it for imperative access — picking, reading the viewport, or reaching the raw View/Renderer for advanced work.

view and renderer are null until the state is attached to an on-screen FilamentView, and become null again when that view leaves composition.

val viewState = rememberFilamentViewState()
FilamentView(scene = scene, viewState = viewState, ...)

// Pick on tap (Filament's viewport origin is bottom-left, so flip Y):
Modifier.pointerInput(Unit) {
detectTapGestures { offset ->
val v = viewState.view ?: return@detectTapGestures
viewState.pick(offset.x.toInt(), v.viewport.height - offset.y.toInt()) { result -> ... }
}
}

Properties

Link copied to clipboard
Link copied to clipboard
var view: View?

Functions

Link copied to clipboard
fun pick(x: Int, y: Int, onResult: (View.PickingQueryResult) -> Unit)

Issues a Filament picking query at viewport pixel (x, y) and delivers the result to onResult on the render thread. No-op while not attached. Note Filament's viewport origin is bottom-left — flip Compose's top-left Y against view.viewport.height.