_torus = function _torus() {
                for (var i = 0; i <= this.detailY; i++) {
                  var v = i / this.detailY;
                  var phi = 2 * Math.PI * v;
                  var cosPhi = Math.cos(phi);
                  var sinPhi = Math.sin(phi);
                  var r = 1 + tubeRatio * cosPhi;

                  for (var j = 0; j <= this.detailX; j++) {
                    var u = j / this.detailX;
                    var theta = 2 * Math.PI * u;
                    var cosTheta = Math.cos(theta);
                    var sinTheta = Math.sin(theta);

                    var p = new _main.default.Vector(
                      r * cosTheta,
                      r * sinTheta,
                      tubeRatio * sinPhi
                    );

                    var n = new _main.default.Vector(
                      cosPhi * cosTheta,
                      cosPhi * sinTheta,
                      sinPhi
                    );

                    this.vertices.push(p);
                    this.vertexNormals.push(n);
                    this.uvs.push(u, v);
                  }
                }
              }
Draw a torus with given radius and tube radius

DetailX and detailY determine the number of subdivisions in the x-dimension and
the y-dimension of a torus. More subdivisions make the torus appear to be smoother.
The default and maximum values for detailX and detailY are 24 and 16, respectively.
Setting them to relatively small values like 4 and 6 allows you to create new
shapes other than a torus.
@method torus
@param  {Number} [radius]      radius of the whole ring
@param  {Number} [tubeRadius]  radius of the tube
@param  {Integer} [detailX]    number of segments in x-dimension,
                               the more segments the smoother geometry
                               default is 24
@param  {Integer} [detailY]    number of segments in y-dimension,
                               the more segments the smoother geometry
                               default is 16
@chainable
@example
<div>
<code>
// draw a spinning torus
// with ring radius 30 and tube radius 15
function setup() {
  createCanvas(100, 100, WEBGL);
}

function draw() {
  background(205, 102, 94);
  rotateX(frameCount * 0.01);
  rotateY(frameCount * 0.01);
  torus(30, 15);
}
</code>
</div>

@example
<div>
<code>
// slide to see how detailX works
let detailX;
function setup() {
  createCanvas(100, 100, WEBGL);
  detailX = createSlider(3, 24, 3);
  detailX.position(10, height + 5);
  detailX.style('width', '80px');
}

function draw() {
  background(205, 102, 94);
  rotateY(millis() / 1000);
  torus(30, 15, detailX.value(), 12);
}
</code>
</div>

@example
<div>
<code>
// slide to see how detailY works
let detailY;
function setup() {
  createCanvas(100, 100, WEBGL);
  detailY = createSlider(3, 16, 3);
  detailY.position(10, height + 5);
  detailY.style('width', '80px');
}

function draw() {
  background(205, 102, 94);
  rotateY(millis() / 1000);
  torus(30, 15, 16, detailY.value());
}
</code>
</div>