/** * 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 = {}; } if (apiControls instanceof GameLib.Controls) { return apiControls; } GameLib.API.Controls.call( this, apiControls.id, apiControls.controlsType, apiControls.name, apiControls.domElement, apiControls.parentEntity ); var linkedObjects = { domElement : GameLib.DomElement }; var delayed = false; if (this.controlsType === GameLib.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.API.Controls.prototype); GameLib.Controls.prototype.constructor = GameLib.Controls; GameLib.Controls.D3 = function() {}; /** * Controls Type * @type {number} */ GameLib.Controls.CONTROLS_TYPE_EDITOR = 0x0; GameLib.Controls.CONTROLS_TYPE_TOUCH = 0x1; GameLib.Controls.CONTROLS_TYPE_KEYBOARD = 0x2; GameLib.Controls.CONTROLS_TYPE_MOUSE = 0x3; /** * 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.controlsType, this.name, 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 ); };