Creating Spheres

Balls are called spheres in geometry and in 3D programming. There are two ways to control spheres in JavaScript.

Size: SphereGeometry(100)

The first way that we can control a sphere is to describe how big it is. When we said new THREE.SphereGeometry(100), we created a ball whose radius was 100. What happens when you change the radius to 250?

»​var​ shape = ​new​ THREE.SphereGeometry(250);
​ ​var​ cover = ​new​ THREE.MeshNormalMaterial(flat);
​ ​var​ ball = ​new​ THREE.Mesh(shape, cover);
​ scene.add(ball);

This should make it much bigger:

images/getting_started/3de_sphere_250.png

What happens if you change the 250 to 10? As you probably guessed, ...

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.