SceneView class Widgets

A widget that renders a Scene and drives its per-frame repaint.

This is the supported way to display a scene: it owns the frame ticker and the CustomPaint that calls Scene.render, so applications do not write their own CustomPainter. The scene is app-owned and mutated imperatively over time (attach and detach Nodes, swap materials); SceneView is a view onto it, not the owner of its contents.

Provide the camera either as a fixed camera or, for a camera that changes over time, a cameraBuilder that receives the elapsed time each frame.

SceneView(
  scene,
  cameraBuilder: (elapsed) {
    final t = elapsed.inMicroseconds / 1e6;
    return PerspectiveCamera(
      position: Vector3(sin(t) * 5, 2, cos(t) * 5),
      target: Vector3.zero(),
    );
  },
)

Place SceneView where it receives bounded constraints (for example inside a SizedBox.expand or an Expanded); it fills the space it is given.

The active scene is exposed to descendants through SceneScope, so widgets below can resolve the scene from their BuildContext.

For a fully declarative scene, use SceneView.declarative: the view owns an internal Scene and declarative scene widgets (SceneNode, SceneMesh, SceneModel) describe its contents in children. Both constructors accept children, so declarative subtrees also compose over an app-owned scene.

Inheritance

Constructors

SceneView(Scene scene, {Key? key, Camera? camera, SceneCameraBuilder? cameraBuilder, SceneViewsBuilder? viewsBuilder, bool autoTick = true, double? pixelRatio, SceneTickCallback? onTick, ResourceGroup? loading, SceneLoadingBuilder? loadingBuilder, Duration revealMinDuration = Duration.zero, bool warmUp = false, bool debugWidgetInput = false, List<Widget> children = const []})
Renders scene, driving a repaint each frame.
const
SceneView.declarative({Key? key, EnvironmentMap? environment, double environmentIntensity = 1.0, double exposure = 1.0, ToneMappingMode toneMapping = ToneMappingMode.pbrNeutral, Camera? camera, SceneCameraBuilder? cameraBuilder, SceneViewsBuilder? viewsBuilder, bool autoTick = true, double? pixelRatio, SceneTickCallback? onTick, ResourceGroup? loading, SceneLoadingBuilder? loadingBuilder, Duration revealMinDuration = Duration.zero, bool warmUp = false, bool debugWidgetInput = false, List<Widget> children = const []})
Renders a view-owned Scene described declaratively by children.
const

Properties

autoTick → bool
Whether to drive a repaint every frame with an internal Ticker.
final
camera → Camera?
A fixed camera. Mutually exclusive with cameraBuilder and viewsBuilder.
final
cameraBuilder → SceneCameraBuilder?
Builds the camera each frame from the elapsed time. Mutually exclusive with camera and viewsBuilder.
final
children → List<Widget>
Declarative scene widgets mounted at the scene root (via SceneScope).
final
debugWidgetInput → bool
Debug-only: overlays the automatic widget-input pointer's state (hit node, UV, distance, and a marker at the pointer position), the first tool to reach for when a widget surface does not respond to input.
final
environment → EnvironmentMap?
The owned scene's environment map (SceneView.declarative only). Identity-diffed; null means the scene's default studio environment.
final
environmentIntensity → double
The owned scene's environment intensity (SceneView.declarative only).
final
exposure → double
The owned scene's exposure (SceneView.declarative only).
final
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
loading → ResourceGroup?
Resources this view waits for before it reveals the scene.
final
loadingBuilder → SceneLoadingBuilder?
Builds the widget shown while the view waits to reveal the scene.
final
onTick → SceneTickCallback?
Called once per frame while ticking. See SceneTickCallback.
final
pixelRatio → double?
Logical-to-physical pixel multiplier for the offscreen render target, forwarded to Scene.render. Defaults to the view's device pixel ratio.
final
revealMinDuration → Duration
The minimum time the loading widget stays up once shown, so a fast load does not flash it for a single frame. Defaults to Duration.zero.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scene → Scene?
The scene to render, owned and mutated by the application. Null when the view owns its scene (SceneView.declarative).
final
toneMapping → ToneMappingMode?
The owned scene's tone mapping (SceneView.declarative only). Null on the app-owned-scene constructor, which never writes scene properties.
final
viewsBuilder → SceneViewsBuilder?
Builds the list of views to render each frame (split-screen, picture-in-picture). Mutually exclusive with camera and cameraBuilder.
final
warmUp → bool
Whether to compile the scene's render pipelines before revealing it, so the first visible frame does not stall while shaders compile.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<SceneView>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

resolveCamera(Duration elapsed, {Camera? camera, SceneCameraBuilder? cameraBuilder, Camera? sceneCamera}) → Camera
Resolves the camera for a single-view frame.