# gl-simplicial-complex

> Draws a simplicial complex in WebGL

Latest version **3.0.4** (published 2015-02-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install gl-simplicial-complex
pnpm add gl-simplicial-complex
yarn add gl-simplicial-complex
bun add gl-simplicial-complex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2015-02-26 |
| First published | 2013-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Author | Mikola Lysenko |
| Maintainers | mikolalysenko |
| Keywords | webgl, simplicial, complex, debug, simple |

## Links

- npm: https://www.npmjs.com/package/gl-simplicial-complex
- Repository: https://github.com/mikolalysenko/gl-simplicial-complex
- Issues: https://github.com/mikolalysenko/gl-simplicial-complex/issues
- npm.io page: https://npm.io/package/gl-simplicial-complex

## Dependencies (12)

- [gl-vao](https://npm.io/package/gl-vao.md) ^1.1.3
- [gl-mat4](https://npm.io/package/gl-mat4.md) ^1.0.0
- [glslify](https://npm.io/package/glslify.md) ^1.6.0
- [ndarray](https://npm.io/package/ndarray.md) ^1.0.15
- [normals](https://npm.io/package/normals.md) ^1.0.0
- [colormap](https://npm.io/package/colormap.md) ^2.0.1
- [gl-buffer](https://npm.io/package/gl-buffer.md) ^2.0.8
- [gl-shader](https://npm.io/package/gl-shader.md) ^4.0.0
- [barycentric](https://npm.io/package/barycentric.md) ^1.0.1
- [gl-texture2d](https://npm.io/package/gl-texture2d.md) ^2.0.8
- [polytope-closest-point](https://npm.io/package/polytope-closest-point.md) ^1.0.0
- [glsl-specular-cook-torrance](https://npm.io/package/glsl-specular-cook-torrance.md) ^2.0.1

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 3.0.4 (latest) — 2015-02-26
- 3.0.3 — 2015-02-20
- 3.0.2 — 2014-12-12
- 3.0.1 — 2014-12-12
- 3.0.0 — 2014-12-05
- 2.0.0 — 2014-11-15
- 1.2.2 — 2014-08-28
- 1.2.1 — 2014-08-27
- 1.2.0 — 2014-08-26
- 1.1.2 — 2014-08-26
- 1.1.1 — 2014-08-25
- 1.1.0 — 2014-08-25
- 1.0.0 — 2014-02-25
- 0.0.1 — 2014-02-07
- 0.0.0 — 2013-08-21

## README

gl-simplicial-complex
=====================
Basic module for drawing a simplicial complex.  This code can be used to get something on the screen quickly.  It is useful for debugging and prototyping, though in a real 3d engine you would probably want to write your own shaders and vertex formats.

Example
=======

```javascript
var shell = require("gl-now")()
var camera = require("game-shell-orbit-camera")(shell)
var mat4 = require("gl-matrix").mat4
var bunny = require("bunny")
var createSimplicialComplex = require("gl-simplicial-complex")

var mesh

shell.on("gl-init", function() {
  var gl = shell.gl
  gl.enable(gl.DEPTH_TEST)
  bunnyMesh = createSimplicialComplex(gl, bunny)
})

shell.on("gl-render", function() {
  bunnyMesh.draw({
    view: camera.view(),
    projection: mat4.perspective(mat4.create(),
          Math.PI/4.0,
          shell.width/shell.height,
          0.1,
          1000.0)
  })
})
```

[Try out the example in your browser](http://mikolalysenko.github.io/gl-simplicial-complex/)

Install
=======

    npm instal gl-simplicial-complex
    
API
===

```javascript
var createSimplicialComplex = require("gl-simplicial-complex")
```

### `var mesh = createSimplicialComplex(gl, params)`
Creates a simplicial complex that can be drawn directly in a WebGL context.

* `gl` - is a handle to a WebGL context
* `params` is an object that has the following properties:

    + `cells` *(Required)* An indexed list of vertices, edges and/or faces.
    + `positions` *(Required)* An array of positions for the mesh, encoded as arrays
    + `vertexColors` A list of per vertex color attributes encoded as length 3 rgb arrays
    + `vertexUVs`
    + `cellUVs`
    + `vertexIntensity`
    + `cellIntensity`
    + `cellColors` A list of per cell color attributes
    + `meshColor` A constant color for the entire mesh
    + `vertexNormals` An array of per vertex normals
    + `cellNormals` An array of per cell normals
    + `useFacetNormals` A flag which if set to `true` forces `cellNormals` to be computed
    + `pointSizes` An array of point sizes
    + `pointSize` A single point size float
    + `ambientLight`
    + `diffuseLight`
    + `specularLight`
    + `lightPosition`
    + `roughness`
    + `fresnel`

**Returns** A renderable mesh object

### `mesh.draw(params)`
Draws the mesh to the current buffer using a Phong material.

* `params` is an object that has the following properties
    + `model` The model matrix for the object
    + `view` The view matrix for the camera
    + `projection` The projection matrix for the display
    
### `mesh.update(params)`
Updates the contents of the simplicial complex in place.

* `params` is a list of parameters which are in the same format as `createSimplicialComplex`

### `mesh.drawPick(params)`
Draws the mesh for the purposes of point picking and selection.

### `mesh.pick(pickData)`
Using the output from gl-select finds the point on the mesh closest to the given pick data.

**Returns** An object with the following properties:

* `positions` the position of the picked point on the mesh
* `cellId`  the index of the closest cell
* `cell` the cell of the closest point
* `index` the index of the closest vertex

### `mesh.dispose()`
Destroys the mesh object and releases all resources assigned to it.

# Credits
(c) 2013 Mikola Lysenko. MIT License

---
_Source: https://npm.io/package/gl-simplicial-complex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
