Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...
    • Calculates the +Z camera distance that fits a bounding box in view. X/Y are the screen plane and Z is depth, matching fitCameraToBounds' fixed face-on pose. The larger X/Y extent fills fitRatio of the shorter viewport axis at the nearest Z face. If both projected extents are zero, half the Z extent is used as a conservative fallback so the camera stays off the geometry.

      Parameters

      • box: BoundingBox

        Bounding box to fit

      • camera: CameraConfig

        Camera configuration

      • fitRatio: number = config.scene.defaultFitRatio

        How much of the view to fill (0-1, default 0.75)

      • target: { x: number; y: number; z: number } = ...

        Look-at target; defaults to the bounding-box center

      Returns number

      Optimal +Z camera distance from the look-at target