raycasting on a mesh with altered vertices gives wrong point/distance?
See original GitHub issueHello,
First of all my hat off to you guys, your framework is amazing and I’m using it with love in my heart.
I have a terrain mesh which I need to raycast on to determine the walking height for my character. My terrain mesh consists of 16 planes (tiles) that are merged together and is located at (0,0,0). Since every tile needs a different texture I simply create a plane, give it a texture, translate it, alter the vertices height using a perlin function and merge it with the terrain mesh (using GeometryUtils.merge() )
I added the mesh and my character, and then I do a raycast like this:
var ray = new THREE.Ray( player.position.clone().addSelf( new THREE.Vector3(0, 50, 0) ), new THREE.Vector3(0, -1, 0));
var intersects = ray.intersectObject(terrainMesh);
if ( intersects.length > 0 ) {
However, the distance returned from intersects is always 50, even though the vertices from the terrain are raised! What am I doing wrong?
Thanks!
Issue Analytics
- State:
- Created 11 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Modifying a mesh's vertices with vertex shader doesn't change ...
Raycasting happens on the CPU. If you are going to displace vertices on the GPU (via the vertex shader), raycasting can' work correctly ......
Read more >Raycast against mesh with baked vertices - Babylon.js Forum
Hello, and I have been working on a scene whereby I would like to align some mesh instances to an imported GLTF model....
Read more >Geometry Queries — NVIDIA PhysX SDK 3.4.0 Documentation
A raycast query traces a point along a line segment until it hits a geometry object. PhysX supports raycasts for all geometry types....
Read more >Question - Get vertices of a face using Raycast? - Unity Forum
Then edit the noise values, and regenerate the mesh for that chunk / terrain tile. Other than that, RaycastHit returns you the triangleindex ......
Read more >Using the Raycast Node in Blender 3.0 and Beyond - YouTube
In this video, we revisit the Raycast node and check out how it actually ended up in Blender 3.0 final release with all...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If anyone else ever finds this - computeCentroids was dropped a long time ago. Also make sure
geometry.computeBoundingSphere()is run after altering the verticesAnswer from this StackOverflow question
Although, yeah … beware the non-planar quads!