2016-12-19 17:44:15 +01:00
|
|
|
/**
|
|
|
|
* This component renders a scene
|
|
|
|
* @param id String
|
|
|
|
* @param name String
|
2017-01-09 15:20:48 +01:00
|
|
|
* @param rendererType
|
2016-12-19 17:44:15 +01:00
|
|
|
* @param scene GameLib.D3.Scene
|
|
|
|
* @param camera GameLib.D3.Camera
|
|
|
|
* @param autoClear bool
|
|
|
|
* @param localClipping
|
|
|
|
* @param width
|
|
|
|
* @param height
|
2017-01-02 17:05:40 +01:00
|
|
|
* @param parentEntity
|
2017-01-09 15:20:48 +01:00
|
|
|
* @param preserveDrawingBuffer
|
2016-12-19 17:44:15 +01:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Renderer = function (
|
|
|
|
id,
|
|
|
|
name,
|
2017-01-09 15:20:48 +01:00
|
|
|
rendererType,
|
2016-12-19 17:44:15 +01:00
|
|
|
scene,
|
|
|
|
camera,
|
|
|
|
autoClear,
|
|
|
|
localClipping,
|
|
|
|
width,
|
2017-01-02 17:05:40 +01:00
|
|
|
height,
|
2017-01-09 15:20:48 +01:00
|
|
|
parentEntity,
|
|
|
|
preserveDrawingBuffer
|
2016-12-19 17:44:15 +01:00
|
|
|
) {
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(rendererType)) {
|
|
|
|
rendererType = GameLib.Component.COMPONENT_RENDERER;
|
|
|
|
}
|
|
|
|
this.rendererType = rendererType;
|
|
|
|
|
2016-12-19 17:44:15 +01:00
|
|
|
GameLib.Component.call(
|
|
|
|
this,
|
2017-01-09 15:20:48 +01:00
|
|
|
rendererType,
|
2016-12-20 17:27:36 +01:00
|
|
|
{
|
|
|
|
'scene' : GameLib.D3.Scene,
|
|
|
|
'camera' : GameLib.D3.Camera
|
2017-01-02 17:05:40 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
parentEntity
|
2016-12-19 17:44:15 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
|
|
|
id = GameLib.Utils.RandomId();
|
|
|
|
}
|
|
|
|
this.id = id;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
2017-01-09 15:20:48 +01:00
|
|
|
name = "Renderer (" + this.id + ")";
|
2016-12-19 17:44:15 +01:00
|
|
|
}
|
|
|
|
this.name = name;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(scene)) {
|
|
|
|
scene = null;
|
|
|
|
}
|
|
|
|
this.scene = scene;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(camera)) {
|
|
|
|
camera = null;
|
|
|
|
}
|
|
|
|
this.camera = camera;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(autoClear)) {
|
|
|
|
autoClear = true;
|
|
|
|
}
|
|
|
|
this.autoClear = autoClear;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(localClipping)) {
|
|
|
|
localClipping = false;
|
|
|
|
}
|
|
|
|
this.localClipping = localClipping;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(width)) {
|
|
|
|
width = 800;
|
|
|
|
}
|
|
|
|
this.width = width;
|
|
|
|
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(height)) {
|
|
|
|
height = 600;
|
|
|
|
}
|
|
|
|
this.height = height;
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(preserveDrawingBuffer)) {
|
|
|
|
preserveDrawingBuffer = false;
|
|
|
|
}
|
|
|
|
this.preserveDrawingBuffer = preserveDrawingBuffer;
|
2016-12-19 17:44:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
GameLib.D3.API.Renderer.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.D3.API.Renderer.prototype.constructor = GameLib.D3.API.Renderer;
|
2017-01-06 16:53:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Object to GameLib.D3.API.Renderer
|
|
|
|
* @param objectComponent
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.D3.API.Renderer.FromObjectComponent = function(objectComponent) {
|
|
|
|
return new GameLib.D3.API.Renderer(
|
|
|
|
objectComponent.id,
|
|
|
|
objectComponent.name,
|
2017-01-09 15:20:48 +01:00
|
|
|
objectComponent.rendererType,
|
2017-01-06 16:53:53 +01:00
|
|
|
objectComponent.scene,
|
|
|
|
objectComponent.camera,
|
|
|
|
objectComponent.autoClear,
|
|
|
|
objectComponent.localClipping,
|
|
|
|
objectComponent.width,
|
|
|
|
objectComponent.height,
|
2017-01-09 15:20:48 +01:00
|
|
|
objectComponent.parentEntity,
|
|
|
|
objectComponent.preserveDrawingBuffer
|
2017-01-06 16:53:53 +01:00
|
|
|
);
|
|
|
|
};
|