Leenzur Posted June 7, 2014 Share Posted June 7, 2014 Hi everybody and welcome to my first topic in this forum ! Firstly, a lot of thanks for babylon's js developpers.Secondly, I'm a french newbie in developpment, 3D and in english language, so please, use not too much complicated words .My question is... is there a solution to know 2D position of a 3D mesh rendered on the canvas ?My aim is to render a sprite on the screen which represent a circle of selection around the mesh after picked it. Maybe a better solution than sprites already exists and i'm open to suggestions. In advance, thank you for your replies . JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 7, 2014 Share Posted June 7, 2014 Hi, welcome. You can pick which allows you to retrieve the item click a ground for example var pickInfo = ground.pick(evt.clientX, evt.clientY);var x = pickInfo.pickedPoint.x;var y = pickInfo.pickedPoint.y;var z = pickInfo.pickedPoint.z;sprite.position = new BABYLON.Vector3(x, y, z);In 2D you just need x and y JackFalcon and Leenzur 2 Quote Link to comment Share on other sites More sharing options...
Leenzur Posted June 7, 2014 Author Share Posted June 7, 2014 I just tried your code dad72 and it works very well, thank you .This result brings me to an other question.I'm in a 3D scene, and i would like the sprite always render in 2D independently of the 3D scene, like a layer 'on' the canvas and not 'in' the 3D scene. Or just always make if face the camera (even if i think this method could be very difficult to make or calculate with matrices). Difficult for me to explain sorry, but have you any idea ? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 7, 2014 Share Posted June 7, 2014 So a face always face object has the camera you have:sprite.lookAt(camera.position);You may learn more by looking in the documentation. Leenzur 1 Quote Link to comment Share on other sites More sharing options...
Leenzur Posted June 7, 2014 Author Share Posted June 7, 2014 Work like a charm ! This library is very powerfull !I'll take look at the documentation now Thank you very much for your help and your time dad72 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted June 7, 2014 Share Posted June 7, 2014 You are welcome. Yes babylon is extraordinary. you will have lots of fun with. Leenzur and GameMonetize 2 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.