/** * Raw Viewport API object - should always correspond with the Viewport Schema * @param id * @param name * @param width * @param height * @param x * @param y * @param scenes * @param parentEntity * @constructor */ GameLib.D3.API.Viewport = function( id, name, width, height, x, y, scenes, parentEntity ) { GameLib.Component.call( this, GameLib.Component.COMPONENT_VIEWPORT, { 'scenes' : [GameLib.D3.Scene] }, parentEntity ); if (GameLib.Utils.UndefinedOrNull(id)) { id = GameLib.Utils.RandomId(); } this.id = id; if (GameLib.Utils.UndefinedOrNull(name)) { name = 'Viewport (' + this.id + ')'; } this.name = name; if (GameLib.Utils.UndefinedOrNull(width)) { width = 800; } this.width = width; if (GameLib.Utils.UndefinedOrNull(height)) { height = 600; } this.height = height; if (GameLib.Utils.UndefinedOrNull(x)) { x = 0; } this.x = x; if (GameLib.Utils.UndefinedOrNull(y)) { y = 0; } this.y = y; if (GameLib.Utils.UndefinedOrNull(scenes)) { scenes = []; } this.scenes = scenes; }; GameLib.D3.API.Viewport.prototype = Object.create(GameLib.Component.prototype); GameLib.D3.API.Viewport.prototype.constructor = GameLib.D3.API.Viewport; /** * Creates an API Viewport from an Object Viewport * @param objectViewport * @constructor */ GameLib.D3.API.Viewport.FromObject = function(objectViewport) { return new GameLib.D3.API.Viewport( objectViewport.id, objectViewport.name, objectViewport.width, objectViewport.height, objectViewport.x, objectViewport.y, objectViewport.scenes, objectViewport.parentEntity ); };