diff --git a/.gitignore b/.gitignore index 8078087..05eef16 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ !.gitignore !site/ -!site/**/ +!site/**/ !*.nu diff --git a/site/_includes/cube.vto b/site/_includes/cube.vto index 6437aa3..d88bc3d 100644 --- a/site/_includes/cube.vto +++ b/site/_includes/cube.vto @@ -76,14 +76,6 @@ this.z - that.z, ); }, - - mul(that) { - return Vec( - this.x * that.x, - this.y * that.y, - this.z * that.z, - ); - }, }); Vec.ZERO = Vec(0, 0, 0); @@ -126,30 +118,18 @@ const sensitivityMouse = 0.01; const sensitivityWheel = 0.006; - // 10 seconds. - const screensaverTimeoutMs = 10 * 1000; - // 10 minutes. - const stateDeleteTimeoutMs = 10 * 60 * 1000; - - const lastSave = JSON.parse(localStorage.getItem("lastSave")); - if (!lastSave || Date.now() - lastSave > stateDeleteTimeoutMs) { - localStorage.removeItem("mouseDown"); - localStorage.removeItem("mouseLastMove"); - localStorage.removeItem("mousePrevious"); - localStorage.removeItem("cubeOrient"); - localStorage.removeItem("velocity"); - localStorage.removeItem("impulseThisFrame"); - } + // 15 seconds. + const screensaverTimeoutMs = 15 * 1000; const mouse = { - down: JSON.parse(localStorage.getItem("mouseDown")) ?? false, - lastMove: JSON.parse(localStorage.getItem("mouseLastMove")) ?? -screensaverTimeoutMs, - previous: Vec(...JSON.parse(localStorage.getItem("mousePrevious")) ?? [0, 0, 0, 1]), - }; + down: false, + lastMove: -screensaverTimeoutMs, + previous: Vec.ZERO, + }; const orient = { elements: document.querySelectorAll("cube-itself"), - quat: Quat(...JSON.parse(localStorage.getItem("cubeOrient")) ?? [0, 0, 0, 1]), + quat: Quat(0, 0, 0, 1), set(q) { this.quat = q; @@ -165,84 +145,9 @@ }, }; - let velocity = Vec(...JSON.parse(localStorage.getItem("velocity")) ?? [0, 0, 0]); - - let impulseThisFrame = Vec(...JSON.parse(localStorage.getItem("impulseThisFrame")) ?? [0, 0, 0]); - - window.addEventListener("beforeunload", () => { - localStorage.setItem("mouseDown", JSON.stringify(mouse.down)); - localStorage.setItem("mouseLastMove", JSON.stringify(-(globalThis.performance.now() - mouse.lastMove))); - localStorage.setItem("mousePrevious", JSON.stringify([ - mouse.previous.x, - mouse.previous.y, - mouse.previous.z, - mouse.previous.w, - ])); - - localStorage.setItem("cubeOrient", JSON.stringify([ - orient.quat.x, - orient.quat.y, - orient.quat.z, - orient.quat.w, - ])); - - localStorage.setItem("velocity", JSON.stringify([ - velocity.x, - velocity.y, - velocity.z, - ])); - - localStorage.setItem("impulseThisFrame", JSON.stringify([ - impulseThisFrame.x, - impulseThisFrame.y, - impulseThisFrame.z, - ])); - - localStorage.setItem("lastSave", JSON.stringify(Date.now())); - }); - - document.addEventListener("keydown", (event) => { - const shift = event.shiftKey ? Vec(-1, -1, -1) : Vec(1, 1, 1); - - let effect; - - switch (event.key) { - case "Enter": - effect = Vec(0, 0, 4).mul(shift); - break; - - case " ": - effect = Vec(4, 0, 0).mul(shift); - break; - - case "h": - case "ArrowLeft": - effect = Vec(0, -4, 0); - break; - - case "j": - case "ArrowDown": - effect = Vec(-4, 0, 0); - break; - - case "k": - case "ArrowUp": - effect = Vec(4, 0, 0); - break; - - case "l": - case "ArrowRight": - effect = Vec(0, 4, 0); - break; - - default: - return; - } - - velocity = velocity.sum(effect); - - mouse.lastMove = globalThis.performance.now(); - }); + let velocity = Vec.ZERO; + let impulseThisFrame = Vec.ZERO; + let impulseIdle = Vec(2, 2, -2); const handleUp = () => { mouse.down = false; @@ -356,7 +261,6 @@ } if (globalThis.performance.now() - mouse.lastMove > screensaverTimeoutMs) { - const impulseIdle = Vec(2, 2, -2); velocity = velocity.sum(impulseIdle.scale(effectiveDelta)); } diff --git a/site/_includes/text.vto b/site/_includes/text.vto index a88008d..a8ce842 100644 --- a/site/_includes/text.vto +++ b/site/_includes/text.vto @@ -37,9 +37,9 @@ layout: default.vto Copyright © {{ Temporal.Now.plainDateISO().year }} - {{ set cube_size = "0.75rem" }} + {{ set cube_size = "0.75rem" }} {{ set cube_small = true }} - {{ set cube_last = true }} + {{ set cube_last = true }} {{ include "rgbcube.vto" }} diff --git a/site/assets/css/default.css b/site/assets/css/default.css index 9fafbf2..28ef8e4 100644 --- a/site/assets/css/default.css +++ b/site/assets/css/default.css @@ -230,9 +230,10 @@ html, body { code:not(pre > code) { @apply border-1 border-dotted px-2 py-0.5 border-black dark:border-white; - a:hover &:not(:is(h1, h2, h3, h4, h5, h6) *), - a:active &:not(:is(h1, h2, h3, h4, h5, h6) *) { - @apply border-transparent; + &:not(a code) { + a:hover &, a:active & { + @apply border-transparent; + } } } diff --git a/site/blog.vto b/site/blog.vto index 9aa527f..d524fc1 100644 --- a/site/blog.vto +++ b/site/blog.vto @@ -162,12 +162,12 @@ Blog Articles context.shadowColor = "#94f475"; context.textBaseline = "top"; context.textAlign = "center"; - + for (const strip of strips) { context.font = `${strip.size}px sans`; if (strip.y > canvas.height + (strip.size * 40)) { - Object.assign(strip, randomStrip()); + Object.assign(strip, randomStrip()) } let { y: yCopy } = strip; @@ -192,7 +192,7 @@ Blog Articles strip.y += strip.deltaY; } - + data.animationFrameId = requestAnimationFrame(animate); }; diff --git a/site/blog/test.md b/site/blog/a.md similarity index 99% rename from site/blog/test.md rename to site/blog/a.md index a2d599b..a744cd4 100644 --- a/site/blog/test.md +++ b/site/blog/a.md @@ -2,7 +2,6 @@ date: 2024-01-01 title: Test description: "Testing" -draft: true --- # Test