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).

Hierarchy

  • WebXRFeaturesManager

Implements

Index

Constructors

constructor

Find examples in Playground

Methods

attachFeature

Find examples in Playground
  • attachFeature(featureName: string): void
  • 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

detachFeature

Find examples in Playground
  • detachFeature(featureName: string): 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

disableFeature

Find examples in Playground
  • disableFeature(featureName: string | object): boolean
  • Used to disable an already-enabled feature The feature will be disposed and will be recreated once enabled.

    Parameters

    • featureName: string | object

      the feature to disable

    Returns boolean

    true if disable was successful

dispose

Find examples in Playground
  • dispose(): void

enableFeature

Find examples in Playground
  • enableFeature(featureName: string | object, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature
  • 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.

    Parameters

    • featureName: string | object

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

    • Optional version: number | string

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

    • Optional moduleOptions: any

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

    • Optional attachIfPossible: boolean

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

    • Optional required: boolean

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

    Returns IWebXRFeature

    a new constructed feature or throws an error if feature not found.

extendXRSessionInitObject

Find examples in Playground
  • This function will exten 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 XRSessionInit

    an extended XRSessionInit object

getEnabledFeature

Find examples in Playground
  • get the implementation of an enabled feature.

    Parameters

    • featureName: string

      the name of the feature to load

    Returns IWebXRFeature

    the feature class, if found

getEnabledFeatures

Find examples in Playground
  • getEnabledFeatures(): string[]
  • Get the list of enabled features

    Returns string[]

    an array of enabled features

Static AddWebXRFeature

Find examples in Playground
  • AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void
  • 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

    • Optional version: number

      the (babylon) version of the module

    • Optional stable: boolean

      is that a stable version of this module

    Returns void

Static ConstructFeature

Find examples in Playground
  • ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): function
  • Returns a constructor of a specific feature.

    Parameters

    • featureName: string

      the name of the feature to construct

    • version: number | undefined

      the version of the feature to load

    • xrSessionManager: WebXRSessionManager

      the xrSessionManager. Used to construct the module

    • Optional options: any

      optional options provided to the module.

    Returns function

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

Static GetAvailableFeatures

Find examples in Playground
  • GetAvailableFeatures(): string[]
  • Can be used to return the list of features currently registered

    Returns string[]

    an Array of available features

Static GetAvailableVersions

Find examples in Playground
  • GetAvailableVersions(featureName: string): string[]
  • Gets the versions available for a specific feature

    Parameters

    • featureName: string

      the name of the feature

    Returns string[]

    an array with the available versions

Static GetLatestVersionOfFeature

Find examples in Playground
  • GetLatestVersionOfFeature(featureName: string): number
  • 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

Static GetStableVersionOfFeature

Find examples in Playground
  • GetStableVersionOfFeature(featureName: string): number
  • 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

Generated using TypeDoc