/** * GameLib.D3.Camera.Stereo * @param graphics GameLib.GraphicsRuntime * @param apiStereoCamera * @constructor */ GameLib.D3.Camera.Stereo = function( graphics, apiStereoCamera ) { this.graphics = graphics; this.graphics.isNotThreeThrow(); if (GameLib.Utils.UndefinedOrNull(apiStereoCamera)) { apiStereoCamera = { cameraType : GameLib.D3.API.Camera.CAMERA_TYPE_STEREO }; } GameLib.D3.API.Camera.Stereo.call( this, apiStereoCamera, apiStereoCamera.stereoMode ); GameLib.D3.Camera.call( this, this.graphics, this ); }; GameLib.D3.Camera.Stereo.prototype = Object.create(GameLib.D3.Camera.prototype); GameLib.D3.Camera.Stereo.prototype.constructor = GameLib.D3.Camera.Stereo; /** * Creates a camera instance * @returns {*} */ GameLib.D3.Camera.Stereo.prototype.createInstance = function() { this.instance = new THREE.PerspectiveCamera(); var instance = new THREE.StereoCamera(); for (var property in instance) { if ( instance.hasOwnProperty(property) || typeof instance[property] === 'function' ) { this.instance[property] = instance[property]; } } GameLib.D3.Camera.prototype.createInstance.call(this); }; /** * Updates the instance with the current state */ GameLib.D3.Camera.Stereo.prototype.updateInstance = function(property) { if (property === 'stereoMode') { console.warn('todo: update stereo mode'); return; } GameLib.D3.Camera.prototype.updateInstance.call(this, property); }; /** * Converts a GameLib.D3.Camera to a GameLib.D3.API.Camera * @returns {GameLib.D3.API.Camera} */ GameLib.D3.Camera.Stereo.prototype.toApiObject = function() { var apiCamera = GameLib.D3.Camera.prototype.toApiObject.call(this); var apiStereoCamera = new GameLib.D3.API.Camera.Stereo( apiCamera, this.stereoMode ); return apiStereoCamera; };