Hagop Posted January 29, 2017 Share Posted January 29, 2017 Hi all I have a free camera which has a mesh which in front of it which is 70 cm wide (x) and 110 cm length (z) with it's pivot point at the its center. Now I want this mesh to be constantly in front of my free camera when the camera is moving. The problem starts when I start to rotate the camera. I want the mesh to be in the center of the screen (in the direction of the camera) and at a fixed distance from the camera. Is that possible? Does it involve complicated math calculations? Would a followcamera do the job? cart.babylon Quote Link to comment Share on other sites More sharing options...
JohnK Posted January 29, 2017 Share Posted January 29, 2017 Have you tried parenting the mesh to the camera, its probably worth an attempt. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 29, 2017 Share Posted January 29, 2017 Why not use an arcRotateCamera. You can with this camera be in orbit around a mesh with a given distance. Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 29, 2017 Share Posted January 29, 2017 @JohnKs parenting suggestion seems pretty solid: http://www.babylonjs-playground.com/#P1YTR#0 gryff 1 Quote Link to comment Share on other sites More sharing options...
Hagop Posted January 30, 2017 Author Share Posted January 30, 2017 iiceman: Thanks, parenting solved my problem. I found out that after parenting the position of the parented mesh is relative to the parent camera and not absolute. If I have an ellipsoid on the mesh, should that be defined as relative to the parent camera? Is there a way of tracing the positions of an ellipsoid or seeing it visually? Quote Link to comment Share on other sites More sharing options...
iiceman Posted January 30, 2017 Share Posted January 30, 2017 I assume you are referring to this: https://doc.babylonjs.com/tutorials/cameras,_mesh_collisions_and_gravity -> 4 - Object vs. object collision ... right? I think the position is always relative to the mesh, because you set it as a property of the mesh. There was a short discussion about it that I remember: ...but with no real solution. I know that offset behaves strangely. What I did was just try different value and see what fits best. Maybe somebody else has a better idea. Would be great if it could be visualized somehow! (Maybe with @jeromes ribbon from the above link?) 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.