fenomas Posted April 20, 2015 Share Posted April 20, 2015 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.) Quote Link to comment Share on other sites More sharing options...
darcome Posted April 20, 2015 Author Share Posted April 20, 2015 yeah!!!! It works! I think I only had to press F5!!! Thank you very much Fenomas! In he end your suggestion of using a container works like a charm!! Thank you again! fenomas 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted April 22, 2015 Share Posted April 22, 2015 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 pressedthen systematically :rotationZ += deltaZrotationX += deltaXthen systematically rotate the mesh both on Z then Xtorus.rotation.z = rotationZ;torus.rotation.x = rotationX; it should work imho with no parent intermediate mesh Quote Link to comment Share on other sites More sharing options...
fenomas Posted April 22, 2015 Share Posted April 22, 2015 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) Quote Link to comment Share on other sites More sharing options...
jerome Posted April 22, 2015 Share Posted April 22, 2015 ok I guess the BJS engine has its own order and doesn't respect any user order ... so my solution wasn't goodyou're right let's go on with quaternions or intermediate mesh Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted April 22, 2015 Share Posted April 22, 2015 : http://www.babylonjs...d.com/#1PM4XG#8 realy ? r u checked this for best answerd in this solution box is not rotate !! cannonjs is fix that . http://schteppe.gith...gidVehicle.html Quote Link to comment Share on other sites More sharing options...
darcome Posted April 22, 2015 Author Share Posted April 22, 2015 I checked it because what fenomas writes in that post is the correct answer: I have to use a container mesh Even if the PG doesn't seem to work Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.