Renderer beta
Interface of @v12-engine/render
export interface RendererThe 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
readonly aspect: number;The main view's width over its height, as its last frame had it
batch
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
readonly camera: CameraState;The main view's camera, written in place
capture
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
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
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
clearColour: readonly [number, number, number];What the view's target is cleared to: the colour behind everything
cloudMask
readonly cloudMask: DataTexture;A texel a cell, its alpha where clouds are
cloudPicture
readonly cloudPicture: DataTexture;256 by 256, its alpha the clouds; mips() after it is written
debug
debug: number;A debug view: 1 shows how much of the sun reaches each pixel
dispose
dispose(): void;Stops, and frees the card: every target, buffer and texture with the device. Nothing of the renderer is used after
engine
readonly engine: EngineContext;Lite's engine under it
fogOfWar
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
geometry(data: GeometryData): Geometry;A mesh's points sent to the card, for batches to draw
glow
readonly glow: GlowSettings;The glow of the batches given one (Batch.glow): how bright, how wide, at what size; read every frame
kindMaterial
kindMaterial(kind: MaterialKind, options: KindMaterialOptions): Material;A material of a kind of the caller's own
lamps
readonly lamps: Lamps;The lamps: lights at a place with a reach, added, moved and removed by the game (lamps.ts)
map
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
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
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
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
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
readonly outlines: Outlines;The outlines' styles (layers.ts): a batch's copies are outlined in one by Batch.outline
picture
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
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
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
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
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
readonly running: boolean;Whether it is drawing: after start, until stop
sampler
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
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
screenshot(): Promise<Capture>;The canvas as the next frame leaves it: what the screen shows, read back
shadows
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
readonly sky: SkyState;The sky's light, written in place
start
start(): Promise<void>;Starts drawing, or again after stop; resolves after the first frame
stats
stats(): FrameStats;What the last frame drew, a copy, with the card's time and the frames left out
stop
stop(): void;Stops drawing: no frame is asked for until start
stream
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
readonly sun: SunState;The sun, written in place
texture
texture(options: DataTextureOptions): Promise<DataTexture>;A texture of the game's own data, for a kind's bindings
timePasses
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
uniforms(data: Float32Array): Uniforms;A block of uniforms for a kind's bindings, data its floats (a multiple of four)
view
view(options?: ViewOptions): Promise<SideView>;Another view (views.ts): its own camera, lights, batches and target, drawn when asked or with every frame
viewPlanes
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
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
readonly world: WorldState;The world's terms every material of the view applies, written in place