chandlerprall / Physijs

Physics plugin for Three.js
MIT License
2.75k stars 455 forks source link

Line Collision #244

Open mjkaufer opened 8 years ago

mjkaufer commented 8 years ago

Is it possible to add collision events between Three.JS lines and other objects? I don't see a specific reference to this in the documentations, so is there perhaps a straightforwards way?

I am considering making a cylinder between my two points and having collisions for the cylinder, but the points - and thus the line - are moving consistently, so relocating the cylinder would be a hassle.

ghost commented 8 years ago

@mjkaufer you can just go with raycasting. The THREE.Raycaster object has features for detecting collision with lines. It even has .linePrecision factor to control how precise the intersection detection should be. More on the documentation. As for collision response, I think you should just place a Physijs.SphereMesh wherever the collision between the cylinder and the line occured.