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:
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;
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;
private _getGLTFTextureSampler(texture: BaseTexture): ISampler {
const sampler = this._getGLTFTextureWrapModesSampler(texture);
let samplingMode = texture instanceof Texture ? texture.samplingMode : null;
if (samplingMode != null) {
switch (samplingMode) {
case Texture.LINEAR_LINEAR: {
sampler.magFilter = TextureMagFilter.LINEAR;
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;