QVignaud Posted July 21, 2017 Share Posted July 21, 2017 Hi everyone! I have actually a problem which is quite stupid but I really need help to solve it: I have a sphere (position 0,0,0) on which I want to "put" a mesh. I have a ray coming from the center on the sphere to a point somewhere in space, and want to put the mesh on the sphere surface, oriented to the center of the sphere, as if the sphere was a planet. I don't find anything in order to rotate a mesh from a ray in Babylon, and all the tries I do with a trigonometric approach aren't satisfying… Here is the code doing that: http://www.babylonjs-playground.com/#C1M3C7 Thanks for your help! Quote Link to comment Share on other sites More sharing options...
jerome Posted July 21, 2017 Share Posted July 21, 2017 http://doc.babylonjs.com/overviews/how_rotations_and_translations_work#generating-a-rotation-from-a-target-system GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
QVignaud Posted July 24, 2017 Author Share Posted July 24, 2017 Thanks a lot for your answer! However, there is a last problem to fix… Actually I don't understand how to make the up of the mesh pointing to the outside of the sphere, all my tries have weird results with positions where the corner is inclined and not straight up from the center? On that base code the mesh is currently "lying" on the surface, I have to make it stand up to the sphere: http://www.babylonjs-playground.com/#C1M3C7#1 Quote Link to comment Share on other sites More sharing options...
jerome Posted July 24, 2017 Share Posted July 24, 2017 this way ? https://www.babylonjs-playground.com/#C1M3C7#2 Quote Link to comment Share on other sites More sharing options...
QVignaud Posted July 24, 2017 Author Share Posted July 24, 2017 Yes this is one of the things I tried, but at some positions the corner is still strangely inclined… Quote Link to comment Share on other sites More sharing options...
adam Posted July 24, 2017 Share Posted July 24, 2017 https://www.babylonjs-playground.com/#C1M3C7#3 jerome 1 Quote Link to comment Share on other sites More sharing options...
QVignaud Posted July 25, 2017 Author Share Posted July 25, 2017 That's exactly that, thanks @jerome and @adam ! 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.