Files
personal/lib/arrowFullscreen.ts
T
virtheart 6b1f329231 feat: 移植 hyper-space 超空间区块(cursor.glb 条纹箭头 + 8vh 滚动叙事)与箭头全屏白模式
- HyperspaceModel.tsx:1:1 移植原站 cx——cursor.glb 合并几何、屏幕矩形追踪(12 帧缓存+滚动增量修正)、restScale 0.1→峰值 hypot(vw,vh)×1.64/radius 的吞噬缩放(damp 32/s)、shrink 折叠、条纹 shader(uStripeReveal 蓝底→黑底星空放射)、scaleSpinDegrees 180 收拢自旋、指针跟随高光
- HyperSpaceSection.tsx:8 视口高 + sticky,段位推进 seg0-primary/secondary(Innovate with purpose / human touch)→ seg1(进度环 + 四段主张)→ end(FUTURE-FIRST/ALWAYS);逐字符哈希延迟 stagger(hsstFadeIn/Out)
- arrowFullscreen.ts:原站 module 1111 进度 store(setDampedScaleT 阈值翻转订阅,header 0.5 阈值白模式、section 0.5 白模式同步)
- Header:箭头过阈值后整体转白(ARROW_FULLSCREEN_DOM_COLOR_TRANSITION)
- 修复:main 不再是滚动容器(原站 sticky 依赖内部滚动,我们的 Lenis 是窗口级,sticky 永不钉住导致末段文案不出现)
- scrollBus 增加 subscribeScroll/notifyScroll 供 DOM 侧响应式读取;useLightController 从 GlassModels 导出复用
- 验证:glError=0 无反馈环;段位推进/白模式触发与回落/区块顺序 全部 CDP 行为探针通过;build+tsc 通过
2026-09-01 17:38:56 +08:00

71 lines
2.0 KiB
TypeScript

"use client";
/**
* Arrow-fullscreen progress store — 1:1 port of the original module 1111
* (arrowFullscreenProgressStore):
*
* The WebGL hyperspace model (cursor.glb stripes) reports its normalized
* scale progress t (restScale→peak) every frame via `setDampedScaleT`.
* DOM consumers (header text color, the hyper-space section itself) read a
* boolean "past threshold" through `useArrowFullscreenPastThreshold`, whose
* subscription only notifies when the boolean flips — so 60fps store writes
* never re-render the header.
*
* Threshold semantics (original `r(mode, snapshot, e)`): "gte" →
* snapshot >= threshold. Server snapshot: 0 >= threshold.
*/
import { useCallback, useSyncExternalStore } from "react";
type Listener = () => void;
let value = 0;
const listeners = new Set<Listener>();
function notify() {
for (const cb of listeners) cb();
}
export const arrowFullscreenProgressStore = {
getSnapshot: () => value,
subscribe(cb: Listener) {
listeners.add(cb);
return () => {
listeners.delete(cb);
};
},
setDampedScaleT(t: number) {
const next = Math.min(1, Math.max(0, t));
if (0.001 >= Math.abs(next - value)) return;
value = next;
notify();
},
reset() {
if (value !== 0) {
value = 0;
notify();
}
},
};
export function readArrowFullscreenPastThreshold(threshold = 0.5): boolean {
return arrowFullscreenProgressStore.getSnapshot() >= threshold;
}
export function useArrowFullscreenPastThreshold(threshold = 0.5): boolean {
return useSyncExternalStore(
arrowFullscreenProgressStore.subscribe,
useCallback(
() => arrowFullscreenProgressStore.getSnapshot() >= threshold,
[threshold]
),
useCallback(() => 0 >= threshold, [threshold])
);
}
/**
* Original constant ARROW_FULLSCREEN_DOM_COLOR_TRANSITION — every DOM
* element whose color follows the arrow fullscreen state carries this.
*/
export const ARROW_FULLSCREEN_DOM_COLOR_TRANSITION =
"transition-colors duration-300 ease-out motion-reduce:transition-none";