Teddy Bear

Code

Before looking at the code for the teddy bear, let's look at some of the parameters for building it. You see these in the dat.GUI, above:

  

Now, here's the function that builds the bear. Notice the use of sub-functions to organize and modularize the code. While the whole function is very long, it is divided into short, focused pieces. You'll also see the usefulness of using an object literal as a way to make keyword arguments for a function, instead of this function having 33 parameters!