feature request: transparent surfaces
adamwong246 opened this issue · comments
Is your feature request related to a problem? Please describe.
I am attempting to build a game with dynamic lights and shadows. That is, visibility is restricted to surfaces in FOV which are also lit. I would like to implement this with raycasters- light sources produce light-rays, used to build a "light-shape". Some of the edges of this shape describe lit walls, but some edges describe the boundary of light and dark on the floor.
Secondly, the camera entities raycast against that "light-shape" to produce the FOV.
The problem with the current implementation is that I need the camera-rays to act somewhat differently that light-rays. Whereas light-rays are stopped by any surface, camera-rays need to be able to pass through those light-shadow boundaries. It should be able to detect the light-dark boundaries, but also should pass through them to detect any further light-shapes that might lie beyond.
I hope that question does not sound too crazy :-)
Describe the solution you'd like
The ability to mark some surfaces as transparent, but detectable.
Hello,
You can cast different rays against different groups of mapped objects.
To do so you have to pass array of mapped objects to Ray.cast()
/Ray.castCircle()
/Ray.castCone()
methods.
Docs: Raycaster.Ray.cast()
Example
Codepen: https://codepen.io/wiserim/pen/qBQYxOx
let lightObstacles = [obj1, obj2, obj3];
let cameraObstacles = [obj1, obj2];
lightRay.castCircle({
objects: lightObstacles
});
cameraRay.castCircle({
objects: cameraObstacles
});