/** * Controls Superset - The apiControls properties get moved into the Controls object itself, and then the instance is created * @param apiControls GameLib.API.Controls * @constructor */ GameLib.Controls = function ( apiControls ) { if (GameLib.Utils.UndefinedOrNull(apiControls)) { apiControls = {}; } GameLib.API.Controls.call( this, apiControls.id, apiControls.name, apiControls.controlsType, apiControls.canvas, apiControls.parentEntity ); var linkedObjects = { canvas : GameLib.Canvas }; var delayed = false; if (apiControls.controlsType === GameLib.API.Controls.CONTROLS_TYPE_EDITOR) { linkedObjects.raycaster = GameLib.D3.Raycaster; linkedObjects.camera = GameLib.D3.Camera; delayed = true; } GameLib.Component.call( this, linkedObjects, delayed ); }; GameLib.Controls.prototype = Object.create(GameLib.Component.prototype); GameLib.Controls.prototype.constructor = GameLib.Controls; GameLib.Controls.D3 = function() {}; /** * Creates a mesh instance or updates it */ GameLib.Controls.prototype.createInstance = function() { GameLib.Component.prototype.createInstance.call(this); }; /** * Updates the mesh instance */ GameLib.Controls.prototype.updateInstance = function(property) { if (property === 'canvas') { GameLib.Event.Emit( GameLib.Event.CANVAS_CHANGE, { component: this } ); } GameLib.Component.prototype.updateInstance.call(this, property); }; /** * Converts a GameLib.Controls to a GameLib.API.Controls * @returns {GameLib.API.Controls} */ GameLib.Controls.prototype.toApiObject = function() { var apiControls = new GameLib.API.Controls( this.id, this.name, this.controlsType, GameLib.Utils.IdOrNull(this.canvas), GameLib.Utils.IdOrNull(this.parentEntity) ); return apiControls; };