API

Class WebXRFeaturesManager

The WebXR features manager is responsible of enabling or disabling features required for the current XR session. It is mainly used in AR sessions.

A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).

Implements

Index
  • This function will extend the session creation configuration object with enabled features. If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list, according to the defined "required" variable, provided during enableFeature call

    Parameters

    • xrSessionInit: XRSessionInit

      the xr Session init object to extend

    Returns Promise<XRSessionInit>

    an extended XRSessionInit object

  • Attach a feature to the current session. Mainly used when session started to start the feature effect. Can be used during a session to start a feature

    Parameters

    • featureName: string

      the name of feature to attach

    Returns void

  • Can be used inside a session or when the session ends to detach a specific feature

    Parameters

    • featureName: string

      the name of the feature to detach

    Returns void

  • Used to disable an already-enabled feature The feature will be disposed and will be recreated once enabled.

    Parameters

    • featureName: string | { Name: string }

      the feature to disable

    Returns boolean

    true if disable was successful

  • Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts. If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.

    Type Parameters

    Parameters

    • featureName: T | { Name: T }

      the name of the feature to load or the class of the feature

    • version: string | number = "latest"

      optional version to load. if not provided the latest version will be enabled

    • moduleOptions: ResolveWebXRFeatureOptions<T> = ...

      options provided to the module. Ses the module documentation / constructor

    • attachIfPossible: boolean = true

      if set to true (default) the feature will be automatically attached, if it is currently possible

    • required: boolean = true

      is this feature required to the app. If set to true the session init will fail if the feature is not available.

    Returns ResolveWebXRFeature<T>

    a new constructed feature or throws an error if feature not found or conflicts with another enabled feature.

  • Used to register a module. After calling this function a developer can use this feature in the scene. Mainly used internally.

    Parameters

    • featureName: string

      the name of the feature to register

    • constructorFunction: WebXRFeatureConstructor

      the function used to construct the module

    • version: number = 1

      the (babylon) version of the module

    • stable: boolean = false

      is that a stable version of this module

    Returns void

  • Returns a constructor of a specific feature.

    Parameters

    • featureName: string

      the name of the feature to construct

    • version: number = 1

      the version of the feature to load

    • xrSessionManager: WebXRSessionManager

      the xrSessionManager. Used to construct the module

    • Optionaloptions: any

      optional options provided to the module.

    Returns () => IWebXRFeature

    a function that, when called, will return a new instance of this feature

  • Gets the versions available for a specific feature

    Parameters

    • featureName: string

      the name of the feature

    Returns string[]

    an array with the available versions

  • Return the latest unstable version of this feature

    Parameters

    • featureName: string

      the name of the feature to search

    Returns number

    the version number. if not found will return -1

  • Return the latest stable version of this feature

    Parameters

    • featureName: string

      the name of the feature to search

    Returns number

    the version number. if not found will return -1