@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
87 lines (86 loc) • 3.52 kB
TypeScript
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.
*
*
* @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 TeleportTarget component (see {@link TeleportTarget})
* @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 {};