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
When enabled the controller will automatically emit pointer down events to the Needle Engine Input System.
When enabled the controller will automatically emit pointer move events to the Needle Engine Input System.
When enabled the controller will automatically emit pointer up events to the Needle Engine Input System.
Readonly
indexthe input source index
Readonly
inputAssigned the model that you use for rendering. This can be used as a hint for other components
The angle threshold for pointer move events. This value is in radians.
The distance threshold for pointer move events. This value is in units in rig space
Readonly
xrthe Needle XR Session
Is the controller still connected?
Grip rotation in rig space
shorthand for inputSource.gripSpace
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 dot product of the hand palm with the up vector. This is a number between -1 and 1, where 1 means the palm is directly up and -1 means the palm is directly down (upside down). This value is undefined if there's no hand
true if this is a hand (otherwise this is a controller)
true if the hand is upside down
is left side. shorthand for side === 'left'
is right side. shorthand for side === 'right'
is XR stylus, e.g. Logitech MX Ink
true if the hand is upside down and we got a pinch down event this frame.
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 rotation in rig space
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
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
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
NOTE: The hit test source should be cancelled once it's not needed anymore. Call cancelHitTestSource
to do this
Get the pointer id for a specific button of this input device.
This is useful if you want to check if a button (e.g. trigger) is currently being in use which can be queried on the inputsystem.
the pointer id for the button or undefined if the button is not supported
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