r3-legacy/src/game-lib-d3-api-viewport.js

89 lines
1.8 KiB
JavaScript
Raw Normal View History

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
2017-06-06 11:25:02 +02:00
* @param scenes
2017-01-11 16:09:06 +01:00
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Viewport = function(
id,
name,
width,
height,
x,
y,
2017-06-06 11:25:02 +02:00
scenes,
2017-01-11 16:09:06 +01:00
parentEntity
) {
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_VIEWPORT,
2017-06-06 11:25:02 +02:00
{
'scenes' : [GameLib.D3.Scene]
},
2017-01-11 16:09:06 +01:00
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
if (GameLib.Utils.UndefinedOrNull(scenes)) {
scenes = [];
}
this.scenes = scenes;
2017-01-11 16:09:06 +01:00
};
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
*/
2017-06-06 11:25:02 +02:00
GameLib.D3.API.Viewport.FromObjectComponent = 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,
2017-06-06 11:25:02 +02:00
objectViewport.scenes,
2017-01-11 16:09:06 +01:00
objectViewport.parentEntity
);
};