Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

torus-mesh

mattdesl40MIT1.0.0

creates a 3D torus mesh

torus, mesh, simplicial, complex, meshes, geo, geometry, meshes, 3d, circle, ring, tori, tube, arc, geom

readme

torus-mesh

stable

Generates an indexed 3D torus mesh.

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

console.log(mesh)
=> { positions, cells, normals, uvs }

It returns a simplicial complex, but also includes normals and uvs for lighting and texturing.

Usage

NPM

mesh = torus([opt])

Creates a new torus with options:

  • majorRadius the radius of the major ring R, default 1.0
  • minorRadius the radius of the minor ring r, default 0.25
  • majorSegments the number of segments for the major ring, default 32
  • minorSegments the number of segments for the minor ring, defualt 64
  • arc the arc to draw, default Math.PI * 2 (full circle)

Credits

The algorithm here is from ThreeJS TorusGeometry.

License

MIT. See LICENSE.md for details.