So I have made this small JS example (see below) where I pack Integers it to bit-mask and the decode back. It kind for works, but I think there must be a more robust and generally faster way (only using bit operators?). Live project to play with https://jsfiddle.net/sa7vkcnd/
var mask = 0;
var lod = 2;
var x = 5;
var y = 8;
mask|=(lod);
mask<<=4;
mask|=(x);
mask<<=10;
mask|=(y);
mask<<=10;
var lodr = mask >> 24;
console.log(lodr);
var xr = mask >> 20;
console.log(xr - (lodr << 4));
var yr = mask >> 10;
console …