@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) • 918 B
JavaScript
import { ak as DV, T as ThrowLiteError, j as U8 } from './index-By0tcgYN.esm.js';
function parseGlbContainer(buffer) {
const view = new DV(buffer);
const magic = view.getUint32(0, true);
if (magic !== 1179937895) {
ThrowLiteError(93);
}
let offset = 12;
const jsonLength = view.getUint32(offset, true);
const jsonType = view.getUint32(offset + 4, true);
if (jsonType !== 1313821514) {
ThrowLiteError(94);
}
const jsonStr = new TextDecoder().decode(new U8(buffer, offset + 8, jsonLength));
const json = JSON.parse(jsonStr);
offset += 8 + jsonLength;
const binLength = view.getUint32(offset, true);
const binType = view.getUint32(offset + 4, true);
if (binType !== 5130562) {
ThrowLiteError(95);
}
const binChunk = new DV(buffer, offset + 8, binLength);
return { json, binChunk };
}
export { parseGlbContainer };
//# sourceMappingURL=gltf-glb-parser-qVmUtFsl.esm.js.map