2017-01-11 16:09:06 +01:00
|
|
|
/**
|
|
|
|
* Raw Viewport API object - should always correspond with the Viewport Schema
|
|
|
|
* @param id
|
|
|
|
* @param name
|
|
|
|
* @param width
|
|
|
|
* @param height
|
|
|
|
* @param x
|
|
|
|
* @param y
|
|
|
|
* @param parentEntity
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Viewport = function(
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
x,
|
|
|
|
y,
|
|
|
|
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;
|
2017-06-06 11:25:02 +02:00
|
|
|
|
2017-12-04 13:23:15 +01:00
|
|
|
GameLib.API.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.VIEWPORT,
|
|
|
|
parentEntity
|
|
|
|
);
|
2017-01-11 16:09:06 +01:00
|
|
|
};
|
|
|
|
|
2018-01-07 12:40:16 +01:00
|
|
|
GameLib.D3.API.Viewport.prototype = Object.create(GameLib.API.Component.prototype);
|
2017-01-11 16:09:06 +01:00
|
|
|
GameLib.D3.API.Viewport.prototype.constructor = GameLib.D3.API.Viewport;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an API Viewport from an Object Viewport
|
|
|
|
* @param objectViewport
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.D3.API.Viewport.FromObject = function(objectViewport) {
|
2017-01-11 16:09:06 +01:00
|
|
|
return new GameLib.D3.API.Viewport(
|
|
|
|
objectViewport.id,
|
|
|
|
objectViewport.name,
|
|
|
|
objectViewport.width,
|
|
|
|
objectViewport.height,
|
|
|
|
objectViewport.x,
|
|
|
|
objectViewport.y,
|
|
|
|
objectViewport.parentEntity
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|