I have created a terrain geometry using this JavaScript code:
var geometry = new THREE.PlaneGeometry(100, 100, 100 , 100 );
for (var i = 0, l = geometry.vertices.length; i < l; i++) {
geometry.vertices[i].z = Math.random() / 2;
}
geometry.computeFaceNormals();
floor = new THREE.Mesh(geometry, floorMaterial);
Now, I have another object3d that needs to move on the surface of this terrain. How can I determine the elevation difference my object needs to adjust, possibly using raycasting?
[Edited] I have successfully addressed the first part, however, I am facing an issue with the raycaster. The distance returned by the raycaster seems to be incorrect, as it is flipped for each face. Here is an example to demonstrate this: