How know which particles of a particlesystem are in the frustum

493 views Asked by At

I'm using Three.js and webGLrender to display a hockey stadium with its seats (80k particles) and i want to be able to do picking on each seat. I've tried to create a hidden object to use ray interception but with 80k objects all becomes too slow. So I think the best way is only to create the objects when the zoom is near enough that is only displaying a set of seats. The problem is that i don't know very well how to detect which particles (Vertex) of the particlesystem are falling inside the frustum.

Any ideas or samples?

Thanks in advance!

1

There are 1 answers

0
JS. On

I dont know about three.js specifically, but have a look at view frustum culling, this link explains in detail how it's done:

http://www.lighthouse3d.com/tutorials/view-frustum-culling/

The fastest and least accurate way might be to calculate the barycentre of each seat and just do a point inclusion test to determine whether the seat should be considered for picking. More complicated approaches could involve precalculating bounding cubes/spheres for each seat and doing the inclusion test on those.

Another approach might be to use a spatial indexing data structure to reduce the lookup cost, such as an octree.