How should I use Preprocessor Macro in PBRCustomMaterial

Here is the playground

My needs are:
I can turn an effect on or off with a macro

Uncomment lines 38-41 of code, which works fine
But I want to achieve the same effect by clicking handle

Like this, but it doesn’t work

button.addEventListener("click", () => {
        // TO DO
        // How do I turn effects on or off with a button interaction setting macro?
        // This is not effective
        customMaterial.Fragment_Definitions(`
            #define USE_WORLD_CLIP
            #define USE_COLOR_MIX
        `)
    })

If you can help, thank you very much!!!

Using defines in a custom material is not supported. The best you can do is to create two different materials, and use one or the other on the click event.

Switching textures should cause a flash, which is not what I need
Can I achieve a non-inductive replacement material?

If you don’t want a flash (no shader recompilation), you should not use defines but uniform parameters instead. Something like:

if (use_color_mix) {
    ...
}
if (use_world_clip) {
   ...
}

And use AddUniform to add use_color_mix and use_world_clip as uniforms to the material.

Ok, I understand. I did this before, but I thought preprocessor-macro might work better