Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private static _GetTextureSamplingMode(context: string, sampler: ISampler): number {
// Set defaults if undefined
const magFilter = sampler.magFilter == undefined ? TextureMagFilter.LINEAR : sampler.magFilter;
const minFilter = sampler.minFilter == undefined ? TextureMinFilter.LINEAR_MIPMAP_LINEAR : sampler.minFilter;
if (magFilter === TextureMagFilter.LINEAR) {
switch (minFilter) {
case TextureMinFilter.NEAREST: return Texture.LINEAR_NEAREST;
case TextureMinFilter.LINEAR: return Texture.LINEAR_LINEAR;
case TextureMinFilter.NEAREST_MIPMAP_NEAREST: return Texture.LINEAR_NEAREST_MIPNEAREST;
case TextureMinFilter.LINEAR_MIPMAP_NEAREST: return Texture.LINEAR_LINEAR_MIPNEAREST;
case TextureMinFilter.NEAREST_MIPMAP_LINEAR: return Texture.LINEAR_NEAREST_MIPLINEAR;
case TextureMinFilter.LINEAR_MIPMAP_LINEAR: return Texture.LINEAR_LINEAR_MIPLINEAR;
default:
Tools.Warn(`${context}/minFilter: Invalid value (${minFilter})`);
return Texture.LINEAR_LINEAR_MIPLINEAR;
}
}
else {
if (magFilter !== TextureMagFilter.NEAREST) {
Tools.Warn(`${context}/magFilter: Invalid value (${magFilter})`);
}
switch (minFilter) {
case TextureMinFilter.NEAREST: return Texture.NEAREST_NEAREST;
case TextureMinFilter.LINEAR: return Texture.NEAREST_LINEAR;
case TextureMinFilter.NEAREST_MIPMAP_NEAREST: return Texture.NEAREST_NEAREST_MIPNEAREST;
case TextureMinFilter.LINEAR_MIPMAP_NEAREST: return Texture.NEAREST_LINEAR_MIPNEAREST;
case TextureMinFilter.NEAREST_MIPMAP_LINEAR: return Texture.NEAREST_NEAREST_MIPLINEAR;
private static _GetTextureSamplingMode(context: string, sampler: ISampler): number {
// Set defaults if undefined
const magFilter = sampler.magFilter == undefined ? TextureMagFilter.LINEAR : sampler.magFilter;
const minFilter = sampler.minFilter == undefined ? TextureMinFilter.LINEAR_MIPMAP_LINEAR : sampler.minFilter;
if (magFilter === TextureMagFilter.LINEAR) {
switch (minFilter) {
case TextureMinFilter.NEAREST: return Texture.LINEAR_NEAREST;
case TextureMinFilter.LINEAR: return Texture.LINEAR_LINEAR;
case TextureMinFilter.NEAREST_MIPMAP_NEAREST: return Texture.LINEAR_NEAREST_MIPNEAREST;
case TextureMinFilter.LINEAR_MIPMAP_NEAREST: return Texture.LINEAR_LINEAR_MIPNEAREST;
case TextureMinFilter.NEAREST_MIPMAP_LINEAR: return Texture.LINEAR_NEAREST_MIPLINEAR;
case TextureMinFilter.LINEAR_MIPMAP_LINEAR: return Texture.LINEAR_LINEAR_MIPLINEAR;
default:
Logger.Warn(`${context}/minFilter: Invalid value (${minFilter})`);
return Texture.LINEAR_LINEAR_MIPLINEAR;
}
}
else {
if (magFilter !== TextureMagFilter.NEAREST) {
private static _GetTextureSamplingMode(context: string, sampler: ISampler): number {
// Set defaults if undefined
const magFilter = sampler.magFilter == undefined ? TextureMagFilter.LINEAR : sampler.magFilter;
const minFilter = sampler.minFilter == undefined ? TextureMinFilter.LINEAR_MIPMAP_LINEAR : sampler.minFilter;
if (magFilter === TextureMagFilter.LINEAR) {
switch (minFilter) {
case TextureMinFilter.NEAREST: return Texture.LINEAR_NEAREST;
case TextureMinFilter.LINEAR: return Texture.LINEAR_LINEAR;
case TextureMinFilter.NEAREST_MIPMAP_NEAREST: return Texture.LINEAR_NEAREST_MIPNEAREST;
case TextureMinFilter.LINEAR_MIPMAP_NEAREST: return Texture.LINEAR_LINEAR_MIPNEAREST;
case TextureMinFilter.NEAREST_MIPMAP_LINEAR: return Texture.LINEAR_NEAREST_MIPLINEAR;
case TextureMinFilter.LINEAR_MIPMAP_LINEAR: return Texture.LINEAR_LINEAR_MIPLINEAR;
default:
Tools.Warn(`${context}/minFilter: Invalid value (${minFilter})`);
return Texture.LINEAR_LINEAR_MIPLINEAR;
}
}
else {
if (magFilter !== TextureMagFilter.NEAREST) {
sampler.minFilter = TextureMinFilter.LINEAR;
break;
}
case Texture.LINEAR_NEAREST: {
sampler.magFilter = TextureMagFilter.LINEAR;
sampler.minFilter = TextureMinFilter.NEAREST;
break;
}
case Texture.NEAREST_LINEAR: {
sampler.magFilter = TextureMagFilter.NEAREST;
sampler.minFilter = TextureMinFilter.LINEAR;
break;
}
case Texture.NEAREST_LINEAR_MIPLINEAR: {
sampler.magFilter = TextureMagFilter.NEAREST;
sampler.minFilter = TextureMinFilter.LINEAR_MIPMAP_LINEAR;
break;
}
case Texture.NEAREST_NEAREST: {
sampler.magFilter = TextureMagFilter.NEAREST;
sampler.minFilter = TextureMinFilter.NEAREST;
break;
}
case Texture.NEAREST_LINEAR_MIPNEAREST: {
sampler.magFilter = TextureMagFilter.NEAREST;
sampler.minFilter = TextureMinFilter.LINEAR_MIPMAP_NEAREST;
break;
}
case Texture.LINEAR_NEAREST_MIPNEAREST: {
sampler.magFilter = TextureMagFilter.LINEAR;
sampler.minFilter = TextureMinFilter.NEAREST_MIPMAP_NEAREST;
break;
Logger.Warn(`${context}/minFilter: Invalid value (${minFilter})`);
return Texture.LINEAR_LINEAR_MIPLINEAR;
}
}
else {
if (magFilter !== TextureMagFilter.NEAREST) {
Logger.Warn(`${context}/magFilter: Invalid value (${magFilter})`);
}
switch (minFilter) {
case TextureMinFilter.NEAREST: return Texture.NEAREST_NEAREST;
case TextureMinFilter.LINEAR: return Texture.NEAREST_LINEAR;
case TextureMinFilter.NEAREST_MIPMAP_NEAREST: return Texture.NEAREST_NEAREST_MIPNEAREST;
case TextureMinFilter.LINEAR_MIPMAP_NEAREST: return Texture.NEAREST_LINEAR_MIPNEAREST;
case TextureMinFilter.NEAREST_MIPMAP_LINEAR: return Texture.NEAREST_NEAREST_MIPLINEAR;
case TextureMinFilter.LINEAR_MIPMAP_LINEAR: return Texture.NEAREST_LINEAR_MIPLINEAR;
default:
Logger.Warn(`${context}/minFilter: Invalid value (${minFilter})`);
return Texture.NEAREST_NEAREST_MIPNEAREST;
}
}
}