GraphicsShapes class final
The GPU side of the shapes (Primitive3D): 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.
Constructors
-
GraphicsShapes(ModelUploader uploader, Future<
Uint8List> read(String path), {Iterable<Object> inUse()?, MaterialLibrary? library}) -
Shapes uploaded with
uploader, their textures read byread; what is drawn now is told byinUse.
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 → MaterialLibrary?
-
The material files a shape may be drawn with (Primitive3D.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: now and then, lets go of what has not been used for keepFrames frames and is not inUse.
-
materialFor(
Primitive3D shape, {Map< String, Object?> overrides = const {}}) → GpuMaterial -
shape's material: its material file's once that is read (its own look meanwhile), withoverrides(its entity's own values, MaterialOverrides3D) on top; else its own look, with its texture once that has loaded. -
meshFor(
Primitive3D shape, Vector3 scale) → GpuPrimitive? -
shape's mesh, for an entity scaled byscale(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
-
reloadTexture(
String path) → void -
Forgets
path's texture so it is read again (it changed on disk). -
tilesInMetres(
Primitive3D 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
-
linear(
Color c) → (double, double, double) -
sRGB
cas linear RGB. -
materialDataOf(
Primitive3D shape) → MaterialData -
shape's look as a glTF-style material: colours made linear, blended when it is not opaque, its texture (as texture 0) repeated Primitive3D.tiling times. -
uvFor(
Primitive3D shape, Vector3 scale) → ShapeUv -
How
shape's texture is laid out atscale, drawn with its own look.
Constants
- keepFrames → const int
- Frames something stays unused before it is let go.