magic-pixels
    Preparing search index...

    Interface Renderer

    A renderer draws a scene. The interface sits above the GPU API: it deals in scenes, cameras, meshes, materials and textures, not in buffers or programs, so a WebGPU implementation can live next to the WebGL2 one.

    Scene objects are plain data. The renderer creates, caches and frees the GPU resources for them, and injects the built-in uniforms when a shader declares them: the matrices modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix and normalMatrix, and the lights of the frame (ambientLightColor, directionalLight*, pointLight*).

    interface Renderer {
        dispose(object?: BufferGeometry | Texture | Material): void;
        render(scene: Scene, camera: Camera): void;
        setClearColor(color: string | Color, alpha?: number): void;
        setPixelRatio(pixelRatio: number): void;
        setSize(width: number, height: number): void;
    }

    Implemented by

    Index
    • Free GPU resources. Without an argument, everything the renderer created is freed and the renderer is unusable afterwards. With a geometry, material or texture, only that object's resources are freed; they are recreated on the next render if still in use.

      Parameters

      Returns void

    • Color the frame is cleared to before drawing (default black)

      Parameters

      • color: string | Color
      • Optionalalpha: number

      Returns void

    • Device pixel ratio applied by setSize (default 1)

      Parameters

      • pixelRatio: number

      Returns void

    • Resize the drawing surface in CSS pixels; pixelRatio is applied

      Parameters

      • width: number
      • height: number

      Returns void