import { Intersection, Object3D, Quaternion, Vector3 } from "three"; export type ObjectEventTypes = "press" | "release" | "cancel" | "select" | "move" | "enter" | "leave" | "wheel" | "losteventcapture"; export type XIntersection = Intersection & { inputDevicePosition: Vector3; inputDeviceRotation: Quaternion; capturedObject?: Object3D; pointOnFace: Vector3; localPoint: Vector3; intersections: Array; }; export declare function isXIntersection(val: Intersection): val is XIntersection; export type EventDispatcher = { [Key in ObjectEventTypes]: (object: Object3D, intersection: I, inputDeviceElementId?: number) => void; } & { bind(event: E, eventTranslater: EventTranslator): void; hasEventHandlers(object: Object3D): boolean; }; export declare const voidObject: Object3D; /** * translates the events from one input device to a 3D Scene */ export declare class EventTranslator { readonly inputDeviceId: number; private readonly dispatchPressAlways; protected eventDispatcher: EventDispatcher; protected computeIntersections: (event: ReceivedEvent, capturedEvents?: Map) => Array; protected getPressedElementIds: (intersection?: I) => Array; protected getInputDeviceTransformation: (position: Vector3, rotation: Quaternion) => void; protected wasDragged?: ((inputDeviceElementId: number) => boolean) | undefined; onIntersections?: ((intersections: ReadonlyArray) => void) | undefined; filterIntersections?: ((intersections: Array) => Array) | undefined; onStartEventCaptures?: ((event: ReceivedEvent) => void) | undefined; onEndEventCaptures?: ((event: ReceivedEvent) => void) | undefined; intersections: Array; private lastPositionChangeTime; private capturedEvents; private objectInteractionStateMap; constructor(inputDeviceId: number, dispatchPressAlways: boolean, eventDispatcher: EventDispatcher, //SendEvent computeIntersections: (event: ReceivedEvent, capturedEvents?: Map) => Array, getPressedElementIds: (intersection?: I) => Array, getInputDeviceTransformation: (position: Vector3, rotation: Quaternion) => void, wasDragged?: ((inputDeviceElementId: number) => boolean) | undefined, onIntersections?: ((intersections: ReadonlyArray) => void) | undefined, filterIntersections?: ((intersections: Array) => Array) | undefined, onStartEventCaptures?: ((event: ReceivedEvent) => void) | undefined, onEndEventCaptures?: ((event: ReceivedEvent) => void) | undefined); /** * called when the input device receives a press, release, or move event * @param positionChanged flag to indicate that the input device was moved and therefore requires the **sceneIntersections** to recompute. When the **sceneIntersections** are recomputed, we check whether objects where hovered or released and dispatch events accordingly. * @param pressChanged flag to indicate that any input device element was either pressed or released. Therefore, we check whether the objects in **sceneIntersections** are released or pressed and dispatch events accordingly. * @param dispatchPressFor list of ids of elements that were pressed after the last update */ update(event: ReceivedEvent, positionChanged: boolean, pressChanged: boolean, ...dispatchPressFor: Array): void; cancel(event: ReceivedEvent): void; wheel(event: ReceivedEvent): void; leave(event: ReceivedEvent): void; private updateElementStateMap; private dispatchPress; private dispatchRelease; /** * @returns if the object was entered */ private dispatchEnterOrMove; addEventCapture(fromEvent: ReceivedEvent, eventObject: Object3D, intersection: I): void; removeEventCapture(fromEvent: ReceivedEvent, eventObject: Object3D): void; hasEventCapture(eventObject: Object3D): boolean; /** * @param callback returns false if the event should stop bubbeling upwards */ private traverseIntersections; blockFollowingIntersections(eventObject: Object3D): void; private getInteractionState; } export * from "./intersections/index.js";