WebglRendererPlugin

View source

ExtendsPlugin

Provides the WebGL 2 rendering backend for an App.

Register this plugin to render mesh and material assets through the WebGL 2 context associated with the app’s main Window. The main window must provide a canvas with a WebGL 2 context; this plugin does not create a canvas.

The plugin includes a built-in 3D pipeline for BasicMaterial. Register another WebglMaterialPlugin for a different material type and matching shader pair. The built-in material configuration also requires Transform3DPlugin.

Register DefaultPlugin or the required dependencies before app startup. Dependencies are checked but are not installed automatically.

Examples

import { App } from '@wimaengine/app'
import { DefaultPlugin } from '@wimaengine/misc'
import { WebglRendererPlugin } from '@wimaengine/render-webgl'

new App()
  .registerPlugin(new DefaultPlugin())
  .registerPlugin(new WebglRendererPlugin())
  .run()

Constructor


constructor()

Methods


register(app: App): void

View source

Stages the renderer resources and built-in material configuration in an App.

The default world receives ProgramCache, MeshCache, UBOCache, ClearColor, AttributeMap, and WebglProgramCache. The attribute map starts with built-in MeshAttribute descriptors for position, normal, tangent, UV, UVB, and color data.

The built-in BasicMaterial configuration uses WebglMaterialPlugin with the bundled 3D shaders. Register another WebglMaterialPlugin when an app needs a different material and shader pair. Rendering uses the canvas for the main Window in Windows; the canvas must provide a WebGL 2 context.

Parameters

NameDescriptionDefault
app

The App to configure with this renderer.

—