1 | import { Object3DEventMap } from "../../core/Object3D.js";
|
2 | import { Vector3 } from "../../math/Vector3.js";
|
3 | import { Group } from "../../objects/Group.js";
|
4 |
|
5 | export type XRControllerEventType = XRSessionEventType | XRInputSourceEventType | "disconnected" | "connected";
|
6 |
|
7 | export class XRJointSpace extends Group {
|
8 | readonly jointRadius: number | undefined;
|
9 | }
|
10 |
|
11 | export type XRHandJoints = Record<XRHandJoint, XRJointSpace>;
|
12 |
|
13 | export interface XRHandInputState {
|
14 | pinching: boolean;
|
15 | }
|
16 |
|
17 | export interface WebXRSpaceEventMap extends Object3DEventMap {
|
18 | select: { data: XRInputSource };
|
19 | selectstart: { data: XRInputSource };
|
20 | selectend: { data: XRInputSource };
|
21 | squeeze: { data: XRInputSource };
|
22 | squeezestart: { data: XRInputSource };
|
23 | squeezeend: { data: XRInputSource };
|
24 |
|
25 | connected: { data: XRInputSource };
|
26 | disconnected: { data: XRInputSource };
|
27 |
|
28 | pinchend: { handedness: XRHandedness; target: WebXRController };
|
29 | pinchstart: { handedness: XRHandedness; target: WebXRController };
|
30 |
|
31 | move: {};
|
32 | }
|
33 |
|
34 | export class XRHandSpace extends Group<WebXRSpaceEventMap> {
|
35 | readonly joints: Partial<XRHandJoints>;
|
36 | readonly inputState: XRHandInputState;
|
37 | }
|
38 |
|
39 | export class XRTargetRaySpace extends Group<WebXRSpaceEventMap> {
|
40 | hasLinearVelocity: boolean;
|
41 | readonly linearVelocity: Vector3;
|
42 | hasAngularVelocity: boolean;
|
43 | readonly angularVelocity: Vector3;
|
44 | }
|
45 |
|
46 | export class XRGripSpace extends Group<WebXRSpaceEventMap> {
|
47 | hasLinearVelocity: boolean;
|
48 | readonly linearVelocity: Vector3;
|
49 | hasAngularVelocity: boolean;
|
50 | readonly angularVelocity: Vector3;
|
51 | }
|
52 |
|
53 | export class WebXRController {
|
54 | constructor();
|
55 |
|
56 | getHandSpace(): XRHandSpace;
|
57 | getTargetRaySpace(): XRTargetRaySpace;
|
58 | getGripSpace(): XRGripSpace;
|
59 | dispatchEvent(event: { type: XRControllerEventType; data?: XRInputSource }): this;
|
60 | connect(inputSource: XRInputSource): this;
|
61 | disconnect(inputSource: XRInputSource): this;
|
62 | update(inputSource: XRInputSource, frame: XRFrame, referenceSpace: XRReferenceSpace): this;
|
63 | }
|