YUMatty
YUMatty

Reputation: 83

Three.js: Camera Collision on Terrain

How should I go about adding camera collision to a terrain in three.js.

The terrain is from 'mrdoob's three.js' examples and is randomly generated and I am currently converting it to height map.

I am thinking of implementing the collision as follows:

How should I go about doing this?

Upvotes: 3

Views: 728

Answers (1)

gaitat
gaitat

Reputation: 12632

The theory is that you send a ray from the location you are (camera position) straight down. You find the intersection point and based on the distance you decide what to do. Implementation wise I cannot help you but THREE.Ray should help you.

Upvotes: 3

Related Questions