new Renderer(canvas, options)
The renderer is resposible for drawing the structure into the canvas element.
Its also resposible for managing the canvas state.
Parameters:
Name | Type | Description |
---|---|---|
canvas |
DOM | Canvas to render the content. |
options |
Object | Renderer canvas options. |
- Source:
Members
autoClear
Indicates if the canvas should be automatically cleared on each new frame.
- Source:
canvas
Canvas DOM element, has to be managed by the user.
- Source:
context
Canvas 2D rendering context used to draw content.
- Source:
pointer
Pointer input handler object.
- Source:
Methods
createRenderLoop(group, viewport, onUpdate)
Creates a infinite render loop to render the group into a viewport each frame.
The render loop cannot be destroyed, and it automatically creates a viewport controls object.
Parameters:
Name | Type | Description |
---|---|---|
group |
Object2D | Group to be rendererd. |
viewport |
Viewport | Viewport into the objects. |
onUpdate |
function | Function called before rendering the frame. |
- Source:
update(object, viewport)
Update the renderer state, update the input handlers, calculate the object and viewport transformation matrices.
Render the object using the viewport into a canvas element.
The canvas state is saved and restored for each individual object, ensuring that the code of one object does not affect another one.
Should be called at a fixed rate preferably using the requestAnimationFrame() method, its also possible to use the createRenderLoop() method, that automatically creates a infinite render loop.
Parameters:
Name | Type | Description |
---|---|---|
object |
Object2D | Object to be updated and drawn into the canvas, the Object2D should be used as a group to store all the other objects to be updated and drawn. |
viewport |
Viewport | Viewport to be updated (should be the one where the objects will be rendered after). |
- Source: