xeroxM Posted May 5, 2018 Share Posted May 5, 2018 Hey Guys, first of all, I want to thank you for your great work in this forum, you really saved me a lot of time wanting to flip tables But now i found something, what is driving me nuts for already two weeks. So I am trying to develop a viewer for 3D objects which has, broken down on the most important things, two cameras which you can change. Those cameras happen to be the ArcRotateCam and the UniversalCam. What I want to happen is, that if the user clicks a button the camera changes (this already works fine), I also want both cameras to have a default position where they "start" (which they already have) and I want the camera to always be at the right position with the right angle (the default position/angle i set with initalizing them) when the user changes to the selected cam (this is where something odd is happening). So let's take this case: - User uses ArcRotate Cam, moves the camera and wants to change to Universal Cam. - User clicks the button and changes to Universal Cam -> Universal Cam is set to default position and default angle as its supposed to be. - User moves Universal Cam - User wants to change to ArcRotate Cam again and clicks button -> result: camera is not in default mode but there is some odd camera movement going on and camera is somewhere else. - If the user now moves the ArcRotate Cam again and changes to the Universal Cam, the camera moves away from the target, instead of being directly on it. I hope I described my problem properly and I really hope you got some answers. I broke the problem down in a Playground for you: http://playground.babylonjs.com/#P5PWBB There may be something missing cause I really broke the camera module down on the most important things. So if something is not clear, let me know! All the best! xeroxM Quote Link to comment Share on other sites More sharing options...
xeroxM Posted May 5, 2018 Author Share Posted May 5, 2018 Oh this might be important: If you initialize the cameras again, this problem ain't happening. But i really don't want to reinitalize them. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2018 Share Posted May 6, 2018 You had an error Vector3 undefined, line: 95 and 113 It seems to work here: (on google chrome) http://playground.babylonjs.com/#P5PWBB#2 Quote Link to comment Share on other sites More sharing options...
xeroxM Posted May 6, 2018 Author Share Posted May 6, 2018 You're right, i forgot to define Vector3 there, but thats just some copy/paste error from my orignial code. The odd camera movement sadly still occurs ? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 6, 2018 Share Posted May 6, 2018 Ok, I saw the problem now. I have no idea why this is happening. ? Quote Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2018 Share Posted May 10, 2018 Can you make sure to call detachControl on a camera when it is no more active? xeroxM 1 Quote Link to comment Share on other sites More sharing options...
xeroxM Posted May 10, 2018 Author Share Posted May 10, 2018 @Deltakosh this was the real deal! Thank you so much! http://playground.babylonjs.com/#P5PWBB#3 Quote Link to comment Share on other sites More sharing options...
Guest Posted May 10, 2018 Share Posted May 10, 2018 Good job 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.