Class Renderer

Creates a renderer object to use for drawing to a WebGL2 canvas

Hierarchy

  • Renderer

Constructors

  • Creates a WebGL context for the given canvas element

    Parameters

    • enableStencilBuffer: boolean = false

      Whether to enable the stencil buffer for the WebGL context

    Returns Renderer

Properties

background: Color

The background color of the viewport

gfxCanvas: HTMLCanvasElement

The canvas element that the renderer draws to

gl: WebGL2RenderingContext

The WebGL2 context used by the renderer

viewport: Viewport

The viewport of the renderer

Methods

  • Gets the normalized device coordinates from the provided mouse coordinates.

    Returns

    The normalized device coordinates.

    Parameters

    • mouseX: number

      The x coordinate of the mouse.

    • mouseY: number

      The y coordinate of the mouse.

    Returns Vector2

  • Resizes the graphics canvas and adjusts the viewport to maintain the provided aspect ratio.

    Parameters

    • width: number

      The width of the graphics canvas in pixels.

    • height: number

      The height of the graphics canvas in pixels.

    • aspectRatio: number

      The aspect ratio of the graphics canvas.

    Returns void

Generated using TypeDoc