Graphics3DShapes class final

The GPU side of the shapes (Primitive3DComponent): meshes made from their sizes and materials from their looks, uploaded once and shared by every shape alike — twenty equal crates are one mesh and one material, drawn in one instanced draw.

Textures load in the background; a shape draws in its colour until its texture arrives. What no shape has used for a while is let go — never what inUse says is on screen, nor a texture such a material holds. A renderer that counts its users (hold, release) has what it stops using let go at once: a shape whose size animates keeps one mesh, not one a frame.

Constructors

Graphics3DShapes(ModelUploader uploader, Future<Uint8List> read(String path), {Iterable<Object> inUse()?, Material3DLibrary? library})
Shapes uploaded with uploader, their textures read by read; what is drawn now is told by inUse.

Properties

counts → (int, int, int)
How many meshes and materials are held.
no setter
hashCode → int
The hash code for this object.
no setterinherited
inUse → Iterable<Object> Function()?
The meshes and materials drawn now, asked for only when old ones are let go: these are kept however long ago they were asked for. A renderer asks meshFor and materialFor only when a shape changes, so what stays on screen unchanged would otherwise look unused.
final
library → Material3DLibrary?
The material files a shape may be drawn with (Primitive3DComponent.material); without one, every shape is drawn with its own look.
final
read → Future<Uint8List> Function(String path)
The bytes of an asset (a texture).
final
revision → int
Changes when a texture arrives: materials asked for before should be asked for again.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
uploader → ModelUploader
Where meshes and materials go.
final

Methods

clear() → void
Lets go of everything.
endFrame() → void
A frame has been drawn: lets go of what its last holder released in it (release) and nothing asked for again; now and then, of what has not been used for keepFrames frames and is not inUse.
hold(Object thing) → void
Counts one more user of thing — a mesh from meshFor, or a material from materialFor — until it calls release.
materialFor(Primitive3DComponent shape, {Map<String, Object?> overrides = const {}}) → GpuMaterial
shape's material: its material file's once that is read (its own look meanwhile), with overrides (its entity's own values, MaterialOverrides3DComponent) on top; else its own look, with its texture once that has loaded.
meshFor(Primitive3DComponent shape, Vector3 scale) → GpuPrimitive?
shape's mesh, for an entity scaled by scale (which counts only for a texture tiled per metre); null when it has no triangles.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
release(Object thing) → void
One user of thing (counted by hold) stopped drawing it: once none does, it is let go as the frame ends — unless asked for again in it — rather than after keepFrames. Asked for later, it is made again.
releaseUnused() → void
Lets go now, however recently used, of every mesh, material and texture that nothing inUse draws and no user holds (hold): asked for again, it is made again.
reloadTexture(String path) → void
Reads path's texture again (it changed on disk). What it was is drawn until the new one arrives; then the materials made with it are made again.
tilesInMetres(Primitive3DComponent shape) → bool
Whether shape's maps repeat per metre of the world, so its mesh is made for its scale: its own texture tiled per metre, or a material file laid out in metres.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

materialDataOf(Primitive3DComponent shape) → Material3DData
shape's look as a glTF-style material: colours made linear, blended when it is not opaque, its texture (as texture 0) repeated Primitive3DComponent.tiling times.
uvFor(Primitive3DComponent shape, Vector3 scale) → Shape3DUv
How shape's texture is laid out at scale, drawn with its own look.

Constants

keepFrames → const int
Frames something stays unused before it is let go.