Model loading · class
TextureSet
Explained in Importing models.
class TextureSet<T>import { TextureSet } from '@driftengine/assets';Accessors
| Name | Type | Description |
|---|---|---|
sizeget | number | How many textures were created, which is not the number the file carried. |
Methods
fromstatic
static from<T>(textures: readonly DrftTexture[], create: (texture: DrftTexture, at: number) => T | null): TextureSet<T>Build the lookup as the textures are created, in file order.
| Parameter | Type | Description |
|---|---|---|
textures | readonly DrftTexture[] | |
create | (texture: DrftTexture, at: number) => T | null |
More
create returning null means that image could not be decoded, which is survivable: the
surface draws untextured and the slot stays addressable, so a later replace can still
put something there. Dropping the entry instead would renumber everything after it.
all
all(): readonly T[]Every created texture, for disposal rather than for addressing.
at
at(index: number): T | nullThe texture a material named, by its index in the file, or null.
| Parameter | Type | Description |
|---|---|---|
index | number |
has
has(name: string): booleanWhether a name resolves, for a caller that wants to ask rather than to handle a throw.
| Parameter | Type | Description |
|---|---|---|
name | string |
get
get(name: string): TThe texture called this, or a refusal naming every texture the asset does have.
| Parameter | Type | Description |
|---|---|---|
name | string |
More
Throwing beats returning null. A caller asking by name has a specific image in mind, and a null it forgets to check is the silent-wrong-surface failure that indices already had.