webXRMotionControllerManager.d.ts 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import type { WebXRAbstractMotionController } from "./webXRAbstractMotionController";
  2. import type { Scene } from "../../scene";
  3. /**
  4. * A construction function type to create a new controller based on an xrInput object
  5. */
  6. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  7. /**
  8. * Motion controller manager is managing the different webxr profiles and makes sure the right
  9. * controller is being loaded.
  10. */
  11. export declare class WebXRMotionControllerManager {
  12. private static _AvailableControllers;
  13. private static _Fallbacks;
  14. private static _ProfileLoadingPromises;
  15. private static _ProfilesList;
  16. /**
  17. * The base URL of the online controller repository. Can be changed at any time.
  18. */
  19. static BaseRepositoryUrl: string;
  20. /**
  21. * Which repository gets priority - local or online
  22. */
  23. static PrioritizeOnlineRepository: boolean;
  24. /**
  25. * Use the online repository, or use only locally-defined controllers
  26. */
  27. static UseOnlineRepository: boolean;
  28. /**
  29. * Disable the controller cache and load the models each time a new WebXRProfileMotionController is loaded.
  30. * Defaults to true.
  31. */
  32. static DisableControllerCache: boolean;
  33. /**
  34. * Clear the cache used for profile loading and reload when requested again
  35. */
  36. static ClearProfilesCache(): void;
  37. /**
  38. * Register the default fallbacks.
  39. * This function is called automatically when this file is imported.
  40. */
  41. static DefaultFallbacks(): void;
  42. /**
  43. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44. * @param profileId the profile to which a fallback needs to be found
  45. * @returns an array with corresponding fallback profiles
  46. */
  47. static FindFallbackWithProfileId(profileId: string): string[];
  48. /**
  49. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50. * The order of search:
  51. *
  52. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  55. * 4) return the generic trigger controller if none were found
  56. *
  57. * @param xrInput the xrInput to which a new controller is initialized
  58. * @param scene the scene to which the model will be added
  59. * @param forceProfile force a certain profile for this controller
  60. * @returns A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  61. */
  62. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  63. /**
  64. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  65. *
  66. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  67. *
  68. * @param type the profile type to register
  69. * @param constructFunction the function to be called when loading this profile
  70. */
  71. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  72. /**
  73. * Register a fallback to a specific profile.
  74. * @param profileId the profileId that will receive the fallbacks
  75. * @param fallbacks A list of fallback profiles
  76. */
  77. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  78. /**
  79. * Will update the list of profiles available in the repository
  80. * @returns a promise that resolves to a map of profiles available online
  81. */
  82. static UpdateProfilesList(): Promise<{
  83. [profile: string]: string;
  84. }>;
  85. /**
  86. * Clear the controller's cache (usually happens at the end of a session)
  87. */
  88. static ClearControllerCache(): void;
  89. private static _LoadProfileFromRepository;
  90. private static _LoadProfilesFromAvailableControllers;
  91. }