By using an octree I get an array of faces that is close to an object. How can I ray cast to them. I can only find how to ray cast to a mesh, line or point?
0
votes
are you asking how to use an octree? Intersection test between a ray and a face is a different thing.
- pailhead
I've got the octree working. What I wonder is if I can Ray cast to the faces alone, stored in an array or if I have to create a mesh out of them.
- arpo
I think you need to improve the question. What have you tried so far. As far as i know, three.js offers classes and functions to test an intersection of a triangle and a ray.
- pailhead
I think you just answer the question. I can probably use Ray and intersectTriangle :)
- arpo
1 Answers
1
votes
If you're using threeoctree, you do the following:
// get the faces using octree search
var octreeObjects = this.octree.search( raycaster.ray.origin, raycaster.ray.far, true, raycaster.ray.direction );
// find the intersections only with the faces you found
var intersections = raycaster.intersectOctreeObjects( octreeObjects );