isPowerOfTwo
function isPowerOfTwo(value) {
return (value & (value - 1)) === 0 && value !== 0;
}
for (let i = 0; i < 66; i++) {
console.log(i, isPowerOfTwo(i));
}
I’ve had the pleasure of using THREE.js quite a bit over the years. The MathUtils file has some great utility functions. This version of isPowerOfTwo
comes straight from there. I may post a few more from there in the future…