/** * R3.D3.Composer.Renderer * @param apiComponent * @constructor */ R3.D3.Composer.Renderer = function( apiComponent ) { __RUNTIME_COMPONENT__; R3.D3.API.Composer.Renderer.call( this, apiComponent, apiComponent.renderer ); if (this.renderer instanceof R3.API.Renderer.D3) { this.renderer = R3.Component.ConstructFromObject(this.renderer); } var linkedComponents = { renderer : R3.Renderer.D3 }; R3.D3.Composer.call( this, linkedComponents ); }; R3.D3.Composer.Renderer.prototype = Object.create(R3.D3.Composer.prototype); R3.D3.Composer.Renderer.prototype.constructor = R3.D3.Composer.Renderer; /** * Creates a Composer instance * @returns {*} */ R3.D3.Composer.Renderer.prototype.createInstance = function() { if ( R3.Utils.UndefinedOrNull(this.renderer) ) { throw new Error('Need at least a renderer to create a composer renderer object') } if ( this.renderer instanceof R3.Renderer.D3.Target || this.renderer instanceof R3.Renderer.D3.Canvas.Target ) { this.width = this.renderer.target.width; this.height = this.renderer.target.height; } else if ( this.renderer instanceof R3.Renderer.D3.Canvas ) { /** * This composer belongs to a scene which belongs to a viewport */ var viewport = this.getFirstParent(R3.D3.Viewport); /** * The canvas is associated to the renderer - it has the actual size of the canvas and we need the size * of the viewport to determine the actual pixel size of this composer */ var canvas = this.renderer.canvas; this.width = canvas.width * viewport.width; this.height = canvas.height * viewport.height; } else { throw new Error('Unhandled renderer type : ' + this.renderer); } /** * Right - now we should have the right size of the composer - we can continue */ this.instance = this.graphics.Composer( renderer, null, this.passes, { width : this.width, height : this.height } ); __CREATE_INSTANCE__; }; /** * Updates Composer instance */ R3.D3.Composer.Renderer.prototype.updateInstance = function(property) { if (property === 'renderer') { console.warn('todo update composer renderer'); return; } R3.D3.Composer.prototype.updateInstance.call(this, property); }; /** * Checks if this composer is ready for rendering * @returns {boolean} */ R3.D3.Composer.Renderer.prototype.ready = function() { if (R3.Utils.UndefinedOrNull(this.instance)) { return false; } if (R3.Utils.UndefinedOrNull(this.renderer)) { return false; } return R3.D3.Composer.prototype.ready.call(this); };