The Fourth Wall

How to 3D

Chapter 8: Interaction

The Fourth Wall

Rendering by itself produces aquariums—worlds we can see but can't interact with. They teem with colorful creatures living their own lives, 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 be part of 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 the objects within, and they must respond.

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

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 the wall between our physical and virtual worlds.

Smoothing Inputs →