2017-01-10 17:04:30 +01:00
|
|
|
/**
|
|
|
|
* Renders a scene with a camera
|
|
|
|
* @param graphics GameLib.D3.Graphics
|
|
|
|
* @param apiComposer GameLib.D3.API.Composer
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.Composer = function (
|
|
|
|
graphics,
|
|
|
|
apiComposer
|
|
|
|
) {
|
|
|
|
|
|
|
|
this.graphics = graphics;
|
|
|
|
this.graphics.isNotThreeThrow();
|
|
|
|
|
2017-01-12 17:40:17 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(apiComposer)) {
|
2017-05-11 04:48:02 +02:00
|
|
|
apiComposer = {};
|
2017-01-12 17:40:17 +01:00
|
|
|
}
|
|
|
|
|
2017-05-11 04:48:02 +02:00
|
|
|
if (apiComposer instanceof GameLib.D3.Composer) {
|
|
|
|
return apiComposer;
|
|
|
|
}
|
|
|
|
|
2017-01-10 17:04:30 +01:00
|
|
|
GameLib.D3.API.Composer.call(
|
|
|
|
this,
|
|
|
|
apiComposer.id,
|
|
|
|
apiComposer.name,
|
|
|
|
apiComposer.renderer,
|
|
|
|
apiComposer.renderTarget,
|
|
|
|
apiComposer.passes,
|
|
|
|
apiComposer.parentEntity
|
|
|
|
);
|
|
|
|
|
2017-06-16 15:49:53 +02:00
|
|
|
GameLib.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.COMPONENT_COMPOSER,
|
|
|
|
{
|
|
|
|
'renderer' : GameLib.D3.Renderer,
|
|
|
|
'renderTarget' : GameLib.D3.RenderTarget,
|
|
|
|
'passes' : [GameLib.D3.Pass]
|
|
|
|
}
|
2017-02-21 18:55:18 +01:00
|
|
|
);
|
2017-01-10 17:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.Composer.prototype = Object.create(GameLib.D3.API.Composer.prototype);
|
|
|
|
GameLib.D3.Composer.prototype.constructor = GameLib.D3.Composer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a Composer instance
|
|
|
|
* @returns {*}
|
|
|
|
*/
|
2017-10-23 14:52:35 +02:00
|
|
|
GameLib.D3.Composer.prototype.createInstance = function() {
|
2017-01-19 17:50:11 +01:00
|
|
|
|
2017-06-16 15:49:53 +02:00
|
|
|
//TODO : Fix this too - make it nice (no circular references)
|
|
|
|
// var instance = null;
|
|
|
|
//
|
|
|
|
// if (update) {
|
|
|
|
// instance = this.instance;
|
|
|
|
// }
|
|
|
|
|
|
|
|
//TODO : Fix this still (renderer and renderTarget should be objects)
|
|
|
|
// if (this.renderer &&
|
|
|
|
// this.renderTarget) {
|
|
|
|
//
|
|
|
|
// if (!THREE.EffectComposer) {
|
|
|
|
// console.warn('No THREE.EffectComposer');
|
|
|
|
// throw new Error('No THREE.EffectComposer');
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// instance = new THREE.EffectComposer(
|
|
|
|
// this.renderer.instance,
|
|
|
|
// this.renderTarget.instance
|
|
|
|
// );
|
|
|
|
//
|
|
|
|
// this.passes.map(
|
|
|
|
// function(pass) {
|
|
|
|
// this.instance.addPass(pass.instance);
|
|
|
|
// }.bind(this)
|
|
|
|
// );
|
|
|
|
// }
|
2017-10-23 14:52:35 +02:00
|
|
|
console.log('GameLib.D3.Composer.prototype.createInstance() - fix me');
|
|
|
|
|
|
|
|
GameLib.Component.prototype.createInstance.call(this);
|
2017-01-10 17:04:30 +01:00
|
|
|
|
2017-10-23 14:52:35 +02:00
|
|
|
//return instance;
|
2017-01-10 17:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates Composer instance
|
|
|
|
*/
|
|
|
|
GameLib.D3.Composer.prototype.updateInstance = function() {
|
2017-10-23 14:52:35 +02:00
|
|
|
console.log('GameLib.D3.Composer.prototype.updateInstance() - fix me');
|
2017-01-10 17:04:30 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GameLib.D3.Composer to GameLib.D3.API.Composer
|
|
|
|
* @returns {GameLib.D3.API.Composer}
|
|
|
|
*/
|
2017-05-16 14:51:57 +02:00
|
|
|
GameLib.D3.Composer.prototype.toApiObject = function() {
|
2017-01-10 17:04:30 +01:00
|
|
|
|
|
|
|
var apiComposer = new GameLib.D3.API.Composer(
|
|
|
|
this.id,
|
|
|
|
this.name,
|
|
|
|
GameLib.Utils.IdOrNull(this.renderer),
|
|
|
|
GameLib.Utils.IdOrNull(this.renderTarget),
|
|
|
|
this.passes.map(
|
|
|
|
function(pass) {
|
|
|
|
return GameLib.Utils.IdOrNull(pass);
|
|
|
|
}
|
|
|
|
),
|
|
|
|
GameLib.Utils.IdOrNull(this.parentEntity)
|
|
|
|
);
|
|
|
|
|
|
|
|
return apiComposer;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param graphics
|
|
|
|
* @param objectComponent
|
|
|
|
* @returns {GameLib.D3.Composer}
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.Composer.FromObject = function(graphics, objectComponent) {
|
2017-01-10 17:04:30 +01:00
|
|
|
|
2017-06-14 14:21:57 +02:00
|
|
|
var apiComposer = GameLib.D3.API.Composer.FromObject(objectComponent);
|
2017-01-10 17:04:30 +01:00
|
|
|
|
|
|
|
return new GameLib.D3.Composer(
|
|
|
|
graphics,
|
|
|
|
apiComposer
|
|
|
|
);
|
|
|
|
};
|