Building Flat Surfaces with Planes

A plane is a flat surface. Planes are especially useful for the ground, but they can also be handy to mark doors and edges in our games.

PlaneGeometry(100, 100)

Since planes are just flat squares, they are much simpler than the other objects we’ve seen so far. Below your cylinder code (and a blank line), type the following:

​ ​var​ shape = ​new​ THREE.PlaneGeometry(100, 100);
​ ​var​ cover = ​new​ THREE.MeshNormalMaterial(flat);
​ ​var​ ground = ​new​ THREE.Mesh(shape, cover);
​ scene.add(ground);
​ ground.rotation.​set​(0.5, 0, 0);

Don’t forget the rotation on the last line. Planes are so thin that you might not see them when looking at them sideways.

The numbers ...

Get 3D Game Programming for Kids, 2nd Edition 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.