154 lines
3.4 KiB
JavaScript
154 lines
3.4 KiB
JavaScript
|
/**
|
||
|
* Raw Texture API object - should always correspond with the Texture Schema
|
||
|
* @param id
|
||
|
* @param typeId
|
||
|
* @param name
|
||
|
* @param imagePath
|
||
|
* @param wrapS
|
||
|
* @param wrapT
|
||
|
* @param repeat
|
||
|
* @param data
|
||
|
* @param format
|
||
|
* @param mapping
|
||
|
* @param magFilter
|
||
|
* @param minFilter
|
||
|
* @param textureType
|
||
|
* @param anisotropy
|
||
|
* @param offset
|
||
|
* @param generateMipmaps
|
||
|
* @param flipY
|
||
|
* @param mipmaps
|
||
|
* @param unpackAlignment
|
||
|
* @param premultiplyAlpha
|
||
|
* @param encoding
|
||
|
* @constructor
|
||
|
*/
|
||
|
GameLib.D3.API.Texture = function(
|
||
|
id,
|
||
|
typeId,
|
||
|
name,
|
||
|
imagePath,
|
||
|
wrapS,
|
||
|
wrapT,
|
||
|
repeat,
|
||
|
data,
|
||
|
format,
|
||
|
mapping,
|
||
|
magFilter,
|
||
|
minFilter,
|
||
|
textureType,
|
||
|
anisotropy,
|
||
|
offset,
|
||
|
generateMipmaps,
|
||
|
flipY,
|
||
|
mipmaps,
|
||
|
unpackAlignment,
|
||
|
premultiplyAlpha,
|
||
|
encoding
|
||
|
) {
|
||
|
if (GameLib.D3.Utils.UndefinedOrNull(id)) {
|
||
|
id = GameLib.D3.Tools.RandomId();
|
||
|
}
|
||
|
this.id = id;
|
||
|
|
||
|
if (GameLib.D3.Utils.UndefinedOrNull(typeId)) {
|
||
|
typeId = GameLib.D3.Texture.TEXTURE_TYPE_DIFFUSE;
|
||
|
}
|
||
|
this.typeId = typeId;
|
||
|
|
||
|
if (GameLib.D3.Utils.UndefinedOrNull(name)) {
|
||
|
name = 'Texture (' + typeId + ')';
|
||
|
}
|
||
|
this.name = name;
|
||
|
|
||
|
if (GameLib.D3.Utils.UndefinedOrNull(imagePath)) {
|
||
|
imagePath = null;
|
||
|
}
|
||
|
this.imagePath = imagePath;
|
||
|
|
||
|
if (typeof wrapS == 'undefined') {
|
||
|
wrapS = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
||
|
}
|
||
|
this.wrapS = wrapS;
|
||
|
|
||
|
if (typeof wrapT == 'undefined') {
|
||
|
wrapT = GameLib.D3.Texture.TYPE_REPEAT_WRAPPING;
|
||
|
}
|
||
|
this.wrapT = wrapT;
|
||
|
|
||
|
if (typeof repeat == 'undefined') {
|
||
|
repeat = new GameLib.D3.Vector2(1, 1);
|
||
|
}
|
||
|
this.repeat = repeat;
|
||
|
|
||
|
if (typeof data == 'undefined') {
|
||
|
data = null;
|
||
|
}
|
||
|
this.data = data;
|
||
|
|
||
|
if (typeof format == 'undefined') {
|
||
|
format = GameLib.D3.Texture.TYPE_RGBA_FORMAT;
|
||
|
}
|
||
|
this.format = format;
|
||
|
|
||
|
if (typeof mapping == 'undefined') {
|
||
|
mapping = GameLib.D3.Texture.TYPE_UV_MAPPING;
|
||
|
}
|
||
|
this.mapping = mapping;
|
||
|
|
||
|
if (typeof magFilter == 'undefined') {
|
||
|
magFilter = GameLib.D3.Texture.TYPE_LINEAR_FILTER;
|
||
|
}
|
||
|
this.magFilter = magFilter;
|
||
|
|
||
|
if (typeof minFilter == 'undefined') {
|
||
|
minFilter = GameLib.D3.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
||
|
}
|
||
|
this.minFilter = minFilter;
|
||
|
|
||
|
if (typeof textureType == 'undefined') {
|
||
|
textureType = GameLib.D3.Texture.TYPE_UNSIGNED_BYTE;
|
||
|
}
|
||
|
this.textureType = textureType;
|
||
|
|
||
|
if (typeof anisotropy == 'undefined') {
|
||
|
anisotropy = 1;
|
||
|
}
|
||
|
this.anisotropy = anisotropy;
|
||
|
|
||
|
if (typeof offset == 'undefined') {
|
||
|
offset = new GameLib.D3.Vector2(0, 0);
|
||
|
}
|
||
|
this.offset = offset;
|
||
|
|
||
|
if (typeof generateMipmaps == 'undefined') {
|
||
|
generateMipmaps = true;
|
||
|
}
|
||
|
this.generateMipmaps = generateMipmaps;
|
||
|
|
||
|
if (typeof flipY == 'undefined') {
|
||
|
flipY = true;
|
||
|
}
|
||
|
this.flipY = flipY;
|
||
|
|
||
|
if (typeof mipmaps == 'undefined') {
|
||
|
mipmaps = [];
|
||
|
}
|
||
|
this.mipmaps = mipmaps;
|
||
|
|
||
|
if (typeof unpackAlignment == 'undefined') {
|
||
|
unpackAlignment = 4;
|
||
|
}
|
||
|
this.unpackAlignment = unpackAlignment;
|
||
|
|
||
|
if (typeof premultiplyAlpha == 'undefined') {
|
||
|
premultiplyAlpha = false;
|
||
|
}
|
||
|
this.premultiplyAlpha = premultiplyAlpha;
|
||
|
|
||
|
if (typeof encoding == 'undefined') {
|
||
|
encoding = GameLib.D3.Texture.TYPE_LINEAR_ENCODING;
|
||
|
}
|
||
|
this.encoding = encoding;
|
||
|
};
|