Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Function projectBoxDiagonalPx

    • Project a world-space :type:BoundingBox through the camera and return the diagonal of the screen-space AABB in pixels.

      Treats the bbox's 8 corners independently (works for both perspective and orthographic projection without a closed-form radius). NDC → pixels assumes the viewport size matches the renderer canvas.

      Near-plane saturation. Projects with an explicit homogeneous w (the combined projectionMatrix * matrixWorldInverse, not THREE's Vector3.project which divides by w unguarded). If any corner has w <= W_EPSILON — i.e. the camera is inside or straddling the box — the group fills the screen, so we return +Infinity to saturate the selector to its finest level (pickChildWithHysteresis then picks the top index; the value is never fed to finite arithmetic, so no NaN). This is the inverse of the old behaviour, where a corner crossing behind the near plane collapsed the diagonal and wrongly dropped to a coarse level on close approach. Orthographic cameras keep w == 1 and so never saturate.

      Exported for unit testing.

      Parameters

      • box: BoundingBox
      • camera: Camera
      • viewport: { width: number; height: number }
      • OptionalprecomputedProjView: Matrix4

      Returns number