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
+72 -1
View File
@@ -6,6 +6,8 @@ import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
import { mergeGeometries } from "three/examples/jsm/utils/BufferGeometryUtils.js";
import { scrollBus } from "@/lib/scrollBus";
import { usePointer } from "@/lib/pointer";
import { loadingBus } from "@/lib/loadingBus";
/**
* Glass models for the hero section, reverse-engineered 1:1 from the
@@ -299,6 +301,51 @@ function useFloatOffset(enabled: boolean) {
);
}
/**
* Specular light controller — 1:1 port of the original `ca()`: a light that
* orbits at radius hypot(4, 9) in the XY plane, its azimuth following the
* pointer (raycast onto the z=0 plane) with exponential damping (6/s), and
* falling back to the initial azimuth when the pointer leaves.
*/
function useLightController() {
return useMemo(() => {
const initialAzimuth = Math.atan2(9, 4);
const radius = Math.hypot(4, 9);
let azimuth = initialAzimuth;
let current = initialAzimuth;
const raycaster = new THREE.Raycaster();
const ndc = new THREE.Vector2();
const plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
const hit = new THREE.Vector3();
return {
update({
uv,
inside,
camera,
delta,
}: {
uv: { x: number; y: number };
inside: boolean;
camera: THREE.Camera;
delta: number;
}) {
ndc.set(2 * uv.x - 1, 2 * uv.y - 1);
raycaster.setFromCamera(ndc, camera);
const intersected = raycaster.ray.intersectPlane(plane, hit) !== null;
const tx = -hit.x;
const ty = -hit.y;
if (inside && intersected && tx * tx + ty * ty > 1e-6) {
azimuth = Math.atan2(ty, tx);
}
const target = inside ? azimuth : initialAzimuth;
const diff = Math.atan2(Math.sin(target - current), Math.cos(target - current));
current += diff * (1 - Math.exp(-6 * delta));
return { x: radius * Math.cos(current), y: radius * Math.sin(current) };
},
};
}, []);
}
function GlassModel({
url,
position = [0, 0, 0],
@@ -452,6 +499,15 @@ function GlassModel({
// Float bob: desktop only in the original (floatingMotion && !isMobileWidth)
const floatEnabled = floating && !isMobile;
const getFloat = useFloatOffset(floatEnabled);
const lightController = useLightController();
const { uv: pointerUv, insideRef: pointerInsideRef } = usePointer();
// Heavy-asset readiness for the entrance (original onReady → load progress).
useEffect(() => {
if (mergedGeometry) {
loadingBus.mark(`model:${url.split("/").pop()}`);
}
}, [mergedGeometry, url]);
// Counter tilt: cancels rotationAxisTilt so the model's static orientation
// is upright; the tilt only skews the spin axis (original nests -tilt
@@ -540,6 +596,19 @@ function GlassModel({
spin.rotation.y = THREE.MathUtils.damp(spin.rotation.y, ty, 6, delta);
spin.rotation.z = THREE.MathUtils.damp(spin.rotation.z, tz, 6, delta);
}
// Pointer-following specular light (original ca() + uLight.set(x, y, lightZ))
const light = lightController.update({
uv: pointerUv,
inside: pointerInsideRef.current && !isMobile,
camera,
delta,
});
materialRef.current?.uniforms.uLight.value.set(
light.x,
light.y,
LIGHT_PARAMS.lightZ
);
}, -2);
if (!mergedGeometry) return null;
@@ -599,7 +668,9 @@ export function CursorStar({ isMobile = false }: { isMobile?: boolean }) {
afterRotation={[0, 720, 0]}
rotation={[0, 0, 0]}
scale={0.1}
tintColors={["#009dff", "#64c3ff"]}
// Original tingColor light theme: tint A and B are BOTH #009dff
// (m[0]/m[1]); #64c3ff (m[2]/m[3]) is the dark-theme value.
tintColors={["#009dff", "#009dff"]}
tintEnabled
isMobile={isMobile}
scrollSyncFactor={0.72}