Skip to content

Renderer beta ​

Interface of @v12-engine/render

ts
export interface Renderer

The renderer: a canvas, the world's geometries, pictures, materials and batches of copies, a camera, the sun and the sky, and a frame drawn from them

Members ​

aspect ​

ts
readonly aspect: number;

The main view's width over its height, as its last frame had it

batch ​

ts
batch(geometry: Geometry, material: Material, matrices: Float32Array, count: number, options?: BatchOptions): Batch;

A batch of capacity copies at most, count of them given now in matrices (which the batch keeps and reads)

camera ​

ts
readonly camera: CameraState;

The main view's camera, written in place

capture ​

ts
capture(options?: CaptureOptions): Promise<Capture>;

The main view drawn once more as its last frame was, at scale times its pixels, through the picture's passes, and read back

card ​

ts
readonly card: Card;

The card under the renderer, for a pass of the caller's own into a texture (a picture baked of a model): its device, and what a geometry, a data texture and a picture are on it

casters ​

ts
readonly casters: {
        floor: number;
        longest: number;
        edge: number;
        cull: boolean;
        reach: boolean;
        casts?: CastsHook;
        unitsCascades?: number;
    };

What the cascades leave out: the floor shadows fall to (the lowest ground, less a little) and the farthest one reaches (the map from end to end), which a caster out of the view is kept by; how far past the view's edges a caster is kept whatever its shadow; whether the cascades cull what they keep at all (cull: false keeps all that is in a cascade's own box, small and far too: the client's MapShadows.cull); the game's code deciding thing by thing whether it casts, over the culling (casts: the client's WorldShadows.casts, asked for each copy in each cascade every frame); whether the cascades no pixel of the view reads are left out (reach: the nearest of what the view keeps that reads the shadows looked for each frame, stats.nearestRead; true when left alone); how many cascades a unit's copy is cast into at most, the nearest of those its shadow falls in (unitsCascades: of the batches whose caster.unit is set and that say no cascadesMost of their own, read every frame; the client's MapShadows.unitsCascades; 0 or none: every one)

clearColour ​

ts
clearColour: readonly [number, number, number];

What the view's target is cleared to: the colour behind everything

cloudMask ​

ts
readonly cloudMask: DataTexture;

A texel a cell, its alpha where clouds are

cloudPicture ​

ts
readonly cloudPicture: DataTexture;

256 by 256, its alpha the clouds; mips() after it is written

debug ​

ts
debug: number;

A debug view: 1 shows how much of the sun reaches each pixel

dispose ​

ts
dispose(): void;

Stops, and frees the card: every target, buffer and texture with the device. Nothing of the renderer is used after

engine ​

ts
readonly engine: EngineContext;

Lite's engine under it

fogOfWar ​

ts
readonly fogOfWar: DataTexture;

A byte a cell, 255 where seen: written by the game (a rectangle at a time), read with world.fogOfWar on

geometry ​

ts
geometry(data: GeometryData): Geometry;

A mesh's points sent to the card, for batches to draw

glow ​

ts
readonly glow: GlowSettings;

The glow of the batches given one (Batch.glow): how bright, how wide, at what size; read every frame

kindMaterial ​

ts
kindMaterial(kind: MaterialKind, options: KindMaterialOptions): Material;

A material of a kind of the caller's own

lamps ​

ts
readonly lamps: Lamps;

The lamps: lights at a place with a reach, added, moved and removed by the game (lamps.ts)

map ​

ts
map: {
        readonly width: number;
        readonly depth: number;
    };

The map's size in cells, which the fog of war's and the cloud mask's textures are as big as. Set to another: both made again at it (all seen, clouds everywhere, until written) and every binding set that reads them follows; the same objects (fogOfWar, cloudMask) throughout

material ​

ts
material(options: MaterialOptions & {
        tinted?: boolean;
    }): Material;

A standard material: a colour, a picture, the sun and the sky. tinted where its batches' copies carry a tint

maxFps ​

ts
maxFps: number;

The most frames a second it draws (0: as many as the screen shows). A frame in between is left out whole: no callback of onFrame, nothing culled, encoded or sent, the canvas showing what it showed; onFrame's time is from the last frame drawn

onError ​

ts
onError(callback: (error: unknown) => void): () => void;

Hears what a callback of onFrame threw: the frame goes on to the next callback and is drawn, and the loop runs on unless who hears stops it. With nobody hearing, what was thrown is thrown on, as it was

onFrame ​

ts
onFrame(callback: (deltaMs: number) => void): () => void;

Called at the start of every frame, before anything is culled: where the game moves the camera and its batches

outlines ​

ts
readonly outlines: Outlines;

The outlines' styles (layers.ts): a batch's copies are outlined in one by Batch.outline

picture ​

ts
picture(source: ImageBitmap | ImageData, sampling?: PictureSampling): Promise<Picture>;

An image sent to the card as a picture with its mips, for a material, sampled as sampling says (the renderer's own where it says nothing); Picture.dispose frees it

post ​

ts
readonly post: {
        readonly settings: PictureSettings;
        reset(): void;
        readonly passes: number;
        addPass(place: PostPlace, wgsl: string, options?: PostPassOptions): PostPass;
    };

The passes after the view's (picture.ts): settings is read every frame, a stage that is off costs no pass; reset has the temporal blend start over; passes is how many the last frame drew. addPass: a game's own pass over the picture, in WGSL, at one of the old chain's places (post/gamePasses.ts): drawn once the card has made its shader with nothing wrong, while it is on; none added, none drawn

prepare ​

ts
prepare(material: Material): Promise<void>;

Has the card make ready what a material's draws need (its pipelines for the view's pass and a cascade's) without holding a frame up; resolves when they are

ready ​

ts
ready(): Promise<void>;

Resolves when every pipeline of the materials made into batches or prepared so far is ready: what a loading screen waits on before the first frame that shows the world

resize ​

ts
resize(): Promise<void>;

The picture's targets made again at the canvas's size where it changed (the canvas itself follows its place on the page each frame). The frame asks for it by itself once a new size has held a few frames

running ​

ts
readonly running: boolean;

Whether it is drawing: after start, until stop

sampler ​

ts
sampler(sampling?: PictureSampling): unknown;

The sampler of a sampling (one for each alike): what a kind's binding of a picture's sampler takes

samplers ​

ts
readonly samplers: {
        picture: unknown;
        map: unknown;
    };

The samplers a kind's bindings want: a picture's (trilinear, repeating) and a map's (linear, clamped)

screenshot ​

ts
screenshot(): Promise<Capture>;

The canvas as the next frame leaves it: what the screen shows, read back

shadows ​

ts
readonly shadows: {
        cascades: number;
        size: number;
    };

The sun's shadows' quality, set at any time: how many cascades (2 or 3: with 2 the same reach in two parts) and a cascade's side in texels (its targets made again)

sky ​

ts
readonly sky: SkyState;

The sky's light, written in place

start ​

ts
start(): Promise<void>;

Starts drawing, or again after stop; resolves after the first frame

stats ​

ts
stats(): FrameStats;

What the last frame drew, a copy, with the card's time and the frames left out

stop ​

ts
stop(): void;

Stops drawing: no frame is asked for until start

stream ​

ts
stream(options: StreamOptions): Stream;

Many copies of a few vertices with no geometry, each a record of the caller's own (streams.ts): particles, ribbons

sun ​

ts
readonly sun: SunState;

The sun, written in place

texture ​

ts
texture(options: DataTextureOptions): Promise<DataTexture>;

A texture of the game's own data, for a kind's bindings

timePasses ​

ts
timePasses(on: boolean): void;

Times the frame (on) or stops (off: none timed, as it starts): the card's passes (stats().gpuMs, passTimes) and the renderer's parts on the processor (stats().cpu), while on. A timestamp a pass and a read back a frame, so asked only while wanted (the quality's offer of a lower preset, the stats window)

uniforms ​

ts
uniforms(data: Float32Array): Uniforms;

A block of uniforms for a kind's bindings, data its floats (a multiple of four)

view ​

ts
view(options?: ViewOptions): Promise<SideView>;

Another view (views.ts): its own camera, lights, batches and target, drawn when asked or with every frame

viewPlanes ​

ts
readonly viewPlanes: Float32Array;

The main view's four sides as its last frame had them, as planes (a, b, c, d each): not to be written to

viewProjection ​

ts
readonly viewProjection: Mat4;

The main view as its last frame had it: its view and projection without the jitter (the engine's layout, 16 floats), its four sides as planes (a, b, c, d each, of length 1, a point inside where ax + by + c*z + d = 0), its width over its height. Not to be written to

world ​

ts
readonly world: WorldState;

The world's terms every material of the view applies, written in place