PARISRAIN 演示版
SHANGHAI · --:--
← WRITING DECK
NO. 041 · 2026.11.28 · 6 min

120fps 实体展板与双核架构:rainloss.com 工程实践

零框架物理循环、正 Z 轴 3D 命中测试、空闲休眠,以及 Cloudflare × OVH BHS5 零暴露端口回源。

大多数高交互创意网站之所以卡顿发热,根源在于两点:把 120Hz requestAnimationFrame 循环塞进了 React 状态重渲染,以及动画静止后依然空转 GPU。

1. 零分配物理循环与正 Z 轴安全命中

在 deck-physics.ts 中,所有 3D 展板全部通过纯 TypeScript 直接驱动合成层 transform,且保证所有可见卡片均停留在 translateZ >= 0 平面(避免负 Z 轴导致 CSS preserve-3d 侧边卡片点击穿透):

src/engine/deck-physics.ts
const offset = index - currentPos;
const abs = Math.abs(offset);
const tx = offset * spacing;
const tz = Math.max(0, 240 - abs * 120);
const rotY = Math.max(-44, Math.min(44, -offset * 22 + velocity * 90));
const scale = Math.max(0.7, 0.9 - abs * 0.08);

2. 空闲自动休眠守卫

当 |targetPos - pos| < 0.0005 且指针静止超过 450ms 时,主循环自动取消 requestAnimationFrame,在用户下一次 pointermove、wheel、keydown 或 touchstart 时瞬时唤醒。

3. 双核解耦:Cloudflare Pages × OVH BHS5

本次演示随静态页面发布示例快照。仓库另附可部署到 OVH BHS5 的 Go 服务 twin-sync,可按五分钟间隔刷新 GitHub 统计,并为 /v1/snapshot.json 设置边缘缓存。openGym 训练记录和摄影原图待选定后接入。

Cache-Control Header
Cache-Control: public, max-age=60, s-maxage=120, stale-while-revalidate=86400, stale-if-error=604800

访客读取的文章和示例图表都在 Cloudflare Pages,独服维护期间也可以阅读。