Learning Three.js

or WebGL for Dummies

Procedural Generated Pool Balls for Your Three.js Pool Game With threex.poolball

This is post is part of the ‘one threex a day’ challenge. This challenge is to publish every day one game extension for three.js! One per day, every day and that for 2month! In this post, we gonna talk about threex.poolball. threex.poolball is a three.js games extension which helps you build pool balls. It provides dynamically generated models of pool balls, so no model download needed. It may be fun to play with when you start with three.js, funnier than a plain sphere for sure :) You can use it for your bar games, having your characters bet when playing pool, or even your Marble Table games, as I did, adding cool granular sounds when the balls roll.

To see the other posts about one threex a day and forget our moto! “A THREEx extension a day, gets your game on its way!”

Show Don’t Tell

How To Install It

You can install it via script tag

<script src='threex.poolball.js'></script>

Or you can install with bower, as you wish.

bower install threex.poolball

How To Use It

Here is the default usages

var mesh    = THREEx.createPoolBall();

this is with custom arguments

var mesh    = THREEx.createPoolBall({
    ballDesc    : '0',  // the text which gonna be written on the ball
    stripped    : true, // true if the ball must be stripped, false otherwise
    textureW    : 512   // the width/height of the created texture for this ball

Some ball description are already done.

  • cue will return an unstripped white ball
  • black will return an unstripped black ball
  • 1 to 9 will assign the official colors for nine-ball pool