const CANVAS_ID = "canvas"; const GAT_FILE_ID = "gat_file"; const canvas = document.getElementById(CANVAS_ID); if (canvas === null) { throw new Error("couldn't find element #" + CANVAS_ID); } const gl = canvas.getContext("webgl"); if (gl === null) { throw new Error("couldn't initialize webgl context"); } gl.clearColor(0, 0, 0, 1); gl.clear(gl.COLOR_BUFFER_BIT); if (typeof window.rojs !== "object") { throw new Error("ro.js not found, is it loaded?"); } const gatFile = document.getElementById(GAT_FILE_ID); gatFile.addEventListener("change", (e) => { const file = gatFile.files[0]; const reader = new FileReader(); reader.onload = (e) => { const gat = window.rojs.parseGAT(e.target.result); window.rojs.renderGAT(gl, gat); }; reader.readAsArrayBuffer(file); });