Skip to main content

GLB writer

Pack application data into one binary envelope.

GLBWriter writes the GLB container around JSON and binary chunks. Use GLTFWriter when the input is a scenegraph and the writer should perform glTF-specific assembly; use this writer for direct envelope control.

The GLB writing boundary

Start with JSON and bytes. Produce one portable file.

The writer owns container headers, chunk alignment, and binary packing. It does not attempt to turn arbitrary data into a complete glTF scenegraph.

Input

GLB-compatible JSON and binary data

Packing

JSON chunk plus optional BIN chunks

Version

GLB v2 output

Output

One encoded ArrayBuffer

Detailed guide

Writer and envelope details

The reference below covers usage, supported APIs, output shape, version limits, and when GLTFWriter is the better entry point.

The GLBWriter is a writer for the GLB binary "envelope" format.

Note: applications that want to encode GLB-formatted glTF files should normally use the GLTFWriter instead. The GLBWriter enables applications to save custom data that combines JSON and binary resources.

GLBWriter
File Extensions.glb
File TypeBinary
Data FormatSee below
File FormatGLB v2
Supported APIsencode, encodeSync

Usage​

import {GLBWriter} from '@loaders.gl/scene/gltf';
import {encodeSync} from '@loaders.gl/core';

const arrayBuffer = encodeSync(gltf, GLBWriter, options);

Options​

OptionTypeDefaultDescription
N/AN/AN/AN/A

Data Format​

See GLBLoader.

Remarks​

  • While the GLBLoader supports reading both GLB v1 and v2, only GLB v2 can be written.