API

Class WebXRControllerPointerSelection

A module that will enable pointer selection for motion controllers of XR Input Sources

Hierarchy (View Summary)

Index
dependsOn?: string[]

The dependencies of this feature, if any

disableAutoAttach: boolean = false

Should auto-attach be disabled?

disablePointerLighting: boolean = true

Disable lighting on the laser pointer (so it will always be visible)

disableSelectionMeshLighting: boolean = true

Disable lighting on the selection mesh (so it will always be visible)

displayLaserPointer: boolean = true

Should the laser pointer be displayed

displaySelectionMesh: boolean = true

Should the selection mesh be displayed (The ring at the end of the laser pointer)

isDisposed: boolean = false

Is this feature disposed?

laserPointerDefaultColor: Color3 = ...

Default color of the laser pointer

laserPointerPickedColor: Color3 = ...

This color will be set to the laser pointer when selection is triggered

onFeatureAttachObservable: Observable<IWebXRFeature> = ...

Observers registered here will be executed when the feature is attached

onFeatureDetachObservable: Observable<IWebXRFeature> = ...

Observers registered here will be executed when the feature is detached

raySelectionPredicate: (mesh: AbstractMesh) => boolean

Optional filter to be used for ray selection. This predicate shares behavior with scene.pointerMovePredicate which takes priority if it is also assigned.

selectionMeshDefaultColor: Color3 = ...

default color of the selection ring

selectionMeshPickedColor: Color3 = ...

This color will be applied to the selection ring when selection is triggered

Name: "xr-controller-pointer-selection" = WebXRFeatureName.POINTER_SELECTION

The module's name

Version: 1

The (Babylon) version of this module. This is an integer representing the implementation version. This number does not correspond to the WebXR specs version

  • get attachedControllerId(): string

    Get the unique id of the currently attached (active) controller for pointer selection. When enablePointerSelectionOnAllControllers is true, this value is not meaningful because all controllers are active simultaneously.

    Returns string

    the unique id of the attached controller, or an empty string if none is attached

  • Set the active controller for pointer selection during an XR session. Accepts either an XRHandedness value ("left", "right", "none") to select the first matching controller, or a controller unique id string for precise control.

    When a matching controller is found, any in-progress pointer-down state on the previously active controller is properly resolved (pointer-up is simulated).

    This also updates the preferredHandedness option so that if controllers are re-initialized (e.g. on disconnect/reconnect), the new preference persists.

    This method is a no-op when enablePointerSelectionOnAllControllers is true, since all controllers are active simultaneously in that mode.

    Parameters

    • controllerId: any

      the XRHandedness ("left", "right", "none") or the unique id of the controller to attach

    Returns boolean

    true if the active controller was changed, false otherwise