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.