2018-01-29 12:42:46 +01:00
|
|
|
/**
|
|
|
|
* 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,
|
2018-02-05 22:35:58 +01:00
|
|
|
apiStereoCamera.stereoMode
|
2018-01-29 12:42:46 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
GameLib.D3.Camera.call(
|
|
|
|
this,
|
|
|
|
this.graphics,
|
2018-01-30 15:02:47 +01:00
|
|
|
this
|
2018-01-29 12:42:46 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
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() {
|
|
|
|
|
2018-02-05 22:35:58 +01:00
|
|
|
this.instance = new THREE.PerspectiveCamera();
|
2018-01-30 15:02:47 +01:00
|
|
|
|
|
|
|
var instance = new THREE.StereoCamera();
|
|
|
|
|
|
|
|
for (var property in instance) {
|
2018-02-05 22:35:58 +01:00
|
|
|
if (
|
|
|
|
instance.hasOwnProperty(property) ||
|
|
|
|
typeof instance[property] === 'function'
|
|
|
|
) {
|
|
|
|
this.instance[property] = instance[property];
|
|
|
|
}
|
2018-01-30 15:02:47 +01:00
|
|
|
}
|
2018-01-29 12:42:46 +01:00
|
|
|
|
|
|
|
GameLib.D3.Camera.prototype.createInstance.call(this);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the instance with the current state
|
|
|
|
*/
|
|
|
|
GameLib.D3.Camera.Stereo.prototype.updateInstance = function(property) {
|
|
|
|
|
2018-01-30 15:02:47 +01:00
|
|
|
if (property === 'stereoMode') {
|
2018-02-05 22:35:58 +01:00
|
|
|
console.warn('todo: update stereo mode');
|
2018-01-30 15:02:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-29 12:42:46 +01:00
|
|
|
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,
|
2018-02-05 22:35:58 +01:00
|
|
|
this.stereoMode
|
2018-01-29 12:42:46 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return apiStereoCamera;
|
|
|
|
};
|