Common 3D Programming Errors

Keep the JavaScript console open for this section. After the closing curly brace of the eat function, add a blank line and then type the highlighted code.

​ ​function​ eat(food) {
​  console.log(food, ​'!!! Nom. Nom. Nom'​);
​ }
​ 
»​var​ shape = ​new​ THREE.SpherGeometry(100);
»​var​ cover = ​new​ Three.MeshNormalMaterial();
»​var​ ball = ​new​ THREE.Mesh(shape, cover);
»scene.ad(ball);

You’ll notice that the editor does not see any errors in this code. The browser reads the JavaScript code and says, “Yup, that looks like perfectly fine JavaScript to me. I’ll run it now!” However, problems pop up when the code is actually run, and you’ll see errors in the JavaScript ...

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.