/** * Viewport Runtime * @param graphics GameLib.GraphicsRuntime * @param apiViewport GameLib.D3.API.Viewport * @constructor */ GameLib.D3.Viewport = function ( graphics, apiViewport ) { this.graphics = graphics; this.graphics.isNotThreeThrow(); if (GameLib.Utils.UndefinedOrNull(apiViewport)) { apiViewport = {}; } GameLib.D3.API.Viewport.call( this, apiViewport.id, apiViewport.name, apiViewport.width, apiViewport.height, apiViewport.x, apiViewport.y, apiViewport.parentEntity ); GameLib.Component.call(this); }; GameLib.D3.Viewport.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.Viewport.prototype.constructor = GameLib.D3.Viewport; /** * * @returns {boolean} */ GameLib.D3.Viewport.prototype.createInstance = function() { this.instance = new THREE.Vector4( this.x, this.y, this.width, this.height ); GameLib.Component.prototype.createInstance.call(this); }; /** * */ GameLib.D3.Viewport.prototype.updateInstance = function(property) { if ( property === 'x' || property === 'y' || property === 'width' || property === 'height' ) { this.instance.x = this.x; this.instance.y = this.y; this.instance.z = this.width; this.instance.w = this.height; } }; /** * GameLib.D3.Viewport to GameLib.D3.API.Viewport * @returns {GameLib.D3.API.Viewport} */ GameLib.D3.Viewport.prototype.toApiObject = function() { var apiViewport = new GameLib.D3.API.Viewport( this.id, this.name, this.width, this.height, this.x, this.y, GameLib.Utils.IdOrNull(this.parentEntity) ); return apiViewport; };