Files
personal/components/canvas/HeroScene.tsx
T
virtheart ce08eabf62 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 图
2026-09-01 02:00:54 +08:00

70 lines
2.8 KiB
TypeScript

"use client";
import { Canvas } from "@react-three/fiber";
import { PerspectiveCamera } from "@react-three/drei";
import { StickerDrop, StickerCamera } from "@/components/canvas/StickerDrop";
import { HelloModel, CursorStar } from "@/components/canvas/GlassModels";
import ImageLayers from "@/components/canvas/ImageLayers";
import BackgroundFX from "@/components/canvas/BackgroundFX";
import DotOverlay from "@/components/canvas/DotOverlay";
import { useAppReady } from "@/components/dom/LoadingOverlay";
import { useIsMobile } from "@/lib/useIsMobile";
/**
* Hero canvas: animated background + falling stickers + glass models +
* DOM-tracked image layers.
*
* - BackgroundFX renders the original sz multi-pass gradient at
* renderOrder -10; the glass FBO pass (layer-0 mask) captures it, which
* is what tints the glass models blue.
* - Stickers live on layer 0; glass models on layer 0+10 (10 excluded from
* the FBO pass — no self-refraction).
* - Models animate only from scroll (entry/after targets, damp 6); the
* camera intro dolly starts once `ready` (loading gate).
*/
export function HeroScene() {
const isMobile = useIsMobile();
const ready = useAppReady();
return (
// z-30 keeps it above the BackgroundGrid (z-20) to prevent mix-blend-difference from making it gray
<div className="z-30 fixed inset-0 w-full h-full pointer-events-none">
<Canvas
dpr={[1, 2]}
gl={{ alpha: true, antialias: true }}
>
{/* Camera rig: horizontal FOV 60/38, distance lerp(24, 32, sP),
intro dolly z+8 → A (customCubic, 1.2s, ready-gated), mouse
parallax (desktop). */}
<PerspectiveCamera makeDefault position={[0, 0, 32]} near={0.1} far={200} />
<StickerCamera ready={ready} />
{/* Animated background (vignette/swirl/sine/shatter/bokeh → output) */}
<BackgroundFX />
{/* Scroll dot-overlay (original s1): page-bg-colored 4px dot grid
whose opacity = sT(sP) — melts the WebGL scene into the page
background after ~0.75 viewport of scroll (this is the original
"stickers fade out on scroll" behavior); reopens near footer. */}
<DotOverlay />
{/* Falling stickers: 1:1 re-implementation of the original particle system.
Live on layer 0 — visible to the main camera and captured by the
glass FBO pass (which renders with a layer-0 camera mask). */}
<StickerDrop />
{/* DOM-tracked image layers (about section m3.png), rendered above
stickers via renderOrder 20. */}
<ImageLayers />
{/* Glass hero models (hello + blue cursor star), refractive tint shader */}
<HelloModel isMobile={isMobile} />
<CursorStar isMobile={isMobile} />
</Canvas>
</div>
);
}
export default HeroScene;