Interface XrCamera
interface XrCamera {
children: SceneNode[];
eye: XrEye;
farPlane: number;
fov: number;
name?: string;
nearPlane: number;
ortho?: OrthographicBounds | null;
viewport?: NormalizedViewport;
worldMatrix: Mat4;
worldMatrixVersion: number;
}
children: SceneNode[];
eye: XrEye;
farPlane: number;
fov: number;
name?: string;
nearPlane: number;
ortho?: OrthographicBounds | null;
viewport?: NormalizedViewport;
worldMatrix: Mat4;
worldMatrixVersion: number;
}
Hierarchy (View Summary)
- Camera
- XrCamera
Properties
children
Readonlyeye
Which eye this camera renders ("left", "right", or "none" for mono).
far Plane
farPlane: number
fov
fov: number
Optionalname
name?: string
Optional source/debug name. Imported glTF cameras use the glTF camera name,
or camera{index} when the source definition is unnamed.
near Plane
nearPlane: number
Optionalortho
Live orthographic view-volume extents, installed by enableOrthographicCamera
and mutable/animatable thereafter. Null or undefined means the camera projects
perspectively through fov.
Optionalviewport
Readonlyworld Matrix
Readonlyworld Matrix Version
worldMatrixVersion: number
XrCamera — a Camera whose view and projection matrices come from an XRView (one camera per eye) rather than from
fov/position. Pure data, no scene knowledge (pillar 4b).Integration is deliberately zero-cost for non-XR scenes: instead of adding an override branch to the shared
camera.tsgetters (which would grow every scene's bundle), the XR camera writes directly into the existing matrix caches thatgetViewMatrix/getProjectionMatrix/getViewProjectionMatrixalready read:_world = XRView.transform.matrix(the eye pose, view→world, column-major) and bumpworldMatrixVersion.getViewMatrixthen produces the inverse rigid transform (the view matrix) and_packSceneUniformsreads the eye position from the world matrix translation column — both automatically.XRView.projectionMatrix, which the symmetric-perspectivegetProjectionMatrixcannot reproduce. We inject it straight into_projCacheand set_projVer/_projAspectso the cache returns it verbatim for the exact aspect the render task will request.Handedness + depth. WebXR reports right-handed poses/projections while Babylon Lite renders a left-handed world with a reverse-Z ([near→1, far→0]) depth buffer. The eye pose is converted with
H·T·Hand the projection withP·H, whereH = diag(1,1,-1,1). Input and hand poses use the same boundary conversion, so every material pipeline sees an ordinary left-handed scene with normal winding.XRView.projectionMatrixtargetsz ∈ [0,1](near→0, far→1). Babylon Lite's pipeline expects reverse-Z (near→1, far→0), so we remaprow2 ← row3 − row2. This is handedness-independent and specific to this engine.