O'Reilly logo

Learning Three.js: The JavaScript 3D Library for WebGL by Jos Dirksen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the dat.GUI library to make experimenting easier

A couple of guys from Google created a library called dat.GUI (you can find the documentation online at http://code.google.com/p/dat-gui/), which allows you to very easily create a simple user interface component that can change the variables in your code. In this part of the chapter, we'll use dat.GUI to add a user interface to our example that allows us to:

  • Control the speed of the bouncing ball
  • Control the rotation of the cube

Just like we had to do for the statistics, we will first add this library to the <header> of our HTML page by using the following code:

<script type="text/javascript" src="../libs/dat.gui.js"></script>

The next thing that we need to configure is a JavaScript object which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required