Package Exports
- icomesh
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (icomesh) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
icomesh
Fast JavaScript icosphere mesh generation library for WebGL visualizations. Interactive demo:
Icosphere is a type of geodesic polyhedron that provides a good quality triangular mesh approximation of a sphere with relatively evenly distributed vertices. This project is inspired by an article by Andreas Kahler.
Example
import icomesh from 'icomesh';
// generate an icosphere with 4 subdivisions
const {vertices, triangles} = icomesh(4);
API
icomesh(order = 4, uvMap = false)
Generates an icosphere mesh with order
subdivisions (4
by default, 10
max).
Returns an object with:
vertices
: AFloat32Array
array ofx, y, z
vertices.triangles
: AUint16Array
orUint32Array
array of triangle indices.uv
: ifuvMap
istrue
, aFloat32Array
ofu, v
values for mapping vertices to a texture with an equirectangular projection.
You can reuse vertex data for normals because they are equal for a unit sphere.
Install
Install with npm install icomesh
or yarn add icomesh
(module environments only),
or use a browser build from CDN: