I have a raycaster already set up in Three.js, which works.
Here's the code that determines what happens when you mouse over an object in the scene:
function onDocumentMouseMove( event ){
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = -( event.clientY / window.innerHeight ) * 2 + 1;
raycaster.setFromCamera( mouse, camera );
if (intersects.length > 0) { // if an object has been moused over
// set object to 75% opacity
intersects[0].object.material.opacity = 0.75;
}
}
All this does is set the object's opacity to 0.75 when the user places their cursor over the object. However, after the object is no longer moused over, I would like to reset the opacity back to 1.
How exactly would I do this with raycaster? I wanted to set up a boolean that becomes false after it is not moused over, but you can only reference the object when it is moused over.