You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
796 B

  1. const CANVAS_ID = "canvas";
  2. const GAT_FILE_ID = "gat_file";
  3. const canvas = document.getElementById(CANVAS_ID);
  4. if (canvas === null) {
  5. throw new Error("couldn't find element #" + CANVAS_ID);
  6. }
  7. const gl = canvas.getContext("webgl");
  8. if (gl === null) {
  9. throw new Error("couldn't initialize webgl context");
  10. }
  11. gl.clearColor(0, 0, 0, 1);
  12. gl.clear(gl.COLOR_BUFFER_BIT);
  13. if (typeof window.rojs !== "object") {
  14. throw new Error("ro.js not found, is it loaded?");
  15. }
  16. const gatFile = document.getElementById(GAT_FILE_ID);
  17. gatFile.addEventListener("change", (e) => {
  18. const file = gatFile.files[0];
  19. const reader = new FileReader();
  20. reader.onload = (e) => {
  21. const gat = window.rojs.parseGAT(e.target.result);
  22. window.rojs.renderGAT(gl, gat);
  23. };
  24. reader.readAsArrayBuffer(file);
  25. });