Code: Making an Avatar
This is the final version of the avatar code from Chapter 3, âProject: Making an Avatarâ:
â | <body></body> |
â | <script src=â"/three.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.8); |
â | scene.add(light); |
â | |
â | â// The "camera" is what sees the stuff:â |
â | âvarâ aspectRatio = window.innerWidth / window.innerHeight; |
â | âvarâ camera = ânewâ THREE.PerspectiveCamera(75, aspectRatio, 1, 10000); |
â | camera.position.z = 500; |
â | scene.add(camera); |
â | |
â | â// The "renderer" draws ... |
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.