Graphics3DSceneRenderer class final
Draws a world's 3-D components (Model, the shapes, Light, Environment)
from the engine's camera — the SceneRenderer a Graphics3D adds.
Each frame it brings its scene up to date with the world: the model and shape instances are looked over only when the world's structure changes or a model finishes loading — what still stands is kept, only what is new is made — and otherwise just follow their entities' transforms — a shape whose sizes or look changed takes another mesh or material from shapes. It does so once a frame however many views it draws (an editor's panes), when frame says which frame is drawn. It then renders into a texture at the viewport's size in physical pixels times renderScale and draws that texture over the viewport.
Between fixed updates an entity is drawn the frame's interpolation of the way from its previous pose to its pose, when whatever moves it captured that previous pose in the last update (TransformComponent.captureCount: physics bodies and characters). Anything else is drawn where it is: a transform only gameplay writes has a previous pose that may be stale.
Without a GPU (unsupportedReason set) it still keeps the models' bounds up to date, and draws a short note instead of the image.
What it draws from stays loaded — models, material files, maps — until releaseUnused lets go of what the world no longer draws (after a level changes, say).
- Inheritance
-
- Object
- SceneRenderer
- Graphics3DSceneRenderer
Constructors
- Graphics3DSceneRenderer({required World world(), required Renderer3D renderer, required Graphics3DModels models, String? unsupportedReason, int? frame()?})
-
Draws the world
worldgives withrenderer, models frommodels.
Properties
- aids ↔ SceneEditorAids?
-
What an editor adds to its views; null in a game.
getter/setter pair
-
debugInstances
→ Map<
String, int> -
The models drawn, for tests: path → instance count.
no setter
-
debugModelInstances
→ List<
MeshInstance> -
The models drawn, for tests: every instance of every one.
no setter
-
debugShapeInstances
→ List<
MeshInstance?> -
The shapes drawn, for tests: each one's instance (null while it has
no triangles).
no setter
- debugSurfaces → int
-
How many views' surfaces are kept, for tests.
no setter
- dynamicResolution → DynamicResolution
-
Lowers the resolution while frames run slow (off by default).
final
- enabled → bool
-
Skipped while false.
no setteroverride
- frame → int? Function()?
-
The frame being drawn, asked for each view: an engine's
(
() => engine.rendering.drawingFrame). Views drawn in one frame — an editor's panes, its preview of the game's camera — share one look at the world (models posed, shapes, providers, lights and environment followed); only what differs per view (the editor's aids, the camera) is done for each. Null, or a null answer (a view drawn outside the engine's frame), looks the world over again for every view.final - hashCode → int
-
The hash code for this object.
no setterinherited
-
lastFrame
↔ Future<
bool> ? -
Completes when the GPU has finished the last frame.
getter/setter pair
- materials → Material3DLibrary
-
The material files shapes and models are drawn with
(Primitive3DComponent.material, ModelComponent.materials).
latefinal
- models → Graphics3DModels
-
Where models come from.
final
-
modelsInUse
→ Iterable<
GpuModel> -
The GPU models in use.
no setter
- order → int
-
Draw order among scene renderers; lower first.
no setteroverride
- pixelRatio ↔ double?
-
Physical pixels per viewport pixel; null reads the screen's.
getter/setter pair
- providers → RenderProviders
-
What kits draw (terrain, scatter, tiles): the world's context's
RenderProviders.
no setter
- renderer → Renderer3D
-
What draws it.
final
- renderScale ↔ double
-
Fraction of the physical resolution rendered (0.25..1 makes sense;
above 1 supersamples).
getter/setter pair
- renderWithoutGpu ↔ bool
-
Renders on a device with no GPU too (tests of the CPU side).
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scene → Render3DScene
-
The scene as last extracted from the world.
final
- shapes → Graphics3DShapes
-
The shapes' meshes and materials.
latefinal
- unsupportedReason → String?
-
Why there is no GPU to draw with, or null when there is one.
final
- visible ↔ bool
-
Drawn at all.
getter/setter pair
- world → World Function()
-
The world drawn, asked for each frame: an engine's
(
() => engine.world).final
Methods
-
dispose(
) → void - Stops listening to models and lets go of its views' surfaces; call once it is no longer drawn.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
releaseUnused(
) → (int, int) - Lets go of every model, material file and map the world's entities do not draw with — the switched-off ones' are kept — and of the shapes' meshes and materials nothing draws: what a level left behind leaves the GPU. Call once the next level is in the world; whatever is drawn again later is loaded again. Returns how many models and material files went.
-
reload(
String path) → void - A file changed on disk: the material files and maps, the shapes' textures and the skybox read from it are read again — what they were is drawn until they arrive. (A model is read again by Graphics3DModels.reload.)
-
render(
Canvas canvas, FrameView view) → void -
Draw into
canvas, whose coordinates are viewport pixels, whatviewsees.override -
toString(
) → String -
A string representation of this object.
inherited
-
update(
FrameView view) → void -
Brings scene and the render view up to date with the world and
view. render calls it; tests may call it alone.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- keepSurfaceRenders → const int
- Renders a view's surface is kept for after its last: one that stops drawing (an editor's split panes put away) lets go of its textures.