July 2018
Beginner to intermediate
374 pages
8h 54m
English
This is the moving-avatar code from Chapter 4, Project: Moving Avatars:
| | <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 what the camera sees onto the screen: |
| | var renderer = new THREE.WebGLRenderer({antialias: true}); |
| | renderer.setSize(window.innerWidth, ... |
Read now
Unlock full access