From aabf0a32ee24f18c725bcdb62bcd16e3ebb9f16d Mon Sep 17 00:00:00 2001 From: Rezmason Date: Tue, 2 Aug 2022 21:39:47 -0700 Subject: [PATCH] Double click now toggles full screen. Delayed initializing regl until the camera is set up, so its start time comes after the visitor closes the browser prompt --- js/regl/main.js | 34 +++++++++++++++++----------------- js/regl/mirrorPass.js | 7 ++++--- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/js/regl/main.js b/js/regl/main.js index 11dc130..3e7eecf 100644 --- a/js/regl/main.js +++ b/js/regl/main.js @@ -44,21 +44,25 @@ export default async (canvas, config) => { canvas.height = Math.ceil(canvas.clientHeight * config.resolution); }; window.onresize = resize; - // if (document.fullscreenEnabled || document.webkitFullscreenEnabled) { - // window.onclick = () => { - // if (document.fullscreenElement == null) { - // if (canvas.webkitRequestFullscreen != null) { - // canvas.webkitRequestFullscreen(); - // } else { - // canvas.requestFullscreen(); - // } - // } else { - // document.exitFullscreen(); - // } - // }; - // } + if (document.fullscreenEnabled || document.webkitFullscreenEnabled) { + window.ondblclick = () => { + if (document.fullscreenElement == null) { + if (canvas.webkitRequestFullscreen != null) { + canvas.webkitRequestFullscreen(); + } else { + canvas.requestFullscreen(); + } + } else { + document.exitFullscreen(); + } + }; + } resize(); + if (config.useCamera) { + await setupCamera(); + } + const regl = createREGL({ canvas, extensions: ["OES_texture_half_float", "OES_texture_half_float_linear"], @@ -68,10 +72,6 @@ export default async (canvas, config) => { const lkg = await getLKG(config.useHoloplay, true); - if (config.useCamera) { - await setupCamera(); - } - // All this takes place in a full screen quad. const fullScreenQuad = makeFullScreenQuad(regl); const effectName = config.effect in effects ? config.effect : "plain"; diff --git a/js/regl/mirrorPass.js b/js/regl/mirrorPass.js index ae81f31..4beeafa 100644 --- a/js/regl/mirrorPass.js +++ b/js/regl/mirrorPass.js @@ -1,7 +1,7 @@ import { loadImage, loadText, makePassFBO, makePass } from "./utils.js"; import { cameraCanvas, cameraAspectRatio } from "../camera.js"; -let start = Date.now(); +let start; const numClicks = 5; const clicks = Array(numClicks).fill([0, 0, -Infinity]).flat(); let aspectRatio = 1; @@ -18,8 +18,6 @@ export default ({ regl, config }, inputs) => { const cameraTex = regl.texture(cameraCanvas); - start = Date.now(); - const output = makePassFBO(regl, config.useHalfFloat); const mirrorPassFrag = loadText("shaders/glsl/mirrorPass.frag.glsl"); const render = regl({ @@ -35,6 +33,9 @@ export default ({ regl, config }, inputs) => { }, framebuffer: output, }); + + start = Date.now(); + return makePass( { primary: output,