primitive-sphere
A minimal UV sphere geometry for 3D rendering, including normals, UVs and cell indices. The algorithm has been adapted from BabylonJS.
Example
var radius = 1var mesh = radius segments: 16 // the simplicial complexconsole // rendering attributesconsoleconsole
Usage
mesh = sphere(radius, [opt])
Creates a new UV sphere mesh with the given radius
(default 1) and options:
segments
number of segments to use, defaults to 32
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], ... ]
}
See Also
- primitive-icosphere
- sphere-mesh - numerically robust
- icosphere - a simple icosphere simplicial complex
License
MIT, see LICENSE.md for details.