Renderer

Renderer

The Renderer is the component which must draw the game on the client. It will be instantiated once on each client, and must implement the draw method. The draw method will be invoked on every iteration of the browser's render loop.

Constructor

new Renderer(gameEngine, clientEngine)

Constructor of the Renderer singleton.

Parameters:
Name Type Description
gameEngine GameEngine

Reference to the GameEngine instance.

clientEngine ClientEngine

Reference to the ClientEngine instance.

Source:

Methods

addObject(obj)

Handle the addition of a new object to the world.

Parameters:
Name Type Description
obj Object

The object to be added.

Source:

draw(t, dt)

The main draw function. This method is called at high frequency, at the rate of the render loop. Typically this is 60Hz, in WebVR 90Hz. If the client engine has been configured to render-schedule, then this method must call the clientEngine's step method.

Parameters:
Name Type Description
t Number

current time (only required in render-schedule mode)

dt Number

time elapsed since last draw

Source:

init() → {Promise}

Initialize the renderer.

Source:
Returns:

Resolves when renderer is ready.

Type
Promise

removeObject(obj)

Handle the removal of an old object from the world.

Parameters:
Name Type Description
obj Object

The object to be removed.

Source:

runClientStep(t, dt)

The main draw function. This method is called at high frequency, at the rate of the render loop. Typically this is 60Hz, in WebVR 90Hz.

Parameters:
Name Type Description
t Number

current time

dt Number

time elapsed since last draw

Source:

stop()

Called when clientEngine has stopped, time to clean up

Source: