118 lines
2.6 KiB
JavaScript
118 lines
2.6 KiB
JavaScript
|
/**
|
||
|
* Raw Viewport API object - should always correspond with the Viewport Schema
|
||
|
* @param id
|
||
|
* @param name
|
||
|
* @param width
|
||
|
* @param height
|
||
|
* @param x
|
||
|
* @param y
|
||
|
* @param composer GameLib.D3.API.Composer
|
||
|
* @param renderer GameLib.D3.API.Renderer
|
||
|
* @param scene GameLib.D3.API.Scene
|
||
|
* @param camera GameLib.D3.API.Camera
|
||
|
* @param parentEntity
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.API.Viewport = function(
|
||
|
id,
|
||
|
name,
|
||
|
width,
|
||
|
height,
|
||
|
x,
|
||
|
y,
|
||
|
composer,
|
||
|
renderer,
|
||
|
scene,
|
||
|
camera,
|
||
|
parentEntity
|
||
|
) {
|
||
|
GameLib.Component.call(
|
||
|
this,
|
||
|
GameLib.Component.COMPONENT_VIEWPORT,
|
||
|
{
|
||
|
'composer' : GameLib.D3.Composer,
|
||
|
'renderer' : GameLib.D3.Renderer,
|
||
|
'scene' : GameLib.D3.Scene,
|
||
|
'camera' : GameLib.D3.Camera
|
||
|
},
|
||
|
null,
|
||
|
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(composer)) {
|
||
|
composer = null;
|
||
|
}
|
||
|
this.composer = composer;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(renderer)) {
|
||
|
renderer = null;
|
||
|
}
|
||
|
this.renderer = renderer;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(scene)) {
|
||
|
scene = null;
|
||
|
}
|
||
|
this.scene = scene;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
||
|
camera = null;
|
||
|
}
|
||
|
this.camera = camera;
|
||
|
|
||
|
};
|
||
|
|
||
|
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.FromObjectViewport = function(objectViewport) {
|
||
|
return new GameLib.D3.API.Viewport(
|
||
|
objectViewport.id,
|
||
|
objectViewport.name,
|
||
|
objectViewport.width,
|
||
|
objectViewport.height,
|
||
|
objectViewport.x,
|
||
|
objectViewport.y,
|
||
|
objectViewport.composer,
|
||
|
objectViewport.renderer,
|
||
|
objectViewport.scene,
|
||
|
objectViewport.camera,
|
||
|
objectViewport.parentEntity
|
||
|
);
|
||
|
};
|
||
|
|