The Fourth Wall

How to 3D

Chapter 8: Interaction

The Fourth Wall

Rendering by itself produces aquariums. These aquariums teem with colorful creatures darting back and forth, but we users remain on the other side of the glass, passively spectating. We don't just want to see a virtual world; we want to interact with it. Cameras add some interactivity, allowing us to move around inside the aquarium. But for a renderer to be truly interactive, it must allow us to touch and manipulate objects.

In our discussion of cameras, you learned how a renderer can respond to taps on the glass with pointer event listeners:

window.addEventListener('pointerdown', event => {
  // handle down events
});

window.addEventListener('pointerup', event => {
  // handle up events
});
window.addEventListener('pointerdown', event => {
  // handle down events
});

window.addEventListener('pointerup', event => {
  // handle up events
});

In this chapter, we'll examine what needs to go inside these event listeners so that the user's 2D gestures influence the 3D world behind the glass. By the chapter's end, you'll be able to answer the following questions:

Let's tear down a wall.

Untransforming →