Class WebXRLayers
Hierarchy (View Summary)
- WebXRAbstractFeature
- WebXRLayers
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new WebXRLayers(
_xrSessionManager: WebXRSessionManager,
_options?: IWebXRLayersOptions,
): WebXRLayersParameters
- _xrSessionManager: WebXRSessionManager
- _options: IWebXRLayersOptions = {}
Returns WebXRLayers
Properties
Optionaldepends On
The dependencies of this feature, if any
disable Auto Attach
Should auto-attach be disabled?
is Disposed
Is this feature disposed?
on Feature Attach Observable
Observers registered here will be executed when the feature is attached
on Feature Detach Observable
Observers registered here will be executed when the feature is detached
Static ReadonlyName
The module's name
Static ReadonlyVersion
The (Babylon) version of this module. This is an integer representing the implementation version. This number does not correspond to the WebXR specs version
Accessors
attached
-
get attached(): boolean
Is this feature attached
Returns boolean
is Max Render Layers Supported
-
get isMaxRenderLayersSupported(): boolean
Whether the active XR session exposes its compositor layer limit.
Returns boolean
max Render Layers
-
Gets the maximum number of native layers accepted in the active session's render-state
layersarray. The projection layer counts toward this limit. Fallback mesh layers do not.Returns Nullable<number>
The native layer limit, or
nullwhen the runtime does not expose it.
xr Native Feature Name
-
get xrNativeFeatureName(): string
The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
Returns string
-
set xrNativeFeatureName(name: string): void
The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
Parameters
- name: string
Returns void
Methods
add Fullscreen Advanced Dynamic Texture
-
addFullscreenAdvancedDynamicTexture(
texture: DynamicTexture,
options?: { distanceFromHeadset: number },
): Nullable<
WebXRCompositionLayerWrapper<XRCompositionLayer, WebXRLayerType>,
>ExperimentalThis will support full screen ADT when used with WebXR Layers. This API might change in the future. Note that no interaction will be available with the ADT when using this method
Parameters
- texture: DynamicTexture
the texture to display in the layer
- options: { distanceFromHeadset: number } = ...
optional parameters for the layer
Returns Nullable<WebXRCompositionLayerWrapper<XRCompositionLayer, WebXRLayerType>>
a composition layer containing the texture, or null when WebGPU quad layers are unavailable
- texture: DynamicTexture
add XR Session Layer
-
Add a new layer to the already-existing list of layers
Parameters
- wrappedLayer: WebXRLayerWrapper<WebXRSupportedLayerType>
the new layer to add to the existing ones
Returns void
- wrappedLayer: WebXRLayerWrapper<WebXRSupportedLayerType>
attach
-
Attach this feature. Will usually be called by the features manager.
Returns boolean
true if successful.
create Cube Layer
-
createCubeLayer(
options?: IWebXRCompositionLayerCreationOptions<
XRCubeLayerInit,
XRGPUCubeLayerInit,
>,
): Nullable<WebXRFallbackLayerWrapper | WebXRCubeLayerWrapper>Creates a graphics-backed cube layer and adds it to the current XR session. Cube layers synchronize only the rotation of their transform node because the WebXR API does not support cube-layer translation.
Parameters
- options: IWebXRCompositionLayerCreationOptions<XRCubeLayerInit, XRGPUCubeLayerInit> = {}
initialization and transform-node options for the layer
Returns Nullable<WebXRFallbackLayerWrapper | WebXRCubeLayerWrapper>
the created layer wrapper, or
nullwhen the active graphics binding does not support cube layers - options: IWebXRCompositionLayerCreationOptions<XRCubeLayerInit, XRGPUCubeLayerInit> = {}
create Cylinder Layer
-
createCylinderLayer(
options?: IWebXRCompositionLayerCreationOptions<
XRCylinderLayerInit,
XRGPUCylinderLayerInit,
>,
): Nullable<WebXRLayerCreationResult<XRCylinderLayer, "XRCylinderLayer">>Creates a graphics-backed cylinder layer and adds it to the current XR session.
Parameters
- options: IWebXRCompositionLayerCreationOptions<
XRCylinderLayerInit,
XRGPUCylinderLayerInit,
> = {}initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XRCylinderLayer, "XRCylinderLayer">>
the created layer wrapper, or
nullwhen the active graphics binding does not support cylinder layers - options: IWebXRCompositionLayerCreationOptions<
create Equirect Layer
-
createEquirectLayer(
options?: IWebXRCompositionLayerCreationOptions<
XREquirectLayerInit,
XRGPUEquirectLayerInit,
>,
): Nullable<WebXRLayerCreationResult<XREquirectLayer, "XREquirectLayer">>Creates a graphics-backed equirectangular layer and adds it to the current XR session.
Parameters
- options: IWebXRCompositionLayerCreationOptions<
XREquirectLayerInit,
XRGPUEquirectLayerInit,
> = {}initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XREquirectLayer, "XREquirectLayer">>
the created layer wrapper, or
nullwhen the active graphics binding does not support equirectangular layers - options: IWebXRCompositionLayerCreationOptions<
create Media Cylinder Layer
-
createMediaCylinderLayer(
video: HTMLVideoElement,
options?: IWebXRMediaLayerCreationOptions<XRMediaCylinderLayerInit>,
): Nullable<WebXRLayerCreationResult<XRCylinderLayer, "XRCylinderLayer">>Creates a video-backed cylinder layer and adds it to the current XR session.
Parameters
- video: HTMLVideoElement
the video element presented by the XR compositor
- options: IWebXRMediaLayerCreationOptions<XRMediaCylinderLayerInit> = {}
initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XRCylinderLayer, "XRCylinderLayer">>
the created media layer wrapper, or
nullwhen XRMediaBinding is unavailable - video: HTMLVideoElement
create Media Equirect Layer
-
createMediaEquirectLayer(
video: HTMLVideoElement,
options?: IWebXRMediaLayerCreationOptions<XRMediaEquirectLayerInit>,
): Nullable<WebXRLayerCreationResult<XREquirectLayer, "XREquirectLayer">>Creates a video-backed equirectangular layer and adds it to the current XR session.
Parameters
- video: HTMLVideoElement
the video element presented by the XR compositor
- options: IWebXRMediaLayerCreationOptions<XRMediaEquirectLayerInit> = {}
initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XREquirectLayer, "XREquirectLayer">>
the created media layer wrapper, or
nullwhen XRMediaBinding is unavailable - video: HTMLVideoElement
create Media Quad Layer
-
createMediaQuadLayer(
video: HTMLVideoElement,
options?: IWebXRMediaLayerCreationOptions<XRMediaQuadLayerInit>,
): Nullable<WebXRLayerCreationResult<XRQuadLayer, "XRQuadLayer">>Creates a video-backed quad layer and adds it to the current XR session.
Parameters
- video: HTMLVideoElement
the video element presented by the XR compositor
- options: IWebXRMediaLayerCreationOptions<XRMediaQuadLayerInit> = {}
initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XRQuadLayer, "XRQuadLayer">>
the created media layer wrapper, or
nullwhen XRMediaBinding is unavailable - video: HTMLVideoElement
create Projection Layer
-
createProjectionLayer(
params?: XRProjectionLayerInit,
multiview?: boolean,
): WebXRProjectionLayerWrapperCreates a new XRProjectionLayer.
Parameters
- params: XRProjectionLayerInit = DefaultXRProjectionLayerInit
an object providing configuration options for the new XRProjectionLayer.
- multiview: boolean = ...
whether the projection layer should render with multiview. Will be tru automatically if the extension initialized with multiview.
Returns WebXRProjectionLayerWrapper
the projection layer
- params: XRProjectionLayerInit = DefaultXRProjectionLayerInit
create Quad Layer
-
createQuadLayer(
options?: IWebXRCompositionLayerCreationOptions<
XRQuadLayerInit,
XRGPUQuadLayerInit,
>,
): Nullable<WebXRLayerCreationResult<XRQuadLayer, "XRQuadLayer">>Creates a graphics-backed quad layer and adds it to the current XR session.
Parameters
- options: IWebXRCompositionLayerCreationOptions<XRQuadLayerInit, XRGPUQuadLayerInit> = {}
initialization and transform-node options for the layer
Returns Nullable<WebXRLayerCreationResult<XRQuadLayer, "XRQuadLayer">>
the created layer wrapper, or
nullwhen the active graphics binding does not support quad layers - options: IWebXRCompositionLayerCreationOptions<XRQuadLayerInit, XRGPUQuadLayerInit> = {}
create XR Web GL Layer
-
Creates a new XRWebGLLayer.
Parameters
- params: XRWebGLLayerInit = DefaultXRWebGLLayerInit
an object providing configuration options for the new XRWebGLLayer
Returns WebXRWebGLLayerWrapper
the XRWebGLLayer
- params: XRWebGLLayerInit = DefaultXRWebGLLayerInit
detach
-
detach this feature.
Returns boolean
true if successful, false if failed or already detached
dispose
-
Dispose this feature and all of the resources attached.
Returns void
is Compatible
-
This function will be executed during before enabling the feature and can be used to not-allow enabling it. Note that at this point the session has NOT started, so this is purely checking if the browser supports it
Returns boolean
whether or not the feature is compatible in this environment
is Layer Type Supported
-
Checks whether the active runtime exposes the factory needed for a layer type. This is a capability check only; creation can still fail when an initialization dictionary is invalid.
Parameters
- layerType: any
the concrete WebXR layer type
- source: WebXRLayerSource = "graphics"
whether to check a graphics-backed or media-backed layer
Returns boolean
whether the requested factory is available
- layerType: any
remove Layer
-
Removes either a native spatial layer or a fallback layer created by this feature.
Parameters
- wrappedLayer: WebXRLayerCreationResult<any>
the native or fallback layer wrapper to remove
- dispose: boolean = true
whether to dispose resources owned by the wrapper
Returns boolean
whether the wrapper was present and removed
- wrappedLayer: WebXRLayerCreationResult<any>
remove XR Session Layer
-
removeXRSessionLayer(
wrappedLayer: WebXRLayerWrapper<WebXRSupportedLayerType>,
dispose?: boolean,
): booleanRemoves a non-projection layer from the current XR session.
Parameters
- wrappedLayer: WebXRLayerWrapper<WebXRSupportedLayerType>
the layer wrapper to remove
- dispose: boolean = true
whether to dispose the wrapper and destroy its native composition layer
Returns boolean
whether the layer was present and removed
- wrappedLayer: WebXRLayerWrapper<WebXRSupportedLayerType>
set XR Session Layers
-
Sets the layers to be used by the XR session. Note that you must call this function with any layers you wish to render to since it adds them to the XR session's render state (replacing any layers that were added in a previous call to setXRSessionLayers or updateRenderState). This method also sets up the session manager's render target texture provider as the first layer in the array, which feeds the WebXR camera(s) attached to the session.
Parameters
- wrappedLayers: WebXRLayerWrapper<WebXRSupportedLayerType>[] = ...
An array of WebXRLayerWrapper, usually returned from the WebXRLayers createLayer functions.
Returns void
- wrappedLayers: WebXRLayerWrapper<WebXRSupportedLayerType>[] = ...
Exposes the WebXR Layers API.