GlbReader

object GlbReader

Reads a glTF 2.0 binary container (GLB) blob into its JSON chunk + BIN chunk. The format:

Bytes 0..3   : magic = "glTF" (0x46546C67)
Bytes 4..7 : version (uint32 LE) = 2
Bytes 8..11 : byteLength (uint32 LE)
Then N chunks, each:
chunkLength (uint32 LE)
chunkType (4 bytes ASCII; "JSON" = 0x4E4F534A, "BIN\0" = 0x004E4942)
chunkData (chunkLength bytes)

The first chunk is always JSON; the second (when present) is BIN. Any further chunks are extensions and ignored.

Throws IllegalArgumentException on a structural mismatch — callers (the b3dm/i3dm loaders, the 3D Tiles 1.1 GLB content path) translate that into a logged failure on the tile.

Types

Link copied to clipboard
class Decoded

Decoded GLB payload. binChunk is null when the asset has no BIN chunk (rare — only happens for JSON-only assets that reference external buffers via URI, which we don't support inside 3D Tiles content).

Functions

Link copied to clipboard
fun parse(bytes: ByteArray, offset: Int = 0, length: Int = bytes.size - offset): GlbReader.Decoded