@threlte/xr

<Controller>

<Controller /> represents a THREE.XRTargetRaySpace, a THREE.XRGripSpace, and a controller model for a specified hand.

<Controller left />
<Controller right />

It will by default load a controller model that attempts to match the physical controller.

Default controller models are fetched from the immersive web group’s webxr input profile repo. If you are developing an offline app, you should download and provide any anticipated models.

<Controller> can accept three snippets.

If a children snippet is provided, the default controller model will not be rendered, and will be replaced with the children content.

<Controller left>
  <T.Mesh>
    <T.IcosahedronGeometry args={[0.2]} />
    <T.MeshStandardMaterial color="turquoise" />
  </T.Mesh>
</Controller>

Two additional snippets exist to place children in the controller’s grip space and the controller’s target ray space.

<Controller left>
  {#snippet grip()}
    <T.Mesh>
      <T.IcosahedronGeometry args={[0.2]} />
      <T.MeshStandardMaterial color="hotpink" />
    </T.Mesh>
  {/snippet}

  {#snippet targetRay()}
    <T.Mesh>
      <T.IcosahedronGeometry args={[0.2]} />
      <T.MeshStandardMaterial color="orange" />
    </T.Mesh>
  {/snippet}
</Controller>

Component Signature

Events

name
payload
description

connected
XRControllerEvent<'connected'>
Fired when the controller connects.

disconnected
XRControllerEvent<'disconnected'>
Fired when the controller disconnects.

select
XRControllerEvent<'select'>
Fired when a the user has completed a primary action.

selectstart
XRControllerEvent<'selectstart'>
Fired when a the user begins a primary action.

selectend
XRControllerEvent<'selectend'>
Fired when a the user ends a primary action or when the controller that is in the process of handling an ongoing primary action is disconnected without successfully completing the action.

squeeze
XRControllerEvent<'squeeze'>
Fired when the controller has completed a primary squeeze action.

squeezestart
XRControllerEvent<'squeezestart'>
Fired when the user begins a primary squeeze action.

squeezeend
XRControllerEvent<'squeezeend'>
Fired when a the user ends a primary squeeze action or when the controller that is in the process of handling an ongoing primary squeeeze action is disconnected without successfully completing the action.