'How to calculate bvh axis angels in three.js?

I am currently writing bvh exporter for threejs, passing Skeleton and AnimationClip and it should returns a bvh string. I am now getting stucks at parsing keyframe datas to bvh’s motion session. From what I have gathered, the motion session consist of position of root, rotations offset from initial rotations( in euler angles) for each bones in every frame representing lines in order.

Two questions I have are: is it make sense for me to able to get the angle results from:

extracting a offset rotation quaternion from keyframetracks in a frame convert initial rotation of a bone, invert it and multipy it with the offset quaternion. If above is correct, how exactly will the syntax in three.js will be?

I am new to three.js and 3d computation, any feedbacks are much appreciated.

The repository: https://github.com/kayden1940/bvhLoader-testground

1 Red part is the part to be solve.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source