API

Function createSurface

  • Create an auxiliary rendering surface bound to an existing engine. The surface configures its own GPUCanvasContext against engine._device and is appended to engine.surfaces. GPU resources (textures, buffers, pipelines) are shared across all surfaces of the same engine because they're device-scoped — render to multiple canvases by creating additional surfaces and binding scenes / renderers to each.

    The engine's own primary surface (engine.surfaces[0] === engine) is created automatically by createEngine(canvas); use createSurface only for additional canvases beyond that one.

    Accepts either a DOM canvas (main thread) or an OffscreenCanvas (e.g. transferred to a Web Worker via transferControlToOffscreen()).

    Parameters

    Returns SurfaceContext