Webgl

Webgl

new Webgl(paramsopt)

Constructs a new WebglRenderer
Parameters
Name Type Attributes Default Description
params object <optional>
{} context type
Properties
Name Type Attributes Default Description
type string <optional>
webgl context type
canvas object <optional>
null canvas to attach the renderer
width number <optional>
window.innerWidth width of the renderer
height number <optional>
window.innerHeight height of the renderer
contextOptions object <optional>
{} options to pass to the webgl context
fallback function <optional>
null function called when webgl is not possible

Methods

append(containeropt)

Append the renderer into an htmlElement
Parameters
Name Type Attributes Default Description
container object <optional>
document.body html element to add the canvas

attr(mesh)

Add all the attributes of a mesh
Parameters
Name Type Description
mesh object instance of a Mesh

bindBuffer(mesh)

Bind all the buffer of a mesh
Parameters
Name Type Description
mesh object instance of a Mesh

clear()

Clear the color buffer & depth buffer

clearColor(r, v, b, a)

Set clearColor of the renderer
Parameters
Name Type Description
r number red channel
v number green channel
b number blue channel
a number alpha channel

render(mesh, camera)

Render to the canvas
Parameters
Name Type Description
mesh object | array instance of a Mesh or array of Mesh
camera object instance of a Camera

resize()

Resize the canvas

setDefaultUniforms(mesh, camera)

Set default uniforms to a mesh
Parameters
Name Type Description
mesh object instance of a Mesh
camera object instance of a Camera

setUniforms(mesh)

Set all the uniforms of a mesh
Parameters
Name Type Description
mesh object instance of a Mesh

unbindBuffer(mesh)

Unbind all the buffer of a mesh
Parameters
Name Type Description
mesh object instance of a Mesh

useProgram(program)

Set the current program
Parameters
Name Type Description
program object instance of a Shader