UNPKG

2.38 kBTypeScriptView Raw
1/// <reference types="webxr" />
2
3import { ArrayCamera } from "../../cameras/ArrayCamera.js";
4import { PerspectiveCamera } from "../../cameras/PerspectiveCamera.js";
5import { EventDispatcher } from "../../core/EventDispatcher.js";
6import { Vector4 } from "../../math/Vector4.js";
7import { Mesh } from "../../objects/Mesh.js";
8import { Texture } from "../../textures/Texture.js";
9import { WebGLRenderer } from "../WebGLRenderer.js";
10import { XRGripSpace, XRHandSpace, XRTargetRaySpace } from "./WebXRController.js";
11
12export type WebXRCamera = PerspectiveCamera & { viewport: Vector4 };
13export type WebXRArrayCamera = Omit<ArrayCamera, "cameras"> & { cameras: [WebXRCamera, WebXRCamera] };
14
15export interface WebXRManagerEventMap {
16 sessionstart: {};
17 sessionend: {};
18 planeadded: { data: XRPlane };
19 planeremoved: { data: XRPlane };
20 planechanged: { data: XRPlane };
21 planesdetected: { data: XRPlaneSet };
22}
23
24export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {
25 /**
26 * @default true
27 */
28 cameraAutoUpdate: boolean;
29
30 /**
31 * @default false
32 */
33 enabled: boolean;
34
35 /**
36 * @default false
37 */
38 isPresenting: boolean;
39
40 constructor(renderer: WebGLRenderer, gl: WebGLRenderingContext);
41
42 getController: (index: number) => XRTargetRaySpace;
43
44 getControllerGrip: (index: number) => XRGripSpace;
45
46 getHand: (index: number) => XRHandSpace;
47
48 setFramebufferScaleFactor: (value: number) => void;
49
50 setReferenceSpaceType: (value: XRReferenceSpaceType) => void;
51
52 getReferenceSpace: () => XRReferenceSpace | null;
53
54 setReferenceSpace: (value: XRReferenceSpace) => void;
55
56 getBaseLayer: () => XRWebGLLayer | XRProjectionLayer;
57
58 getBinding: () => XRWebGLBinding;
59
60 getFrame: () => XRFrame;
61
62 getSession: () => XRSession | null;
63
64 setSession: (value: XRSession | null) => Promise<void>;
65
66 getEnvironmentBlendMode: () => XREnvironmentBlendMode | undefined;
67
68 getDepthTexture: () => Texture | null;
69
70 updateCamera: (camera: PerspectiveCamera) => void;
71
72 getCamera: () => WebXRArrayCamera;
73
74 getFoveation: () => number | undefined;
75
76 setFoveation: (value: number) => void;
77
78 hasDepthSensing: () => boolean;
79
80 getDepthSensingMesh: () => Mesh | null;
81
82 setAnimationLoop: (callback: XRFrameRequestCallback | null) => void;
83
84 dispose: () => void;
85}