Chevron Down
Table of Contents
Chevron DownAPI Reference

GLBLoader

The GLBLoader parses a GLB binary "envelope".

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

LoaderCharacteristic
File Extensions.glb
File TypeBinary
File FormatGLB
Data FormatSee below
Decoder TypeSynchronous
Worker Thread SupportNo
Streaming SupportNo

Usage

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

Options

OptionTypeDefaultDescription
magicNumberglTFThe magic number to be save in the file.

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)