MaterialLibrary 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.

Constructors

MaterialLibrary(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
final

Methods

clear() → void
Lets go of everything, unsaved previews too.
complete(MaterialFile 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) → MaterialFile?
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 MaterialFile.animatableKeys) on top; null until the file is read, or when it is broken.
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, MaterialFile 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.
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.
sourceOf(String path) → MaterialFile?
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(MaterialFile file, {List<MaterialFile?> layers = const []}) → MaterialData
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 overridden materials kept before they are all let go.