@threlte/xr
Version:
Tools to more easily create VR and AR experiences with Threlte
28 lines (27 loc) • 1.27 kB
TypeScript
import { type Mesh, Raycaster, type Intersection } from 'three';
import type { CurrentWritable } from '@threlte/core';
export type ComputeFunction = (context: Context, handContext: HandContext) => void;
export type TeleportEvents = Record<string, (arg: unknown) => void>;
export interface Context {
interactiveObjects: Mesh[];
surfaces: Map<string, Mesh>;
blockers: Map<string, Mesh>;
dispatchers: WeakMap<Mesh, Record<string, (arg: unknown) => void>>;
addBlocker: (mesh: Mesh) => void;
removeBlocker: (mesh: Mesh) => void;
addSurface: (mesh: Mesh, events: TeleportEvents) => void;
removeSurface: (mesh: Mesh) => void;
}
export interface HandContext {
hand: 'left' | 'right';
enabled: CurrentWritable<boolean>;
active: CurrentWritable<boolean>;
hovered: CurrentWritable<Intersection | undefined>;
/** Per-hand raycaster — keeps intersection state isolated between hands. */
raycaster: Raycaster;
compute: ComputeFunction;
}
export declare const getHandContext: (hand: "left" | "right") => HandContext;
export declare const setHandContext: (hand: "left" | "right", context: HandContext) => void;
export declare const useTeleportControls: () => Context;
export declare const createTeleportContext: () => Context;