I’m looking for a way to raycast against current scene geometry, without involving colliders. Eventually, I want to get the distance to the closest triangle from some point in space. Is there any way to do that?
My current approximate solution is to have a scene with somewhat evenly distributed vertices and then find the closest vertex to the point. But still, it introduces huge error when the point is located close enough to the geometry.
The other typical way of doing “raycasts” is to use the Scene Picker which lets you determine which mesh instance has been selected. This project has a good example of the two methods.
However, I don’t think entity picking willing give you the absolute depth from the camera. It will just tell you which meshinstance was clicked on. I’m not sure if you can pull out the distance from the depth buffer though.
@underlight - Did you get anywhere with this? I am trying to raycast onto a car so I can place a .obj where ever the user clicks. But it seems the only built in PC solution is to use a cube or sphere collider (pc.BoundingBox) which just will not be accurate enough. Perhaps I can use multiple bounding boxes somehow but that seems really wrong …
The latest way I am trying to do this is to surround the car with boxes and use pc.BoundingBox on each box to capture the click event and place the object. But the “intersectsRay” depending on the angle will sometimes go through both boxes and instead place the object onto the second box behind the car so I cannot do that.
I would much rather be able to just use the car mesh to capture the click events and let the user place an object on the car section that they have clicked. I did take a look at the ammo.js docs but there was nothing in there that I could use and I really would prefer to find a Playcanvas solution to this as I am sure there must be one.
The bounding box solution I mentioned in my last comment that @will provided works but unfortunately it creates a cube shaped object that the raycast hits. So it’s not very accurate for most cars when you try to select them from a side view. So I have just manually created a work around which is a pity as the demo I did for my company is not nearly as accurate as I am sure it could be. It sure would be nice to have an outline of the object that was a little more accurate. PS “After the flood” is quite amazing.