101 lines
2.3 KiB
JavaScript
101 lines
2.3 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 texture
|
|
* @param parentEntity
|
|
* @constructor
|
|
*/
|
|
GameLib.D3.API.RenderTarget = function (
|
|
id,
|
|
name,
|
|
width,
|
|
height,
|
|
minFilter,
|
|
magFilter,
|
|
format,
|
|
stencilBuffer,
|
|
texture,
|
|
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;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(texture)) {
|
|
texture = null;
|
|
}
|
|
this.texture = texture;
|
|
|
|
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
|
|
parentEntity = null;
|
|
}
|
|
this.parentEntity = parentEntity;
|
|
|
|
};
|
|
|
|
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.FromObject = 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.texture,
|
|
objectComponent.parentEntity
|
|
);
|
|
};
|