Say I’ve loaded a GLTF object such as a wall containing a door - I can animate the object using an AnimationMixer just fine. Now I want to do the same for the door’s physics.
The physics are a separate scene graph (I’m using Rapier3D as my physics engine, loading the Rust-based engine using Wasm). The “door” in this case is a Box object, which is defined by a center point and 3 half-sizes, which is fairly standard for most physics engines.
There are a couple of approaches I have thought of: first is to try and get the matrix for the visible door, decompose it into position and rotation, and then apply that to the physics object. A different approach would be to try and find the animation track for the visible door, and extract out the quaternion from that.
This is complicated by the fact that for performance reasons, the physics engine has no concept of a “Group”, so all transforms have to be in world space. Also, the physics engine has no concept of scaling (again for performance reasons), so transforms have to specified as a position + quaternion, not a full matrix. This makes the process of converting three.js transformations into physics transformations somewhat hard to visualize mentally, at least for me.
I’d be interested if anyone has any thoughts or advise on this topic.