Two.WebGLRenderer

Extends: Two.Events

This class is used by Two when constructing with type of Two.Types.webgl. It takes Two.js' scenegraph and renders it to a <canvas /> through the WebGL api.

Constructor

ArgumentDescription
parametersThis object is inherited when constructing a new instance of Two.
parameters.domElementThe <canvas /> to draw to. If none given a new one will be constructed.
parameters.offscreenElementThe offscreen two dimensional <canvas /> to render each element on WebGL texture updates.
parameters.antialiasDetermines whether the canvas should clear render with antialias on.

Utils

A massive object filled with utility functions and properties to render Two.js objects to a <canvas /> through the WebGL API.

domElement

The <canvas /> associated with the Two.js scene.

scene

The root group of the scenegraph.

overdraw

Determines whether the canvas clears the background each draw call.

ctx

Associated two dimensional context to render on the <canvas />.

programs

Associated WebGL programs to render all elements from the scenegraph.

setSize

Triggers:

  • event:resize
ArgumentDescription
widthThe new width of the renderer.
heightThe new height of the renderer.
ratioThe new pixel ratio (pixel density) of the renderer. Defaults to calculate the pixel density of the user's screen.

Change the size of the renderer.

render

Render the current scene to the <canvas />.