/** * Viewport Runtime * @param graphics GameLib.D3.Graphics * @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 = {}; } if (apiViewport instanceof GameLib.D3.Viewport) { return apiViewport; } GameLib.D3.API.Viewport.call( this, apiViewport.id, apiViewport.name, apiViewport.width, apiViewport.height, apiViewport.x, apiViewport.y, apiViewport.scenes, apiViewport.parentEntity ); this.buildIdToObject(); this.instance = this.createInstance(); }; GameLib.D3.Viewport.prototype = Object.create(GameLib.D3.API.Viewport.prototype); GameLib.D3.Viewport.prototype.constructor = GameLib.D3.Viewport; //GameLib.D3.Viewport.VIEWPORT_TYPE_GAME = 0x1; /** * * @param update * @returns {*} */ GameLib.D3.Viewport.prototype.createInstance = function(update) { var instance = null; if (update) { instance = this.instance; } return instance; }; /** * */ GameLib.D3.Viewport.prototype.updateInstance = function() { this.instance = this.createInstance(true); }; /** * 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, this.scenes.map(function(scene){ return GameLib.Utils.IdOrNull(scene); }), GameLib.Utils.IdOrNull(this.parentEntity) ); return apiViewport; }; /** * GameLib.D3.Viewport from Object Viewport * @param graphics * @param objectComponent * @returns {GameLib.D3.Viewport} * @constructor */ GameLib.D3.Viewport.FromObject = function(graphics, objectComponent) { var apiViewport = GameLib.D3.API.Viewport.FromObject(objectComponent); return new GameLib.D3.Viewport( graphics, apiViewport ); };