Used as a global class to create a GPUCurtainsRenderer, create all objects that need a reference to a renderer, listen to various events such as scroll and resize and render.

Example

// set our main GPUCurtains instance
const gpuCurtains = new GPUCurtains({
container: '#canvas' // selector of our WebGPU canvas container
})

// set the GPU device
// note this is asynchronous
await gpuCurtains.setDevice()

Constructors

Properties

type: string

The type of this GPUCurtains

Options used to create this GPUCurtains

container: HTMLElement

HTMLElement that will hold the WebGPU HTMLCanvasElement

deviceManager: GPUDeviceManager

GPUDeviceManager used to handle the GPUAdapter and GPUDevice

scrollManager: ScrollManager

Tiny scroll event listener wrapper

animationFrameID: number

Request animation frame callback returned id if used

_onRenderCallback: (() => void) = ...

function assigned to the onRender callback

Type declaration

    • (): void
    • function assigned to the onRender callback

      Returns void

_onScrollCallback: (() => void) = ...

function assigned to the onScroll callback

Type declaration

    • (): void
    • function assigned to the onScroll callback

      Returns void

_onErrorCallback: (() => void) = ...

function assigned to the onError callback

Type declaration

    • (): void
    • function assigned to the onError callback

      Returns void

_onContextLostCallback: ((info?) => void) = ...

function assigned to the onContextLost callback

Type declaration

    • (info?): void
    • function assigned to the onContextLost callback

      Parameters

      • Optional info: GPUDeviceLostInfo

      Returns void

_onContextDestroyedCallback: ((info?) => void) = ...

function assigned to the onContextLost callback

Type declaration

    • (info?): void
    • function assigned to the onContextLost callback

      Parameters

      • Optional info: GPUDeviceLostInfo

      Returns void

Accessors

Methods

  • Set the container

    Parameters

    • container: string | Element

      HTMLElement or string representing an HTMLElement selector to use

    Returns void