Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera Collision with FirstPersonCamera #424

Closed
willcrichton opened this issue Aug 14, 2011 · 1 comment
Closed

Camera Collision with FirstPersonCamera #424

willcrichton opened this issue Aug 14, 2011 · 1 comment
Labels

Comments

@willcrichton
Copy link

I'm trying to use the collision utilities so that the camera will collide with some Box geometries that I have. I've successfully added the Boxes to the colliders list, but the trick is I don't really know how the collision is supposed to work. I figure that you'd probably want to overwrite THREE.Camera.prototype.translate. I took a look at some of the collision examples, but most of the stuff with rays and projection just went way over my head. I figured something like this would be a great example to include with the default package.

So, my question is: how can I overwrite the camera's translate method such that it will check for any blocks in the path of movement, and then prevent the camera from moving into a block in its path?

@mrdoob
Copy link
Owner

mrdoob commented Aug 14, 2011

I don't think you need to overwrite anything. You know in which direction the camera is going, right? Most likely: camera.target.position - camera.position. So using that vector you can throw a ray into the scene and check if it's colliding. I haven't used CollisionSystem yet thiough, I would use Ray myself.

@mrdoob mrdoob closed this as completed Aug 29, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants