rememberFilamentScene

fun rememberFilamentScene(engine: Engine = rememberFilamentEngine(), skyboxState: SkyboxState? = null, indirectLightState: IndirectLightState? = null, content: @Composable FilamentSceneScope.() -> Unit): FilamentScene

Declares a Filament Scene as a value. The content lambda declares the world — lights, models, primitives, groups — via scene composables; it emits no UI and runs once at this call site regardless of how many FilamentViews later render the scene.

val scene = rememberFilamentScene(skyboxState = sky) {
DirectionalLight(intensity = LightIntensity.LuminousPower(100_000f))
GltfInstance(asset = duck)
}
FilamentView(scene = scene, cameraState = cam,
postProcessing = PostProcessing(bloom = Bloom(strength = 0.2f)))

Parameters

engine

Engine backing the scene. Defaults to a dedicated engine created and destroyed with this composable. Pass a rememberFilamentEngine value to share an engine.

skyboxState

Optional hoisted skybox state. Null = no skybox (the default).

indirectLightState

Optional hoisted IBL state. Null = no IBL (the default).

content

Scene composables (io.github.erkko68.filament.compose.scene.Light, GltfInstance, Group, primitives, …). They are extensions on FilamentSceneScope.


Overload wiring a loaded Environment (from rememberKTXEnvironment / rememberHDREnvironment) into the scene in one argument, instead of threading its two states by hand:

val engine = rememberFilamentEngine()
val env = rememberKTXEnvironment(engine = engine, ibl = { … })
val scene = rememberFilamentScene(engine, env) { GltfInstance(asset = duck) }

Parameters

engine

Required here (no default): it must be the same engine the environment's textures were loaded on — a fresh default engine would mix resources across engines.

environment

Loaded environment supplying both the skybox and IBL states.

content

Scene composables, as in the primary overload.