My only suggestion here is not to push the uniforms from the onBeforeCompile
but push them into.
Ie.
myMaterial.userData.uniforms = { myUniform }
myMaterial.onBeforeCompile = shader=> shader.uniform.myUniform = myMaterial.myUniform
You can also bind onBeforeCompile
. This way you have your uniforms already during instantiation, you don’t have to wait for three to do it’s… thing