UNPKG

mdx-m3-viewer

Version:

A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.

33 lines 1.32 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const math_1 = require("../../common/math"); /** * Tests for issues in DDS textures. */ function sanityTest(texture) { const nodes = []; const width = texture.width; const height = texture.height; const mipmaps = texture.mipmaps(); const expectedMipmaps = Math.log2(Math.max(width, height)); if (mipmaps < expectedMipmaps) { nodes.push({ type: 'warning', message: `Expected ${expectedMipmaps} mipmaps, but got ${mipmaps}` }); } if ((width % 4 !== 0) || (height % 4 !== 0)) { nodes.push({ type: 'warning', message: `Expected the width and height to be multiples of four, but got ${width}x${height}` }); } if (!(0, math_1.isPowerOfTwo)(width) || !(0, math_1.isPowerOfTwo)(height)) { nodes.push({ type: 'warning', message: `Expected the width and height to be powers of two, but got ${width}x${height}` }); } for (let i = 0; i < mipmaps; i++) { try { texture.getMipmap(i); } catch (e) { nodes.push({ type: 'warning', message: `Mipmap ${i}: Decoding failed` }); } } return { nodes, warnings: nodes.length }; } exports.default = sanityTest; //# sourceMappingURL=sanitytest.js.map