Coldwave Read the docs

Protocol: frame, part 1 of 2#

The frame commands a program sends to a running game, as the engine describes them: what each takes, what it answers and what it does. Back to all commands.

frame.capture#

frame.capture {width?: integer, height?: integer, overlay?: text, target?: text, view?: record, eye?: record, pose?: record, step?: integer, from?: integer, inputs?: [record], steps?: integer, fill?: value, fast?: value, times?: value} -> {png: png, width: integer, height: integer, view: record, view_size: record, view_projection: [number], game_rect: record, took: record} · read, read-only

Draws the game as it is now, off-screen, and returns the picture: whole, or shrunk to fit inside a width and a height for a client that shows it small.

ParametersTypeMeaning
width?integerThe most pixels across, 1 or more. The picture keeps its shape, the smaller of the two bounds decides, and it is never larger than the frame. A project with filter = "linear" is shrunk smoothly, any other to hard pixels. Left out: no bound. With eye: the picture's width, exactly, 1 to 4096, drawn at that size and never shrunk; left out, the frame's.
height?integerThe most pixels down, 1 or more. Left out: no bound. With eye: the picture's height, exactly, 1 to 4096; left out, the frame's.
overlay?text"physics": every collider's outline, every joint and every contact drawn over the frame, one pixel wide, from what physics.read answers. Grey is static, blue kinematic, green dynamic, yellow a mover, pink a sensor, orange a one-way platform, white a joint and red a contact. "skeleton": the bones of every thing a 3D game poses (a Pose on a model with bones), as the pose drawn places them, a pose asked for the picture's too: a yellow (ffec27) line from each bone to the bone above it and a white 3-pixel square at each joint, over everything, one pixel wide; refused in a game with no rigged model. Left out: the frame alone.
target?textOne of the frame graph's own targets, by its name in the project's [render], as the frame left it, in place of the frame: what a pass drew before an effect read it. A 16-bit float target is cut to 0 to 1. Not with overlay, and not with eye, whose picture keeps none. Left out: the frame. render.passes lists the targets.
view?record{left, bottom, right, top}: a rectangle of the world in world units, y upwards as frame.view gives it, drawn in place of what the game's camera shows: what an editor that sees more than the camera, or less, shows. The picture is the rectangle's shape, at the frame's own pixels to a world unit as the camera's zoom gives them, its longer side at most 4096 (then smaller, keeping its shape), before width and height shrink it. What is on the screen (the interface, a Screen thing) is drawn on the camera's rectangle at the camera's scale, never stretched over the view. The game is not changed: the same step, the same checksum. Not with overlay or target. In a 3D game E0449: it is looked at from an eye. Left out: what the camera shows, as ever.
eye?recordIn a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle.
pose?recordIn a 3D game, {entity, clip, time?}: one thing (by name or id, with a Mesh whose model has clips) drawn time seconds (0 or more; left out 0) into one of its model's clips, for this answer alone, in place of what its Pose says: what an editor scrubbing a clip on a thing in the game shows. Nothing is written: the world, its checksum, its Pose and what the recording replays are as they were, and the next answer without it draws the Pose again. A clip that goes round is drawn round, one that does not holds its end, as a Pose plays it. Picking (frame.at, frame.in) meets things by their box at rest, with or without it. Refused (BadParams) for a thing with no Mesh, a model with no clips, or a clip its model has not, naming its clips.
step?integerA step to draw in place of the game as it stands: the picture a game.seek to that step would show, without seeking. The run is the one a seek winds through, the game loaded from its files and stepped on its recording (at rest past its end), not input held live; the engine plays it aside from the moment it keeps nearest at or before the step (else from the start, on a game loaded aside from the same files) and draws that world, with eye, pose, view and the rest as for any picture. The game is not moved: its step, world, checksum and kept moments and snapshots are as they were. Refused past the furthest of the steps the session has played, its recording's end and its replay's. Its cost is the replay: about a step's time a step from the moment it starts at.
from?integerA snapshot's id (game.snapshot): draw the game a game.try of inputs from it would leave, without moving the game, byte for byte what that try then a capture shows. Played aside: the game's step, world, checksum, kept moments and snapshots are as they were, and eye, pose, view and overlay combine as for any picture. Refused when the game has had a change since the snapshot that playing the inputs does not make again: a client's change at a step inside the stretch (named, with its step and command), or a script's code swapped since. Not with step. Its cost is the replay: a step's time a step, and a copy of the world each way.
inputs?[record]With from: the input to play from the snapshot, as game.try takes it, one {steps, ACTION: value, ..., player} per stretch. Left out: none, every player at rest.
steps?integerWith from: how many steps to play, each player at rest past their own inputs. Left out: as many as the longest player's inputs come to.
fill?valuetrue: the game's own camera draws the frame into a picture of exactly width by height pixels (both needed, 1 to 4096) with no bars: the frame in the middle, as large as fits at its own shape, its interface laid out in it as ever, and beside it what the same camera sees on (in 3D, its meshes, the camera's field of view held within the frame), so the frame's part is the game's own picture. game_rect says where it is. Not with eye, view, target or overlay. Left out: false.
fast?valuetrue: the PNG is written 25 to 35 times faster and is a tenth to a fifth larger, with the same pixels; for a picture shown live and thrown away. Left out: as small as it can be.
times?valuetrue: the answer says what the picture took, as took. Left out: false.
ResultTypeMeaning
pngpngThe frame as a PNG file, in base64.
widthintegerThe picture's width in pixels.
heightintegerThe picture's height in pixels.
viewrecordThe part of the world the picture shows, {left, bottom, right, top} in world units, as frame.view gives it: the world at the picture's edges, whatever size it is shrunk to. With view, the view asked: the rectangle the picture shows, to its edges. null with eye: its picture shows no rectangle of a flat world, and view_projection says what it shows.
view_sizerecord{width, height}: with view, the picture's size in pixels as it was drawn, before width and height shrink it: the frame's own pixels to a world unit at the camera's zoom, unless the longer side would pass 4096 (then fewer, the same each way). Pixels of frame.at, frame.in and blame.pixel with the same view are of this size. null without view.
view_projection[number]In a 3D game, the 16 numbers the meshes of this picture were drawn with: the matrix from the world to clip space, its four columns one after another (column-major), multiplied with a point (x, y, z, 1) on the right. After the divide by w, clip x and y from -1 to 1 span the whole picture, bars included, x to the right and y up, so a point is at the pixel ((x + 1) / 2 * width, (1 - y) / 2 * height); depth is reversed, 1 at the camera's near plane and 0 at its far one (or towards 0 for ever with no far plane), and a point behind the camera has w at or below 0. It is the camera of the step drawn, paused or sought to as it is; a pass that bends the picture (panini) moves its pixels from where this puts them. Left out in a 2D game, whose view says it.
game_rectrecordWith fill: {x, y, w, h}, where the frame stands in the picture, in whole pixels from its top left; the rest is what the camera sees beside it. Left out without fill.
tookrecordWith times true: {draw, read, encode, text}, what the picture took in milliseconds: its drawing, submitted (the device's wait is in read); its read back from the device, with the physics drawn over it and its shrinking; its PNG; and its base64 text. Time is not part of the game and differs from run to run. Left out without times.

frame.at#

frame.at {x: integer, y: integer, view?: record, eye?: record, pose?: record, width?: integer, height?: integer} -> {step: integer, x: integer, y: integer, hits: [record], drawn: record} · read, read-only

Says what is drawn at a pixel of the frame: every entity that draws there, the one in front first. It asks the batch a frame is drawn from, so it needs no graphics device, takes no picture and changes nothing. In a 3D game it also says each thing the ray through the pixel meets, by its collider or else its mesh's box, the nearest first. What an editor asks to pick the thing under the pointer.

ParametersTypeMeaning
xintegerThe pixel's column, 0 at the frame's left edge, as in a frame.capture at full size.
yintegerThe pixel's row, 0 at the frame's top edge.
view?record{left, bottom, right, top}, as frame.capture takes it: x and y are then pixels of that picture at its full size (before width and height shrink it), and boxes are counted in them too. Left out: pixels of the frame.
eye?recordIn a 3D game, {at: [x, y, z], turn: [x, y, z, w], fov?, near?, far?, ortho?}: a place the game is looked at from in place of its Camera, for this answer only: what an editor that looks around a paused game draws, picks and measures through. at is in the world; turn is a quaternion as a Transform's qx to qw, one long (made so within a hundredth, refused beyond), looking along its own -z with +y up; fov (degrees bottom to top, 1 to 179), near (0.0001 or more) and far (more than near, or 0 for none) are the game Camera's where left out. ortho, in place of fov, is a picture with no perspective (a Top, Front or Side view): how many world units it shows from its bottom to its top, more than 0; its far end, where far is 0 or the Camera's is, is 10000 past near, its view_projection has w 1 everywhere, and a hit's distance is then measured along the way the eye looks, from the plane it is in. The picture is width by height pixels, the command's own (1 to 4096 each, the frame's where left out), drawn at exactly that size, and fov and ortho are held from bottom to top whatever its shape, so a wider picture shows more to the sides. The answer's view_projection is this eye's and that shape's, and frame.at and frame.in ask the picture it shows. What the layers draw (a HUD) is the game's own view and is left out: not drawn, and no hit. Nothing is written or kept: the world, its checksum, the input and the next answer without an eye are as they were. E0449 in a 2D game, whose view is a rectangle.
pose?recordIn a 3D game, {entity, clip, time?}: one thing (by name or id, with a Mesh whose model has clips) drawn time seconds (0 or more; left out 0) into one of its model's clips, for this answer alone, in place of what its Pose says: what an editor scrubbing a clip on a thing in the game shows. Nothing is written: the world, its checksum, its Pose and what the recording replays are as they were, and the next answer without it draws the Pose again. A clip that goes round is drawn round, one that does not holds its end, as a Pose plays it. Picking (frame.at, frame.in) meets things by their box at rest, with or without it. Refused (BadParams) for a thing with no Mesh, a model with no clips, or a clip its model has not, naming its clips.
width?integerWith eye: the width in pixels of the picture it is asked about, 1 to 4096, as a frame.capture with the same eye, width and height draws it: the pixels counted, the boxes and view_projection are that picture's. Left out: the frame's. Without eye it is refused: the game's own picture is the frame's size.
height?integerWith eye: the picture's height in pixels, 1 to 4096. Left out: the frame's.
ResultTypeMeaning
stepintegerHow many fixed steps have run.
xintegerThe column asked.
yintegerThe row asked.
hits[record]One {entity, name, kind, tile, node, layer, alpha, coverage, added, fills, box, turned, pass, material} per entity that draws at the pixel, the one in front first; none where only the background shows. kind is the component it draws there with: "Rect", "Sprite", "Text", "Tilemap" or "Shape"; an entity that draws with two is there twice. A sprite counts only where its picture is not clear, a text where a letter has ink. tile is null, or for a Tilemap {column, row} of the tile there: column 0 is the left one and row 0 the first line of rows. node is true for an interface node (an entity with a Node; ui.tree says what it is). layer is the layer it is drawn in. alpha is how much it covers of what is behind it at the pixel, 1 to 255: its colour, its Opacity and its picture there; nothing that covers 0 is listed. coverage is its picture's own alpha at the pixel, 1 to 255, and 255 for what draws with no picture: a client that wants to pass through nearly clear pixels compares this. added is true when it is added to what is behind and hides nothing. fills is the share of the frame, 0 to 1, that the box around everything the entity draws with that component covers: a backdrop is near 1. box is that box, {x, y, w, h} in the frame's pixels with x and y its top-left corner, counted as the pixel asked is: it stands upright around a thing that is turned, is not cut at the frame's edges (x and y may be below 0), need not be whole numbers, and for a Tilemap is around the tiles that touch the frame. turned is for a thing that is turned (a Rotation): {x, y, w, h, angle}, the box around the same, measured along its own sides as it would stand unturned about its own middle and counted as box is, and the turn about that middle in degrees, anticlockwise as the picture shows it, above -180 and up to 180, to three places. Turned so, it is where the thing is drawn, its Scale and Pivot in it: an editor draws it as the thing's outline. turned is null for what is not turned (a whole turn is none), for a Text and a Tilemap, and where what the entity draws with that component is not all turned alike: then box is its outline. pass is the frame graph's pass that draws its layer (render.passes lists them), null when none does; material is what it is drawn with: "sprite", the built-in material every quad has. In a 3D game the things themselves come after what the layers draw over the meshes, the nearest first: each thing the ray through the pixel's middle meets between the camera's near plane and its far one, by its Collider as physics.read gives it (kind "Collider"), else by the box around its Mesh's model where its parents put it (kind "Mesh"); a thing with neither is not met, nor one the ray starts inside. Such a hit has projected true, point, [x, y, z] where the ray meets it in the world, and distance, from the camera to there; its box is around what frame.view's view_projection makes of the box about it, cut at the near plane and the far one only, so a thing that passes the camera has a very large one; layer is 0, alpha and coverage 255, tile and turned null, pass the meshes' pass for a thing with a Mesh and else null, material its Mesh's or null; box, fills, point and distance are to three places. It also has part: for kind "Mesh", {index, mesh, primitive, material, point, distance}, the first triangle of the model the same ray meets, whichever way it faces, as the model stands in its file (nothing moves its corners): index the part among the model's parts as they are drawn (its primitives of one material are one part), mesh the name of the mesh the triangle came from (its node's name in the glTF file, else its mesh's, else "mesh N"), primitive that primitive's place in the mesh, material its material's name in the file ("material N" where the file names none, null for a primitive with no material), point and distance where the triangle is met, at or behind where the box is; null when the ray is in the box and meets no triangle, so nothing of the model is drawn at the pixel, and null for kind "Collider".
drawnrecordIn a 3D game, what is drawn at the pixel: of every thing with a Mesh, the triangle the ray through the pixel's middle meets first past the near plane, as the thing is drawn (its matrix, its pose's shapes), whatever colliders the game has: {entity, name, part (its place among the model's parts as drawn), mesh and primitive (of its file), triangle (its place among the primitive's), material (its name, or null), masked (its material cuts out under an alpha, which is not looked at), lod (the level of detail drawn at the pixel: 0 the model's own file, 1 or 2 its .lod1/.lod2 beside it; in a band where two are drawn, the one whose screen door keeps this pixel), point, distance}. The device decides a pixel on a triangle's very edge. And how it is lit, as the lit pass works it out (frost_gfx::lit, the pass's twin, held to the device's pixel within one level): light, one {name, kind, share, why} for every light of the game (ambient, sky, sun, point, spot; reflection for the sky mirrored by metal; glow for the surface's own and inherited emission; fog, an independent Fog without Sky, or haze, the Sky's, when it fades the point into its horizon: its share is how far, the lights' theirs of what it leaves), share its part of the pixel's brightness before it is cut to 1 (they sum to 1), why the frame's words ("in shadow" from the sun's shadow map read where the pass reads it, "faces away", "out of its reach", how far, "outside its cone", "not drawn" for a point or spot light not among the sixteen the picture chose); color, the pixel the twin works out [r, g, b]; Material roughness, metal, inherited tint and emission follow the shader. With transparency, color is the premultiplied sRGB surface contribution, cover is its coverage, and light shares describe only that surface; the destination behind it remains unread. unread names the missing calculations and texture samples (white or a flat normal is used for a missing sample), so color and shares are partial while unread is nonempty. Null where no mesh is drawn; a 2D game's answer has none.

Generated from Coldwave 0.0.1 r289, 2026-11-30 by the binary itself: do not edit by hand.