Code: Working with Lights and Materials

This is the final version of the code that we used to explore lights and materials in Chapter 12, ​Working with Lights and Materials​:

​ <body></body>
​ <script src=​"/three.js"​></script>
​ <script src=​"/controls/OrbitControls.js"​></script>
​ <script>
​  ​// The "scene" is where stuff in our game will happen:​
​  ​var​ scene = ​new​ THREE.Scene();
​  ​var​ flat = {flatShading: ​true​};
​  ​var​ light = ​new​ THREE.AmbientLight(​'white'​, 0.1);
​  scene.add(light);
​ 
​  ​// The "camera" is what sees the stuff:​
​  ​var​ aspectRatio = window.innerWidth / window.innerHeight;
​  ​var​ camera = ​new​ THREE.PerspectiveCamera(75, ...

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.