# triangles-mesh-viewer-sdl-regl

> node.js simple 3d mesh viewer with fps controls via SDL + regl

Latest version **0.0.118** (published 2023-03-06) · MIT license · 30 weekly downloads

## Install

```sh
npm install triangles-mesh-viewer-sdl-regl
pnpm add triangles-mesh-viewer-sdl-regl
yarn add triangles-mesh-viewer-sdl-regl
bun add triangles-mesh-viewer-sdl-regl
```

## Health

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

Positive: no vulnerabilities; growing popularity.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.118 |
| Published | 2023-03-06 |
| First published | 2022-09-24 |
| Weekly downloads | 30 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 180.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | stonkpunk |
| Maintainers | stonkpunk |
| Keywords | triangle, area, 3d, cross product |

## Links

- npm: https://www.npmjs.com/package/triangles-mesh-viewer-sdl-regl
- Homepage: https://github.com/stonkpunk/my-npm-modules/tree/main/triangles-mesh-viewer-sdl-regl
- npm.io page: https://npm.io/package/triangles-mesh-viewer-sdl-regl

## Dependencies (13)

- [regl](https://npm.io/package/regl.md) ^2.1.0
- [bunny](https://npm.io/package/bunny.md) ^1.0.1
- [chance](https://npm.io/package/chance.md) ^1.1.8
- [bvh-aabbs](https://npm.io/package/bvh-aabbs.md) 0.0.11
- [gl-matrix](https://npm.io/package/gl-matrix.md) ^3.4.3
- [@kmamal/gl](https://npm.io/package/@kmamal/gl.md) ^4.9.0-2
- [regl-model](https://npm.io/package/regl-model.md) ^1.0.2
- [@kmamal/sdl](https://npm.io/package/@kmamal/sdl.md) ^0.3.7
- [regl-primitive](https://npm.io/package/regl-primitive.md) ^1.0.1
- [triangles-index](https://npm.io/package/triangles-index.md) 0.0.42
- [raycasting-utils](https://npm.io/package/raycasting-utils.md) 0.0.213
- [slide-along-wall](https://npm.io/package/slide-along-wall.md) 0.0.31
- [triangles-distance-fast](https://npm.io/package/triangles-distance-fast.md) ^1.0.7

## Recent versions

- 0.0.118 (latest) — 2023-03-06
- 0.0.117 — 2023-03-01
- 0.0.116 — 2023-03-01
- 0.0.115 — 2023-02-28
- 0.0.114 — 2023-02-28
- 0.0.113 — 2022-11-04
- 0.0.112 — 2022-11-04
- 0.0.111 — 2022-11-03
- 0.0.11 — 2022-09-24
- 0.0.1 — 2022-09-24

## README

# triangles-mesh-viewer-sdl-regl

very simple 3d mesh viewer with fps controls [ASWD+mouse] via SDL + regl, for node.js

meant to quickly view meshes in the same format as `bunny` and just as a simple boilerplate to be hacked and modified.

## Installation

```sh
npm i triangles-mesh-viewer-sdl-regl
```

## Usage 

```javascript
var tmv = require('triangles-mesh-viewer-sdl-regl');

//modelViewer(theModel? = bunny); //default model is require('bunny')

var bunny = require('bunny');

//example with smooth vertex colors
//bunny.vertexColors = bunny.positions.map((p,i)=>[Math.random(),Math.random(),Math.random()]);

//example with discontinuous vertex colors -- force each tri to have its own verts
//bunny = require('triangles-index').demergeMeshTriangles_meshView(require('bunny'));
//bunny.vertexColors = bunny.positions.map((p,i)=>[Math.random(),Math.random(),Math.random()]);

//random face colors
//bunny.faceColors = bunny.cells.map((p,i)=>[Math.random(),Math.random(),Math.random()]);

var meshViewer = tmv.meshViewer.modelViewer(bunny);

//change the model:
//var newModel = require('bitey'); //note that bitey has much bigger scale than bunny
//meshViewer.updateModel(newModel);

//can also get raw buffers using getBuffers(), can then update the mesh with subdata command on the buffer 
//see test.js or https://github.com/regl-project/regl/blob/master/API.md#buffer-update
//tmv.meshViewer.getBuffers(); //{positionBuffer, normalBuffer, cellsBuffer}

//just for hacking/fun/experimentation -- can also launch regl raytracing test scene
//var meshViewer = tmv.raytraceBvhViewer.modelViewer(); //this is just a static test scene, model cannot be updated
```

![bunny](https://i.imgur.com/hzDDPSd.png)

![raytracing](https://i.imgur.com/n7URvAd.png)

## See Also
- [@kmamal/sdl](https://www.npmjs.com/package/@kmamal/sdl)
- [regl](https://www.npmjs.com/package/regl) 
- [triangles-mesh-renderer](https://www.npmjs.com/package/triangles-mesh-renderer) - CPU mesh renderer, no SDL/GL/GPU needed, but slow


[![stonks](https://i.imgur.com/UpDxbfe.png)](https://www.npmjs.com/~stonkpunk)

---
_Source: https://npm.io/package/triangles-mesh-viewer-sdl-regl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
