Skip to content

GLCanvas<U>

ts
type GLCanvas<U> = Disposable & {
  gl: WebGL2RenderingContext;
  render: (options?: RenderOptions<UniformContext>) => void;
  onCanvasReady: (callback: () => void) => void;
  canvas: HTMLCanvasElement | OffscreenCanvas;
  setSize: (size: { width: number; height: number }) => void;
  play: () => void;
  pause: () => void;
  dpr: number;
  uniforms: U;
  onUpdated: (callback: UpdatedCallback<U>) => void;
  onBeforeRender: (callback: () => void) => void;
  onAfterRender: (callback: () => void) => void;
  resizeObserver: ReturnType<typeof onResize> | null;
};

The object returned by glCanvas.

Type Declaration

NameTypeDescription
glWebGL2RenderingContextThe WebGL2 rendering context.
render()(options?: RenderOptions<UniformContext>) => voidExecutes one render of the complete pipeline.
onCanvasReady()(callback: () => void) => voidRegisters a callback called after the first canvas resize.
canvasHTMLCanvasElement | OffscreenCanvasThe HTML canvas or OffscreenCanvas being rendered into.
setSize()(size: { width: number; height: number; }) => voidResizes the canvas and every managed render target.
play()() => voidStarts the internal animation clock.
pause()() => voidPauses the internal animation clock.
dprnumberThe device pixel ratio used for CSS-sized canvas resizing.
uniformsUReactive proxy containing the main pass's original uniform sources.
onUpdated()(callback: UpdatedCallback<U>) => voidRegisters a callback whenever a main-pass uniform source changes.
onBeforeRender()(callback: () => void) => voidRegisters a callback before the complete pipeline renders.
onAfterRender()(callback: () => void) => voidRegisters a callback after the complete pipeline renders.
resizeObserver| ReturnType<typeof onResize> | nullThe resize observer, or null when sizing is manual or fixed.

Type Parameters

U

U extends UniformSources<UniformContext> = UniformSources<UniformContext>

Released under the MIT License.