Skip to content

The native runtime for three.js: three.js, down to the metal. 45× smaller than Electron, on a Sony PS3, and path-traced at 60 fps on ray-tracing GPUs.

Site: the hero reel follows a rotation; the community list revalidates; the showroom clip's description (Bugbot)

Evan (Yifeng) Wang4449d9feb170
diff --git a/site/js/threert.js b/site/js/threert.js
index 1542c62..965301a 100644
--- a/site/js/threert.js
+++ b/site/js/threert.js
@@ -152,11 +152,21 @@ function clip(el, panes) {
* The still stays where the clip should not or cannot play (reduced motion, a data saver, autoplay refused).
*/
export function backdrop(el) {
- const d = el.dataset, tall = !!d.videoTall && matchMedia("(max-aspect-ratio: 4/5)").matches;
+ const d = el.dataset, mq = matchMedia("(max-aspect-ratio: 4/5)");
+ const isTall = () => !!d.videoTall && mq.matches;
+ let tall = isTall(), v = null, state = () => {};
const img = el.appendChild(Object.assign(new Image(), { alt: "", draggable: false, src: (tall && d.posterTall) || d.poster }));
img.decoding = "async";
+ // A rotation crosses the breakpoint the page's overlay uses (the same media query in the page's CSS): the still and
+ // the clip follow it, so the grid under the overlay is always the one laid out for the screen's shape.
+ mq.addEventListener("change", () => {
+ if (isTall() === tall) return;
+ tall = isTall();
+ img.src = (tall && d.posterTall) || d.poster;
+ if (v?.getAttribute("src")) { v.src = (tall && d.videoTall) || d.video; state(); }
+ });
if (matchMedia("(prefers-reduced-motion: reduce)").matches || navigator.connection?.saveData) return;
- const v = el.appendChild(Object.assign(document.createElement("video"), { muted: true, loop: true, playsInline: true, preload: "auto" }));
+ v = el.appendChild(Object.assign(document.createElement("video"), { muted: true, loop: true, playsInline: true, preload: "auto" }));
v.setAttribute("muted", "");
v.setAttribute("playsinline", "");
v.setAttribute("aria-hidden", "true");
@@ -165,7 +175,7 @@ export function backdrop(el) {
const ICON = { pause: `<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><rect x="2" y="1.5" width="3" height="9" fill="currentColor"/><rect x="7" y="1.5" width="3" height="9" fill="currentColor"/></svg>`, play: `<svg width="12" height="12" viewBox="0 0 12 12" aria-hidden="true"><path d="M3 1.5v9l7.5-4.5z" fill="currentColor"/></svg>` };
let visible = false, paused = false;
v.addEventListener("playing", () => { el.classList.add("playing"); pp.hidden = false; }, { once: true });
- const state = () => {
+ state = () => {
pp.innerHTML = paused ? ICON.play : ICON.pause;
pp.setAttribute("aria-label", paused ? "Play the reel" : "Pause the reel");
if (visible && !paused) v.play().catch(() => {});
@@ -174,7 +184,7 @@ export function backdrop(el) {
pp.addEventListener("click", () => { paused = !paused; state(); });
new IntersectionObserver(([en]) => {
visible = en.isIntersecting;
- if (visible && !v.src) v.src = (tall && d.videoTall) || d.video;
+ if (visible && !v.getAttribute("src")) v.src = (tall && d.videoTall) || d.video;
state();
}, { threshold: 0.05 }).observe(el);
}
diff --git a/site/media/reel/reel.json b/site/media/reel/reel.json
index c3f5b6b..4091dcc 100644
--- a/site/media/reel/reel.json
+++ b/site/media/reel/reel.json
@@ -134,7 +134,7 @@
},
{
"id": "showroom",
- "what": "Boutique Showroom in the evening: walking to the sneaker, then the chair",
+ "what": "Boutique Showroom in the evening: walking to the sneaker, then the sunglasses",
"width": 960,
"height": 540,
"scale": 1,
diff --git a/site/showcase/index.html b/site/showcase/index.html
index 9eb5f10..d8f9576 100644
--- a/site/showcase/index.html
+++ b/site/showcase/index.html
@@ -188,7 +188,7 @@
// The community's entries (showcase/community.json: repositories registered through the issue form below).
$("#submit").href = `${GITHUB}/issues/new?template=showcase.yml`;
guard("community", async () => {
- const r = await fetch(new URL("showcase/community.json", ROOT));
+ const r = await fetch(new URL("showcase/community.json", ROOT), { cache: "no-cache" }); // a fixed path: always revalidate
const items = r.ok ? (await r.json()).items ?? [] : [];
$("#made").innerHTML = items.map((g) => {
const open = g.package ? g.package.replace(/^https:/, "threerts:").replace(/^http:/, "threert:") : null;
diff --git a/tools/site-reel.ts b/tools/site-reel.ts
index 03f7dec..ab54c1d 100644
--- a/tools/site-reel.ts
+++ b/tools/site-reel.ts
@@ -93,7 +93,7 @@ const CLIPS: Record<string, Clip> = {
src: "showcase/moon-phases/moon-phases.game.ts",
},
showroom: {
- what: "Boutique Showroom in the evening: walking to the sneaker, then the chair",
+ what: "Boutique Showroom in the evening: walking to the sneaker, then the sunglasses",
src: "showcase/showroom/showroom.game.ts", at: [[0.6, ev("next")], [4.4, ev("next")]],
},
};