Fix boot safely, add social OG image, restore performance gains

Guard fitCanvas until Engine is ready, show a boot placeholder during shader compile, generate a 1200x630 OG image for X and WhatsApp, and point repo meta to lumenshaders.vercel.app.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonxlnx
2026-06-11 17:39:45 +02:00
parent bf0e0517e2
commit 87e9af6b0f
7 changed files with 200 additions and 89 deletions
+19 -3
View File
@@ -5,6 +5,8 @@ var Engine = (function () {
var canvas, gl, program, uniforms = {};
var playing = true;
var suspended = false;
var started = false;
var ready = false;
var loopT = 0; // seconds into current loop
var lastTick = 0;
var fps = 60, fpsAcc = 0, fpsN = 0, fpsCb = null;
@@ -32,13 +34,14 @@ var Engine = (function () {
return sh;
}
function init(canvasEl, paramsGetter) {
function init(canvasEl, paramsGetter, opts) {
opts = opts || {};
canvas = canvasEl;
getParams = paramsGetter;
gl = canvas.getContext("webgl2", {
antialias: false,
preserveDrawingBuffer: true,
powerPreference: "high-performance"
powerPreference: "default"
});
if (!gl) throw new Error("WebGL2 not available");
@@ -61,14 +64,25 @@ var Engine = (function () {
uniforms[n] = gl.getUniformLocation(program, n);
});
ready = true;
lastTick = performance.now();
started = false;
if (opts.autostart !== false) start();
}
function start() {
if (!ready || started) return;
started = true;
suspended = false;
lastTick = performance.now();
requestAnimationFrame(tick);
}
function setSize(w, h) {
if (!canvas) return;
canvas.width = w;
canvas.height = h;
gl.viewport(0, 0, w, h);
if (gl) gl.viewport(0, 0, w, h);
}
function pushUniforms(P, phase) {
@@ -168,6 +182,8 @@ var Engine = (function () {
return {
init: init,
start: start,
isReady: function () { return ready; },
setSize: setSize,
renderAt: renderAt,
readPixels: readPixels,