@relu-interactives/spatial-ecs
@relu-interactives/spatial-ecs / index / OcclusionCullingSystem
Class: OcclusionCullingSystem ​
Defined in: systems/OcclusionCullingSystem.ts:66
Skips drawing objects hidden behind OccluderComponents.
Every frame, after the camera has moved, the occluders' boxes are drawn into a small CPU depth buffer (OcclusionBuffer) and each model and primitive is tested against it. An object becomes visible the frame it's no longer covered, and is hidden only after two covered frames in a row.
A default system. Off in the editor, off in a world without occluders, and off while a headset presents unless xr is set: the test uses one camera, a headset draws two eyes.
Implements ​
Constructors ​
Constructor ​
new OcclusionCullingSystem(isEditor?): OcclusionCullingSystem;Defined in: systems/OcclusionCullingSystem.ts:90
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
isEditor | boolean | false |
Returns ​
OcclusionCullingSystem
Properties ​
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
runsWhilePaused | readonly | true | true | Keep ticking while the world is paused. Leave it unset for anything that moves the game on: such a system stops at world.pause() and picks up where it was at world.resume(). | systems/OcclusionCullingSystem.ts:67 |
enabled | public | boolean | true | Turn occlusion culling off without removing occluders. | systems/OcclusionCullingSystem.ts:69 |
xr | public | boolean | false | Also cull while a headset presents (tested from the head, not each eye). | systems/OcclusionCullingSystem.ts:71 |
maxOccluders | public | number | 64 | Most occluders drawn a frame: the biggest on screen first. | systems/OcclusionCullingSystem.ts:73 |
idleInterval | public | number | 15 | While nothing has been hidden for this many frames, test only one frame in this many: a scene where occluders hide nothing doesn't pay for them every frame. 1 tests every frame. | systems/OcclusionCullingSystem.ts:79 |
buffer | public | OcclusionBuffer | undefined | The depth buffer. 256 x 128 by default; setResolution for slower devices. | systems/OcclusionCullingSystem.ts:83 |
Methods ​
addOccluderSource() ​
addOccluderSource(source): () => void;Defined in: systems/OcclusionCullingSystem.ts:93
Let another system add occluders each frame (terrain does). Returns a remover.
Parameters ​
| Parameter | Type |
|---|---|
source | OccluderSource |
Returns ​
() => void
setResolution() ​
setResolution(width, height): void;Defined in: systems/OcclusionCullingSystem.ts:99
A smaller buffer is cheaper and hides less.
Parameters ​
| Parameter | Type |
|---|---|
width | number |
height | number |
Returns ​
void
getStats() ​
getStats(): OcclusionStats;Defined in: systems/OcclusionCullingSystem.ts:103
Returns ​
update() ​
update(world): void;Defined in: systems/OcclusionCullingSystem.ts:107
Parameters ​
| Parameter | Type |
|---|---|
world | World |
Returns ​
void

