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.

Inheritance

Constructors

SceneView(Scene scene, {Key? key, Camera? camera, SceneCameraBuilder? cameraBuilder, SceneViewsBuilder? viewsBuilder, bool autoTick = true, double? pixelRatio, SceneTickCallback? onTick, bool debugWidgetInput = false})
Renders scene, driving a repaint each frame.
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
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
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
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
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.
final
viewsBuilder → SceneViewsBuilder?
Builds the list of views to render each frame (split-screen, picture-in-picture). Mutually exclusive with camera and cameraBuilder.
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