XRCompositionLayer.needsRedraw

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

No specification found

No specification data found for api.XRCompositionLayer.needsRedraw.
Check for problems with this page or contribute a missing spec_url to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.

Browser compatibility

No compatibility data found for api.XRCompositionLayer.needsRedraw.
Check for problems with this page or contribute missing data to mdn/browser-compat-data.

See also