Hello everyone,
We are having problems with animations loaded from glTF when animation data is stored in interleaved buffer view (buffer view which has property byteStride
set and multiple accessors use that same buffer view).
The problem
The glTF scene is loaded fine, it looks OK until animation is started. When animation starts, whole model gets distorted.
Description
We store animation data (positions, rotations, scale values) in interleaved buffers. Buffer views have properly set byteStride
values, but looks like glTF loader does not check that value when loading data into accessor.
I checked animation data in BabylonJS viewer objects when the model is loaded (using Chrome dev tools) and it looks like there are wrong values loaded into animation data.
We have buffer view defined like this:
{
"buffer": 2,
"byteLength": 2560,
"byteStride": 40,
"byteOffset": 256
}
And then three accessors that use this buffer view look like this:
{
"bufferView": 9,
"byteOffset": 0,
"type": "VEC4",
"componentType": 5126,
"count": 64
},
{
"bufferView": 9,
"byteOffset": 16,
"type": "VEC3",
"componentType": 5126,
"count": 64
},
{
"bufferView": 9,
"byteOffset": 28,
"type": "VEC3",
"componentType": 5126,
"count": 64
}
I checked source code in glTFLoader.ts
and it looks like method _loadAccessorAsync(...)
calls loadBufferViewAsync(...)
, but neither of methods take bufferView.byteStride
property into consideration and they just load data directly from buffer into accessor._data
.
Example
Example for this issue is gltf file on dropbox (sorry, I am new user on forum, so I can only put two URLs):
-
ball_cube_three_buf.gltf
- anim_three_buf.bin
- ball.bin - www. dropbox. com/s/uhi0apx9lmpz7ul/ball.bin
- cube.bin - www. dropbox. com/s/sctpycnqxaop2x7/cube.bin
Other JS glTF libraries
I tried this same animation in vscode using glTF extension and different js libraries:
- babylon 4.1.0 - objects get distorted as described
- cesium 1.73 - animation works fine
- filament 1.8.1 - this animation works, but there are issues with similar gltf scenes
- three.js r120 - cannot even start the animation
Thank you,
Nikola