WebXRWalkingLocomotion.d.ts 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import type { TransformNode } from "../../Meshes/transformNode";
  2. import type { WebXRCamera } from "../webXRCamera";
  3. import type { WebXRSessionManager } from "../webXRSessionManager";
  4. import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
  5. /**
  6. * Options for the walking locomotion feature.
  7. */
  8. export interface IWebXRWalkingLocomotionOptions {
  9. /**
  10. * The target to be moved by walking locomotion. This should be the transform node
  11. * which is the root of the XR space (i.e., the WebXRCamera's parent node). However,
  12. * for simple cases and legacy purposes, articulating the WebXRCamera itself is also
  13. * supported as a deprecated feature.
  14. */
  15. locomotionTarget: WebXRCamera | TransformNode;
  16. }
  17. /**
  18. * A module that will enable VR locomotion by detecting when the user walks in place.
  19. */
  20. export declare class WebXRWalkingLocomotion extends WebXRAbstractFeature {
  21. /**
  22. * The module's name.
  23. */
  24. static get Name(): string;
  25. /**
  26. * The (Babylon) version of this module.
  27. * This is an integer representing the implementation version.
  28. * This number has no external basis.
  29. */
  30. static get Version(): number;
  31. private _sessionManager;
  32. private _up;
  33. private _forward;
  34. private _position;
  35. private _movement;
  36. private _walker;
  37. private _locomotionTarget;
  38. private _isLocomotionTargetWebXRCamera;
  39. /**
  40. * The target to be articulated by walking locomotion.
  41. * When the walking locomotion feature detects walking in place, this element's
  42. * X and Z coordinates will be modified to reflect locomotion. This target should
  43. * be either the XR space's origin (i.e., the parent node of the WebXRCamera) or
  44. * the WebXRCamera itself. Note that the WebXRCamera path will modify the position
  45. * of the WebXRCamera directly and is thus discouraged.
  46. */
  47. get locomotionTarget(): WebXRCamera | TransformNode;
  48. /**
  49. * The target to be articulated by walking locomotion.
  50. * When the walking locomotion feature detects walking in place, this element's
  51. * X and Z coordinates will be modified to reflect locomotion. This target should
  52. * be either the XR space's origin (i.e., the parent node of the WebXRCamera) or
  53. * the WebXRCamera itself. Note that the WebXRCamera path will modify the position
  54. * of the WebXRCamera directly and is thus discouraged.
  55. */
  56. set locomotionTarget(locomotionTarget: WebXRCamera | TransformNode);
  57. /**
  58. * Construct a new Walking Locomotion feature.
  59. * @param sessionManager manager for the current XR session
  60. * @param options creation options, prominently including the vector target for locomotion
  61. */
  62. constructor(sessionManager: WebXRSessionManager, options: IWebXRWalkingLocomotionOptions);
  63. /**
  64. * Checks whether this feature is compatible with the current WebXR session.
  65. * Walking locomotion is only compatible with "immersive-vr" sessions.
  66. * @returns true if compatible, false otherwise
  67. */
  68. isCompatible(): boolean;
  69. /**
  70. * Attaches the feature.
  71. * Typically called automatically by the features manager.
  72. * @returns true if attach succeeded, false otherwise
  73. */
  74. attach(): boolean;
  75. /**
  76. * Detaches the feature.
  77. * Typically called automatically by the features manager.
  78. * @returns true if detach succeeded, false otherwise
  79. */
  80. detach(): boolean;
  81. protected _onXRFrame(frame: XRFrame): void;
  82. }