mdx-m3-viewer
Version:
A browser WebGL model viewer. Mainly focused on models of the games Warcraft 3 and Starcraft 2.
11 lines (10 loc) • 419 B
text/typescript
/**
* Returns a number, which when multiplied with a number of fromBits bits, will convert it to a toBits bits number.
*
* For example, 7 * convertBitRange(3, 8) == 255.
*
* In other words, if we look at the bits, 111 is the same to 3 bits as 11111111 is to 8 bits.
*/
export default function convertBitRange(fromBits: number, toBits: number) {
return ((1 << toBits) - 1) / ((1 << fromBits) - 1);
}