aWeirdo Posted May 8, 2016 Share Posted May 8, 2016 Hi guys, i'm working on a right-click to move mesh system and within that, a rotation of the mesh first, (mesh rotates slowly towards destination, and then start moving.) Got it working "ok", it uses the lowest angle of rotation, except, when going from high rotation point to a low, and vice versa, if the mesh.rotation.y is at 350 degree's and you want to rotate towards lets say 5 degree's, instead of jumping 350 -> 360 -> 5. it starts turning the long way around (350-) and i'm not sure how to handle it best. which is why i'm posting this topic, hoping someone can help me out while i'm having a brainfart.. PG: http://www.babylonjs-playground.com/#CZRC0#0 rotation is controlled by right-clicks, the sphere to the left of the box is around 360 / 0 degree's, try clicking below it, then above it to see the issue. then try doing the same on the right side of the box to see how it's supposed to act^^ Cheers. Quote Link to comment Share on other sites More sharing options...
adam Posted May 8, 2016 Share Posted May 8, 2016 http://www.babylonjs-playground.com/#CZRC0#1 aWeirdo 1 Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted May 8, 2016 Author Share Posted May 8, 2016 @adam Thank you that was bugging me so bad.. really apreciate the help one minor error though, notised when i put it together with my movement, (hard to spot with a square box lol). it was using the wrong angle^^ Quote var ang = -Math.atan2(rt1.z, rt1.x) - Math.PI / 2; updated PG for anyone who might be doing something simular in the future. http://www.babylonjs-playground.com/#CZRC0#2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 8, 2016 Share Posted May 8, 2016 Cool subject, guys. Nice troubleshooting, Adam. Would one or both of you... please test our mesh.lookAt(somemesh.position) and make sure it uses "shortest rotation direction", too? Oh wait... that is instantaneous, so I guess it doesn't apply. Nevermind. As long as we don't accidentally invent animateToLookAt(), we're fine. What's that you say? Weirdo just now invented it? On no! Way to go, aW! Now we're all screwed. @iiceman is dirty-hands in this, also. He did some animate-rotation-to-click-spot back in the 40's... on a little space ship. Yeah, you thought we had forgotten about that, eh Ice? Quote Link to comment Share on other sites More sharing options...
iiceman Posted May 8, 2016 Share Posted May 8, 2016 Seems like you already found a solution @Wingnut, Yeah, I remember that... I think that was my latest result: http://p215008.mittwaldserver.info/space/ There is a playground somewhere where I tried a lot of stuff. I think it all works well as long as you stick to rotating around 1 axis. As soon as I tried to rotate simultaneously around a second axis everything fell apart. jerome and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 8, 2016 Share Posted May 8, 2016 Oh yeah, that's right. Good memory, Ice! Yuh yuh yuh, rotation... maybe the #1 forum topic. Oh how I wish we had "The Ultimate Interactive Rotation WorkLab". Upper 2/3 screen has the renderCanvas, lower 1/3 has nothing but knobs and dials... to learn localSpace, worldSpace, maybe even teach matrix transforms. It'd be like our rotation tutorials/overviews... coming alive. *sigh* What a dream-come-true that would be. But oh, how to design and implement. Erf. Everything is fine... until we add a camera to the scene. I have a difficult time maintaining an orientation in REAL LIFE, speak nothing of doing it in projective geometry. 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.