Camera detachPostProcess accumulates null elements

Hi everyone,

The detachPostProcess method from the Camera class sets detached post-processes to null : Babylon.js/camera.ts at d4ecd48d23c59315feca12f8d6bcdceb50f6b394 · BabylonJS/Babylon.js · GitHub

Wouldn’t it make more sense to splice the array instead, replacing

this._postProcesses[idx] = null;

with

this._postProcesses.splice(idx);

?

This issue was already mentionned in this post Disabling SSAO2 breaks FXAA - #12 by CraigFeldspar but it was not solved in the PR.

Is there a good reason behind this ? To avoid garbage collection for example ? (maybe in the same spirit as this [GC] Switch `= []` to `.length = 0` where possible by RaananW · Pull Request #12802 · BabylonJS/Babylon.js · GitHub ?)
Or maybe some code relies on the index of the post-process in this list ?

If that is not the case, I think splice would be better, it would avoid null elements from accumulating, for example if a post-process is attached/detached on every frame: Babylon.js Playground

What do you think?

This is done for not changing and reallocating arrays internally when the size of the array is changing IIRC.