Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Hierarchy

  • WebXRFeaturesManager

Implements

Index

Constructors

constructor

  • constructs a new features manages.

    Parameters

    Returns WebXRFeaturesManager

Methods

_extendXRSessionInitObjectSearch playground for _extendXRSessionInitObject

  • 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

attachFeatureSearch playground for attachFeature

  • 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

detachFeatureSearch playground for detachFeature

  • 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

disableFeatureSearch playground for disableFeature

  • disableFeature(featureName: string | { Name: string }): boolean
  • 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

disposeSearch playground for dispose

  • dispose(): void
  • dispose this features manager

    Returns void

enableFeatureSearch playground for enableFeature

  • enableFeature(featureName: string | { Name: string }, 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 | { Name: string }

      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 or conflicts with another enabled feature.

getEnabledFeatureSearch playground for getEnabledFeature

  • get the implementation of an enabled feature.

    Parameters

    • featureName: string

      the name of the feature to load

    Returns IWebXRFeature

    the feature class, if found

getEnabledFeaturesSearch playground for getEnabledFeatures

  • getEnabledFeatures(): string[]
  • Get the list of enabled features

    Returns string[]

    an array of enabled features

Static AddWebXRFeatureSearch playground for AddWebXRFeature

  • 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 ConstructFeatureSearch playground for ConstructFeature

  • 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 () => IWebXRFeature

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

Static GetAvailableFeaturesSearch playground for GetAvailableFeatures

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

    Returns string[]

    an Array of available features

Static GetAvailableVersionsSearch playground for GetAvailableVersions

  • 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 GetLatestVersionOfFeatureSearch playground for GetLatestVersionOfFeature

  • 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 GetStableVersionOfFeatureSearch playground for GetStableVersionOfFeature

  • 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

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method