There seems to be an issue from 4.2.1 to 5.x with ParticleSystem.clone()
.
var custom = { ...this._customWrappers };
...
if (engine.createEffectForParticles) {
if (this.customShader != null) {
program = this.customShader;
var defines: string = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
// this line. createEffectForParticles returns an Effect
custom[0] = engine.createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
}
}
...
result.customShader = program;
result._customWrappers = custom;
It is setting custom[0]
to an Effect
object, where before the clone it would have been a DrawWrapper
object. This means that any calls to getCustomEffect
will return undefined:
public getCustomEffect(blendMode: number = 0): Nullable<Effect> {
return this._customWrappers[blendMode]?.effect ?? this._customWrappers[0]!.effect;
}
because now this._customWrappers[blendMode]
IS the effect.