A minimal capsule geometry for 3D rendering, including normals, UVs and cell indices (faces).
mesh = createCapsule([r, h, numSubdivisionsHeight, numSegments])
Parameters:
r
- radius, defaults to 0.5
h
- height, defaults to r*2
numSubdivisionsHeight
- num height segments, defaults to 12
numSegments
- num side segments, defaults to 12
var createCapsule = require('primtivie-capsule');
var capsule = createCapsule();
capsule
will have the following structure:
{
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], ... ]
}
Download or clone this repo and run:
cd demo
npm install
npm start
Ported from C++ code from Cinder https://github.com/cinder/Cinder
MIT, see LICENSE.md for details.