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) 921 B
import { ar as DV, T as ThrowLiteError, p as U8 } from './index-DMbDahsc.esm.js'; function parseGlbContainer(buffer) { const view = new DV(buffer); const magic = view.getUint32(0, true); if (magic !== 1179937895) { ThrowLiteError(103); } let offset = 12; const jsonLength = view.getUint32(offset, true); const jsonType = view.getUint32(offset + 4, true); if (jsonType !== 1313821514) { ThrowLiteError(104); } 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(105); } const binChunk = new DV(buffer, offset + 8, binLength); return { json, binChunk }; } export { parseGlbContainer }; //# sourceMappingURL=gltf-glb-parser-vjcPWLyX.esm.js.map