Ever load a 3D model and watch it disappear? No error, no crash, just nothing on screen.
That's what happened in my fork gdx-gltf-KHR, which adds support for glTF compression extensions like EXT_meshopt_compression and KHR_mesh_quantization. Static compressed meshes loaded fine, but as soon as I extended the pipeline to handle rigged, animated meshes, they went invisible. [
1]
Inspecting the raw vertex stream showed something odd:
Bone Attribute Layout -> 2 components
Vertex 0: Index=6.0, Weight=4.6006E-41 | bits2=0x803f
A weight of 4.6006E-41 is effectively zero. The vertex shader was multiplying the skinning transform by zero, so the mesh collapsed to a point. But why that number?
The cause: a manual read loop
The glTF binary spec requires all data to be little-endian. When the engine uses bulk array copies (asFloatBuffer().get()), the JVM handles byte order for you.
But bone weights need custom interleaving, so they were read element by element in a manual loop:
// The manual loop fallback path:
for(int i=0; i
A Java ByteBuffer read with .getFloat() defaults to BIG_ENDIAN unless you set the order.
The file stored a weight of 1.0f (bytes 3F 80 00 00). Read backwards as 00 00 80 3F, that became 4.6006E-41.
The fix
It belongs at the parsing layer. Set the byte order before any manual decode loop:
public float[] readBufferFloat(int accessorID) {
ByteBuffer bytes = prepareForReading();
// Force the stream to evaluate using Little-Endian order globally!
bytes.order(java.nio.ByteOrder.LITTLE_ENDIAN);
// Manual loop now evaluates 3F 80 00 00 flawlessly on any platform architecture
for(int i=0; i < count; i++) {
data[i] = bytes.getFloat();
}
return data;
}
The lesson:
when you move from bulk array copies to manual reads, byte order is no longer automatic. A single missing .order() can zero out your whole render. With it, the fork now handles both static and animated compressed meshes. [
1]