rememberKTXEnvironment

fun rememberKTXEnvironment(engine: Engine, intensity: Float, key: Any = Unit, onError: (Throwable) -> Unit? = null, skybox: suspend () -> ByteArray? = null, ibl: suspend () -> ByteArray): Environment

Loads an IBL environment (and optional skybox) from KTX1 data and wires it into the scene's indirect-light/skybox state. This is the convenience path over hand-wiring KTX1Loader, texture lifetimes, and IndirectLightState/SkyboxState.

Call it outside rememberFilamentScene { } (its result feeds the scene's parameters), so the engine must be hoisted via io.github.erkko68.filament.compose.rememberFilamentEngine and shared with the scene.

The returned Environment is non-null and stable; its states fill in once the KTX bytes load. Failures (load lambda throwing, or undecodable KTX) are reported once via onError and leave the corresponding state empty.

For raw equirectangular .hdr images (no offline cmgen bake) use rememberHDREnvironment.

Parameters

engine

The hoisted engine, shared with the scene that consumes the returned states.

intensity

IBL intensity scale.

key

Reloads when this changes. Defaults to Unit for static assets.

onError

Invoked once per failure (load threw, or the KTX failed to decode).

skybox

Optional loader for the skybox cubemap KTX. Null = IBL only, no background.

ibl

Loader for the IBL KTX (prefiltered reflection cubemap + irradiance SH).