Cloning a NodeMaterial

Is there a reason that the clone operation does not work on NodeMaterials? I have been messing around with NodeMaterial Editor trying to make a forcefield shader. My original plan was to clone the material and provide different Color3 values for different shield colors.

Here is a playground illustrating the issue.

I suppose I could export the shaders and load them in through ShaderMaterial but I’m not very experienced working with GLSL code yet.

This looks like it might work as a workaround:

I ll check if I can add a clone function to the nodeMaterial.

1 Like

As I can see it, the clone method is not implemented in the NodeMaterial class, so you get the default implementation that simply returns null.

I don’t know if implementing the function is planned but in the meantime you can simply reload the material:

[EDIT] Ah, @sebavan solution is better than mine! [/EDIT]

1 Like

Our messages crossed :slight_smile: so 2 workarounds and I ll look into adding the clone :slight_smile:

Should be up in 10 minutes

All in your playground now works :slight_smile:

1 Like

Ah thanks the update works great! Now my follow-up question would be how do I get this latest build from the ES6 npm packages? Do I need to pull the preview tag?

I can always use the workarounds for npm builds in the meantime.

Yup, I just published 15 min ago so just install preview and you should be good to go.