Material3DLibrary class final

The material files (*.material.json) the scene's shapes and models draw with, read once each and made into GPU materials.

Everything arrives in the background: gpuOf is null until the file (and, for a variant, every parent) is read, and the material is made again as each of its maps arrives — revision goes up each time, so whoever draws with one asks again. Colour and glow maps are read as sRGB, the others as plain numbers; a layered material's layers are each layer file's colour map.

A variant is drawn with its parents laid under it (MaterialChain); an editor shows unsaved edits by preview; an entity's own values go on top through gpuOf's overrides. Only what uses a file is made again when it changes.

What a level no longer uses goes with retainOnly; a material made for an entity's own values goes as soon as the last user that counted itself (hold) lets go of it (release).

Constructors

Material3DLibrary(ModelUploader uploader, Future<Uint8List> read(String path))
A library reading files through read and making GPU things with uploader.

Properties

hashCode → int
The hash code for this object.
no setterinherited
read → Future<Uint8List> Function(String path)
Reads a project file's bytes (the editor's own reader while editing).
final
revision → int
Goes up whenever a material is read, made again or forgotten.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
uploader → ModelUploader
Makes the GPU materials and uploads the maps.
final

Methods

clear() → void
Lets go of everything, unsaved previews too.
complete(Material3DFile file) → Future<GpuMaterial>
file's material with every map read first — for a picture of it, not a scene drawn frame by frame. A variant's parents, its layers' files and the maps are read through read too (or taken from a preview). Throws what reading the file's maps or layers throws; a parent that cannot be read is skipped.
endPreview(String path) → void
path drawn as saved again.
errorOf(String path) → Object?
Why path could not be read; null when it was, or still is being.
fileOf(String path) → Material3DFile?
The material at path as it is drawn: its parents laid under it, an unsaved edit standing in for a file — reading it the first time asked; null meanwhile, or when it could not be read (errorOf).
gpuOf(String path, {Map<String, Object?> overrides = const {}}) → GpuMaterial?
path's GPU material, with what of its maps has arrived and overrides (an entity's values, by Material3DFile.animatableKeys) on top; null until the file is read, or when it is broken.
hold(GpuMaterial material) → void
Counts one more user of material, one gpuOf made with an entity's values, until it calls release. Any other material is not counted.
isPreviewing(String path) → bool
Whether path is drawn from an unsaved edit.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
preview(String path, Material3DFile file) → void
Draws path as file — unsaved edits — until endPreview: what uses it, its variants and the layered materials it is a layer of follow.
problemsOf(String path) → List<String>
What is wrong with path's parents — one missing, a loop — for a person; empty when nothing is, or while they are read.
release(GpuMaterial material) → void
One user of material (counted by hold) stopped drawing it: once none does, it is let go — made again if asked for again.
reload(String path) → void
Reads path again — a material file, or a map one uses — after it changed on disk. What it was is drawn until it arrives.
retainOnly(Iterable<String> keep) → int
Lets go of every material file no path in keep is drawn with — not one of them, nor a parent or a layer of one — with the maps only they use and the materials made from them: what a level no longer uses leaves the GPU. Unsaved previews stay. Returns how many files went.
sourceOf(String path) → Material3DFile?
The file at path as saved (or as preview shows it), not resolved: a variant's own keys only. Null until read.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

dataOf(Material3DFile file, {List<Material3DFile?> layers = const []}) → Material3DData
file's values as the renderer takes them: colours made linear, the maps' tiling, offset and turn on each; a layered one's layers tiled as each layer file says (layers, read or null).

Constants

maxOverridden → const int
The most materials with an entity's values kept that no user holds; past it, the least recently asked for goes.