UNPKG

@babylonjs/viewer

Version:

The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.

29 lines (26 loc) 1.09 kB
import { F as F32 } from './index-By0tcgYN.esm.js'; const FLOAT = 5126; const UNSIGNED_SHORT = 5123; const UNSIGNED_BYTE = 5121; const COMP_BYTES = { [UNSIGNED_BYTE]: 1, [UNSIGNED_SHORT]: 2, [FLOAT]: 4 }; function resolveUvVec2(json, binChunk, idx) { const accessor = json.accessors[idx]; const ct = accessor.componentType; const cb = COMP_BYTES[ct] ?? 4; const bv = json.bufferViews[accessor.bufferView]; const stride = bv.byteStride ?? 2 * cb; const inv = ct === UNSIGNED_BYTE ? 1 / 255 : ct === UNSIGNED_SHORT ? 1 / 65535 : 1; const base = (bv.byteOffset ?? 0) + (accessor.byteOffset ?? 0); const out = new F32(accessor.count * 2); for (let v = 0; v < accessor.count; v++) { const row = base + v * stride; for (let c = 0; c < 2; c++) { const off = row + c * cb; const raw = ct === FLOAT ? binChunk.getFloat32(off, true) : ct === UNSIGNED_SHORT ? binChunk.getUint16(off, true) : binChunk.getUint8(off); out[v * 2 + c] = raw * inv; } } return out; } export { resolveUvVec2 }; //# sourceMappingURL=gltf-uv-denorm-BG4PirBz.esm.js.map