Jump to content

ArcRotateCamera.target different than FreeCamera.lockedTarget?


darcome
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...