And here’s an updated version of your playground with the effect I think you were going for:
I think what was happening is that the intersection detection (that’s fun to say) was happening at some point in the scene…perhaps before the rendered change of the position? And once it was set to red, it just never gets set to back.
By putting the hit detection inside the registerBeforeRender call as it demonstrates in the documentation, you essentially assign a material to the sphere before every frame based on whether the intersection is true or false.
Hope that all makes sense.