Wind!

Now that we’re getting good with these JavaScript objects, let’s try typing out the Wind object all at once. Start with the constructor, which can go below all of the methods for Basket—after the score() method. The constructor will call methods to draw the wind on the scene and start changing it.

​ ​function​ Wind() {
​  ​this​.draw();
​  ​this​.change();
​ }

As we’ve done with the other objects, the methods for Wind can follow after the constructor. First, add the draw() method, which will use the arrow helper again.

​ Wind.prototype.draw = ​function​(){
​  ​var​ dir = ​new​ THREE.Vector3(1, 0, 0);
​  ​var​ start = ​new​ THREE.Vector3(0, 200, 250);
​  ​this​.arrow = ​new ...

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.