diff --git a/webgl/helpers.mjs b/webgl/helpers.mjs index 116554f..4f1748b 100644 --- a/webgl/helpers.mjs +++ b/webgl/helpers.mjs @@ -43,4 +43,22 @@ export function calcNormalMatrix(modelView) mat4.invert(normalMatrix, modelView); mat4.transpose(normalMatrix, normalMatrix); return normalMatrix; +} + +export function rgbaToArray(val) +{ + return [ + (val & 0xff) / 255.0, + (val >> 8 & 0xff) / 255.0, + (val >> 16 & 0xff) / 255.0, + (val >> 24 & 0xff) / 255.0, + ]; +} + +export function arrayToRGBA(arr) +{ + return Math.round(arr[0]) | + (Math.round(arr[1]) << 8) | + (Math.round(arr[2]) << 16) | + (Math.round(arr[3]) << 24); } \ No newline at end of file diff --git a/webgl/index.html b/webgl/index.html index 63dc35e..d020cb0 100644 --- a/webgl/index.html +++ b/webgl/index.html @@ -9,5 +9,9 @@ import {run} from './webgl.mjs'; run(); +
Click to add voxels
+Hold alt and click to remove voxels
+Scroll to zoom
+Press middle mouse and drag to rotate