O'Reilly logo

WebGL Beginner's Guide by Brandon Jones, Diego Cantor

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

Time for action — bouncing ball

  1. Open ch5_BouncingBalls.html in your HTML5-enabled Internet browser.
  2. The orbiting camera is activated by default. Move the camera and you will see how all the objects adjust to the global transform (camera) and yet they keep bouncing according to its local transform (bouncing ball).
    Time for action — bouncing ball
  3. Let's explain here a little bit more in detail how we keep track of each ball.
    • First of all let's define some global variables and constants:
    var ball = []; //Each element of this array is a ball
    var BALL_GRAVITY = 9.8; //Earth acceleration 9.8 m/s2
    var NUM_BALLS = 50; //Number of balls in this simulation
    
    • Next, we need to initialize the ball ...

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