/** * This component renders a scene * @param id String * @param name String * @param passType * @param camera * @param scene * @param renderToScreen * @param parentEntity * @constructor */ GameLib.D3.API.Pass = function ( id, name, passType, camera, scene, renderToScreen, parentEntity ) { GameLib.Component.call( this, GameLib.Component.COMPONENT_PASS, { 'camera' : GameLib.D3.Camera, 'scene' : GameLib.D3.Scene }, null, parentEntity ); if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Render Pass (' + id + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Render Pass (' + id + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(passType)) { passType = GameLib.D3.Pass.PASS_TYPE_RENDER; } this.passType = passType; if (GameLib.Utils.UndefinedOrNull(scene)) { scene = null; } this.scene = scene; if (GameLib.Utils.UndefinedOrNull(renderToScreen)) { if (this.passType == GameLib.D3.Pass.PASS_TYPE_RENDER) { renderToScreen = false; } else if (GameLib.D3.Pass.PASS_TYPE_COPY_SHADER) { renderToScreen = true; } else { console.warn('Unsupported Render Pass Type : ' + this.passType); throw new Error('Unsupported Render Pass Type : ' + this.passType); } } this.renderToScreen = renderToScreen; }; GameLib.D3.API.Pass.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Pass.prototype.constructor = GameLib.D3.API.Pass; /** * Object to GameLib.D3.API.Pass * @param objectComponent * @constructor */ GameLib.D3.API.Pass.FromObjectComponent = function(objectComponent) { return new GameLib.D3.API.Pass( objectComponent.id, objectComponent.name, objectComponent.passType, objectComponent.camera, objectComponent.scene, objectComponent.renderToScreen, objectComponent.parentEntity ); };