DracoDecoder

interface DracoDecoder

Pluggable codec for Draco mesh compression (KHR_draco_mesh_compression glTF extension).

The engine has no built-in Draco decoder — Draco's algorithm is ~50K LOC of C++ (edge- breaker connectivity + ANS entropy coding + quantized attribute prediction) and a real decoder ships as a native library per platform. Apps that need to render Draco- compressed 3D Tiles (Google Photorealistic 3D Tiles, many Cesium Ion photogrammetry assets) wire in a platform-specific implementation by setting GltfDecoderRegistry.dracoDecoder once at startup.

Implementations are expected to be:

  • Thread-safe: GltfReader.parse is called from background coroutines, potentially in parallel for different tiles.

  • Stateless between calls: each decode runs against fresh input and produces fresh output; no setup/teardown across decode calls.

  • Fast: decode runs on every tile fetch on the streaming hot path; native implementations should reuse internal buffers.

Typical app-side wiring:

GltfDecoderRegistry.dracoDecoder = MyJvmDracoDecoder() // JNI-backed

When no decoder is registered, GltfReader logs once per tile + skips the Draco-encoded primitive (its vertices are unavailable; nothing visible from that primitive will render).

Functions

Link copied to clipboard
abstract fun decode(compressedBuffer: ByteArray, attributeIds: Map<String, Int>): DracoMesh

Decode a single Draco-compressed primitive into vertex / index arrays.