Jump to content

Increased Y axis on arcRotateCamera.target = moving mesh.


aWeirdo
 Share

Recommended Posts

Hi all,

i'm trying to find a good way to set a arcRotateCamera.target / setTarget() with an increased height on the Y axis, on a moving target..

right now, it "focuses" on the bottom of the mesh, i'd like it to focus on the top of the mesh, but changing the Y axis while still following the target isn't as easy as i'd hoped..

I've tried:

camera.target = movingMesh; // follows the target correctly, but the y axis focus is around ground level, at the bottom of the mesh.
camera.target.y += 5; // does nothing when target is set to a mesh as above^.

camera.target = new BABYLON.Vector3(movingMesh.position.x, movingMesh.position.y + 5, movingMesh.position.z); // now the Y axis looks good, but it doesn't follow the target..

camera.target = movingMesh.position; //follows the target correctly..
camera.target.y += 5; //Still focusing the bottom of the mesh, now the entire movingMesh is moved upwards on the Y axis by 5.. as if you set movingMesh.position.y += 5;

//Even tried editting the babaylonJs source code to apply the height change as target is being set. 
//but it also increase the Y position of the movingMesh instead of the target y axis of the camera..  

//same happens for camera.setTarget()..

I hope someone knows, or have a good idea as to how it can be done.

and preferably without adding it to any kind of loop if possible, i know it can be done by updating the target x/y/z or vector3 in registerBeforeRender, but it appears rather choppy sometimes, even at 60 fps it is notiseable.

 

PG: http://www.babylonjs-playground.com/#24IFYG

Cheers for any help and ideas!

Link to comment
Share on other sites

@adam 

Thanks for your reply, already tried that and it appeared alittle choppy on my scene from time to time,
But i suppose it will have to do for now, and copyFrom seems to work slightly better than mesh.position.clone() which i used.. better than before atleast :)

Cheers

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...