I am using https://github.com/KhronosGroup/glTF-Blender-Exporter in a script and trying to compare the exported rotation values. But none of them seem to match. Ie. for exported values in the gltf file such as :

"rotation": [0.7071068286895752, 0.0, 0.0, 0.7071067094802856]

the exported object in blender has the following values:

---> OBJECT ROTATION QUATERNION: <Quaternion (w=0.3715, x=0.6323, y=0.4318, z=-0.5251)>
---> OBJECT MATRIX LOCAL: <Quaternion (w=0.3715, x=0.6323, y=0.4318, z=-0.5251)>
---> OBJECT MATRIX WORLD: <Quaternion (w=0.3715, x=0.6323, y=0.4318, z=-0.5251)>

while exporting, the settings are set to export_yup=False so I guess no other transformation should be involved?

  • $\begingroup$ it seems that the tool exports raw matrix data instead of converting it to quaternions. The only true way is to find this piece of code in the source, and read it out. $\endgroup$ – Mechanic Nov 24 '18 at 23:01

I'm not seeing exactly the same issue. If I take the default Blender cube and rotate it, and look at the quaternion on the UI, this is what I see:

Blender screenshot

In glTF, the order of the quaternion's components is different. Blender is showing [W, X, Y, Z], but in glTF they are expressed as [X, Y, Z, W].

Thus, my exported cube (with export_yup turned off) looks like this:

VSCode screenshot

These are the same numbers, it's just that W has moved from the front to the back of the array.

Your example shows completely different numbers. There can be various reasons for this, including parent hierarchy and "parent inverse" transforms. But there's another potential explanation, too: The node orientation is being handled as matrices, not TRS (Translation, Rotation, Scale), in the exporter, and each matrix is being decomposed into TRS during the export process (source code). If the node's matrix happens to have more than one way to decompose into TRS, it's possible the decompose function will pick some other quaternion from the one you were expecting. But the end result should still work the same.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.