Class WebXRFeaturesManager
Implements
Constructors
constructor
-
constructs a new features manages.
Parameters
- _xrSessionManager: WebXRSessionManager
an instance of WebXRSessionManager
Returns WebXRFeaturesManager
- _xrSessionManager: WebXRSessionManager
Methods
_ extend XR Session Init Object
-
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
- xrSessionInit: XRSessionInit
attach Feature
-
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
- featureName: string
detach Feature
-
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
- featureName: string
disable Feature
-
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
- featureName: string | { Name: string }
dispose
-
dispose this features manager
Returns void
enable Feature
-
enableFeature<T extends WebXRFeatureNameType>(
featureName: T | { Name: T },
version?: string | number,
moduleOptions?: ResolveWebXRFeatureOptions<T>,
attachIfPossible?: boolean,
required?: boolean,
): ResolveWebXRFeature<T>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
- T extends WebXRFeatureNameType
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.
get Enabled Feature
-
get the implementation of an enabled feature.
Type Parameters
- T extends WebXRFeatureNameType
Parameters
- featureName: T
the name of the feature to load
Returns ResolveWebXRFeature<T>
the feature class, if found
get Enabled Features
-
Get the list of enabled features
Returns string[]
an array of enabled features
StaticAdd Web XR Feature
-
AddWebXRFeature(
featureName: string,
constructorFunction: WebXRFeatureConstructor,
version?: number,
stable?: boolean,
): voidUsed 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
- featureName: string
StaticConstruct Feature
-
ConstructFeature(
featureName: string,
version?: number,
xrSessionManager: WebXRSessionManager,
options?: any,
): () => IWebXRFeatureReturns 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: anyoptional options provided to the module.
Returns () => IWebXRFeature
a function that, when called, will return a new instance of this feature
- featureName: string
StaticGet Available Features
-
Can be used to return the list of features currently registered
Returns string[]
an Array of available features
StaticGet Available Versions
-
Gets the versions available for a specific feature
Parameters
- featureName: string
the name of the feature
Returns string[]
an array with the available versions
- featureName: string
StaticGet Latest Version Of Feature
-
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
- featureName: string
StaticGet Stable Version Of Feature
-
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
- featureName: string
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).