scene library
3D rendering for Flutter, built on Flutter GPU and Impeller.
The entry points most applications need are:
- Scene — the scene graph root and renderer. Construct one, attach
Nodes, and call Scene.render from a
CustomPainter(or anydart:uiCanvas). - Node — a transform in the scene graph that may carry a Mesh and
child nodes. Load 3D content with loadScene (preprocessed
.fscenebpackages, by source path) or Node.fromGlbBytes / Node.fromGlbAsset (runtime glTF binary). - Camera / PerspectiveCamera — view configuration passed to Scene.render.
- Material, PhysicallyBasedMaterial, UnlitMaterial,
Environment— shading. - Animation, AnimationClip, AnimationPlayer — playback and blending of imported animations.
Flutter Scene currently requires the Flutter master channel because it depends on the Flutter GPU API.
Classes
- AmbientOcclusionSettings
- Screen-space ambient occlusion settings for a Scene.
- Animation
- A reusable description of an animation, parsed from a model.
- AnimationClip
- An instance of an Animation that has been bound to a specific Node.
- AnimationPlayer
- Drives playback and blending for the AnimationClips on a single node subtree.
- BasicCollider
- Pure-Dart Collider implementation registered with the ancestor BasicPhysicsWorld on mount.
- BasicKinematicBody
- Pure-Dart RigidBody implementation. Always BodyType.kinematic; the user moves the owning node's transform directly and the body records velocity for components that read it. There is no dynamics solver in the basic backend, so force and impulse APIs are no-ops.
- BasicPhysicsWorld
- Pure-Dart PhysicsWorld suitable for picking, area triggers, and kinematic-only gameplay.
- BezierPath
- A path of joined cubic Bezier segments.
- BloomSettings
- Makes bright areas bleed light into their surroundings. Computed in a chain of HDR passes and added back to the scene before tone mapping.
- BoxShape
- An axis-aligned box of the given halfExtents centered at the collider's local origin.
- Camera
- A view onto a scene: a world-space eye position and orientation paired with a lens projection, used by Scene.render to map the scene into clip space.
- CameraComponent
- An engine Component that places a Camera in the scene.
- CameraProjection
- A lens projection that maps view-space coordinates into clip space.
- CapsuleShape
- A capsule aligned with the local Y axis. halfHeight is the half length of the cylindrical section, excluding the hemispherical caps.
- CatmullRomPath
- A smooth curve passing through every one of a list of points.
- ChromaticAberrationSettings
- Splits the red and blue channels toward the edges, like a simple lens. Sampled from the scene color before grading and tone mapping.
- Collider
- Common surface for a collision volume attached to a Node.
- CollisionBegan
- Fired the first step a pair of solid colliders touch.
- CollisionEnded
- Fired the step a previously-touching solid pair separates.
- CollisionEvent
- Base type for collision lifecycle events streamed by a physics world.
- ColorGradingSettings
- Color grading applied to the linear HDR scene color, before exposure and tone mapping.
- Component
- A unit of data or behavior attached to a Node.
- CompoundChild
- One child of a CompoundShape: a shape positioned by localPose relative to the compound's origin.
- CompoundShape
- A union of children, each positioned by its own local pose.
- ContactPoint
- One contact point in a CollisionBegan event.
- ConvexHullShape
-
The convex hull of points, stored as packed
xyztriplets. - CuboidGeometry
-
An axis-aligned box geometry spanning
-extents/2to+extents/2on each axis, with flat per-face normals. - CylinderShape
- A cylinder aligned with the local Y axis. halfHeight is half the total height.
- DashPattern
- A repeating dash-and-gap pattern for a PolylineGeometry, measured in scene units along the line's arc length.
- DirectionalLight
- An infinitely-distant light source (e.g. the sun) that illuminates the whole scene from a single direction.
- DirectionalLightComponent
- An engine Component that places a DirectionalLight in the scene.
- EnvironmentMap
- A source of image-based lighting: diffuse irradiance plus prefiltered specular radiance, both derived from an equirectangular environment.
- EnvironmentSkySource
- Shows the scene's image-based-lighting environment as the background, optionally blurred.
- ExtrudeGeometry
- An arbitrary closed 2D profile swept along a ScenePath.
- FilmGrainSettings
- Adds animated noise over the final image, after tone mapping.
- FixedJoint
- Welds two bodies together with zero degrees of freedom.
- FmatMaterialRegistry
-
Resolves and loads
.fmatmaterials registered through DataAssets. - GenericJoint
- A fully configurable six-degree-of-freedom joint.
- Geometry
- Vertex (and optional index) data along with the vertex shader used to transform it.
- GeometryBuilder
- Assembles a MeshGeometry one vertex and triangle at a time.
- GradientSkySource
- A stylized gradient sky: zenith, horizon, and ground colors with an HDR sun disk.
- HeightFieldShape
- A row-major heightfield of width x depth samples, scaled by scale. Heights are sampled in the local XZ plane and offset along Y.
- InstancedMesh
- Many copies of one Geometry / Material pair, each placed by its own model transform.
- InstancedMeshComponent
- An engine Component that draws an InstancedMesh.
- Joint
- A constraint linking the owning node's rigid body to another body.
- JointAxisConfig
- The configuration of one of a GenericJoint's six axes.
- JointMotor
- A spring-damper drive on a single GenericJoint axis.
- Lighting
- The lighting state handed to a Material when it binds for a draw.
- Material
- Base class for shading a MeshPrimitive.
- MaterialParameters
- Type-checked, name-addressed parameters for a custom material.
- Mesh
- Defines the shape and appearance of a 3D model in the scene.
- MeshComponent
- An engine Component that draws a Mesh.
- MeshGeometry
- A triangle mesh built at runtime from vertex attribute arrays.
- MeshPrimitive
- Represents a single part of a Mesh, containing both Geometry and Material properties.
- Node
-
A
Noderepresents a single element in a 3D scene graph. - NodeCamera
-
A Camera whose view comes from a node's world transform: the
+Zaxis is the look direction,+Yis up, and the translation is the eye. This is the inverse of the eye/target/up convention PerspectiveCamera builds, so a node placed atinverse(camera.getViewMatrix())yields the same view. - OverlapHit
- One collider returned by an overlap query (sphere or box).
- PerspectiveCamera
- A standard pinhole-style perspective camera.
- PerspectiveProjection
- A standard pinhole perspective projection.
- PhysicallyBasedMaterial
- A glTF-style metallic-roughness physically based material with image-based lighting.
- PhysicalSkySource
- A physically based daylight sky: an analytic single-scattering atmosphere (Rayleigh and Mie terms) with an HDR sun disk, producing plausible day, sunset, and twilight skies from a sun direction.
- PhysicsMaterial
- Surface properties (friction, restitution, density) of a collider.
- PhysicsWorld
- The simulation world for a subtree of the scene graph.
- PlaneGeometry
-
A flat rectangular grid in the XZ plane, centered on the origin, with
its surface facing
+Y. - PolylineGeometry
- A thick, camera-facing line through a list of points.
- PolylinePath
- A path of straight segments connecting a list of points.
- PostEffect
- A custom, user-authored post-processing effect: a fragment shader that reads the current color and writes a new one.
- PostProcessSettings
- Built-in post-processing settings for a Scene.
- PreprocessedMaterial
-
A material driven by a
.fmatcustom-material shader and its sidecar metadata (produced at build time bybuildMaterials). - PreprocessedSky
-
A sky driven by a
.fmatsky shader (sky { vec3 Sky(vec3 direction) }) and its sidecar metadata (produced at build time bybuildMaterials). - PrismaticJoint
- A slider: one translational degree of freedom along a shared axis.
- RaycastHit
- The closest collider intersected by a Ray, or one entry of a raycast-all result list.
- RenderTexture
-
An offscreen render target a
RenderViewcan render into. - RenderTextureSampling
- Sampling options used when a material samples a RenderTexture.
- RenderTextureUpdate
- When a RenderTexture re-renders.
- RenderTextureView
- Displays a live RenderTexture in the widget tree.
- RenderView
-
One view of a
Scene: a camera plus where and how its image is drawn. - RevoluteJoint
- A hinge: one rotational degree of freedom around a shared axis.
- RibbonGeometry
- A flat strip of constant width swept along a ScenePath.
- RigidBody
- A simulated rigid body attached to a Node.
- Scene
- Represents a 3D scene, which is a collection of nodes that can be rendered onto the screen.
- ScenePath
- A curve through 3D space, independent of any geometry or rendering.
- ScenePathFrame
- An oriented coordinate frame at a point along a ScenePath.
- ScenePointer
- A programmatic pointer into a scene: a crosshair, a gamepad-driven cursor, a VR laser, or the built-in pointer behind automatic widget input.
- SceneRaycastHit
-
A render-geometry intersection from raycastNode (or
Scene.raycast). - SceneRegistry
-
Resolves DataAssets-backed
.fscenebfiles by source path, the.fscenecounterpart ofModelRegistry. - SceneScope
- Exposes the active Scene (and the per-frame elapsed time) to descendants of a SceneView.
- SceneView
- A widget that renders a Scene and drives its per-frame repaint.
- ShaderMaterial
- A Material backed by a caller-supplied fragment shader.
- ShaderSkySource
- Draws a custom sky from a fragment shader.
- ShadowCascade
- One cascade of a cascaded shadow map, produced by DirectionalLight.computeCascades.
- Shape
- Geometric description of a collider's volume.
- ShapeCastHit
- The first collider intersected by a shape cast, with the same fields as RaycastHit plus the cast direction's hit distance.
- Skin
- A skeletal binding used by skinned meshes for animation.
- SkinnedGeometry
- Geometry whose vertices use the skinned 80-byte layout: the unskinned attributes followed by 4 joint indices and 4 joint weights.
- Skybox
- The visible background drawn behind a Scene.
- SkyEnvironment
-
Drives
Scene.environmentfrom a sky on a refresh policy. - SkySource
- A source of skybox color as a function of world-space view direction.
- SphereGeometry
- A UV sphere centered on the origin.
- SphereShape
- A sphere centered at the collider's local origin.
- SphericalJoint
- A ball-and-socket joint: three rotational degrees of freedom, zero translational.
- Surface
- Manages the swapchain color textures a Scene composites onto the Flutter canvas, plus the pools of transient render-graph attachments.
- TriggerEntered
- Fired the first step a non-trigger collider overlaps a trigger volume.
- TriggerExited
- Fired the step a previously-overlapping pair stops overlapping a trigger volume.
- TriMeshShape
-
A triangle mesh defined by vertices (packed
xyztriplets) and indices (groups of three vertex indices forming one triangle each). - TubeGeometry
- A round cross-section of constant radius swept along a ScenePath.
- UnlitMaterial
- A material that draws geometry with a flat color or texture, ignoring scene lighting.
- UnskinnedGeometry
-
Geometry whose vertices use the unskinned 48-byte layout: position
(
vec3), normal (vec3), tex coords (vec2), color (vec4). - VignetteSettings
- Darkens the image toward the edges, after tone mapping.
- WedgeGeometry
-
A triangular-prism wedge (a ramp), centered on the origin in X and Z
with its base on the
y = 0plane. - WidgetComponent
- A live widget subtree on a scene surface.
- WidgetTexture
- Hosts a live widget subtree and streams its visual output into a WidgetTextureController's texture for sampling inside a scene.
- WidgetTextureController
- Owns the gpu.Texture a WidgetTexture streams its child into.
- WidgetUpdatePolicy
-
When a WidgetTexture (or a
WidgetComponent) re-captures its child.
Enums
- AlphaMode
-
How a PhysicallyBasedMaterial's alpha channel is interpreted,
matching glTF's
alphaMode. - AntiAliasingMode
- Anti-aliasing strategy used when rendering a Scene.
- BodyType
- Simulation mode for a RigidBody.
- CombineRule
- How a per-contact friction or restitution value is derived from the two participating materials.
- GeometryStorage
- How a MeshGeometry manages its GPU buffers over its lifetime.
- JointAxis
- One of the six degrees of freedom a GenericJoint constrains. The linear axes are translations along, and the angular axes rotations about, the joint frame's local X / Y / Z (oriented by the joint's local bases on each body).
- JointAxisMotion
- Whether a GenericJoint axis is locked, free, or limited.
- JointMotorModel
- How a JointMotor turns its drive parameters into a force.
- PolylineCap
- How a PolylineGeometry finishes its two end points.
- PolylineWidthMode
- How a PolylineGeometry's width is measured.
- PostInsertion
- Where in the post-processing chain a PostEffect runs.
- RibbonAlignment
- How a RibbonGeometry orients its strip across the path.
- SkyEnvironmentRefresh
- When a SkyEnvironment re-bakes the sky into the scene's lighting.
- SpecularAmbientOcclusionMode
- How AmbientOcclusionSettings occludes indirect specular reflections.
- ToneMappingMode
- Tone mapping operator applied when resolving the linear HDR scene color to the display-referred image (see Scene.toneMapping).
- WidgetInput
- How a WidgetComponent receives pointer input.
Mixins
- SceneGraph
-
Defines a common interface for managing a scene graph, allowing the addition and removal of
Nodes.
Extensions
- QuaternionSlerp on Quaternion
- Spherical interpolation helpers on Quaternion.
- Vector3Lerp on Vector3
- Per-component arithmetic helpers on Vector3.
Constants
- kDiffuseShCoefficientCount → const int
- Number of L2 spherical-harmonic coefficients used for diffuse irradiance (bands 0..2).
- kRenderLayerAll → const int
- A layer mask that selects every layer (the default render-view mask).
- kRenderLayerDefault → const int
- The default layer a Node occupies (bit 0).
Properties
- baseShaderLibrary → ShaderLibrary
-
The shader bundle shipped with
flutter_scene.no setter
Functions
-
environmentAssetPathOf(
EnvironmentMap environment) → String? -
The radiance asset path
environmentwas loaded from through EnvironmentMap.fromAssets, or null for environments built another way. -
gpuTextureFromAsset(
String assetPath) → Future< Texture> -
Loads an image from the asset bundle at
assetPathand uploads it as a Flutter GPU texture. -
gpuTextureFromImage(
Image image) → Future< Texture> -
Uploads a decoded
dart:uiui.Image to a Flutter GPU texture. -
imageFromAsset(
String assetPath, {AssetBundle? bundle}) → Future< Image> -
Loads and decodes an image from the asset bundle at
assetPath. -
imageFromBytes(
Uint8List bytes) → Future< Image> -
Decodes an encoded image (PNG, JPEG, etc.) from raw
bytes. -
loadBaseShaderLibrary(
) → Future< void> - Asynchronously loads and caches the base shader bundle. Idempotent. Called by Scene.initializeStaticResources so the synchronous baseShaderLibrary getter has a cached library to return (shader assets can't be read synchronously on any backend).
-
loadFmatMaterial(
String sourcePath, {String? package, String? bundleName, AssetBundle? bundle}) → Future< PreprocessedMaterial> -
loadFmatSky(
String sourcePath, {String? package, String? bundleName, AssetBundle? bundle}) → Future< PreprocessedSky> -
Loads a DataAssets-backed
.fmatsky by its source path relative to the owning package's root (for exampleassets/gradient_sky.fmat). -
loadScene(
String sourcePath, {String? package, AssetBundle? bundle, FsceneComponentRegistry? registry, SceneReloadCallback? onReload, Scene? applyStageTo}) → Future< Node> -
Loads a DataAssets-backed
.fscenebscene by its source path relative to the owning package's root (for exampleassets/levels/forest.glb). -
loadSceneSubtree(
Node node, {String? package, AssetBundle? bundle, FsceneComponentRegistry? registry}) → Future< void> -
Streams a lazy placeholder
node's prefab content under it, resolving the referenced prefab by its source path (the registry-aware counterpart ofloadSubtreefor scenes loaded with loadScene). -
prefilterEquirectRadiance(
Texture sourceEquirect, {bool sourceIsLinear = false, bool mipLayout = false}) → Texture - Prefilters an equirectangular radiance texture for image-based specular lighting.
-
raycastNode(
Node root, Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool where(Node node)?, bool includeInvisible = false}) → SceneRaycastHit? -
Casts
ray(direction need not be normalized) throughroot's subtree and returns the nearest hit, or null. -
raycastNodeAll(
Node root, Ray ray, {double maxDistance = double.infinity, int layerMask = 0xFFFFFFFF, bool where(Node node)?, bool includeInvisible = false}) → List< SceneRaycastHit> -
Casts
raythroughroot's subtree and returns every hit, sorted nearest-first. Parameters as in raycastNode.
Typedefs
-
GltfResourceResolver
= Future<
Uint8List> Function(String uri) -
Resolves an external resource referenced by a multi-file glTF
document (a
.binbuffer or an image file). - SceneCameraBuilder = Camera Function(Duration elapsed)
-
Builds a Camera for the current frame from the
elapsedtime since the view started ticking. Use this for time-based cameras (for example an orbiting view); pass a fixed SceneView.camera instead when the camera does not change over time. - SceneReloadCallback = void Function(Node root)
-
Called after a hot-reloaded scene has been patched in place (see
loadScene), so the app can re-apply per-instance customizations the
patch may have discarded: re-apply a custom material, or re-grab inner
nodes by name.
rootis the same root instance the app holds. - SceneTickCallback = void Function(Duration elapsed, double deltaSeconds)
-
Called once per frame with the total
elapsedtime and thedeltaSecondssince the previous tick. Drive per-frame app logic here, or advance the scene with a supplied timestep via Scene.update (after which Scene.render skips its implicit wall-clock tick for that frame).