A common requirement for Three.js applications is to interact with the scene. You might create a shooter where you want to use the mouse for aiming or an RPG where you need to interact with your environment. In this recipe, we'll show you how you can use the mouse to select objects that are rendered on screen.
To apply this effect, we'll need a scene where we can select some objects. For this recipe, we've provided an example, which is 03.10-select-an-object-in-the-scene.html
. If you open this file in your browser, you'll see a number of objects moving around the scene.
You can use your mouse to select any of the objects on screen. The first time you click on them, they'll become transparent, and the next time, they'll become solid again.