Skip to content

UnitModels beta ​

Class of @v12-engine/client/lite-views

ts
export declare class UnitModels

The units' models on the renderer: each loaded once for its key, its batches drawn for every unit of it

Members ​

constructor ​

ts
constructor(renderer: Renderer, assets: UnitAssets, poses: PoseRows, capacity: {
        skeletons: number;
        copies: number;
        shadows: PartShadows;
        velocity?: boolean;
        holes?: unknown;
    });

Constructs a new instance of the UnitModels class

dispose ​

ts
dispose(): void;

Takes away every model's batches and what was made for them on the card

extraClips ​

ts
extraClips: (def: ModelDef) => readonly string[];

The clips baked beside each model's kinds' (the clips its looks swing and cast with)

flush ​

ts
flush(): void;

Once a frame, after every unit is placed and posed

load ​

ts
load(def: ModelDef): Promise<UnitModel>;

A model, once its files are read and on the card

loaded ​

ts
loaded(def: ModelDef): UnitModel | undefined;

A model there to draw now

missing ​

ts
missing(def: ModelDef): boolean;

Whether a model could not be read: one never to be drawn

night ​

ts
get night(): number;

set night(night: number);

How far into the night it is, 0 by day to 1 once the lamps are fully up: what a model that glows by the hour glows with (ModelGlow.night)

onBuilt ​

ts
onBuilt?: (src: string, ms: number) => void;

Told of each model built, its file and the milliseconds from its ask to its batches made (the first-seen report's)

pictureCount ​

ts
get pictureCount(): number;

How many pictures are kept for the models now

pixelsOf ​

ts
pixelsOf?: (bytes: Uint8Array, mime: string) => Promise<{
        data: Uint8Array | Uint8ClampedArray;
        width: number;
        height: number;
    }>;

A picture's pixels as they are stored, the top row first: what the cells of an owner's colour are measured on. The page's canvas where left out

release ​

ts
release(def: ModelDef): boolean;

Lets go of a model nothing draws any more (the client's ModelLibrary.release): its batches, geometries and blocks, and each picture it shows but where another model still shows it (a pack's atlas in every model of it), the picture with the last of them; read anew if it is asked for again. Whether there was one to let go of. Its units are the caller's to have drawn otherwise first (UnitsView.release)

reload ​

ts
reload(files: readonly string[]): Promise<{
        keys: Set<string>;
        retire(): void;
    } | undefined>;

Files changed on disk (hotFiles, their addresses new by Assets.changed): every model read from one of them (its own, what it holds, its clips, its levels) read anew, the one there was kept to draw until it is let go of (retire), and kept as it is where the new file does not load (a save caught half written); one that could not be read before is asked again. Resolves with the keys of the models to draw again (modelKey): undefined where no model was read from them

setAnimation ​

ts
setAnimation(src: string, file: string, how?: AnimationFileDef | null): Promise<{
        keys: Set<string>;
        retire(): void;
    } | undefined>;

Lays an animation file on a model's file at run time (the client's ModelLibrary.setAnimation, client.applyAnimation), as it is now and by its table of bones; with null, none of it. A clip of the model by the file's path from now on, its marks and loop on a look that says none; every model of the file read anew: resolves as setClips does

setClips ​

ts
setClips(src: string, file: string, data?: Uint8Array | null): Promise<{
        keys: Set<string>;
        retire(): void;
    } | undefined>;

Lays a file of clips on a model's file again, for what is drawn of it from now on (the client's ModelLibrary.setClips): the file as it is now, the bytes given (a preview, under any name, of what is not written yet), or with null none of it. Every model of the file read anew as reload reads it: resolves with the keys of the models to draw again, and what lets go of the ones before

stats ​

ts
get stats(): {
        models: number;
        batches: number;
        copies: number;
        grown: number;
    };

How many models are ready, their batches and the copies in them, and how many times a batch that filled was made again twice as long

surfaceOf ​

ts
surfaceOf(model: UnitModel): Promise<{
        piece: ModelPiece;
        skinned: SkinnedPiece;
    }[]>;

A model's pieces as numbers on the processor, each with the piece it is drawn as (its skin's vertices, joints, weights and triangles): what a shatter cuts (shatter.ts). Read again from its file the first time, then kept