import { Material, Object3D } from "three"; import { Line2 } from "three/examples/jsm/lines/Line2.js"; import type { RaycastTestObjectCallback } from "../../../engine/engine_physics.js"; import type { IGameObject } from "../../../engine/engine_types.js"; import { NeedleXRController, type NeedleXREventArgs, NeedleXRSession } from "../../../engine/engine_xr.js"; import { Behaviour } from "../../Component.js"; import type { XRMovementBehaviour } from "../types.js"; declare type HitPointObject = Object3D & { material: Material & { opacity: number; }; }; /** * XRControllerMovement is a component that allows to move the XR rig using the XR controller input. * * It supports movement using the left controller's thumbstick and rotation using the right controller's thumbstick. * * Additionally it supports teleporting using the right controller's thumbstick or by pinching the index finger tip in front of the hand (if hand tracking is enabled). * It also visualizes controller rays and hit points in the scene. * * The component operates on the active XR rig and controllers from the {@link NeedleXRSession} (`args.xr.rig`, * `args.xr.leftController` / `rightController`) and receives `onUpdateXR` regardless of where it sits in the hierarchy. * It does NOT need to be on the same GameObject as {@link WebXR}, and does not read {@link WebXR} from its parents. * * **Duplicate-handler gotcha:** {@link WebXR.setDefaultMovementEnabled} (called when `WebXR.useDefaultControls` is enabled, * the default) adds an `XRControllerMovement` to the WebXR GameObject only if that object has none. If you place your own * `XRControllerMovement` on a different object, WebXR still adds a second, default one at runtime — two handlers then run * simultaneously (doubled movement, and your teleport settings such as {@link XRControllerMovement.useTeleportTarget} are * bypassed by the default handler). Put your component on the WebXR GameObject, or disable `WebXR.useDefaultControls`. * * @summary Move the XR rig using controller input * @category XR * @group Components */ export declare class XRControllerMovement extends Behaviour implements XRMovementBehaviour { /** Movement speed in meters per second * @default 1.5 */ movementSpeed: number; /** How many degrees to rotate the XR rig when using the rotation trigger * @default 30 */ rotationStep: number; /** When enabled you can teleport using the right XR controller's thumbstick by pressing forward * @default true */ useTeleport: boolean; /** * When enabled you can teleport by pinching the right XR controller's index finger tip in front of the hand * @default true */ usePinchToTeleport: boolean; /** Enable to only allow teleporting on objects with a {@link TeleportTarget} component. * * The teleport ray is a **visual raycast against rendered meshes** (not physics colliders): * it hits the rendered geometry and then looks for a {@link TeleportTarget} on the hit object * or any of its parents. A collider is NOT required on the target — only a visible mesh that * is not on the IgnoreRaycast layer. * * When enabled, teleporting is rejected if the ray does not hit a `TeleportTarget` (the * ground-plane fallback used in free teleport mode is also disabled). * @default false */ useTeleportTarget: boolean; /** Enable to fade out the scene when teleporting * @default false */ useTeleportFade: boolean; /** enable to visualize controller rays in the 3D scene * @default true */ showRays: boolean; /** enable to visualize pointer targets in the 3D scene * @default false */ showHits: boolean; readonly isXRMovementHandler: true; readonly xrSessionMode = "immersive-vr"; private _didApplyRotation; private _didTeleport; onUpdateXR(args: NeedleXREventArgs): void; onLeaveXR(_: NeedleXREventArgs): void; onBeforeRender(): void; protected onHandleMovement(controller: NeedleXRController, rig: IGameObject): void; protected onHandleRotation(controller: NeedleXRController, rig: IGameObject): void; private readonly _teleportBuffer; protected onHandleTeleport(controller: NeedleXRController, rig: IGameObject): void; private _plane; private readonly _lines; private readonly _hitDiscs; private readonly _hitDistances; private readonly _lastHitDistances; protected renderRays(session: NeedleXRSession): void; protected renderHits(session: NeedleXRSession): void; private isObjectWithInteractiveComponent; private updateHitPointerPosition; protected hitPointRaycastFilter: RaycastTestObjectCallback; /** create an object to visualize hit points in the scene */ protected createHitPointObject(): HitPointObject; /** create an object to visualize controller rays */ protected createRayLineObject(): Line2; } export {};