rememberKtxEnvironment

fun rememberKtxEnvironment(key: Any = Unit, onError: (Throwable) -> Unit? = null, engine: Engine = LocalFilamentEngine.current ?: noFilamentEngine(), skybox: suspend () -> ByteArray? = null, ibl: suspend () -> ByteArray): Environment

Loads an IBL environment (and optional skybox) from KTX1 data, e.g. the pair Filament's cmgen bakes. Returns at once; the Environment's parts fill in as the data decodes. Failures (a loader throwing, or undecodable KTX) are reported once via onError and leave that part null.

Like the other loaders, call it inside rememberFilamentScene { }, or outside with a hoisted engine to share one environment between scenes.

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

Parameters

key

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

onError

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

engine

Engine the textures are allocated on. Defaults to the engine in the current composition scope, which only exists inside rememberFilamentScene { }.

skybox

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

ibl

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