A minimal 3D cylindrical geometry, including normals, UVs, and mesh.
var cylinder = require('primitive-cylinder')
var mesh = cylinder(10, 10, 50, 10, 10)
// the simplicial complex
console.log(mesh.positions, mesh.cells)
// rendering attributes
console.log(mesh.uvs)
console.log(mesh.normals)
mesh = cylinder(radiusTop, radiusBottom, height, radialSegments, heightSegments)
Creates a new torus with options:
radiusTop
the radius of the cylinder at the topradiusBottom
the radius of the cylinder at the bottomheight
the height of the cylinderradialSegments
the number of segments for the radial axisheightSegments
the number of segments for the height axisThe 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], ... ]
}
Note that you can build a cone by setting one of the radii to be zero.
See stackgl/contributing for details.
The algorithm here is from ThreeJS CylinderGeometry.
MIT. See LICENSE.md for details.