Selecting an object in the scene

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.

Getting ready

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.

Getting ready

You can use your mouse to select ...

Get Three.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.