tbgeorge Posted May 13, 2016 Share Posted May 13, 2016 Hi all, I want to get some indicator arrows on the screen pointing to the location of different meshes when you're not looking at them. For example, there is a box in the world and when the camera is looking at it, there is nothing else on screen, but as soon as the box is off-screen, an arrow shows up on the edge of the screen, pointing me in the direction I need to rotate the camera so that the box is on screen again. I've figured out how to get different meshes screen position based off of their world positions, but I have no idea how I would draw the indicator arrows... Any help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
jerome Posted May 13, 2016 Share Posted May 13, 2016 imagine your arrow is a mesh that will point to the target : http://doc.babylonjs.com/classes/2.3/AbstractMesh#lookat-targetpoint-yawcor-pitchcor-rollcor-rarr-void Quote Link to comment Share on other sites More sharing options...
tbgeorge Posted May 13, 2016 Author Share Posted May 13, 2016 1 minute ago, jerome said: imagine your arrow is a mesh that will point to the target : http://doc.babylonjs.com/classes/2.3/AbstractMesh#lookat-targetpoint-yawcor-pitchcor-rollcor-rarr-void Yeah, I figured it would have to be a plane parented to the camera set to look at the specific mesh, but how would I go about positioning it on the edge of the screen? My initial thought was to have an invisible plane, directly in front of the camera that I can use to convert screen coordinates back into world coordinates, and place my arrow mesh at that location. I'm going to try that in a playground and post it back here. Quote Link to comment Share on other sites More sharing options...
tbgeorge Posted May 13, 2016 Author Share Posted May 13, 2016 http://www.babylonjs-playground.com/#IJA1L Here I have a plane in the example crate scene. I have it parented to the camera and looking at the box, but there are some problems with this: 1. The plane isn't affected if you move the camera around 2. I need it to only rotate on the camera's XY plane 3. lookAt ignores BILLBOARDMODE Quote Link to comment Share on other sites More sharing options...
tbgeorge Posted May 13, 2016 Author Share Posted May 13, 2016 http://www.babylonjs-playground.com/#IJA1L#1 UPDATE: Still working on getting rotation of the plane, but I think I got positioning down. Quote Link to comment Share on other sites More sharing options...
dbawel Posted May 15, 2016 Share Posted May 15, 2016 @jerome always has a good answer. And you might also use a canvas object with a seperate camera so you don't require any other testing or manipulation. Check out CastorGUI, bGUI, and the Dialogue extension for quickly creating the display arrows as canvas objects, as there are many advantages to this. and you should be able to query if an object is within the scene canvas. And for checking an objects position in the display, you can always do this by measuring the deltas between camera and object transforms - but I assume you already know this. Welcome to the forum. DB 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.