Hi everyone,
I’ve created a small demo for making ragdolls with a blender mesh and rapierjs. However I am having an issue where the mesh seems to be scaled in a weird way that I cant find the cause of.
I have the following armature & Mesh in blender:
but when I activate the colliders to sync the mesh it ends up looking like this:
This leads me to think that the arm colliders are in the wrong orientation due to the weird looking mesh. However also the scaling of the mesh is off completely.
What i’ve tried so far:
- Check normals in blender
- Orient the bones in blender
- Rotate the rapierjs colliders initially to apply a 90C offset in +/- to see if it fixes
Has anyone had any similar issues applying rapierjs collider data to bone positions in threejs? Code + Blender file can be found here: rapierjs-ragdoll/src/Ragdoll.ts at 2dd492a0fc8e19d8e3473fe074d00e9f97fff195 · mattvb91/rapierjs-ragdoll · GitHub
Would appreciate any pointers.
The main pointer I can give is that this is a super finicky process, and full of nightmare fuel style bugs.
I ended up writing a whole rigid body exporter for blender to get my ragdolls to match up.. at least then I could do set it up in blender and test it there first before importing.
but for doing it in purely threejs I would say:
pause your simulation, and make sure that the cubes+bones are lined up perfectly first.. scale/adjust the skinnedmesh until it is lined up. (You may have to adjust your ragdoll rig too.)
Then on each rigidbody box, use .attach( to bind its corresponding skinnedmesh bone to it.
haha yup its definitely been finicky to get to this point. Thank you very much for the pointers will take a look and report back if I have any success
Threw claude at this and it managed to actually fix it pretty quickly:
The code is here: Fix blender mesh sync issue by mattvb91 · Pull Request #5 · mattvb91/rapierjs-ragdoll · GitHub
It now also uses the correct lengths of bones that are in the blender mesh. In future ill try to get it to parse them out automatically
It would be helpful for others if you explain the actual fix – what was wrong and how Claude resolved it.
Whoops the video upload failed the first time around and on refresh half of it went missing yea of course:
Key changes:
- Stop overwriting child bone positions. Only the root (
torso/spine) takes its position from physics; every other bone keeps its rest‑pose offset, which is what the skinning expects. This is the main deformation fix.
- Top‑down hierarchical iteration (
torso → head/limbs → extremities) so parents are updated before children.
parent.updateMatrixWorld(true) before reading parent world transform, and bone.updateMatrixWorld(true) after writing the bone, so each child sees the freshly‑updated parent.
- Stop mutating
bodyQuat in place with .multiply(initialQuat) — use bodyQuat.clone().multiply(initialQuat) so a future caller relying on bodyQuat won’t get a corrupted value.
- Dropped the dead
else branch’s broken math (bodyQuat.multiply(parentQuat) mixed world×world); it’s now parentInv * bodyQuat for symmetry with the initialQuat path.
As someone pointed out on the issue this might cause new issues now with IK vs FK rigs but ill cross that bridge when we get there.
Ive updated the demo here: Threejs ragdoll
Reddit user Interesting-Heron549 put together a great VR demo for this… awesome to see: