Documentation
    Preparing search index...

    Interface RendererOptions

    Construction-time options for Renderer.initialize (§61, §45).

    §45's ApplicationOptions is the full menu — width, height, resolution, alpha, powerPreference, autoResize — and each of those lands with the backend that can act on it. This interface carries only what the MVP tier reads; a backend that needs more declares its own options type extending this one.

    interface RendererOptions {
        antialias?: boolean;
        canvas?: unknown;
        stencil?: boolean;
    }

    Hierarchy (View Summary)

    Index
    antialias?: boolean

    Request multisampled anti-aliasing (§45). A hint: a backend that cannot honour it reports so through RendererCapabilities, and never fails initialization over it.

    canvas?: unknown

    The surface to draw into.

    Deliberately typed unknown, not HTMLCanvasElement | OffscreenCanvas (decision, WP-3.4). This package compiles with no DOM lib: @fourjs/render is the backend-independent layer and must be usable — and type-checkable — in Node, in a worker, and in a headless test, where those DOM types do not exist. Naming them here would drag lib.dom into every consumer of the logical renderer interface, which is the dependency §61 forbids in spirit.

    Each backend narrows it at the point where it can actually validate it: the WebGL 2 backend (WP-3.5) accepts a canvas and fails with RENDERER_INITIALIZATION_FAILED (§89) if what it got is not one. The type is therefore unknown rather than any on purpose — an implementation must narrow before touching it, so the check cannot be skipped by accident.

    Absent means the backend supplies or needs no surface, which is the headless case.

    stencil?: boolean

    Request a stencil buffer on the drawing surface (§67, R-7); false by default.

    §57's Material.stencil describes a stencil test; this is the buffer that test reads and writes. The two are separate because they are separately costly: a material's stencil state costs nothing until a draw uses it, while the buffer is memory the surface carries for its lifetime and a clear every view issues — so a renderer asks for it once, up front, and a scene that never masks never pays.

    A hint in §45's sense, like RendererOptions.antialias: a backend that cannot provide one still initializes and still draws, with masking materials drawing unmasked rather than not at all (§61 forbids failing a frame over render state).

    Masking into an off-screen surface asks the render target instead — RenderTargetOptions.stencil — and leaves this false.