Skip to content

r3f-xr-widgets / EyeLevelGroup

Function: EyeLevelGroup()

EyeLevelGroup(props): Element

Defined in: src/components/EyeLevelGroup.tsx:57

Positions its children at the user's actual eye level in XR.

In XR mode, captures the camera's Y position once when entering a session to determine the user's actual eye level. Outside of XR, uses the provided default eye level.

This component is useful for ensuring UI elements and content are positioned at a comfortable viewing height for each individual user, accounting for differences in height and play space setup.

Parameters

props

EyeLevelGroupProps

Returns

Element

Example

tsx
import { EyeLevelGroup, DEFAULT_EYE_LEVEL } from 'r3f-xr-widgets'

<EyeLevelGroup defaultEyeLevel={DEFAULT_EYE_LEVEL}>
  <mesh position={[0, 0, -1]}>
    <boxGeometry />
    <meshStandardMaterial />
  </mesh>
</EyeLevelGroup>

Released under the MIT License.