I am developing an application in three.js in which I have an orthographic camera which is initialized like this:
const orthographicCamera = new THREE.OrthographicCamera( -1, 1, -1, 1, -1000, 1000)
This is an unconventional use of the near plane parameter (-1000), which the documentation says must be set to a value >= 0. Setting the near plane parameter to -1000 allows me to render objects in the scene that have z coordinate >= 0 without clipping the objects, BUT it also seems to break the threejs raycaster, as triangles on a mesh with z coordinate >= 0 are never intersected by the raycaster, even though they are rendered.
I have been inspecting the raycaster's code to see how it is handling the orthographic camera (and the near plane in particular).
My main question is whether it is possible to set the near plane in negative space, but still have a functional raycaster that can intersect mesh triangles with z coordinates >= 0?
In line with this question, I was also wondering if anyone could please explain the math behind the orthographic camera's raycaster? In particular, the part where it is setting the z position of the ray origin. It uses this expression to set the camera of the z position of the ray origin:
( camera.near + camera.far ) / ( camera.near - camera.far )
Could someone explain what this expression is doing?
I would appreciate any insight anyone can share on this. Thank you.