Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Visamp Docs

Rendering context

Choose the coordinate system once per script:

context 3d
render {
  draw::cube(rotation_y_deg: $TIME_SEC * 20, color: $COLOR_CORAL)
}

context 2d is the default when the declaration is omitted. Both modes are implemented. A context declaration is top-level and can appear before or after properties/functions; convention puts it first. Declaring it twice is an error.

What changes

2D3D
CoordinatesPixels, origin top-left, +Y downWorld units, origin at world centre, +Y up
DrawingShapes, paths, text, imagesSolids, planar shapes, strokes, points, grids, models
Camera/lightsNot usedcamera:: and light::
Previous frameRetained unless clearedScene rebuilt each frame; use scramble for feedback
Text/imagesCanvas coordinatesFinal screen-space overlay
Full-frame effectsGPU post-processingSame GPU post-processing

Math, properties, arrays, functions, audio and input are shared. Some transform and blend calls work in both modes; others require 3D. Check the availability table before moving a 2D sketch into world space. In particular, text and image drawing need gfx::overlay(enabled: true) in a 3D script.

The host recreates the canvas when switching between 2D and 3D scripts, or when adding/removing GPU post-processing. You can change context in the editor; it is not a permanent choice for the whole browser session.

3D, scramble, filters and whole-frame effects require WebGL2. Plain 2D uses Canvas 2D. Backend selection is automatic—there is no backend declaration.

See 3D Mode for camera, lighting, geometry and point fields.