In my game I use a custom terrain (generated from heightmap) intersection method that performs very well. Intersecting the terrain geometry itself is extremely slow so I built this as an alternative.

Basically what I’m doing is determining which terrain “face index” an object is on, grabbing the correlating vertices from the terrain geometry and constructing a THREE.Plane object that is set via the referenced co-planar points and intersecting with that.

In most cases this method works great, but on more extreme slopes it kind of breaks down as demonstrated below:

These are a couple in-game screens showing this effect. The triangle patterns on the slopes indicates to me that I may be making a mistake. Only half the “face” is working.

I’ve been actually looking for a slope terrain sliding function, based on X-Rotation Angle. Would be great if a very simple example could be put out. Thanks alot & have a great easter!

The idea is to compute the distance from the mesh position to the plane and then subtract this value from the y-component of ball.position. But before doing this, you multiply the distance with a value lower than 1 (e.g. 0.2) in order to have a smooth transition.

Note: At the beginning, the ball moves from (0, 0, 0) onto the plane. This can be avoided if you directly assign a valid start position when the mesh is added to the scene.

I’m not sure I understand your raycasting code in intersectTerrain() so I just compute the distance to the plane via Plane.distanceToPoint() which should be a good approximation. It’s also faster than a raycast. The approach is not a perfect solution but it might be sufficient for certain use cases.

Very nice! Perfectly smooth and much more performant!

There are certainly use cases that I will use this for.

Unfortunately for my grass positioning, I really needed that accuracy (which is too bad because load time was much better with your method).

The triangle pattern clue checked out and ultimately revealed the incredibly obvious mistake I was making. I was only checking half the face and completely ignoring the fact the the other triangle within the face could (and likely does) have a much different orientation. Now I make sure that the indices I use to set the intersect plane are from the triangle that the object is actually within.