mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[player] Don't force mipmaps if atlas page is non-POT in WebGL1
This commit is contained in:
parent
7521838264
commit
80e2b78dd1
1
spine-ts/build/spine-player.d.ts
vendored
1
spine-ts/build/spine-player.d.ts
vendored
@ -1004,6 +1004,7 @@ declare module spine {
|
||||
static cbrt(x: number): number;
|
||||
static randomTriangular(min: number, max: number): number;
|
||||
static randomTriangularWith(min: number, max: number, mode: number): number;
|
||||
static isPowerOfTwo(value: number): boolean;
|
||||
}
|
||||
abstract class Interpolation {
|
||||
protected abstract applyInternal(a: number): number;
|
||||
|
||||
@ -8203,6 +8203,9 @@ var spine;
|
||||
return min + Math.sqrt(u * d * (mode - min));
|
||||
return max - Math.sqrt((1 - u) * d * (max - mode));
|
||||
};
|
||||
MathUtils.isPowerOfTwo = function (value) {
|
||||
return value && (value & (value - 1)) === 0;
|
||||
};
|
||||
MathUtils.PI = 3.1415927;
|
||||
MathUtils.PI2 = MathUtils.PI * 2;
|
||||
MathUtils.radiansToDegrees = 180 / MathUtils.PI;
|
||||
@ -11809,10 +11812,15 @@ var spine;
|
||||
var config = this.config;
|
||||
var atlas = this.assetManager.require(config.atlasUrl);
|
||||
var gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
||||
var isWebGL1 = gl.getParameter(gl.VERSION).indexOf("WebGL 1.0") != -1;
|
||||
for (var _i = 0, _a = atlas.pages; _i < _a.length; _i++) {
|
||||
var page = _a[_i];
|
||||
var minFilter = page.minFilter;
|
||||
if (config.mipmaps) {
|
||||
var useMipMaps = config.mipmaps;
|
||||
var isPOT = spine.MathUtils.isPowerOfTwo(page.width) && spine.MathUtils.isPowerOfTwo(page.height);
|
||||
if (isWebGL1 && !isPOT)
|
||||
useMipMaps = false;
|
||||
if (useMipMaps) {
|
||||
if (anisotropic) {
|
||||
gl.texParameterf(gl.TEXTURE_2D, anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, 8);
|
||||
minFilter = spine.TextureFilter.MipMapLinearLinear;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -214,6 +214,10 @@ module spine {
|
||||
if (u <= (mode - min) / d) return min + Math.sqrt(u * d * (mode - min));
|
||||
return max - Math.sqrt((1 - u) * d * (max - mode));
|
||||
}
|
||||
|
||||
static isPowerOfTwo(value: number) {
|
||||
return value && (value & (value - 1)) === 0;
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class Interpolation {
|
||||
|
||||
@ -396,13 +396,17 @@ module spine {
|
||||
|
||||
let config = this.config;
|
||||
|
||||
// Configure filtering, so not force mipmaps on Safari, they require POW2 textures
|
||||
let atlas = this.assetManager.require(config.atlasUrl);
|
||||
// Configure filtering, don't use mipmaps in WebGL1 if the atlas page is non-POT
|
||||
let atlas = this.assetManager.require(config.atlasUrl) as TextureAtlas;
|
||||
let gl = this.context.gl, anisotropic = gl.getExtension("EXT_texture_filter_anisotropic");
|
||||
let isSafari = navigator.vendor.match(/apple/i) && !navigator.userAgent.match(/crios/i) && !navigator.userAgent.match(/fxios/i);
|
||||
let isWebGL1 = gl.getParameter(gl.VERSION).indexOf("WebGL 1.0") != -1;
|
||||
for (let page of atlas.pages) {
|
||||
let minFilter = page.minFilter;
|
||||
if (!isSafari && config.mipmaps) {
|
||||
var useMipMaps: boolean = config.mipmaps;
|
||||
var isPOT = MathUtils.isPowerOfTwo(page.width) && MathUtils.isPowerOfTwo(page.height);
|
||||
if (isWebGL1 && !isPOT) useMipMaps = false;
|
||||
|
||||
if (useMipMaps) {
|
||||
if (anisotropic) {
|
||||
gl.texParameterf(gl.TEXTURE_2D, anisotropic.TEXTURE_MAX_ANISOTROPY_EXT, 8);
|
||||
minFilter = TextureFilter.MipMapLinearLinear;
|
||||
@ -410,7 +414,7 @@ module spine {
|
||||
minFilter = TextureFilter.Linear; // Don't use mipmaps without anisotropic.
|
||||
page.texture.setFilters(minFilter, TextureFilter.Nearest);
|
||||
}
|
||||
if (minFilter != TextureFilter.Nearest && minFilter != TextureFilter.Linear) page.texture.update(true);
|
||||
if (minFilter != TextureFilter.Nearest && minFilter != TextureFilter.Linear) (page.texture as spine.webgl.GLTexture).update(true);
|
||||
}
|
||||
|
||||
// Load skeleton data.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user