Jump to content

Rotation question


darcome
 Share

Recommended Posts

I deleted the workaround and if you use WASD you see the front wheels don't move with the car :(

 

Dunno, works for me. Clear your cache?

 

 

@fenomas

 

main question is this

 

1. rotate x axis ( world or local)

2. rotate y or z axis  ( world or local)

 

how can back to rotation state befor step 1

 

There's no easy way to "undo" Euler angle rotations. That's basically why people use quaternions. ;)  But for things like cars and wheels it's way easier to use multiple meshes and Euler angles (i.e. use mesh.rotation.x, not mesh.rotate(x,y,z)). 

 

 

(Note: I haven't actually used BJS quaternions, I'm just assuming they work in the standard way.)

Link to comment
Share on other sites

Reviewing your PG, I am wondering if there is a simpler way to do.

Imho, the problem is you don't apply local rotations the same way each time (remember : rotations aren't commutative) :

- once only X, once only Z, depending upon the key pressed event

 

I would test this :

 

first, set two var rotationX and rotationZ

 

then in the render loop :

check keys, set two rotation deltas X and Z, this deltas can be zero if nothing pressed

then systematically :

rotationZ += deltaZ

rotationX += deltaX

then systematically rotate the mesh both on Z then X

torus.rotation.z = rotationZ;

torus.rotation.x = rotationX;

 

it should work imho with no parent intermediate mesh

Link to comment
Share on other sites

Jerome, when you use euler angles (rotation.x/y/z) you don't have to track state that way. Conceptually, each mesh starts each frame in an unrotated state and then BJS applies its rotation.x/y/z values in some given order. So it doesn't matter when/how you set the values. As for the intermediate mesh, it's there to let you control the order in which the wheel's rotations are applied, You might get by without it if the order you need happens to be the order BJS uses, but in general you need an intermediary. (unless you're using quaternions)

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...