Skip to main content

GLBLoader

The GLBLoader parses a GLB binary "envelope" extracting the embedded JSON and binary chunks.

Note: applications that want to parse GLB-formatted glTF files would normally use the GLTFLoader instead. The GLBLoader can be used to load custom data that combines JSON and binary resources.

LoaderCharacteristic
File Extensions.glb
File TypeBinary
File FormatGLB v2, GLB v1 *
Data FormatSee below
Supported APIsload, parse, parseSync

* From Website shields.io, the GLBLoader can also load GLB v1 formatted files, returning a normalized GLB v2 compatible data structure, but with the version field set to 1.

Usage​

import {load} from '@loaders.gl/core';
import {GLBLoader} from '@loaders.gl/gltf';
const gltf = await load(url, GLBLoader);

Options​

OptionTypeDefaultDescription
glb.strict (DEPRECATED)BooleanfalseWhether to support non-standard JSON/BIN chunk type numbers.

Remarks:

  • Parses GLB v2 encoded data.
  • Parses GLB v1 encoded data (enabling support for the glTF v1 KHR_binary_gltf extension). Parsed GLB v1 data is returned in the standard GLB format.
  • Extracts multiple binary chunks if present (this is supported by the GLB specification but is not used in the glTF specification).

Data Format​

Returns

{
"header": {
"byteLength": number,
"byteOffset": number
},

"type": string,
"version": number,

// JSON Chunk
"json": any,

// BIN Chunk
"hasBinChunk": boolean,
"binChunks": [
{
"arrayBuffer": ArrayBuffer,
"byteOffset": Number,
"byteLength": Number
}
]
}
FieldTypeDefaultDescription
typeStringglTFString containing the first four bytes of the file
versionNumber2The version number, only version 2 is supported
jsonObject{}Parsed JSON from the JSON chunk
binChunksArrayBuffernullThe binary chunk
binChunks[\*].arrayBufferArrayBuffernullThe binary chunk
binChunks[\*].byteOffsetNumbernulloffset of BIN (e.g. embedded in larger binary block)
binChunks[\*].byteLengthArrayBuffernulllength of BIN (e.g. embedded in larger binary block)
header.byteLengthNumber-length of GLB (e.g. embedded in larger binary block)
header.byteOffsetNumber0offset of GLB (e.g. embedded in larger binary block)