257 lines
7.6 KiB
JavaScript
257 lines
7.6 KiB
JavaScript
/**
|
|
* R3.D3.API.Texture
|
|
* @param apiComponent
|
|
* @param parentMaterials
|
|
* @param mipmaps
|
|
* @param mapping
|
|
* @param wrapS
|
|
* @param wrapT
|
|
* @param magFilter
|
|
* @param minFilter
|
|
* @param anisotropy
|
|
* @param format
|
|
* @param storageType
|
|
* @param offset
|
|
* @param repeat
|
|
* @param rotation
|
|
* @param center
|
|
* @param matrixAutoUpdate
|
|
* @param generateMipMaps
|
|
* @param premultiplyAlpha
|
|
* @param flipY
|
|
* @param unpackAlignment
|
|
* @param encoding
|
|
* @param version
|
|
* @param animated
|
|
* @param reverseAnimation
|
|
* @param forward
|
|
* @param depthBuffer
|
|
* @param stencilBuffer
|
|
* @constructor
|
|
*/
|
|
R3.D3.API.Texture = function(
|
|
apiComponent,
|
|
parentMaterials,
|
|
mipmaps,
|
|
mapping,
|
|
wrapS,
|
|
wrapT,
|
|
magFilter,
|
|
minFilter,
|
|
anisotropy,
|
|
format,
|
|
storageType,
|
|
offset,
|
|
repeat,
|
|
rotation,
|
|
center,
|
|
matrixAutoUpdate,
|
|
generateMipMaps,
|
|
premultiplyAlpha,
|
|
flipY,
|
|
unpackAlignment,
|
|
encoding,
|
|
version,
|
|
animated,
|
|
reverseAnimation,
|
|
forward
|
|
) {
|
|
|
|
__API_COMPONENT__;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.parentMaterials)) {
|
|
apiComponent.parentMaterials = [];
|
|
}
|
|
this.parentMaterials = apiComponent.parentMaterials;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.mipmaps)) {
|
|
apiComponent.mipmaps = [];
|
|
}
|
|
this.mipmaps = apiComponent.mipmaps;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.mapping)) {
|
|
apiComponent.mapping = R3.D3.API.Texture.TYPE_UV_MAPPING;
|
|
}
|
|
this.mapping = apiComponent.mapping;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.wrapS)) {
|
|
apiComponent.wrapS = R3.D3.API.Texture.TYPE_REPEAT_WRAPPING;
|
|
}
|
|
this.wrapS = apiComponent.wrapS;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.wrapT)) {
|
|
apiComponent.wrapT = R3.D3.API.Texture.TYPE_REPEAT_WRAPPING;
|
|
}
|
|
this.wrapT = apiComponent.wrapT;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.magFilter)) {
|
|
apiComponent.magFilter = R3.D3.API.Texture.TYPE_LINEAR_FILTER;
|
|
}
|
|
this.magFilter = apiComponent.magFilter;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.minFilter)) {
|
|
apiComponent.minFilter = R3.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER;
|
|
}
|
|
this.minFilter = apiComponent.minFilter;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.anisotropy)) {
|
|
apiComponent.anisotropy = 1;
|
|
}
|
|
this.anisotropy = apiComponent.anisotropy;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.format)) {
|
|
apiComponent.format = R3.D3.API.Texture.TYPE_RGBA_FORMAT;
|
|
}
|
|
this.format = apiComponent.format;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.storageType)) {
|
|
apiComponent.storageType = R3.D3.API.Texture.TYPE_UNSIGNED_BYTE;
|
|
}
|
|
this.storageType = apiComponent.storageType;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.offset)) {
|
|
apiComponent.offset = new R3.API.Vector2(0, 0);
|
|
}
|
|
this.offset = apiComponent.offset;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.repeat)) {
|
|
apiComponent.repeat = new R3.API.Vector2(1, 1);
|
|
}
|
|
this.repeat = apiComponent.repeat;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.rotation)) {
|
|
apiComponent.rotation = 0;
|
|
}
|
|
this.rotation = apiComponent.rotation;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.center)) {
|
|
apiComponent.center = new R3.API.Vector2(0.5, 0.5);
|
|
}
|
|
this.center = apiComponent.center;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.matrixAutoUpdate)) {
|
|
apiComponent.matrixAutoUpdate = true;
|
|
}
|
|
this.matrixAutoUpdate = apiComponent.matrixAutoUpdate;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.generateMipMaps)) {
|
|
apiComponent.generateMipMaps = true;
|
|
}
|
|
this.generateMipMaps = apiComponent.generateMipMaps;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.premultiplyAlpha)) {
|
|
apiComponent.premultiplyAlpha = false;
|
|
}
|
|
this.premultiplyAlpha = apiComponent.premultiplyAlpha;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.flipY)) {
|
|
apiComponent.flipY = true;
|
|
}
|
|
this.flipY = apiComponent.flipY;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.unpackAlignment)) {
|
|
apiComponent.unpackAlignment = 4;
|
|
}
|
|
this.unpackAlignment = apiComponent.unpackAlignment;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.encoding)) {
|
|
apiComponent.encoding = R3.D3.API.Texture.TYPE_LINEAR_ENCODING;
|
|
}
|
|
this.encoding = apiComponent.encoding;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.version)) {
|
|
apiComponent.version = 0
|
|
}
|
|
this.version = apiComponent.version;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.animated)) {
|
|
apiComponent.animated = false;
|
|
}
|
|
this.animated = apiComponent.animated;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.reverseAnimation)) {
|
|
apiComponent.reverseAnimation = false;
|
|
}
|
|
this.reverseAnimation = apiComponent.reverseAnimation;
|
|
|
|
if (R3.Utils.UndefinedOrNull(apiComponent.forward)) {
|
|
apiComponent.forward = true;
|
|
}
|
|
this.forward = apiComponent.forward;
|
|
|
|
this.needsUpdate = apiComponent.false;
|
|
|
|
};
|
|
|
|
R3.D3.API.Texture.prototype = Object.create(R3.API.Component.prototype);
|
|
R3.D3.API.Texture.prototype.constructor = R3.D3.API.Texture;
|
|
|
|
/**
|
|
* Texture Formats
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_ALPHA_FORMAT = 1019;
|
|
R3.D3.API.Texture.TYPE_RGB_FORMAT = 1020;
|
|
R3.D3.API.Texture.TYPE_RGBA_FORMAT = 1021;
|
|
R3.D3.API.Texture.TYPE_LUMINANCE_FORMAT = 1022;
|
|
R3.D3.API.Texture.TYPE_LUMINANCE_ALPHA_FORMAT = 1023;
|
|
R3.D3.API.Texture.TYPE_DEPTH_FORMAT = 1026;
|
|
|
|
/**
|
|
* Mapping modes
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_UV_MAPPING = 300;
|
|
R3.D3.API.Texture.TYPE_CUBE_REFLECTION_MAPPING = 301;
|
|
R3.D3.API.Texture.TYPE_CUBE_REFRACTION_MAPPING = 302;
|
|
R3.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFLECTION_MAPPING = 303;
|
|
R3.D3.API.Texture.TYPE_EQUI_RECTANGULAR_REFRACTION_MAPPING = 304;
|
|
R3.D3.API.Texture.TYPE_SPHERICAL_REFLECTION_MAPPING = 305;
|
|
R3.D3.API.Texture.TYPE_CUBE_UV_REFLECTION_MAPPING = 306;
|
|
R3.D3.API.Texture.TYPE_CUBE_UV_REFRACTION_MAPPING = 307;
|
|
|
|
/**
|
|
* Wrapping Modes
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_REPEAT_WRAPPING = 1000;
|
|
R3.D3.API.Texture.TYPE_CLAMP_TO_EDGE_WRAPPING = 1001;
|
|
R3.D3.API.Texture.TYPE_MIRRORED_REPEAT_WRAPPING = 1002;
|
|
|
|
/**
|
|
* Mipmap Filters
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_NEAREST_FILTER = 1003;
|
|
R3.D3.API.Texture.TYPE_NEAREST_MIPMAP_NEAREST_FILTER = 1004;
|
|
R3.D3.API.Texture.TYPE_NEAREST_MIPMAP_LINEAR_FILTER = 1005;
|
|
R3.D3.API.Texture.TYPE_LINEAR_FILTER = 1006;
|
|
R3.D3.API.Texture.TYPE_LINEAR_MIPMAP_NEAREST_FILTER = 1007;
|
|
R3.D3.API.Texture.TYPE_LINEAR_MIPMAP_LINEAR_FILTER = 1008;
|
|
|
|
/**
|
|
* Texture Data Types
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_UNSIGNED_BYTE = 1009;
|
|
R3.D3.API.Texture.TYPE_BYTE = 1010;
|
|
R3.D3.API.Texture.TYPE_SHORT = 1011;
|
|
R3.D3.API.Texture.TYPE_UNSIGNED_SHORT = 1012;
|
|
R3.D3.API.Texture.TYPE_INT = 1013;
|
|
R3.D3.API.Texture.TYPE_UNSIGNED_INT = 1014;
|
|
R3.D3.API.Texture.TYPE_FLOAT = 1015;
|
|
R3.D3.API.Texture.TYPE_HALF_FLOAT = 1025;
|
|
|
|
/**
|
|
* Encoding Modes
|
|
* @type {number}
|
|
*/
|
|
R3.D3.API.Texture.TYPE_LINEAR_ENCODING = 3000; // NO ENCODING AT ALL.
|
|
R3.D3.API.Texture.TYPE_SRGB_ENCODING = 3001;
|
|
R3.D3.API.Texture.TYPE_GAMMA_ENCODING = 3007; // USES GAMMA_FACTOR, FOR BACKWARDS COMPATIBILITY WITH WEBGLRENDERER.GAMMAINPUT/GAMMAOUTPUT
|
|
R3.D3.API.Texture.TYPE_RGBE_ENCODING = 3002; // AKA RADIANCE.
|
|
R3.D3.API.Texture.TYPE_LOG_LUV_ENCODING = 3003;
|
|
R3.D3.API.Texture.TYPE_RGBM7_ENCODING = 3004;
|
|
R3.D3.API.Texture.TYPE_RGBM16_ENCODING = 3005;
|
|
R3.D3.API.Texture.TYPE_RGBD_ENCODING = 3006; // MAXRANGE IS 256.
|