RobinHood Posted February 25, 2018 Share Posted February 25, 2018 How do I lock position of object when using arc camera, I want to lock it to upper right of the screen. If possible please also tell me the principle/math behind your answer. I tried this http://www.babylonjs-playground.com/#21IMDW#1 but it does not work for arccamera. Thank You. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted February 25, 2018 Share Posted February 25, 2018 Hiya RH, welcome to the forum. Here ya go... https://www.babylonjs-playground.com/#21IMDW#12 A little parenting in line 17... seems to do the trick. Quote Link to comment Share on other sites More sharing options...
RobinHood Posted February 25, 2018 Author Share Posted February 25, 2018 But now it doesn't rotate at the same place, I just want to restrict its position and not rotation. Here is my attempt, but does not work properly, https://www.babylonjs-playground.com/#ZD2U7J Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 26, 2018 Share Posted February 26, 2018 Hi @RobinHood, I hope your charity work never stopped. So, what @Wingnut showed you is exactly the demo you showed in your first message, but with an arc rotate. Parenting would be the idle candidate for lock an object in relation to the camera (or any other node). If you want to lock the object in front of the camera in a certain position, you can use the camera's direction and move the mesh along this axis. For example, this way - https://www.babylonjs-playground.com/#21IMDW#14 . The fact that the mesh jitters needs to be checked (I will add an issue and we'll see when we address this), but in general, this would be IMO the right way to go. (BTW - any target camera (like the arcrotate) has the function getFrontPosition which can help here - https://www.babylonjs-playground.com/#21IMDW#15. again, same issue, we will see what can be done) 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.