Jump to content

simple ray collision test?


AndyBeaulieu
 Share

Recommended Posts

I have read the basic tutorial for collision detection here - http://github.com/BabylonJS/Babylon.js/wiki/10-Object-collisions

 

But what I want to do is shoot a ray straight down in the Y from a one mesh and see where it intersects with a second mesh. The first mesh is a simple sphere, but I want to snap it to a second mesh that is has vertices data (elevations). 

 

So in this video here - http://www.youtube.com/watch?v=0S08faz1JpE&feature=youtu.be

... you will see a bunch of yellow spheres that appear above mesh tiles. I would like to snap those to the mesh tiles that are directly below them.

 

What is the best way to do this?

 

Thanks in advance!

Link to comment
Share on other sites

Sorry, I am not understanding pickWithRay...

 

Here is a simple jsbin - http://jsbin.com/eHEMaLUJ/2/edit?html,output

 

The sample has a sphere located at (0,20,0) and a plane located at (0,0,0).

 

I want to find the intersection point of a ray shot from the sphere straight down the Y, to the plane. So I do: new BABYLON.Ray(sphere.position, new BABYLON.Vector3(0, -500, 0));

 

I would expect the pickedPoint to be equal to where the ray intersects plane, but instead I get pickedPoint = (0, 19.96, 0).

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...