Implement temporary material and restore original

I implemented collide detection in a gltf scene.
I would like being able to setup red emissive color for colliding objects. And when they do not collide setup the original material .

How can I do this efficiently ?

Have you considered to use the same approach like in this official example?

If you can’t hard-code color values, save the original color in Material.userData.

1 Like