When enabled the controller will create input events in the Needle Engine input system (e.g. when a button is pressed or the controller is moved)
You can disable this if you don't want inputs to go through the input system but be aware that this will result in onPointerDown
component callbacks to not be invoked anymore for this XRController
Readonly
indexthe input source index
Readonly
inputAssigned the model that you use for rendering. This can be used as a hint for other components
Readonly
xrthe Needle XR Session
Is the controller still connected?
the input source gamepad giving raw access to the gamepad values
You should usually use the getButton
and getStick
methods instead to get access to named buttons and sticks
Grip linear velocity in rig space
Grip position in rig space
Grip rotation in rig space
shorthand for inputSource.gripSpace
Controller grip position in worldspace
Controller grip rotation in wordspace
If this is a hand then this is the hand info (XRHand)
threejs XRHandSpace, shorthand for context.renderer.xr.getHand(controllerIndex)
The XRTransientInputHitTestSource can be used to perform hit tests with the controller ray against the real world.
see https://developer.mozilla.org/en-US/docs/Web/API/XRSession/requestHitTestSourceForTransientInput for more information
Requires the hit-test feature to be enabled in the XRSession
true if this is a hand (otherwise this is a controller)
is left side. shorthand for side === 'left'
is right side. shorthand for side === 'right'
The device input layout
The controller object space.
You can use it to attach objects to the controller.
Children will be automatically detached and put into the scene when the controller disconnects
The input source profiles
The controller ray in worldspace
Ray position in rig space
Ray rotation in rig space
Controller ray position in worldspace (this value is calculated once per frame by default - call updateRayWorldPosition
to force an update)
Controller ray rotation in wordspace (this value is calculated once per frame by default - call updateRayWorldQuaternion
to force an update)
If the controller if held in the left or right hand (or if it's a left or right hand)
shorthand for inputSource.targetRayMode
shorthand for inputSource.targetRaySpace
Get a gamepad button
the controller button name e.g. x-button
the gamepad button if it exists on the controller - otherwise undefined
Get the hand joint pose from the current XRFrame. Results are cached for a frame to avoid calling getJointPose multiple times
Perform a hit test against the XR planes or meshes. shorthand for xr.getHitTest(controller)
the hit test result (with position and rotation in worldspace) or null if no hit was found
Generated using TypeDoc
A NeedleXRController wraps a connected XRInputDevice that is either a physical controller or a hand
You can access specific buttons using
getButton
andgetStick
To get spatial data in rig space (position, rotation) use the
gripPosition
,gripQuaternion
,rayPosition
andrayQuaternion
propertiesTo get spatial data in world space use the
gripWorldPosition
,gripWorldQuaternion
,rayWorldPosition
andrayWorldQuaternion
propertiesInputs will also be emitted as pointer events on
this.context.input
- so you can receive controller inputs on objects using the appropriate input events on your components (e.g.onPointerDown
,onPointerUp
etc) - use thepointerType
property to check if the event is from a controller or notLink
https://developer.mozilla.org/en-US/docs/Web/API/XRInputSource