97 lines
2.2 KiB
JavaScript
97 lines
2.2 KiB
JavaScript
|
/**
|
||
|
* This component renders a scene
|
||
|
* @param id String
|
||
|
* @param name String
|
||
|
* @param width
|
||
|
* @param height
|
||
|
* @param minFilter
|
||
|
* @param magFilter
|
||
|
* @param format
|
||
|
* @param stencilBuffer
|
||
|
* @param parentEntity
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.API.RenderTarget = function (
|
||
|
id,
|
||
|
name,
|
||
|
width,
|
||
|
height,
|
||
|
minFilter,
|
||
|
magFilter,
|
||
|
format,
|
||
|
stencilBuffer,
|
||
|
parentEntity
|
||
|
) {
|
||
|
|
||
|
GameLib.Component.call(
|
||
|
this,
|
||
|
GameLib.Component.COMPONENT_RENDER_TARGET,
|
||
|
null,
|
||
|
null,
|
||
|
parentEntity
|
||
|
);
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(id)) {
|
||
|
id = GameLib.Utils.RandomId();
|
||
|
}
|
||
|
this.id = id;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(name)) {
|
||
|
name = 'Render Target (' + 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(minFilter)) {
|
||
|
minFilter = GameLib.D3.RenderTarget.LINEAR_FILTER;
|
||
|
}
|
||
|
this.minFilter = minFilter;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(magFilter)) {
|
||
|
magFilter = GameLib.D3.RenderTarget.LINEAR_FILTER;
|
||
|
}
|
||
|
this.magFilter = magFilter;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(format)) {
|
||
|
format = GameLib.D3.RenderTarget.RGB_FORMAT;
|
||
|
}
|
||
|
this.format = format;
|
||
|
|
||
|
if (GameLib.Utils.UndefinedOrNull(stencilBuffer)) {
|
||
|
stencilBuffer = false;
|
||
|
}
|
||
|
this.stencilBuffer = stencilBuffer;
|
||
|
|
||
|
};
|
||
|
|
||
|
GameLib.D3.API.RenderTarget.prototype = Object.create(GameLib.Component.prototype);
|
||
|
GameLib.D3.API.RenderTarget.prototype.constructor = GameLib.D3.API.RenderTarget;
|
||
|
|
||
|
/**
|
||
|
* Object to GameLib.D3.API.RenderTarget
|
||
|
* @param objectComponent
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.API.RenderTarget.FromObjectComponent = function(objectComponent) {
|
||
|
return new GameLib.D3.API.RenderTarget(
|
||
|
objectComponent.id,
|
||
|
objectComponent.name,
|
||
|
objectComponent.width,
|
||
|
objectComponent.height,
|
||
|
objectComponent.minFilter,
|
||
|
objectComponent.magFilter,
|
||
|
objectComponent.format,
|
||
|
objectComponent.stencilBuffer,
|
||
|
objectComponent.parentEntity
|
||
|
);
|
||
|
};
|