Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const chunkSize = 32;
- const chunkSizeSquare = chunkSize ** 2;
- const toIndex = function (x, y, z) {
- return (y * chunkSizeSquare) + (z * chunkSize) + x;
- };
- const fromIndex2 = function (index) {
- let y = index >> 6;
- let z = (index - (y << 6)) >> 3;
- let x = (index - (y << 6) - (z << 3));
- return {x, y, z};
- };
- const fromIndex = function (index) {
- let y = index >> 10;
- let z = index % 1024 >> 5;
- let x = index % 32;
- return {x, y, z};
- };
- const index = toIndex(5, 6, 7);
- console.log(index);
- console.log(fromIndex(index));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement