XRCompositionLayer: needsRedraw property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The read-only needsRedraw
property of the XRCompositionLayer
interface is a boolean signaling that the layer should be re-rendered in the next frame.
The need for redrawing can occur when the underlying resources of a layer are lost due to textures that might have been freed by the compositor under the hood. This might happen when the device falls asleep or when the browser switches context (to an operating system dialog or similar) and then comes back.
Redrawing is not a problem for layers which are updated with every frame. However, for layers updated infrequently, or for static layers (where you can only draw once after creation or after a redraw
event), the layer's content might be lost and need to be redrawn. If the layer's resources are lost, the needsRedraw
property will be true
and a redraw
event is fired on the layer.
Value
A boolean. true
indicates a rerendering is needed in the next frame, false
indicates no re-rendering is needed.
Examples
Redrawing layers
Use the needsRedraw
property to check if a layer needs to be redrawn and then redraw it.
function onXRFrame(time, frame) {
// …
if (quadLayer.needsRedraw) {
// redraw the layer
}
}
Specifications
Specification |
---|
WebXR Layers API Level 1 # dom-xrcompositionlayer-needsredraw |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
needsRedraw |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
See also
XREquirectLayer
:redraw
eventXRCubeLayer
:redraw
eventXRCylinderLayer
:redraw
eventXRQuadLayer
:redraw
event