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

This commit is contained in:
Rezmason
2022-08-02 21:39:47 -07:00
parent ad81de744d
commit aabf0a32ee
2 changed files with 21 additions and 20 deletions

View File

@@ -44,21 +44,25 @@ export default async (canvas, config) => {
canvas.height = Math.ceil(canvas.clientHeight * config.resolution); canvas.height = Math.ceil(canvas.clientHeight * config.resolution);
}; };
window.onresize = resize; window.onresize = resize;
// if (document.fullscreenEnabled || document.webkitFullscreenEnabled) { if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
// window.onclick = () => { window.ondblclick = () => {
// if (document.fullscreenElement == null) { if (document.fullscreenElement == null) {
// if (canvas.webkitRequestFullscreen != null) { if (canvas.webkitRequestFullscreen != null) {
// canvas.webkitRequestFullscreen(); canvas.webkitRequestFullscreen();
// } else { } else {
// canvas.requestFullscreen(); canvas.requestFullscreen();
// } }
// } else { } else {
// document.exitFullscreen(); document.exitFullscreen();
// } }
// }; };
// } }
resize(); resize();
if (config.useCamera) {
await setupCamera();
}
const regl = createREGL({ const regl = createREGL({
canvas, canvas,
extensions: ["OES_texture_half_float", "OES_texture_half_float_linear"], 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); const lkg = await getLKG(config.useHoloplay, true);
if (config.useCamera) {
await setupCamera();
}
// All this takes place in a full screen quad. // All this takes place in a full screen quad.
const fullScreenQuad = makeFullScreenQuad(regl); const fullScreenQuad = makeFullScreenQuad(regl);
const effectName = config.effect in effects ? config.effect : "plain"; const effectName = config.effect in effects ? config.effect : "plain";

View File

@@ -1,7 +1,7 @@
import { loadImage, loadText, makePassFBO, makePass } from "./utils.js"; import { loadImage, loadText, makePassFBO, makePass } from "./utils.js";
import { cameraCanvas, cameraAspectRatio } from "../camera.js"; import { cameraCanvas, cameraAspectRatio } from "../camera.js";
let start = Date.now(); let start;
const numClicks = 5; const numClicks = 5;
const clicks = Array(numClicks).fill([0, 0, -Infinity]).flat(); const clicks = Array(numClicks).fill([0, 0, -Infinity]).flat();
let aspectRatio = 1; let aspectRatio = 1;
@@ -18,8 +18,6 @@ export default ({ regl, config }, inputs) => {
const cameraTex = regl.texture(cameraCanvas); const cameraTex = regl.texture(cameraCanvas);
start = Date.now();
const output = makePassFBO(regl, config.useHalfFloat); const output = makePassFBO(regl, config.useHalfFloat);
const mirrorPassFrag = loadText("shaders/glsl/mirrorPass.frag.glsl"); const mirrorPassFrag = loadText("shaders/glsl/mirrorPass.frag.glsl");
const render = regl({ const render = regl({
@@ -35,6 +33,9 @@ export default ({ regl, config }, inputs) => {
}, },
framebuffer: output, framebuffer: output,
}); });
start = Date.now();
return makePass( return makePass(
{ {
primary: output, primary: output,