Jump to content

[SOLVED] Mesh rotation around world axis (problem)


jmb462
 Share

Recommended Posts

Hi here,

I've got trouble with mesh rotation around an axis.

Thanks to this forum, i've found a function that manage the rotation around an axis but it doesn't give me the result i'm expecting.

I want to rotate a box around the world Y axes then the world Z axis.

If I do only rotation around Y or around Z, every thing is working.

But when I do a rotation around Y then around Z, the box rotates correctly around the axis BUT spins around its own center with the same angle.

(as the earth that spin while doing its revolution around the sun...)

Here is a playground (the small cube is the reference). I'd like the big cube keep the same orientation as the small one (without parenting).

http://www.babylonjs-playground.com/indexStable.html#DVUAAQ#2

As far I understand, it's seem to be a local / global axis probleme when using the rotation around axis.

Because, if I choose LOCAL for the small one, it gives me the same result that the big one.

But I want global axes (thoses who are shown in the playground).

 

Thanks for any help or idea.

Hope my english is understandable ;)

JMB

Link to comment
Share on other sites

Hi @jmb462 if you have not done so already I suggest you read the following documentation pages

http://doc.babylonjs.com/babylon101/position

http://doc.babylonjs.com/features/position,_rotation,_scaling

http://doc.babylonjs.com/how_to/pivots

http://doc.babylonjs.com/how_to/pivot

http://doc.babylonjs.com/resources/rotation_conventions

From your earlier post I see that you are "planning to make a rubik's cube with babylon. I'm new to babylon and javascript ."  A challenging task - good luck.

Link to comment
Share on other sites

@Gijs Thanks a lot ! That's now working fine. ?

@JohnK Thanks too for the links. I've read several times these pages but I didn't manage to find the problem. I'm surely lacking some knownledge too fully understand some 3D parts.

My cube is now functional.

http://jmbernard.com/cube5/

(Controls are keyboard with standard cube notation (R L U D B F and so) with shift for anticlockwise moves.

I can now implement other function but this 3D rotation programming part was the trickiest part for me I think.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...