If XrInputSource#elementInput is true, this property will hold entity with Element component at which this input source is hovering, or null if not hovering over any element.
Gets whether the input source can interact with ElementComponents.
Sets whether the input source can interact with ElementComponents. Defaults to true.
If input source can be held, then it will have node with its world transformation, that can be used to position and rotate visual object based on it.
Describes which hand input source is associated with. Can be one of the following:
List of active XrHitTestSource instances associated with this input source.
Unique number associated with instance of input source. Same physical devices when reconnected will not share this ID.
XRInputSource object that is associated with this input source.
List of input profile names indicating both the preferred visual representation and behavior of the input source.
True if input source is in active primary action between selectstart and selectend events.
True if input source is in active squeeze action between squeezestart and squeezeend events.
Type of ray Input Device is based on. Can be one of the following:
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Get the linear velocity (units per second) of the input source if it is handheld (XrInputSource#grip is true). Otherwise it will return null.
The world space linear velocity of the handheld input source.
Get the local space position of input source if it is handheld (XrInputSource#grip is true). Local space is relative to parent of the XR camera. Otherwise it will return null.
The world space position of handheld input source.
Get the local space rotation of input source if it is handheld (XrInputSource#grip is true). Local space is relative to parent of the XR camera. Otherwise it will return null.
The world space rotation of handheld input source.
Get the world space position of input source if it is handheld (XrInputSource#grip is true). Otherwise it will return null.
The world space position of handheld input source.
Get the world space rotation of input source if it is handheld (XrInputSource#grip is true). Otherwise it will return null.
The world space rotation of handheld input source.
Attempts to start hit test source based on this input source.
Optional
options: { callback?: XrHitTestStartCallback; entityTypes?: string[]; offsetRay?: Ray } = {}Object for passing optional arguments.
Optional
callback?: XrHitTestStartCallbackOptional callback function called once hit test source is created or failed.
Optional
entityTypes?: string[]Optional list of underlying entity types against which hit tests will be performed. Defaults to [ XRTRACKABLE_PLANE ]. Can be any combination of the following:
Optional
offsetRay?: RayOptional ray by which hit test ray can be offset.
app.xr.input.on('add', function (inputSource) {
inputSource.hitTestStart({
callback: function (err, hitTestSource) {
if (err) return;
hitTestSource.on('result', function (position, rotation, inputSource, hitTestResult) {
// position and rotation of hit test result
// that will be created from touch on mobile devices
});
}
});
});
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Static
EVENT_Fired when new XrHitTestSource is added to the input source. The handler is passed the XrHitTestSource object that has been added.
Static
EVENT_Fired when XrHitTestSource is removed to the the input source. The handler is passed the XrHitTestSource object that has been removed.
Static
EVENT_Fired when hit test source receives new results. It provides transform information that tries to match real world picked geometry. The handler is passed the XrHitTestSource object that produced the hit result, the Vec3 position, the Quat rotation and the XRHitTestResult object that is created by the WebXR API.
Static
EVENT_Fired when XrInputSource is removed.
Static
EVENT_Fired when input source has triggered primary action. This could be pressing a trigger button, or touching a screen. The handler is passed an XRInputSourceEvent object from the WebXR API.
Static
EVENT_Fired when input source has ended triggering primary action. The handler is passed an XRInputSourceEvent object from the WebXR API.
Static
EVENT_Fired when input source has started to trigger primary action. The handler is passed an XRInputSourceEvent object from the WebXR API.
Static
EVENT_Fired when input source has triggered squeeze action. This is associated with "grabbing" action on the controllers. The handler is passed an XRInputSourceEvent object from the WebXR API.
Static
EVENT_Fired when input source has ended triggering squeeze action. The handler is passed an XRInputSourceEvent object from the WebXR API.
Static
EVENT_Fired when input source has started to trigger squeeze action. The handler is passed an XRInputSourceEvent object from the WebXR API.
Represents XR input source, which is any input mechanism which allows the user to perform targeted actions in the same virtual space as the viewer. Example XR input sources include, but are not limited to: handheld controllers, optically tracked hands, touch screen taps, and gaze-based input methods that operate on the viewer's pose.