/** * 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.domElement, apiControls.parentEntity ); var linkedObjects = { domElement : GameLib.DomElement }; var delayed = false; if (this.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() { console.log('default controls update instance'); }; /** * 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.domElement), GameLib.Utils.IdOrNull(this.parentEntity) ); return apiControls; }; /** * Converts a data object to a GameLib.Controls * @param objectControls {Object} * @constructor */ GameLib.Controls.FromObject = function(objectControls) { var apiControls = GameLib.API.Controls.FromObject(objectControls); return new GameLib.Controls( apiControls ); };