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

105 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-12-19 17:44:15 +01:00
/**
* This component renders a scene
* @param id String
* @param name String
* @param autoClear bool
* @param localClipping
* @param width
* @param height
* @param domElement
2017-06-07 11:32:52 +02:00
* @param clearColor
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,
autoClear,
localClipping,
width,
2017-01-02 17:05:40 +01:00
height,
2017-01-31 15:23:38 +01:00
preserveDrawingBuffer,
domElement,
2017-06-07 11:32:52 +02:00
clearColor,
2017-01-31 15:23:38 +01:00
parentEntity
2016-12-19 17:44:15 +01:00
) {
GameLib.Component.call(
this,
2017-01-10 17:04:30 +01:00
GameLib.Component.COMPONENT_RENDERER,
{
'domElement' : GameLib.DomElement
},
2017-01-02 17:05:40 +01:00
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(autoClear)) {
2017-01-31 15:23:38 +01:00
autoClear = true;
2016-12-19 17:44:15 +01:00
}
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)) {
2017-01-31 15:23:38 +01:00
preserveDrawingBuffer = false;
2017-01-09 15:20:48 +01:00
}
this.preserveDrawingBuffer = preserveDrawingBuffer;
if (GameLib.Utils.UndefinedOrNull(domElement)) {
domElement = null;
}
this.domElement = domElement;
2017-06-07 11:32:52 +02:00
if (GameLib.Utils.UndefinedOrNull(clearColor)) {
2017-06-08 18:17:03 +02:00
clearColor = new GameLib.API.Color(0.58, 0.58, 0.58);
2017-06-07 11:32:52 +02:00
}
this.clearColor = clearColor;
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,
objectComponent.autoClear,
objectComponent.localClipping,
objectComponent.width,
objectComponent.height,
2017-01-31 15:23:38 +01:00
objectComponent.preserveDrawingBuffer,
objectComponent.domElement,
2017-06-07 11:32:52 +02:00
objectComponent.clearColor,
2017-01-31 15:23:38 +01:00
objectComponent.parentEntity
2017-01-06 16:53:53 +01:00
);
};