July 2018
Beginner to intermediate
374 pages
8h 54m
English
In 3D programming, you can make simple graphics in two ways. We’ll use both in this game—one kind for the Purple Fruit Monster and the other kind for the fruit. The simple graphic technique that we use for the Purple Fruit Monster is called a sprite.
In the addAvatar() function, we create an invisible, physics-enabled box mesh, then we add the sprite to the box mesh. Add this function below the addGround() function.
| | function addAvatar() { |
| | var shape = new THREE.CubeGeometry(100, 100, 1); |
| | var cover = new THREE.MeshBasicMaterial({visible: false}); |
| | var avatar = new Physijs.BoxMesh(shape, cover, 1); |
| | scene.add(avatar); |
| | |
| | var image = new THREE.TextureLoader().load("/images/monster.png"); |
| | var ... |
Read now
Unlock full access