Robbie Lewis Posted March 14, 2016 Share Posted March 14, 2016 Hey guys, This is my first Babylon.js project, really enjoying it so far! I've found answers to all my questions on this great forum, except for one. I've created a 5x5x5 grid using lines and I'm placing blocks within the space using a cursor. I'm using an ArcRotateCamera to pan around the grid. I'm using the num pad arrows to move the cursor around within the 3d grid and insert/delete to add/remove blocks. See image attached if it helps. The problem is, when I rotate 180 degrees around my grid, the left num pad arrow now moves the block right from the cameras perspective. What I need to do is calculate the direction the ArcRotateCamera is facing and affect the cursor accordingly. I have experimented with the Alpha property of the camera, but the numbers it gives make no sense! A full rotation of the ArcRotateCamera gives a value of around 6.25. This confuses me, I would expect the alpha to be in degrees? How can I calculate the direction the camera is facing? (I only care about the alpha plane for this particular problem) Quote Link to comment Share on other sites More sharing options...
MarianG Posted March 15, 2016 Share Posted March 15, 2016 Hi Robbie. You can calculate direction using this piece of code: camera.direction = BABYLON.Vector3.Normalize(camera.target.subtract(camera.position)); Boz 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted March 15, 2016 Share Posted March 15, 2016 You should consider using a LineSystem (BJS 2.4+) instead of different Lines for a grid http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem 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.