UnitsView beta
Class of @v12-engine/client/lite-views
export declare class UnitsViewThe units and buildings of a game on the renderer: one record each, placed every frame between the last two snapshots and drawn with its parts or its model
Members
constructor
constructor(renderer: Renderer, options: UnitsOptions);Constructs a new instance of the UnitsView class
afterClips
afterClips(id: number, turn: (bones: LiteBones, dt: number) => void): () => void;Turns a unit's bones in code each frame once its clips have posed them, before its pose is drawn (Babylon's scene.onAfterAnimationsObservable with the model's nodes, kit.model(id)): turn is handed its bones (LiteBones: find a node, where it is, turn it about a way of the world) and the frame's seconds. A turn is laid over the clips' pose of the frame, not the last frame's turns. The unit is drawn on a skeleton of its own while it is turned. Until what it gives back is called (one turn a unit: another asked takes its place)
animationRate
animationRate(who: string, rate: number | null): void;How fast the units' clips play, for one who asks (who: a cinematic's slow motion, the game frozen), or its rate let go of with null: they play at every rate asked, one times another (the client's setAnimationRate), so one does not undo another
baked
get baked(): false | {
near?: number;
most?: number;
} | undefined;
set baked(baked: false | {
near?: number;
most?: number;
} | undefined);How the types whose looks say nothing of it are baked (UnitsOptions.baked, the game's kit.looks.baked), changed as the game runs: units drawn from now on (and those that change how they are drawn) go by it
boxOf
boxOf(id: number): {
min: [number, number, number];
max: [number, number, number];
} | undefined;The box an entity is drawn in now, in the world, its sides along the world's axes (the client's drawnBox): around the box it is picked by, which is turned as it stands. Nothing for one that is not drawn
breakApart
breakApart(at: Parameters<LiteDebris['burst']>[0], pieces: Parameters<LiteDebris['burst']>[1], options?: Parameters<LiteDebris['burst']>[2]): boolean;Breaks something into pieces of what it is made of at a place, which fly and land (the client's RenderKit.breakApart, with no physics on this renderer: debris.ts): whether it did
clipRate
get clipRate(): number;How fast the units' clips play now: every rate asked, multiplied (animationRate)
clipsOf
clipsOf(id: number): string[];The clips a unit's model can play, by name
dispose
dispose(): void;Takes away every unit, its picks, its parts' and models' batches and the poses' texture
drawn
drawn(id: number): {
x: number;
y: number;
z: number;
visible: boolean;
} | undefined;Where an entity is drawn right now
frame
frame(alpha: number, dt: number): void;A frame: every unit placed between the last two snapshots (alpha), dt seconds on
hide
hide(id: number, hidden: boolean): void;Hidden or shown by the game (kit.hide)
letGo
letGo(id: number): void;The game lets go of a death it kept (DeathLook keep, kit.letGo)
levels
levels(visit: (thing: {
min: readonly number[];
max: readonly number[];
} | {
x: number;
y: number;
z: number;
reach: number;
}, level: number, picture: boolean) => void): void;What is drawn at which level now, for the debug views (detail): each unit seen, its box in the world and the level its distance picks; one drawn as its picture by its foot
liftOf
liftOf(id: number): number;How far above where it stands an entity is drawn right now: thrown up, or on a leap
marksOf
marksOf(id: number): Record<string, number>;Seconds from now to each mark still to come in what a unit does once, by name
night
set night(night: number);How far into the night it is, 0 by day to 1 once the lamps are fully up (the client's nightOf): what a model whose look glows by the hour glows with
outline
outline(id: number, style: Outline | undefined): void;Outlines a unit in a style of the renderer's (renderer.outlines.style), or no longer (undefined): every copy it is drawn with is marked as one thing, by its id (its parts, its model's pieces and what its hands hold), and marked again wherever its copies stand after: a part that comes and goes, a skeleton given or taken, another level, another variant, a model read later. The flag and the ball over it are not of its shape. A unit of parts is outlined too (the client's line took a model's own meshes alone)
outlineOf
outlineOf(id: number): Outline | undefined;Whether a unit is outlined, and in which style
ownSkeleton
ownSkeleton(id: number): void;Draws a unit with a skeleton of its own for a while (SKELETON_LEASE): something needs its bones exactly
partsOf
partsOf(id: number): string[];The parts of a unit's model by their names, where its model is kept in parts (its look's ModelDef.merge: false, or the game's units.merge): what code may hide or recolour alone (setPart, the client's UnitModels.model(id).meshes by name). None where it is merged, or not drawn yet
playClip
playClip(id: number, clip: string, options?: ClipOptions): boolean;Plays a clip of the game's on a unit (kit.playClip), by its name in its model's files: on its own skeleton, which it is given for it. False where it is not drawn by a model, or its model has no such clip
point
point(id: number, name: string, out?: {
x: number;
y: number;
z: number;
}, offset?: readonly [number, number, number]): {
x: number;
y: number;
z: number;
} | undefined;Where a place of a unit's model is in the world now (kit.point): a point its model declares (ModelDef.points), else a node of its file by that name (handslot.r), as the pose it is drawn in has it, a skeleton's or a baked copy's frame. Nothing for one not drawn, with no model, or with no such place
prepare
prepare(models: readonly ModelDef[]): Promise<void>;The models of looks read ahead (a loading screen's): resolves once each is there to draw, or could not be
prop
prop(model: ModelDef, at: {
x: number;
z: number;
}, options?: {
facing?: number;
scale?: number;
clip?: string;
loop?: boolean;
}): Promise<LiteProp | undefined>;A model placed for a cinematic alone (the client's placeProp, Stage.prop): no entity of the game's, drawn as a unit of the model is (on a skeleton of its own throughout, its clips by the units' Animator), on the ground at a spot, turned and sized; standing, walking at the pace it is moved by the model's stride, or asleep (play of idle, walk, sleep looped), or playing a clip of its model blended, its marks told ('hit': where its blow lands). Once its model is read; none where the units draw no models, or the model could not be read
recolor
recolor(): void;Every unit in its owner's colour as it is now: the player chose other colours
redrawLooks
redrawLooks(): void;What unit types look like changed (client.looks.set): every unit whose look is another now drawn anew with it, its levels as its new look says
release
release(def: ModelDef): boolean;Lets go of a model no unit is drawn with (UnitModels.release, the client's ModelLibrary.release): its batches and the pictures no other model shows. Whether it did: not while a unit, living or dying, is drawn with it
releaseClip
releaseClip(id: number): void;A clip of the game's held on a unit is let go of: it plays out (Animator.release)
reloadModels
reloadModels(files: readonly string[]): Promise<void>;Model files changed on disk (hotFiles): every model read from them read anew (UnitModels.reload), and every unit drawn with one drawn again with the new, its old body let go of; a unit dying in the old is gone with it. A file that does not load leaves what there was
seeThrough
seeThrough(id: number, share: number, hole?: boolean): void;How much of a unit or a building is drawn while it stands in the way of what is seen through it (seeThrough.ts): 1 whole. Less is the dither variant, for as long as it is less and no longer; hole, in front of a unit cut round (cutout), the hole variant, the holes cut through it
setAlpha
setAlpha(id: number, alpha: number): void;How much of a unit is there (kit.setAlpha): less than all of it is dithered
setAnimation
setAnimation(src: string, file: string, how?: AnimationFileDef | null): Promise<void>;Lays an animation file on a model's file at run time, or takes it off with null (the client's applyAnimation): every unit of it drawn again with it. Settles when they are
setClips
setClips(src: string, file: string, data?: Uint8Array | null): Promise<void>;Lays a file of clips on a model's file again (the client's ModelLibrary.setClips, the editor's as it writes a model's clipsFile): the file as it is now, the bytes given (a preview of what is not written yet), or with null none of it; every unit drawn with a model of the file drawn again with its clips as they are now
setMaterial
setMaterial(id: number, name: string, def: MaterialDef | null): void;Lays a material over one of a unit's model's for it alone, by its name in the file ('*': every one): a colour, a picture, what shines (MaterialDef, as a look's ModelDef.material says them for every copy); null takes it off. Its own copy up close and its baked copies alike: its model with them (withMaterials, another model, a crowd of its own far off), drawn once that is read, what it was doing going on. Undone as it is drawn anew for another reason (another look, another owner), as the client's (kit.setMaterial)
setPart
setPart(id: number, name: string, say: PartSay | undefined): boolean;A part of a unit's model, by its name (partsOf), hidden or shown, or recoloured (its colour times tint), alone, as code hid or recoloured one of the client's meshes; undefined gives it back as its model draws it. Kept as the unit is drawn again (another level, its own skeleton or its crowd's). Whether its model has such a part
shatter
shatter(record: UnitRecord, count: number, options?: Parameters<LiteDebris['shards']>[1], random?: () => number): Promise<void>;A unit's model cut into about count pieces of itself where it stands, in the pose it is drawn in (shatter.ts), which fly and settle as debris does (LiteDebris.shards): the client's Debris.shatter. Each of its pieces' share of the count by how much of the model it is; drawn with its picture and colour. Settles once they fly
stats
get stats(): Record<string, unknown>;What is drawn now
stopClip
stopClip(id: number): boolean;A clip of the game's on a unit stopped at once. False where it played none
swing
swing(id: number): number | undefined;Seconds its attack's clip takes at its own pace, where a clip of its model marks its blow: nothing otherwise
sync
sync(changes: StateChanges): void;A snapshot came in: what it added, removed and said happened
tint
tint(id: number, colour: Rgb | null, amount?: number): void;A colour laid over a unit (kit.tint): null for none. amount: how much of it (the client's 0.45)
unitsStand
unitsStand?: 'still' | 'idle';Units stand in the first frame of their loop (a map nobody plays): still; or play it where they stand: idle