Creating a 2D overlay
In most recipes, we only focus on the 3D aspect of Three.js. We show recipes that explain how 3D objects and scenes are rendered, how they can be viewed with different cameras, and how you can change how they look through materials. When you are creating games, you usually also have a 2D layer on top of your 3D scene. You can use this to show health bars, 2D maps, inventory, and much more. In this recipe, we'll show you how to create a 2D overlay using THREE.OrthogonalCamera
and THREE.PerspectiveCamera
together.
Getting ready
For this recipe, we require an image that we will use as an overlay. To demonstrate this recipe, we create a simple image that looks like this:
In this recipe, we'll combine this static image with a 3D ...
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.