quantize-vertices

1.0.2 • Public • Published

quantize-vertices

Quantizes vertices to any bit precision

Takes 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

$ npm install quantize-vertices

Usage

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

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]
]
*/

/quantize-vertices/

    Package Sidebar

    Install

    npm i quantize-vertices

    Weekly Downloads

    9

    Version

    1.0.2

    License

    MIT

    Last publish

    Collaborators

    • thibauts