Implement temporary material and restore original

Hi,
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?

https://threejs.org/examples/webgl_math_obb

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

1 Like