webXRInput.d.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. import { Observable } from "../Misc/observable";
  2. import type { IDisposable } from "../scene";
  3. import type { IWebXRControllerOptions } from "./webXRInputSource";
  4. import { WebXRInputSource } from "./webXRInputSource";
  5. import type { WebXRSessionManager } from "./webXRSessionManager";
  6. import type { WebXRCamera } from "./webXRCamera";
  7. /**
  8. * The schema for initialization options of the XR Input class
  9. */
  10. export interface IWebXRInputOptions {
  11. /**
  12. * If set to true no model will be automatically loaded
  13. */
  14. doNotLoadControllerMeshes?: boolean;
  15. /**
  16. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  17. * If not found, the xr input profile data will be used.
  18. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  19. */
  20. forceInputProfile?: string;
  21. /**
  22. * Do not send a request to the controller repository to load the profile.
  23. *
  24. * Instead, use the controllers available in babylon itself.
  25. */
  26. disableOnlineControllerRepository?: boolean;
  27. /**
  28. * A custom URL for the controllers repository
  29. */
  30. customControllersRepositoryURL?: string;
  31. /**
  32. * Should the controller model's components not move according to the user input
  33. */
  34. disableControllerAnimation?: boolean;
  35. /**
  36. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  37. */
  38. controllerOptions?: IWebXRControllerOptions;
  39. }
  40. /**
  41. * XR input used to track XR inputs such as controllers/rays
  42. */
  43. export declare class WebXRInput implements IDisposable {
  44. /**
  45. * the xr session manager for this session
  46. */
  47. xrSessionManager: WebXRSessionManager;
  48. /**
  49. * the WebXR camera for this session. Mainly used for teleportation
  50. */
  51. xrCamera: WebXRCamera;
  52. private readonly _options;
  53. /**
  54. * XR controllers being tracked
  55. */
  56. controllers: Array<WebXRInputSource>;
  57. private _frameObserver;
  58. private _sessionEndedObserver;
  59. private _sessionInitObserver;
  60. /**
  61. * Event when a controller has been connected/added
  62. */
  63. onControllerAddedObservable: Observable<WebXRInputSource>;
  64. /**
  65. * Event when a controller has been removed/disconnected
  66. */
  67. onControllerRemovedObservable: Observable<WebXRInputSource>;
  68. /**
  69. * Initializes the WebXRInput
  70. * @param xrSessionManager the xr session manager for this session
  71. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  72. * @param _options = initialization options for this xr input
  73. */
  74. constructor(
  75. /**
  76. * the xr session manager for this session
  77. */
  78. xrSessionManager: WebXRSessionManager,
  79. /**
  80. * the WebXR camera for this session. Mainly used for teleportation
  81. */
  82. xrCamera: WebXRCamera, _options?: IWebXRInputOptions);
  83. private _onInputSourcesChange;
  84. private _addAndRemoveControllers;
  85. /**
  86. * Disposes of the object
  87. */
  88. dispose(): void;
  89. }