Three.js: Colliding the camera on the ground
How do I do add terrain camera collision in three.js.
The terrain is from the mrdoob three.js examples and is randomly generated and I am currently converting it to a heightmap.
I'm going to do the collision like this:
- Create a "box" object around the camera.
- If the object of the box is not touching the terrain, move the camera down.
- If the box object touches the terrain, keep the camera Y-axis.
How should I do it?
+3
source to share