geom = createGeometry(gl)
Creates a new geometry attached to the WebGL canvas context
Define a new attribute value, for example using a simplicial complex:
var createGeometry =var bunny =var geom =
The following vertex formats are supported and will be normalized:
Arrays of arrays, e.g.
[[0, 0, 0], [1, 0, 0], [1, 1, 0]].
Flat arrays, e.g.
[0, 0, 0, 1, 0, 0, 1, 1, 0].
Typed arrays, preferably a
simplicial complexes, i.e. an object with a
positionsarray and a
cellsarray. The former is a list of unique vertices in the mesh (if you've used three.js, think
THREE.Vector3), and the latter is an index mapping these vertices to faces (
THREE.Face3) in the mesh. It looks something like this:
Pass a simplicial complex's
cells property here in any of the above formats
to use it as your index when drawing the geometry. For example:
var createGeometry =var bunny =bunnynormals = normalsvar geom =
geom.draw(mode, start, stop)
Draws the geometry to the screen using the currently bound shader.
Optionally, you can pass in the drawing mode, which should be one of the following:
The default value is
gl.TRIANGLES. You're also able to pass in a
stop range for the points you want to render, just the same as you would
Unbinds the underlying VAO. This must be done when you're finished drawing, unless you're binding to another gl-geometry or gl-vao instance.
- ArrayBuffer and Typed Arrays
- The WebGL Context
MIT. See LICENSE.md for details.