Skip to content

DrawAPI

Defined in: render/draw.ts:98

begin(viewProjection, viewportWidth?, viewportHeight?): void

Defined in: render/draw.ts:105

Begins a new draw frame with the given view-projection matrix. Must be called before any draw commands.

Float32Array

number

Framebuffer width used by screen-sized 3D primitives

number

Framebuffer height used by screen-sized 3D primitives

void


circle(center, radius, color, filled?, segments?): void

Defined in: render/draw.ts:167

Draws a filled or outlined circle.

Vec2

Center position

number

Circle radius

Color

RGBA color

boolean

If true draws filled, if false draws outline (default: true)

number

Number of segments for approximation (default: 32)

void


circleOutline(center, radius, color, thickness?, segments?): void

Defined in: render/draw.ts:177

Draws a circle outline.

Vec2

Center position

number

Circle radius

Color

RGBA color

number

Line thickness in pixels (default: 1)

number

Number of segments for approximation (default: 32)

void


drawMesh(geometry, shader, transform): void

Defined in: render/draw.ts:242

Draws a custom mesh with a shader.

number

Geometry handle

number

Shader handle

Float32Array

Transform matrix (4x4, column-major)

void


drawMeshWithMaterial(geometry, material, transform?): void

Defined in: render/draw.ts:258

Draws a custom mesh with a material.

A material whose shader was compiled from a .esshader (Material.compileShader) draws through the reflected MaterialConstants path: its #pragma param values and render state come straight from the engine material store, the shader positions itself via the injected FrameConstants (and params), and transform is unused — this path runs on every backend. A raw-GLSL material (Material.createShader) uses the legacy loose-uniform stream with u_projection/u_model and transform (identity when omitted).

number

Geometry handle

number

Material handle

Float32Array<ArrayBufferLike>

Transform matrix (4x4, column-major) — legacy raw-GLSL path only

void


end(): void

Defined in: render/draw.ts:111

Ends the current draw frame and submits all commands. Must be called after all draw commands.

void


getDrawCallCount(): number

Defined in: render/draw.ts:213

Gets the number of draw calls in the current/last frame.

number


getPrimitiveCount(): number

Defined in: render/draw.ts:218

Gets the number of primitives drawn in the current/last frame.

number


line(from, to, color, thickness?): void

Defined in: render/draw.ts:120

Draws a line between two points.

Vec2

Start point

Vec2

End point

Color

RGBA color

number

Line thickness in pixels (default: 1)

void


line3D(from, to, color, thickness?): void

Defined in: render/draw.ts:129

Draws a line between two points in space.

The ribbon is widened across the view, so it reads as a line from wherever the camera is. Thickness is in WORLD units rather than pixels — a distant line thins out the way the geometry beside it does.

Vec3

Vec3

Color

number

void


line3DScreen(from, to, color, thickness?): void

Defined in: render/draw.ts:135

Draws a world-space line with a stable framebuffer-pixel thickness. The active draw frame must include its framebuffer dimensions.

Vec3

Vec3

Color

number

void


line3DScreenOffset(anchor, fromOffset, toOffset, color, thickness?): void

Defined in: render/draw.ts:138

Draws a framebuffer-sized line at one world anchor. Offsets are pixels, +Y up.

Vec3

Vec2

Vec2

Color

number

void


rect(position, size, color, filled?): void

Defined in: render/draw.ts:148

Draws a filled or outlined rectangle.

Vec2

Center position

Vec2

Width and height

Color

RGBA color

boolean

If true draws filled, if false draws outline (default: true)

void


rectOutline(position, size, color, thickness?): void

Defined in: render/draw.ts:157

Draws a rectangle outline.

Vec2

Center position

Vec2

Width and height

Color

RGBA color

number

Line thickness in pixels (default: 1)

void


setBlendMode(mode): void

Defined in: render/draw.ts:224

Sets the blend mode for subsequent draw operations.

BlendMode

The blend mode to use

void


setDepth(depth): void

Defined in: render/draw.ts:208

Sets the current depth for sorting within a layer.

number

Z depth value

void


setDepthTest(enabled): void

Defined in: render/draw.ts:230

Enables or disables depth testing.

boolean

True to enable depth testing

void


setLayer(layer): void

Defined in: render/draw.ts:202

Sets the current render layer.

number

Layer index (higher layers render on top)

void


texture(position, size, textureHandle, tint?): void

Defined in: render/draw.ts:186

Draws a textured quad.

Vec2

Center position

Vec2

Width and height

number

GPU texture handle

Color

Color tint (default: white)

void


textureRotated(position, size, rotation, textureHandle, tint?): void

Defined in: render/draw.ts:196

Draws a rotated textured quad.

Vec2

Center position

Vec2

Width and height

number

Rotation angle in radians

number

GPU texture handle

Color

Color tint (default: white)

void


withDepthState(state, draw): boolean

Defined in: render/draw.ts:234

Runs synchronous drawing with scoped depth state, restored even on throw. Returns false without drawing on older cores without scoped depth support.

boolean

boolean

() => void

boolean