Problems with MyAvatar.getJointRotation()


I until now have problems with MyAvatar.getJointRotation;

What dos this function give back?
I set all joints to 0.0, 0.0,0.0, but get back other values with Quat.safeEulerAngles(MyAvatar.getJointRotation(joint));


Rotations are always Quaternions.

You have to remember its xyzw. 0,0,0 in euler is 0,0,0,1 quate.


@Menithal , I have already at our last discussion answered, that I set the pose as quaternions:

MyAvatar.setJointRotation(joint, Quat.fromVec3Degrees( rotation ));

But this doesn’t answer my question. Maybe you could try it out. Set all joints at 0,0,0,1 and read out Quat.safeEulerAngles(MyAvatar.getJointRotation(joint))


I have thought, that Myavatar.getJointRotation gives back the rotation together with the pre and post rotation.

So I have made the following test:

  1. Set all joints to rotation 0,0,0 -> Quaternions 0,0,0,1
  2. read in Quat.safeEulerAngles(MyAvatar.getJointRotation(joint)) for all joints. This values are not zero.
  3. Save this values and subtract them from Quat.safeEulerAngles(MyAvatar.getJointRotation(joint)) to get again the Zerorotation
  4. Set this rotation

saving and setting 1-> all dos work well

saving and setting 2-> already small differencies

saving and setting 3-> greater differencies

saving and setting 4 ->messed


Misunderstood the Original Post.

What you demonstrated there is most likely unintended, but a pretty good test.
So it does sound like while the joint rotations are set to 0, it doesnt set the pre-/post rotations. when you get the rotations it keeps the pre-post rotations set, so the rotation that retrieved via get is not correct.

When this is re-applied, the result is inconsistent, as the rotation is no longer 0. This keeps adding it self, until the above.


Yes, if I set the uncorrected the Quat.safeEulerAngles(MyAvatar.getJointRotation(joint)), so the pose is fully messed. If I subtract the first values, which I get, so at the first step it is nearly all zero. Now I set the corrected values again and step by step the Quat.safeEulerAngles(MyAvatar.getJointRotation(joint)) are more changed, because the Quat.safeEulerAngles(MyAvatar.getJointRotation(joint)) are not fully correct.


Here comes a new test. I have made an easy script, which only moves by click the LeftForeArm and prints out in the debug window the values, I set and get back from Quat.safeEulerAngles(MyAvatar.getJointRotation(“LeftForeArm”)).

var buttonImageUrl = “”;

var windowDimensions = Controller.getViewportDimensions();
var buttonWidth = 46;
var buttonHeight = 37;
var buttonPadding = 10;
var buttonPositionX = windowDimensions.x - buttonPadding - 3*buttonWidth;
var buttonPositionY = (windowDimensions.y -120);

var poseButton = Overlays.addOverlay(“image”,{
x: buttonPositionX, y: buttonPositionY, width: buttonWidth, height: buttonHeight,
subImage: { x: 0, y: buttonHeight, width: buttonWidth, height: buttonHeight},
imageURL: buttonImageUrl,
visible: true,
alpha: 1.0});

var rot= {x:0.0, y:0.0, z:0.0};
MyAvatar.setJointRotation(“LeftForeArm”, Quat.fromVec3Degrees( rot ));
var rot2=Quat.safeEulerAngles(MyAvatar.getJointRotation(“LeftForeArm”));
{ mouseLastX = event.x;
mouseLastY = event.y;
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});

if (clickedOverlay == poseButton)

MyAvatar.setJointRotation(“LeftForeArm”, Quat.fromVec3Degrees( rot ));
print(“set pose {x:” +rot.x +", y:" +rot.y +", z:" +rot.z +"},");
print(“Myavatar.getJointRotation {x:” +rot2.x +", y:" +rot2.y +", z:" +rot2.z +"},");

{ Overlays.deleteOverlay(poseButton);


What I have gotten from this is odd. I set the x values. But I get back changed z values.

set pose {x:5, y:0, z:0},
Myavatar.getJointRotation {x:-180, y:90, z:85.00028991699219},

set pose {x:10, y:0, z:0},
Myavatar.getJointRotation {x:-180, y:90, z:80.00028228759766},

set pose {x:15, y:0, z:0},
Myavatar.getJointRotation {x:-180, y:90, z:75.00029754638672},


Would be nice, if somebody could test it, but you must enable Rig animation (Developer->Avatar->enable Rig Animations) for this test. There could also be an error in my script, but I can’t find one.


Could you put the entirety of the script under double or triple
` ?

akin to

var test = "string"

would make it easier to copy paste later.


I’m not sure, what you mean @Menithal, but here is the link to the script. This may be the easiest way.

Today I see changes with interface 3388. The x values change now, how they should - y and z are not influenced.
The y values and z values changes in a mysterious way until now. So I change now in the script for testing the z values of the rotation.

In the changelogg I have read - fix agent avatar animation
Fix animation for ScriptableAvatar (ac agent), and provide a simple working example assignment client script.
Maybe this has brought the changes.