primitive-torus

stable

screen

(demo)

A minimal 3D torus geometry for 3D rendering, including normals, UVs, and cell indices.

Example

var torus = require('primitive-torus')
var mesh = torus()

// the simplicial complex
console.log(mesh.positions, mesh.cells)

// rendering attributes
console.log(mesh.uvs)
console.log(mesh.normals)

Usage

NPM

mesh = torus([opt])

Creates a new torus with options:

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.