Reference torus()

torus()

Draws a torus.

A torus is a 3D shape with triangular faces that connect to form a ring. Toruses with few faces look flattened. Toruses with many faces have smooth surfaces.

The first parameter, radius, is optional. If a Number is passed, as in torus(30), it sets the radius of the ring. By default, radius is 50.

The second parameter, tubeRadius, is also optional. If a Number is passed, as in torus(30, 15), it sets the radius of the tube. By default, tubeRadius is 10.

The third parameter, detailX, is also optional. If a Number is passed, as in torus(30, 15, 5), it sets the number of edges used to draw the hole of the torus. Using more edges makes the hole look more like a circle. By default, detailX is 24.

The fourth parameter, detailY, is also optional. If a Number is passed, as in torus(30, 15, 5, 7), it sets the number of triangle subdivisions to use while filling in the torus’ height. By default, detailY is 16.

Note: torus() can only be used in WebGL mode.

Examples

Syntax

torus([radius], [tubeRadius], [detailX], [detailY])

Parameters

radius

radius of the torus. Defaults to 50.

tubeRadius

radius of the tube. Defaults to 10.

detailX

number of edges that form the hole. Defaults to 24.

detailY

number of triangle subdivisions along the y-axis. Defaults to 16.

Notice any errors or typos? Please let us know. Please feel free to edit src/webgl/3d_primitives.js and open a pull request!

Related References