Plugins

Plugin runtimes

Implement Astrofox shader, canvas worker, and Three.js plugins.

The runtime determines how a plugin renders and which manifest fields it uses.

Shader display#

A shader display writes a new layer from a fragment shader. It receives the stage size, deterministic time, audio level, and any requested FFT data.

Available GLSL inputs include:

Write the final color to gl_FragColor. Alpha is respected when Astrofox composites the display.

Shader effect#

A shader effect receives the composition rendered so far in inputTexture, plus time, delta, and volume. It does not receive FFT or time-domain data:

Map manifest properties to custom uniforms with the uniforms object. Valid types are float, int, vec2, vec3, vec4, and color.

Worker display#

A worker display default-exports a factory. It runs without a DOM inside a dedicated Web Worker and normally draws to an OffscreenCanvas.

Follow these rules:

  • Derive animation from frame.time and frame.delta, never wall-clock time.
  • Seed randomness from frame.seed, which is stable for the plugin instance.
  • Redraw the complete canvas every frame. Transferring the bitmap to the host clears the worker's backing canvas.
  • Release owned resources in dispose().
  • Keep frames responsive. A render that takes longer than about 3 seconds in preview, or 5 seconds during export, is stopped and the instance is marked unresponsive.

Three.js worker display#

Request Astrofox's copy of Three.js instead of downloading or bundling it:

The factory receives libraries.three and a shared, host-configured renderer. Create your own scene, camera, geometry, materials, and lights; use the borrowed renderer for output.

The renderer is shared. Do not dispose it or permanently change its clear color, color space, tone mapping, shadows, render target, scissor state, or other global settings. Reset any state you temporarily change before returning from render().

Host camera controls#

Set "camera": true on a Three.js worker display to add cameraAzimuth, cameraPolar, and cameraDistance properties and enable the stage's orbit-and-dolly camera tool.

The plugin still owns the actual camera and lighting. Astrofox only supplies the user interaction and persisted property values.

Worker plugins cannot access the network unless the manifest requests the network permission. Even with that permission, remote executable imports remain blocked; bundle the code your plugin executes.