@threlte/xr
Version:
Tools to more easily create VR and AR experiences with Threlte
28 lines (27 loc) • 1.25 kB
TypeScript
import { type Mesh, Raycaster, type Intersection } from 'three';
import type { CurrentWritable } from '@threlte/core';
import type { TeleportControlsOptions } from '.';
export type ComputeFunction = (context: Context, handContext: HandContext) => void;
export type TeleportEvents = {};
export interface Context {
interactiveObjects: Mesh[];
surfaces: Map<string, Mesh>;
blockers: Map<string, Mesh>;
dispatchers: WeakMap<Mesh, Record<string, (arg: unknown) => void>>;
raycaster: Raycaster;
compute: ComputeFunction;
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>;
}
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: (compute: TeleportControlsOptions["compute"]) => Context;