Project

General

Profile

Bug #125

Updated by Josip Almasi over 1 year ago

Babylon 5 introduced undocumented breaking changes to gltf character structure.
Some explanations are found in following babylon forum threads:
https://forum.babylonjs.com/t/inconsistent-gltf-bone-transformations/29358
https://forum.babylonjs.com/t/gltf-parsing-is-creating-doubles-and-reparenting-meshes/30079/18

Bottom line, vrspace client heavily relies on Bone.getAbsolutePosition() which now works differently.
Differences include poorly documented parameters, but also need to call computeWorldMatrix(true) on TransformNode associated with the bone after e.g. resizing.

One critical fix for head position was applied right away: https://github.com/jalmasi/vrspace/commit/d1c366159d5b7a019ae7ad72da4dc54fda50cb8a
But this quick fix breaks down everything in XR, as it calls Scene.render() to ensure that getAbsolutePosition() retrieves valid coordinates, and calling Scene.render() in XR is inheritly unsafe.
First thing to fix here is get rid of Scene.render, and use getAbsolutePosition() of head Bone rather than TransformNode, calling computeWorldMatrix if appropriate, as appropriate.

Second thing is to figure out is the orientation of arm and leg bones, required for IK. I.e. around which local axis to apply rotation to move an arm to desired direction.
Avatar class tries to do that in guessRotation and tryRotation methods, by applying rotation in every direction and measuring bone coordinates.
This is definitely the wrong way to do it. This can and should be calculated, I just don't know how.
It was good enough as it's done only once per character, but it doesn't work any longer.
Testbed: https://www.vrspace.org/babylon/avatar-test.html
For example lisa, tiffany, blake_fbx, legendary_robot all rotate in all the wrong ways.

EDIT there's another one: https://forum.babylonjs.com/t/thininstanceadd-incorrect-z-position-on-imported-models-vs-babylon-primitives/33124

Back