question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

raycasting on a mesh with altered vertices gives wrong point/distance?

See original GitHub issue

Hello,

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:closed
  • Created 11 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
DustinJSilkcommented, May 25, 2017

If anyone else ever finds this - computeCentroids was dropped a long time ago. Also make sure geometry.computeBoundingSphere() is run after altering the vertices

Answer from this StackOverflow question

0reactions
aaaidancommented, Feb 7, 2013

Although, yeah … beware the non-planar quads!

THREE.GeometryUtils.triangulateQuads( geometry );
Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found