Build a Raft for Racing

A donut shape will work very nicely as a river raft. Add the addRaft call to the code outline at the top of our code.

​ ​var​ ground = addGround();
​ ​var​ water = addWater();
​ ​var​ scoreboard = addScoreboard();
»​var​ raft = addRaft();

Again, this breaks things because there’s no addRiver() function yet. Let’s add it after the last curly brace in the addScoreboard() function.

​ ​function​ addRaft() {
​  ​var​ shape = ​new​ THREE.TorusGeometry(0.1, 0.05, 8, 20);
​  ​var​ _cover = ​new​ THREE.MeshPhongMaterial({visible: ​false​});
​  ​var​ cover = Physijs.createMaterial(_cover, 0.4, 0.6);
​  ​var​ mesh = ​new​ Physijs.ConvexMesh(shape, cover, 0.25); ...

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.