That is the same road from the previous image. We’ve only replaced the two
lines that create the perspective camera with the following:
varwidth = window.innerWidth,
height = window.innerHeight;
varcamera =newTHREE.OrthographicCamera(
-width/2, width/2, height/2, -height/2, 1, 10000
);
As you might imagine, the perspective camera that gives everything a three-
dimensional feel is very handy in 3D games. Why would you want to use an
orthographic camera?
Orthographic cameras are useful in two cases. The first is when you want to
make a flat, 2D game. Using a 3D camera for a flat game just looks
weird—especially at the edges of the screen. The other is when we make games
with really, really long distances, such as space games. In fact, we can use
orthographic cameras in some of the space simulations we’ll do in a little
while.
9.7 What’s Next
Now that we understand all about cameras, scenes, and JavaScript libraries,
we’ll change them more and more. But first let’s teach our game avatar to not
walk through trees.
report erratum • discuss
10.4 What’s Next
Prepared exclusively for Michael Powell