The demo: https://playground.babylonjs.com/#Z4GXOX#1
Clicking on the green sphere (sphere2 with material2) affects the red sphere (sphere1 with material1). The reds sphere’s material became broken because its effect was disposed (see console log). Red sphere disappears because of that.
As I understand the bug appeared after this PR:
I think these lines cause an effect to be disposed more times than it is expected:
public dispose(): void {
if (this.effect) {
this.effect.dispose();
this.effect = null;
}
this.drawContext?.dispose();
}
Looks like an effect is disposed twice.
-
By this.releaseVertexArrayObject call
-
By set material to null in the next line (setMaterial setter)