primitive-capsule
v3.0.1
Published
A minimal capsule geometry for 3D rendering, including normals, UVs and cell indices (faces).
Downloads
42
Maintainers
Readme
primitive-capsule
A minimal capsule geometry for 3D rendering, including normals, UVs and cell indices (faces).
Usage
mesh = createCapsule([r, h, numSubdivisionsHeight, numSegments])
Parameters:r
- radius, defaults to 0.5
h
- height, defaults to r*2numSubdivisionsHeight
- num height segments, defaults to 12
numSegments
- num side segments, defaults to 12
Example
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], ... ]
}
Demo
Download or clone this repo and run:
cd demo
npm install
npm start
Credits
Ported from C++ code from Cinder https://github.com/cinder/Cinder
License
MIT, see LICENSE.md for details.