gl-tetrahedron
v1.0.1
Published
a simple tetrahedron utility for stackgl
Downloads
1
Maintainers
Readme
gl-tetrahedron
This has been forked from mattdesl's awesome work. I stand on his shoulders.
Creates an indexed tetrahedron that you can draw.
The side lengths of the tetrahedron are 1 by default. The "top" vertex lies on the positive z axis while the "bottom" of the tetrahedron is parallel to the xy plane. The tetrahedron is centered at the origin. This is intended to make it easy to use in utilities where you need some kind of direction indicator. For example, I use it in my gl-vector-field (http://github.com/coballast/gl-vector-field) repo as a default direction mesh. I apply non uniform scaling in the shader to indicate magnitude.
Usage
var gl = require('webgl-context')
var tetra = require('gl-tetrahedron')(gl)
tetra.draw( myShader )
The passed shader is expected to have position
and normal
attributes.
functions
var tetra = createTetra(gl)
Creates a new tetrahedron with position and normal buffers.
tetra.draw([shader])
Draws the tetrahedron with a gl-shader.
If a shader is not passed, it's assumed that you've already bound a shader.
tetra.dispose()
Disposes the tetrahedron.
members
tetra.mesh
The gl-mesh Object backing this tetrahedron.
License
MIT, see LICENSE.md for details.