ProjectorManager

Default texture unit where the depth array sampler is bound.

Constructor

new ProjectorManager()

Members

active

Snapshot of currently active projectors (sorted by priority desc).

activeCount

Total active projectors count (used by consumers to choose _proj / _noproj programs).

depthArrayTexture

Manager-owned TEXTURE_2D_ARRAY containing depth maps for all projectors.

Methods

_ensureDepthArrayTexture()

Lazily allocates the manager-owned TEXTURE_2D_ARRAY at the size of the first projector to be added. All subsequent projectors must use the same size. Returns false if a size mismatch is detected.

_rebindFramebufferToLayer()

Rebinds projector.depthCamera.framebuffer COLOR_ATTACHMENT0 from its own TEXTURE_2D to (this._depthArrayTexture, projector._slot) so renders go directly into the array layer without any per-frame copy. The original TEXTURE_2D stays referenced inside framebuffer.textures[0] so framebuffer.destroy() can free it normally — we never overwrite that slot with the shared array texture.

_restoreFramebufferAttachment()

Restores projector.depthCamera.framebuffer COLOR_ATTACHMENT0 back to its original TEXTURE_2D so subsequent depth renders no longer touch the freed array layer.

bindDeferred(projectorIndex)

Binds exactly one projector for deferred frustum-geometry draw call.

Parameters:
NameTypeDefaultDescription
projectorIndex0

Active projector index in priority-sorted array.

Returns:

1 if projector was bound, 0 if index is out of range.

bindForward()

Binds forward/WOIT projectors to the given shader program. Uses top-K projectors by priority for current draw call.

Returns:

Actual projector count uploaded (0..MAX_FORWARD_PROJECTORS).