Closed zoink closed 4 years ago
Hi, there's no set API for this currently. I have this kind of logic in my own game, but I haven't come up with a nice way to abstract it so it would be generally applicable to all game clients.
The rough outline of how I do it is:
ents.getStatesList(ents.names.mesh)
There could be a better way though.
For the broadphase test, similar logic can be found in the collideEntities
component, that demonstrates how to quickly test a bunch of AABBs. Each entity's position component has an _extents
array, which is in the format expected by the box-intersect
library, so if you make a similar extents array for your ray, that library can quickly find the collisions. Note that the _extents
arrays are in local coordinates, so the ray's extents should also be local.
My current understanding is that fast-voxel-raycast is used to get the highlighted mesh on tick - what is the recommended way to raycast onto other entities in the ECS (with the mesh component attached)? Thanks!