Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thibauts/quantize-vertices
Quantizes vertices to any bit precision
https://github.com/thibauts/quantize-vertices
Last synced: 2 months ago
JSON representation
Quantizes vertices to any bit precision
- Host: GitHub
- URL: https://github.com/thibauts/quantize-vertices
- Owner: thibauts
- License: mit
- Created: 2015-03-01T21:35:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-02T21:37:19.000Z (almost 10 years ago)
- Last Synced: 2024-09-13T23:12:20.226Z (3 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 14
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
quantize-vertices
=================
### Quantizes vertices to any bit precisionTakes vertices of arbitrary dimensions and quantizes their coordinates to any bit precision. The different dimensions can be quantized to different precisions by providing an array instead of an int as the number of bits.
Install
-------```bash
$ npm install quantize-vertices
```Usage
-----```javascript
var quantizeVertices = require('quantize-vertices');var positions = [
[ 1, 0, -0.5],
[ 0, 0.5, 0],
[ 0, 1, 0.5],
];var positions = quantizeVertices(positions, 8);
console.log(positions);
/*
[
[255, 0, 0],
[ 0, 127, 127],
[ 0, 255, 255]
]
*/
```With various precisions for x, y and z
```javascript
var quantizeVertices = require('quantize-vertices');var positions = [
[ 1, 0, -0.5],
[ 0, 0.5, 0],
[ 0, 1, 0.5],
];var positions = quantizeVertices(positions, [2, 4, 8]);
console.log(positions);
/*
[
[3, 0, 0],
[0, 7, 127],
[0, 15, 255]
]
*/
```