Z component in BABYLON.Vector3.Project

Hello,
I use BABYLON.Vector3.Project to compute the normalized screen coordinates of my sphere

I assume that is the X component of the output of BABYLON.Vector3.Project is less than 0, the sphere is outside my frustrum / to left from the camera; and if it is greater than 1, the sphere is outside my frustrum / to tight from the camera.
Y component is analogous , but for the vertical direction.
However, it is not clear meaning of Z component. It apprears that I see my sphere only when 0.0 < Z < 1.0.
So my questions are

  1. Can I assume that center of my sphere is outside the frustrum is if Z < 0 or Z > 1?
  2. Is that correct to assume that the center of the sphere being to the left / right of frustrum purely depends on sign of X or it also depends on value of Z?

thank you,
David

Yes, Z range for points inside the frustum after Project is called is 0…1. There’s a bug in WebGPU, though, that this PR will fix:

For X and Y, the range after Project is called is given by the viewport you pass to the function. As you pass the camera default’s one, it is (0,0,1,1), so points that are in the frustum are in the 0…1 range for both X and Y.

2 Likes