3D Game Programming

(C. Jardin) #1

Figure 10—The Tumblr Post


To get the size correct, adjust the aspect_ratio and renderer size. To make the
renderer 400 wide and 300 tall, you would use this:

// This will draw what the camera sees onto the screen:
varrenderer =newTHREE.CanvasRenderer();
renderer.setSize(400, 300);

The aspect ratio would then be as follows:


// This is what sees the stuff:
varaspect_ratio = 400/300;
varcamera =newTHREE.PerspectiveCamera(75, aspect_ratio, 1, 10000);

You math whizzes will know that you could also write 4/3 for the aspect ratio
there. You do not have to use these numbers—experiment and use what
works best on the page.

Chapter 21. Getting Code on the Web • 214


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf