Class: VideoLayer
Defined in: src/layers/VideoLayer.ts:42
Presents a video as a composition layer where the platform allows it.
The point is resampling. Drawn into the scene, a video goes into the eye buffer and is then warped again by the compositor, so it is sampled twice and the first of those is into a buffer that is already lower resolution than the panel. As a layer it is sampled once, at its own resolution.
Reports VideoLayerState rather than throwing when it cannot, so an app can ask for a layer everywhere and draw the video into the scene on the platforms that have no layers.
Constructors
Constructor
new VideoLayer(
manager):VideoLayer
Defined in: src/layers/VideoLayer.ts:55
Parameters
manager
Owns the layer stack this layer joins.
Returns
VideoLayer
Methods
attach()
attach(
video,session,space,placement):boolean
Defined in: src/layers/VideoLayer.ts:82
Tries to present a video element as a quad layer.
Parameters
video
The element to present. Must already have metadata loaded for its aspect ratio to be known.
session
The active XR session.
space
Reference space the placement is expressed in.
placement
VideoLayerPlacement = {}
Where to put the quad.
Returns
boolean
Whether a layer was created.
detach()
detach():
void
Defined in: src/layers/VideoLayer.ts:225
Stops presenting the layer and returns the video to the scene.
Returns
void
getLayer()
getLayer():
XRQuadLayer|null
Defined in: src/layers/VideoLayer.ts:68
Returns
XRQuadLayer | null
The underlying layer, if one was created.
getPath()
getPath():
VideoLayerPath
Defined in: src/layers/VideoLayer.ts:63
Returns
Which binding is presenting the video.
getState()
getState():
VideoLayerState
Defined in: src/layers/VideoLayer.ts:58
Returns
Whether the video is being presented as a layer.
getUploadCount()
getUploadCount():
number
Defined in: src/layers/VideoLayer.ts:220
How many frames have actually been uploaded.
On the WebGL path the app draws every frame itself, so a count that stays at zero is the difference between a layer that is presenting and one that was created and then quietly did nothing.
Returns
number
Number of successful uploads since attaching.
update()
update(
frame):void
Defined in: src/layers/VideoLayer.ts:156
Draws the current video frame into the layer.
Only the WebGL path needs this: on the media path the compositor pulls frames from the element itself and the app never draws one. Safe to call every frame regardless.
Parameters
frame
The frame being rendered.
Returns
void