darcome Posted April 17, 2015 Share Posted April 17, 2015 Hello everyone! I just created a playground http://www.babylonjs-playground.com/#2KEJW6 to ask a question... The two cameras I created, should be the same, right? Same position and same target (they both have the sphere as the target) So, why are they different? You can see it by clicking on the playground and then press Z key and X key and you see the difference the target property is computed differently for both cameras? What I want to achieve is to use the ArcRotateCamera targeting an object till the user press a certain key, then use a FreeCamera which will follow the same object moving around Please, help me! Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 17, 2015 Share Posted April 17, 2015 Hi, so the problem is the order in which you are executing the functions.The setPosition function of an arc rotate camera is using the camera's target to set the camera's position correctly. if you run the setPosition before setting the target, the position of the camera will not be the same as the position of the FreeCamera you set earlier.Two solutions: http://www.babylonjs-playground.com/#2KEJW6#2 - run it in the correct order http://www.babylonjs-playground.com/#2KEJW6#1 - set the sphere as the target in the constructor already. In both solutions pressing x and z provide the same results. Quote Link to comment Share on other sites More sharing options...
darcome Posted April 17, 2015 Author Share Posted April 17, 2015 Thank you very much for the answer! One more question... How am I supposed to know what is the right order to call the functions? Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 17, 2015 Share Posted April 17, 2015 :-)That's a good question. In this case you will need to look at the code, or understand that the setPosition function requires the target. ArcRotate doesn't have a position parameter. it needs to be calculated. and the target is one of the needed parameters. 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.