Class WebXRFeaturesManager
Hierarchy
- WebXRFeaturesManager
Implements
Index
Constructors
constructor
constructs a new features manages.
Parameters
_xrSessionManager: WebXRSessionManager
an instance of WebXRSessionManager
Returns WebXRFeaturesManager
Methods
_extendXRSession Init ObjectSearch 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
attach FeatureSearch playground for attachFeature
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
detach FeatureSearch playground for detachFeature
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
disable FeatureSearch playground for disableFeature
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 this features manager
Returns void
enable FeatureSearch playground for enableFeature
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: string | number
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.
get Enabled FeatureSearch 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
get Enabled FeaturesSearch playground for getEnabledFeatures
Get the list of enabled features
Returns string[]
an array of enabled features
Static Add WebXRFeatureSearch playground for AddWebXRFeature
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 Construct FeatureSearch playground for ConstructFeature
Returns a constructor of a specific feature.
Parameters
featureName: string
the name of the feature to construct
version: undefined | number
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
Returns a constructor of a specific feature.
Returns IWebXRFeature
a function that, when called, will return a new instance of this feature
Static Get Available FeaturesSearch playground for GetAvailableFeatures
Can be used to return the list of features currently registered
Returns string[]
an Array of available features
Static Get Available VersionsSearch playground for GetAvailableVersions
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 Get Latest Version Of FeatureSearch playground for GetLatestVersionOfFeature
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 Get Stable Version Of FeatureSearch playground for GetStableVersionOfFeature
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
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).