Use attachRenderer rather than the constructor

This makes the renderer optional as well as making the order of instantiation flexible.
This commit is contained in:
Ray Schamp 2016-09-20 15:07:05 -04:00
parent fa10a2279a
commit 4e547556a8
3 changed files with 27 additions and 17 deletions
src/engine

View file

@ -19,20 +19,13 @@ var defaultBlockPackages = {
/**
* Manages targets, scripts, and the sequencer.
* @param {!RenderWebGL} renderer Renderer for the VM
*/
function Runtime (renderer) {
function Runtime () {
// Bind event emitter
EventEmitter.call(this);
// State for the runtime
/**
* Renderer
* @type {!RenderWebGL}
*/
this.renderer = renderer;
/**
* Target management and storage.
* @type {Array.<!Target>}
@ -206,6 +199,14 @@ Runtime.prototype.clearEdgeActivatedValues = function () {
this._edgeActivatedHatValues = {};
};
/**
* Attach the renderer
* @param {!RenderWebGL} renderer The renderer to attach
*/
Runtime.prototype.attachRenderer = function (renderer) {
this.renderer = renderer;
};
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------