WebXRFeaturePointSystem.d.ts 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import type { WebXRSessionManager } from "../webXRSessionManager";
  2. import { Observable } from "../../Misc/observable";
  3. import { Vector3 } from "../../Maths/math.vector";
  4. import { WebXRAbstractFeature } from "./WebXRAbstractFeature";
  5. /**
  6. * A babylon interface for a "WebXR" feature point.
  7. * Represents the position and confidence value of a given feature point.
  8. */
  9. export interface IWebXRFeaturePoint {
  10. /**
  11. * Represents the position of the feature point in world space.
  12. */
  13. position: Vector3;
  14. /**
  15. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  16. */
  17. confidenceValue: number;
  18. }
  19. /**
  20. * The feature point system is used to detect feature points from real world geometry.
  21. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  22. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  23. */
  24. export declare class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  25. private _enabled;
  26. private _featurePointCloud;
  27. /**
  28. * The module's name
  29. */
  30. static readonly Name = "xr-feature-points";
  31. /**
  32. * The (Babylon) version of this module.
  33. * This is an integer representing the implementation version.
  34. * This number does not correspond to the WebXR specs version
  35. */
  36. static readonly Version = 1;
  37. /**
  38. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  39. * Will notify the observers about which feature points have been added.
  40. */
  41. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  42. /**
  43. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  44. * Will notify the observers about which feature points have been updated.
  45. */
  46. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  47. /**
  48. * The current feature point cloud maintained across frames.
  49. */
  50. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  51. /**
  52. * construct the feature point system
  53. * @param _xrSessionManager an instance of xr Session manager
  54. */
  55. constructor(_xrSessionManager: WebXRSessionManager);
  56. /**
  57. * Detach this feature.
  58. * Will usually be called by the features manager
  59. *
  60. * @returns true if successful.
  61. */
  62. detach(): boolean;
  63. /**
  64. * Dispose this feature and all of the resources attached
  65. */
  66. dispose(): void;
  67. /**
  68. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  69. * @param frame
  70. */
  71. protected _onXRFrame(frame: XRFrame): void;
  72. /**
  73. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  74. */
  75. private _init;
  76. }