API Docs for: 0.2.0
Show:

WebGLRenderer Class

Module: LE

The WebGLRenderer class renders the Scene using a WebGL canvas context and a camera

Constructor

WebGLRenderer

(
  • parameters
)

Parameters:

  • parameters Object

    Parameters is an object that contains the WebGLRenderers properties

    • canvas DOMElement
    • [scene=new LE.Scene()] LE.Scene optional
    • [camera=new LE.OrthographicCamera(0, 0)] LE.OrthographicCamera optional

Methods

clear

()

Clears the canvas element

initGL

() private

Initialises the WebGL context

initShaders

() private

Initialises the shaders

prepareGL

() private

Prepares WebGL for rendering

render

()

Renders the objects and lights in the scene to the canvas element

renderLightsAndShadows

()

Renders the lights and shadows in the scene to the canvas element. This should not be called if the render function is being called. This is simply here so each part of the scene can be rendered separately if needed

renderObject

(
  • array
  • i
)
private

Renders a single object

Parameters:

  • array Array
  • i Number

    Index in the given array

renderObjects

()

Renders the objects in the scene to the canvas element. This should not be called if the render function is being called. This is simply here so each part of the scene can be rendered separately if needed

renderShadowObjects

()

Renders the shadow objects in the scene to the canvas element. This should not be called if the render function is being called. This is simply here so each part of the scene can be rendered separately if needed

renderTextureObject

(
  • array
  • i
)
private

Renders a single texture object

Parameters:

  • array Array
  • i Number

    Index in the given array

resize

(
  • width
  • height
)

Resizes the canvas element and the WebGL viewport

Parameters:

  • width Number

    Resize width

  • height Number

    Resize height

setClearColour

(
  • r
  • g
  • b
  • a
)

Sets the clear colour of the canvas

Parameters:

  • r Number

    Red

  • g Number

    Green

  • b Number

    Blue

  • a Number

    Alpha

setMatrixUniforms

(
  • shaderProgram
)
private

Sets projection and model view matrix uniforms

Parameters:

  • shaderProgram Object

translate

(
  • x
  • y
  • rotation
)
private

Wraps on top of the camera translation function

Parameters:

  • x Number
  • y Number
  • rotation Number

Properties

camera

Camera

Stores the Camera. This is interchangeable with any Camera during runtime

Default: new LE.OrthographicCamera(0, 0)

canvas

Object private

Stores the canvas element

gl

Object private

Stores the WebGL canvas context

scene

Scene

Stores the Scene. This is interchangeable with any Scene during runtime

Default: new LE.Scene()

shaders

Shaders private

Stores the shaders

Default: new LE.Shaders()