Filament API
Most applications will only need the high-level ThermionViewer API (see
Viewer and Quick Start). ThermionViewer is itself
a thin wrapper over Filament’s lower-level engine, scene, view, and renderer
objects.
When you need finer control — multiple scenes, headless render targets,
off-screen texture rendering, or direct access to Filament entities — drop down
to the FilamentApp facade. A running ThermionViewer always has a
FilamentApp.instance you can access.
The FilamentApp facade
Section titled “The FilamentApp facade”FilamentApp owns the engine, the render thread, and the swap chain. Key
methods:
final app = FilamentApp.instance!;
// Engine / swap chain / view / scene lifecyclefinal swapChain = await app.createSwapChain(handle);final view = await app.createView(createScene: true);final scene = await app.createScene();
// Camerasfinal camera = await app.createCamera();
// Textures & imagesfinal texture = await app.createTexture(width, height);final sampler = await app.createTextureSampler(...);final image = await app.decodeImage(byteData);
// Materialsfinal unlit = await app.createUnlitMaterialInstance();
// Cleanup — Filament objects are not GC'd; destroy them explicitlyawait app.destroyView(view);await app.destroyScene(scene);await app.destroySwapChain(swapChain);await app.destroy();Headless rendering
Section titled “Headless rendering”For off-screen / server-side rendering (no window), createHeadlessSwapChain
and createRenderTarget let you render to a texture and read pixels back,
without a platform surface. This is how the examples/dart/cli_headless
example renders to a bitmap.
When to use which layer
Section titled “When to use which layer”| Need | Use |
|---|---|
| Show a 3D model in a Flutter app | ViewerWidget (Quickstart) |
| Load assets, animate, swap materials | ThermionViewer (Viewer) |
| Multiple scenes, headless render targets, raw Filament entities | FilamentApp (this page) |
