feat: 移植原版背景/点阵遮罩/入场幕布,修复贴纸淡出与 cursor 颜色

- BackgroundFX: 1:1 移植原版 sz 多通道程序化背景(vignette→swirl→sine→shatter→bokeh→output,30% 分辨率 ping-pong,指针跟随、进度门控跳帧)
- DotOverlay: 移植原版 s1 滚动点阵遮罩(renderOrder 10,uOpacity=sT(sP))——贴纸随滚动溶入页面底色的原版机制
- LoadingCurtain+LoadingOverlay: 移植原版入场流程(径向圆洞幕布 + MaskedDots 点阵化后处理 + 居中进度条,字体/重资产 5:5 计时轴)
- sP 修正: f2 无 footer 时取 1(原版语义),相机 lerp(24,32,sP) 拉远恢复;视差 y 系数修正为 0.6
- 相机: ready 门控 intro dolly(lerp(A+8,A,customCubic),1.2s)+ 鼠标视差(lag .18/leave .05)
- GlassModels: cursor 贴色修正为亮色主题 #009dff/#009dff;新增指针跟随高光控制器 ca()
- 刷新回顶: scrollRestoration=manual + pageshow(bfcache) 双 rAF 重置 + lenis immediate
- 新增 lib/pointer.ts、lib/loadingBus.ts、lib/customCubic.ts;loadingBus 打点: 模型/贴纸/about 图
This commit is contained in:
2026-09-01 02:00:54 +08:00
parent 91ba27ffc0
commit ce08eabf62
15 changed files with 1757 additions and 33 deletions
+44
View File
@@ -0,0 +1,44 @@
/**
* Easing — 1:1 port of the original module 29090 (`customCubic` is the
* Newton/bisection-solved cubic bezier used by the camera intro dolly,
* `easeInOutCubic` the standard curve).
*/
const T = -3 * 0.65 - 1.98;
const N = -0.98 - (-3 * 0.65 - 1.98);
const bez = (u: number) => ((N * u + T) * u + 1.98) * u;
const bezDeriv = (u: number) => (3 * N * u + 2 * T) * u + 1.98;
function solveParam(x: number): number {
let t = x;
for (let n = 0; n < 8; n++) {
const err = bez(t) - x;
const d = bezDeriv(t);
if (Math.abs(err) < 1e-7) return t;
if (Math.abs(d) < 1e-7) break;
t -= err / d;
}
let lo = 0;
let hi = 1;
t = x;
while (lo < hi) {
const v = bez(t);
if (Math.abs(v - x) < 1e-7) break;
if (x > v) lo = t;
else hi = t;
t = (lo + hi) / 2;
}
return t;
}
export function customCubic(e: number): number {
if (e <= 0) return 0;
if (e >= 1) return 1;
const t = solveParam(e);
return (-2 * t + 3) * t * t;
}
export function easeInOutCubic(e: number): number {
return e < 0.5 ? 4 * e * e * e : 1 - Math.pow(-2 * e + 2, 3) / 2;
}
+68
View File
@@ -0,0 +1,68 @@
/**
* Heavy-asset loading progress — mirrors the original's heavy-load tracking
* (models + texture layers + sticker atlas gate the entrance). Components
* report completion via mark(); the overlay reads progress/ready.
*/
const REQUIRED = [
"model:hello.gltf",
"model:cursor.glb",
"stickers",
"img:about",
] as const;
const done = new Set<string>();
const listeners = new Set<() => void>();
let notifyQueued = false;
function notify() {
if (notifyQueued) return;
notifyQueued = true;
queueMicrotask(() => {
notifyQueued = false;
listeners.forEach((l) => l());
});
}
function computeSnapshot() {
const marked = REQUIRED.filter((k) => done.has(k)).length;
return {
progress: Math.round((marked / REQUIRED.length) * 100),
ready: marked === REQUIRED.length,
};
}
let currentSnapshot = computeSnapshot();
export const loadingBus = {
mark(key: string) {
if (!done.has(key)) {
done.add(key);
currentSnapshot = computeSnapshot();
notify();
}
},
/** Safety valve: complete everything (a stalled asset must not soft-lock). */
forceReady() {
let changed = false;
for (const k of REQUIRED) {
if (!done.has(k)) {
done.add(k);
changed = true;
}
}
if (changed) {
currentSnapshot = computeSnapshot();
notify();
}
},
getSnapshot() {
return currentSnapshot;
},
subscribe(listener: () => void) {
listeners.add(listener);
return () => {
listeners.delete(listener);
};
},
};
+46
View File
@@ -0,0 +1,46 @@
"use client";
import { Vector2 } from "three";
/**
* Pointer tracking — 1:1 port of the original PointerProvider (module 16265):
* uv in [0,1] with y up (1 - clientY/height), `inside` false on
* blur/mouseleave/visibilitychange with a (.5,.5) reset. A module singleton
* replaces the original React context (same listeners, capture+passive).
*/
export const pointerUv = new Vector2(0.5, 0.5);
export const pointerInsideRef = { current: false };
let listenersAttached = false;
function attach() {
if (listenersAttached || typeof window === "undefined") return;
listenersAttached = true;
const set = (x: number, y: number, inside: boolean) => {
pointerUv.set(x, y);
pointerInsideRef.current = inside;
};
const onMove = (e: PointerEvent) => {
const w = Math.max(1, window.innerWidth);
const h = Math.max(1, window.innerHeight);
set(e.clientX / w, 1 - e.clientY / h, true);
};
const reset = () => set(0.5, 0.5, false);
const options = { capture: true, passive: true } as const;
window.addEventListener("pointermove", onMove, options);
window.addEventListener("pointerdown", onMove, options);
window.addEventListener("pointerover", onMove, options);
window.addEventListener("blur", reset, options);
document.addEventListener("mouseleave", reset, options);
document.addEventListener("visibilitychange", reset, options);
}
/** Same shape as the original usePointer(): { uv, insideRef }. */
export function usePointer() {
attach();
return { uv: pointerUv, insideRef: pointerInsideRef };
}
+4 -1
View File
@@ -3,10 +3,13 @@ export interface ScrollBusState {
current: number;
velocity: number;
progress: number;
/** Banner/footer-geometry camera progress (original sP global, 0..1). */
sP: number;
}
export const scrollBus: ScrollBusState = {
current: 0,
velocity: 0,
progress: 0,
};
sP: 0,
};