XR Occlusion
Updated
Real objects hide virtual ones behind them.
- Type
comp-xr-occlusion- Script class
XRDepthOcclusionComponent- Per entity
- One
- Version
- 1.0.0
Read about it in XR world: what it does, how to use it from a script, and examples.
Properties
Section titled “Properties”The props the runtime declares for this component, with their defaults and accepted ranges.
| Prop | Default | Range |
|---|---|---|
depthBias |
- |
|
maxDistance |
0.5 ≤ x ≤ 20 |
|
softness |
0 ≤ x ≤ 0.5 |
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
An XR World with XR Light Estimate and XR Depth Occlusion: in AR the scene is lit like the real room and real things hide virtual ones. Buttons switch between a fast mode and high realism, with shadows from the real main light and soft occlusion.
This one needs AR: enter AR on an Android phone or a Quest 3 and press High realism. On a desktop there is no estimate or depth, so the stage lights stay in charge and the buttons only change the settings.
From a script
Section titled “From a script”#pragma lifecycle(startup)
function startup() { const component = self.parent.getComponent(XRDepthOcclusionComponent); if (component) log(component.props);}