Frustum - Min and Max (x,y,z) 3D position

hi, I’m trying to get min and max for 3D world (x, y, z) and I’m using Frustum for that. But I noticed when I rotate my object in my scene, the planes invert the positions. So my minX, turns my maxX and vice-versa. Is there a better way to have this info? Get min and max of 3d area which is visible on the screen?

Code below:

    // frustums are used to determine what is inside the camera's field of view.
    const frustum = new THREE.Frustum();

    frustum.setFromProjectionMatrix(new THREE.Matrix4().multiplyMatrices(,;

    // each Frustum has an array of 6 planes - Frustum(p0 : Plane, p1 : Plane, p2 : Plane, p3 : Plane, p4 : Plane, p5 : Plane)
    if (frustum.planes?.length > 5) {

      const minZ = frustum.planes[2].constant * -1;
      const maxZ = frustum.planes[3].constant;
      const minX = frustum.planes[0].constant * -1;
      const maxX = frustum.planes[1].constant;
      const minY = frustum.planes[4].constant * -1;
      const maxY = frustum.planes[5].constant;

      return { minZ, maxZ, minX, maxX, minY, maxY };


    return null;