setTextureParameters method
void
setTextureParameters(
- dynamic textureType,
- Texture texture,
- dynamic supportsMips
)
Implementation
void setTextureParameters(textureType, Texture texture, supportsMips) {
if (supportsMips) {
gl.texParameteri(textureType, gl.TEXTURE_WRAP_S, wrappingToGL[texture.wrapS]!);
gl.texParameteri(textureType, gl.TEXTURE_WRAP_T, wrappingToGL[texture.wrapT]!);
if (textureType == gl.TEXTURE_3D || textureType == gl.TEXTURE_2D_ARRAY) {
gl.texParameteri(textureType, gl.TEXTURE_WRAP_R, wrappingToGL[texture.wrapR]!);
}
gl.texParameteri(textureType, gl.TEXTURE_MAG_FILTER, filterToGL[texture.magFilter]!);
gl.texParameteri(textureType, gl.TEXTURE_MIN_FILTER, filterToGL[texture.minFilter]!);
} else {
gl.texParameteri(textureType, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(textureType, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
if (textureType == gl.TEXTURE_3D || textureType == gl.TEXTURE_2D_ARRAY) {
gl.texParameteri(textureType, gl.TEXTURE_WRAP_R, gl.CLAMP_TO_EDGE);
}
if (texture.wrapS != ClampToEdgeWrapping || texture.wrapT != ClampToEdgeWrapping) {
print(
'three.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to three.ClampToEdgeWrapping.');
}
gl.texParameteri(textureType, gl.TEXTURE_MAG_FILTER, filterFallback(texture.magFilter));
gl.texParameteri(textureType, gl.TEXTURE_MIN_FILTER, filterFallback(texture.minFilter));
if (texture.minFilter != NearestFilter && texture.minFilter != LinearFilter) {
print(
'three.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to three.NearestFilter or three.LinearFilter.');
}
}
var extension = extensions.get('EXT_texture_filter_anisotropic');
if (extension != null) {
if (texture.type == FloatType && extensions.get('OES_texture_float_linear') == null) return;
if (texture.type == HalfFloatType && (isWebGL2 || extensions.get('OES_texture_half_float_linear') == null)) {
return;
}
if (texture.anisotropy > 1 || properties.get(texture)["__currentAnisotropy"] != null) {
// print("extension: ${extension} ... extension.TEXTURE_MAX_ANISOTROPY_EXT: ${extension.TEXTURE_MAX_ANISOTROPY_EXT} ");
if (kIsWeb) {
gl.texParameterf(textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT,
Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()).toDouble());
} else {
gl.texParameterf(textureType, gl.TEXTURE_MAX_ANISOTROPY_EXT,
Math.min(texture.anisotropy, capabilities.getMaxAnisotropy()).toDouble());
}
properties.get(texture)["__currentAnisotropy"] = texture.anisotropy;
}
}
}