WebGLRenderer Class
The WebGLRenderer class renders the Scene using a WebGL canvas context and a camera
Constructor
WebGLRenderer
-
parameters
Parameters:
-
parameters
ObjectParameters 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
-
Item Index
Methods
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
Renders a single object
Parameters:
-
array
Array -
i
NumberIndex 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
Renders a single texture object
Parameters:
-
array
Array -
i
NumberIndex in the given array
resize
-
width
-
height
Resizes the canvas element and the WebGL viewport
Parameters:
-
width
NumberResize width
-
height
NumberResize height
setClearColour
-
r
-
g
-
b
-
a
Sets the clear colour of the canvas
Parameters:
-
r
NumberRed
-
g
NumberGreen
-
b
NumberBlue
-
a
NumberAlpha
setMatrixUniforms
-
shaderProgram
Sets projection and model view matrix uniforms
Parameters:
-
shaderProgram
Object
translate
-
x
-
y
-
rotation
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()