primitive-torus
A minimal 3D torus geometry for 3D rendering, including normals, UVs, and cell indices.
Example
var torus = var mesh = // the simplicial complexconsole // rendering attributesconsoleconsole
Usage
mesh = torus([opt])
Creates a new torus with options:
majorRadius
the radius of the major ringR
, default 1.0minorRadius
the radius of the minor ringr
, default 0.25majorSegments
the number of segments for the major ring, default 32minorSegments
the number of segments for the minor ring, defualt 64arc
the arc to draw, defaultMath.PI * 2
(full circle)
The returned mesh is an object with the following data:
{
positions: [ [x, y, z], [x, y, z], ... ],
cells: [ [a, b, c], [a, b, c], ... ],
uvs: [ [u, v], [u, v], ... ],
normals: [ [x, y, z], [x, y, z], ... ]
}
Credits
The algorithm here is from ThreeJS TorusGeometry.
License
MIT. See LICENSE.md for details.