TRANSLATE shuffled coordinates

I am experimenting with moving objects using the “translate” command.
I have prepared a simple model where I manage to move a small sphere to the location where I click with the mouse: http://riccardorocca.github.io/home/Test_TRANSLATE.html

What I find odd is that from the mouse click I receive the coordinates [x,y,z], but in order to move the sphere to that same location I have to pass the coordinate as [x,z,-y].

The relevat lines of code are (lines 47-55):
api.addEventListener( ‘click’, function(info) {
if (info.instanceID) {
x_Ball = info.position3D[0];
y_Ball = info.position3D[1];
z_Ball = info.position3D[2];
api.translate(node_Ball, [x_Ball, z_Ball, -y_Ball]);
}
},
{ pick: ‘slow’ });

Any idea why I have to shuffle the coordinates this way?

Thank you,

Riccardo

The transformation are done in the local space of the node, so if one of the node above has a transform (like a rotation), you local space is “transformed”.
Thus, If you want to avoid “shuffling”, the model needs to have no other transformation above.

In your scene graph , there is 2 transform above each object:

( that cannot be done in sketchfab, you need to check in you 3d modeler )

1 Like

Thank you for the hint, Paul.
I had exported the model from Blender.
Now I have figured out the settings to export it properly.
In the “Export FBX” menu, I have set “Forward: -Y Forward” and “Up: -Z Up”, as in the snapshot:

Captura

3 Likes

Nice, Thanks for the followup and sharing the solution!

2 Likes