Jump to content

[Solved] Orientation of a mesh on a sphere


QVignaud
 Share

Recommended Posts

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!

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...