Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59545f7385 | |||
| 36f94e7697 | |||
| 44a518bad1 | |||
| c3b86d8f89 | |||
| 1384554361 | |||
| 76168b6927 | |||
| d7b89b6d46 | |||
| 6454a51fd0 | |||
| 2cd0e007e4 | |||
| 9c86ecc338 |
@@ -9,6 +9,7 @@ import RouteTransitionOverlay from "@/components/dom/RouteTransitionOverlay";
|
||||
import { getPasscodeAccessServer } from "@/lib/passcodeServer";
|
||||
import { getSiteConfig } from "@/lib/siteConfig";
|
||||
import { SITE_URL } from "@/lib/siteUrl";
|
||||
import VisitorHeartbeat from "@/components/site/VisitorHeartbeat";
|
||||
import type { Metadata } from "next";
|
||||
|
||||
/**
|
||||
@@ -76,6 +77,8 @@ export default async function SiteLayout({
|
||||
return (
|
||||
<PasscodeAccessProvider initialAccess={initialAccess}>
|
||||
<FullscreenTransitionProvider>
|
||||
{/* 真实在线统计:模块维度 personal,后端 5 分钟滑动窗口去重 */}
|
||||
<VisitorHeartbeat module="personal" />
|
||||
{/* Original stacking (1:1): the WebGL canvas host is a plain `fixed`
|
||||
z-auto element first in the body; the grid overlay (z-20) comes
|
||||
AFTER it in DOM order so it paints above the canvas, exactly like
|
||||
|
||||
@@ -42,6 +42,11 @@ export default function RootLayout({
|
||||
return (
|
||||
<html
|
||||
lang="zh-CN"
|
||||
// 浏览器插件(沉浸式翻译等)会在 hydration 前往 <html> 注入
|
||||
// data-immersive-translate-page-theme 等属性,触发属性级 hydration
|
||||
// 告警;suppressHydrationWarning 只忽略该元素的属性差异,
|
||||
// 不影响子树的正常 mismatch 检测。
|
||||
suppressHydrationWarning
|
||||
className={`${tiktokSans.variable} ${geistMono.variable} ${departureMono.variable}`}
|
||||
>
|
||||
<head>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef } from "react";
|
||||
import { useFrame, useLoader, useThree } from "@react-three/fiber";
|
||||
import * as THREE from "three";
|
||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
||||
@@ -310,6 +310,16 @@ type GlassModelProps = {
|
||||
*/
|
||||
sectionTopDocY?: number;
|
||||
sectionHeightPx?: number;
|
||||
/**
|
||||
* Live-read the section's document geometry by element id EVERY frame
|
||||
* (original sX readSectionContentLayout: getBoundingClientRect +
|
||||
* scrollTop). Required on mobile: dvh shrinks/grows as the URL bar
|
||||
* collapses/expands, every h-dvh section (hero, footer) reflows, and some
|
||||
* browsers never fire window resize for it — one-shot offsetTop
|
||||
* measurements go stale and the model drifts off its section. Falls back
|
||||
* to the static props above while the element is missing.
|
||||
*/
|
||||
sectionElId?: string;
|
||||
};
|
||||
|
||||
function useFloatOffset(enabled: boolean) {
|
||||
@@ -384,6 +394,7 @@ function GlassModel({
|
||||
isMobile = false,
|
||||
sectionTopDocY = 0,
|
||||
sectionHeightPx,
|
||||
sectionElId,
|
||||
}: GlassModelProps) {
|
||||
const gltf = useLoader(GLTFLoader, url);
|
||||
const groupRef = useRef<THREE.Group>(null!);
|
||||
@@ -452,11 +463,18 @@ function GlassModel({
|
||||
// Scene-texture FBO: render layer 0 (background + stickers) at half res.
|
||||
// Same as the original GlassSystem: one shared pass, camera mask forced to
|
||||
// layer 0 so glass meshes (layer 10) are excluded from their own refraction.
|
||||
// ⚠ type: HalfFloatType —— 原版 sb() 工厂创建的所有 RT 均为 HalfFloat
|
||||
// (4d3f3b68 @200877: {minFilter,magFilter,type:HalfFloatType,...})。
|
||||
// UnsignedByte 的默认 RT 会让折射纹理的暗部量化/截断,Dark 主题下
|
||||
// Hard-Light 着色的底色因此偏灰(模型"发透明感"而非饱和蓝)。
|
||||
const fbo = useMemo(() => {
|
||||
const dpr = gl.getPixelRatio();
|
||||
const w = Math.max(2, Math.floor((size.width * dpr) / 2));
|
||||
const h = Math.max(2, Math.floor((size.height * dpr) / 2));
|
||||
const target = new THREE.WebGLRenderTarget(w, h, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.LinearFilter,
|
||||
type: THREE.HalfFloatType,
|
||||
stencilBuffer: false,
|
||||
depthBuffer: true,
|
||||
samples: 0,
|
||||
@@ -523,44 +541,59 @@ function GlassModel({
|
||||
// flips. Per-model tingColor overrides: m[0]/m[1] light A/B,
|
||||
// m[2]/m[3] dark A/B, missing entries fall back to the theme defaults.
|
||||
const isDark = useResolvedTheme() === "dark";
|
||||
// ⚠ R3F 对 ShaderMaterial 的 `uniforms` prop 做的是「按键浅合并」:
|
||||
// material.uniforms 是独立容器,标量按值拷贝、Vector4/Texture 共享引用,
|
||||
// 且仅在 prop 引用变化时重新合并。材质创建后再改 memo 对象,标量
|
||||
// (uDark、brightness、thickness alpha、loop…)永远到不了 GPU —— Dark
|
||||
// 主题下 uDark 卡在 0、参数卡在 light 值,模型因此失色。原版所有
|
||||
// apply 都写 T.current.uniforms(材质 ref);这里同样穿透到材质,
|
||||
// 材质未挂载时回落到 memo(创建时会被拷贝进去),并以 mergedGeometry
|
||||
// 作为「材质已存在」信号重跑(原版靠 tintYRange Y 的变化触发同一效果)。
|
||||
const matUniforms = () =>
|
||||
(materialRef.current?.uniforms ?? uniforms) as typeof uniforms;
|
||||
// 原版移动端钳制 loop(apply effect: t=O?Math.min(B.loop,2):B.loop)——
|
||||
// 折射采样少一轮,色散/亮度观感随设备宽度变化;桌面 3、移动 2。
|
||||
const loop = isMobile ? Math.min(LIGHT_PARAMS.loop, 2) : LIGHT_PARAMS.loop;
|
||||
useEffect(() => {
|
||||
uniforms.uLoop.value = loop;
|
||||
uniforms.uRgbRefraction.value = +(loop <= 3);
|
||||
}, [loop, uniforms]);
|
||||
const u = matUniforms();
|
||||
u.uLoop.value = loop;
|
||||
u.uRgbRefraction.value = +(loop <= 3);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [loop, uniforms, mergedGeometry]);
|
||||
useEffect(() => {
|
||||
const u = matUniforms();
|
||||
const P = isDark ? DARK_PARAMS : LIGHT_PARAMS;
|
||||
uniforms.uShininess.value = P.shininess;
|
||||
uniforms.uDiffuseness.value = P.diffuseness;
|
||||
uniforms.uFresnelPower.value = P.fresnelPower;
|
||||
uniforms.uFresnelStrength.value = P.fresnelStrength;
|
||||
uniforms.uBrightness.value = P.brightness;
|
||||
uniforms.uContrast.value = P.contrast;
|
||||
uniforms.uGamma.value = P.gamma;
|
||||
uniforms.uSaturation.value = P.saturation;
|
||||
uniforms.uTintMix.value = P.tintMix;
|
||||
uniforms.uTintThicknessMinAlpha.value = P.tintThicknessMinAlpha;
|
||||
uniforms.uTintThicknessMaxAlpha.value = P.tintThicknessMaxAlpha;
|
||||
u.uShininess.value = P.shininess;
|
||||
u.uDiffuseness.value = P.diffuseness;
|
||||
u.uFresnelPower.value = P.fresnelPower;
|
||||
u.uFresnelStrength.value = P.fresnelStrength;
|
||||
u.uBrightness.value = P.brightness;
|
||||
u.uContrast.value = P.contrast;
|
||||
u.uGamma.value = P.gamma;
|
||||
u.uSaturation.value = P.saturation;
|
||||
u.uTintMix.value = P.tintMix;
|
||||
u.uTintThicknessMinAlpha.value = P.tintThicknessMinAlpha;
|
||||
u.uTintThicknessMaxAlpha.value = P.tintThicknessMaxAlpha;
|
||||
const tintA = isDark
|
||||
? (tintColors?.[2] ?? DARK_PARAMS.tintColorA)
|
||||
: (tintColors?.[0] ?? LIGHT_PARAMS.tintColorA);
|
||||
const tintB = isDark
|
||||
? (tintColors?.[3] ?? DARK_PARAMS.tintColorB)
|
||||
: (tintColors?.[1] ?? LIGHT_PARAMS.tintColorB);
|
||||
uniforms.uTintColorA.value.copy(hexToVec4(tintA));
|
||||
uniforms.uTintColorB.value.copy(hexToVec4(tintB));
|
||||
uniforms.uDark.value = isDark ? 1 : 0;
|
||||
}, [isDark, tintColors, uniforms]);
|
||||
u.uTintColorA.value.copy(hexToVec4(tintA));
|
||||
u.uTintColorB.value.copy(hexToVec4(tintB));
|
||||
u.uDark.value = isDark ? 1 : 0;
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [isDark, tintColors, uniforms, mergedGeometry]);
|
||||
|
||||
useEffect(() => {
|
||||
const drawingBufferSize = gl.getDrawingBufferSize(new THREE.Vector2());
|
||||
uniforms.uScreenResolutionPx.value.set(
|
||||
matUniforms().uScreenResolutionPx.value.set(
|
||||
drawingBufferSize.x,
|
||||
drawingBufferSize.y
|
||||
);
|
||||
}, [gl, size, uniforms]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [gl, size, uniforms, mergedGeometry]);
|
||||
|
||||
// Float bob: desktop only in the original (floatingMotion && !isMobileWidth)
|
||||
const floatEnabled = floating && !isMobile;
|
||||
@@ -608,13 +641,31 @@ function GlassModel({
|
||||
const spin = spinRef.current;
|
||||
if (!g) return;
|
||||
|
||||
// --- Section geometry: live DOM read (original sX
|
||||
// readSectionContentLayout) ---
|
||||
// 原版每帧 getBoundingClientRect + scrollTop 重算 section 文档坐标。
|
||||
// 移动端 dvh 随地址栏收起/展开变化,hero/footer 均为 h-dvh,布局随之
|
||||
// 平移;部分浏览器不为此派发 window resize,一次性 offsetTop 测量会
|
||||
// 过期导致锚点漂移(真机偏移、PC 模拟正常的根源)。元素缺失时回落
|
||||
// 到静态测量值。
|
||||
let secTop = sectionTopDocY;
|
||||
let secHeight = sectionHeightPx;
|
||||
if (sectionElId) {
|
||||
const el = document.getElementById(sectionElId);
|
||||
if (el) {
|
||||
const rect = el.getBoundingClientRect();
|
||||
secTop = rect.top + window.scrollY;
|
||||
secHeight = rect.height;
|
||||
}
|
||||
}
|
||||
|
||||
// --- Section-anchored scroll state (banner: top 0, h-dvh) ---
|
||||
const vh = Math.max(1, state.size.height);
|
||||
const sectionH = Math.max(1, sectionHeightPx ?? vh);
|
||||
const sectionH = Math.max(1, secHeight ?? vh);
|
||||
const scrollTop = Math.max(0, scrollBus.current);
|
||||
|
||||
// Original X(): hide the model once its section leaves the viewport.
|
||||
const deltaTop = sectionTopDocY - scrollTop;
|
||||
const deltaTop = secTop - scrollTop;
|
||||
g.visible = deltaTop + sectionH > 0 && deltaTop < vh;
|
||||
|
||||
// Original position sync:
|
||||
@@ -627,7 +678,7 @@ function GlassModel({
|
||||
camera,
|
||||
new THREE.Vector3(0, 0, position[2])
|
||||
).height;
|
||||
const anchorDocY = sectionTopDocY + sectionH / 2;
|
||||
const anchorDocY = secTop + sectionH / 2;
|
||||
const syncWorldY =
|
||||
(0.5 - anchorDocY / vh) * viewportWorldHeight +
|
||||
(scrollTop / vh) * viewportWorldHeight * scrollSyncFactor;
|
||||
@@ -644,7 +695,7 @@ function GlassModel({
|
||||
let entry = 1;
|
||||
let after = afterRotation ? 1 : 0;
|
||||
if (vh > 0) {
|
||||
const i = (scrollTop + vh - sectionTopDocY) / vh;
|
||||
const i = (scrollTop + vh - secTop) / vh;
|
||||
entry = THREE.MathUtils.clamp(i, 0, 1);
|
||||
after = THREE.MathUtils.clamp(i - 1, 0, 1);
|
||||
}
|
||||
@@ -711,7 +762,7 @@ function GlassModel({
|
||||
export function HelloModel({ isMobile = false }: { isMobile?: boolean }) {
|
||||
return (
|
||||
<GlassModel
|
||||
url="/model/hello.gltf"
|
||||
url="/model/hello.glb"
|
||||
position={[-0.1, 0, 2]}
|
||||
beforeRotation={[0, 240, 0]}
|
||||
afterRotation={[0, 90, 0]}
|
||||
@@ -748,35 +799,20 @@ export function CursorStar({ isMobile = false }: { isMobile?: boolean }) {
|
||||
* #contact footer model (original cp call: model/cnt.gltf, scale 19,
|
||||
* beforeRotation [-180,0,0], scrollSyncFactor 1 — the cp default — and
|
||||
* light-theme tingColor m[0]/m[1] = #FFFFFF/#009dff). Anchored to the
|
||||
* footer section's document geometry, measured live so it tracks layout.
|
||||
* footer section via live per-frame DOM reads (original sX), so mobile
|
||||
* URL-bar dvh reflows can't drift the anchor.
|
||||
*/
|
||||
export function FooterModel() {
|
||||
const [geom, setGeom] = useState({ top: 0, height: 0 });
|
||||
useEffect(() => {
|
||||
const measure = () => {
|
||||
const el = document.getElementById("contact");
|
||||
if (el) setGeom({ top: el.offsetTop, height: el.offsetHeight });
|
||||
};
|
||||
measure();
|
||||
window.addEventListener("resize", measure);
|
||||
document.fonts?.ready?.then(measure).catch(() => {});
|
||||
const t = window.setTimeout(measure, 500);
|
||||
return () => {
|
||||
window.removeEventListener("resize", measure);
|
||||
window.clearTimeout(t);
|
||||
};
|
||||
}, []);
|
||||
return (
|
||||
<GlassModel
|
||||
url="/model/cnt.gltf"
|
||||
url="/model/cnt.glb"
|
||||
position={[0, 0, 0]}
|
||||
beforeRotation={[-180, 0, 0]}
|
||||
rotation={[0, 0, 0]}
|
||||
scale={19}
|
||||
tintColors={["#FFFFFF", "#009dff", "#8e9dc4", "#64c3ff"]}
|
||||
tintEnabled
|
||||
sectionTopDocY={geom.top}
|
||||
sectionHeightPx={geom.height}
|
||||
sectionElId="contact"
|
||||
scrollSyncFactor={1}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { EffectComposer } from "@react-three/postprocessing";
|
||||
import { UnsignedByteType, Vector2 } from "three";
|
||||
import { usePointer } from "@/lib/pointer";
|
||||
import { useResolvedTheme } from "@/lib/shellMedia";
|
||||
import { scrollBus } from "@/lib/scrollBus";
|
||||
import {
|
||||
FluidPushPass,
|
||||
@@ -30,10 +31,15 @@ import {
|
||||
* lime trail acts as a pointer indicator over the dot curtain
|
||||
* - params: starRays 6, intensity .7, threshold .99, streakScale
|
||||
* 8·(w/1920)·(mobile?2:1), hotspotPower 32, gate .88,
|
||||
* tailColorLight #ffa300
|
||||
* tailColor 随主题: light #ffa300 / dark #1600ff(原 lensFlare 控制
|
||||
* tailColorLight/tailColorDark,resolvedTheme 切换)。
|
||||
* ⚠ 尾迹色叠在玻璃高光热点上:Dark 下用橙色会把模型区域的
|
||||
* r/g 抬高、显得"发灰发透明"而非原版的饱和蓝。
|
||||
*/
|
||||
|
||||
const BRIGHT_SOURCE_SECTIONS = ["banner", "footer"];
|
||||
const TAIL_COLOR_LIGHT = "#ffa300";
|
||||
const TAIL_COLOR_DARK = "#1600ff";
|
||||
const clamp01 = (v: number) => Math.min(1, Math.max(0, v));
|
||||
const sT = (e?: number) => (e === undefined ? 0 : clamp01(e > 1 ? e / 100 : e));
|
||||
|
||||
@@ -81,6 +87,9 @@ export function PostFX() {
|
||||
const { uv: pointerUv, insideRef } = usePointer();
|
||||
const isMobile = size.width < 1024;
|
||||
const reducedMotion = useReducedMotion();
|
||||
// 尾迹色随主题(原版: resolvedTheme → tailColorDark / tailColorLight)
|
||||
const isDark = useResolvedTheme() === "dark";
|
||||
const tailColor = isDark ? TAIL_COLOR_DARK : TAIL_COLOR_LIGHT;
|
||||
|
||||
const composerRef = useRef<any>(null);
|
||||
|
||||
@@ -95,9 +104,11 @@ export function PostFX() {
|
||||
streakScale: 8,
|
||||
hotspotPower: 32,
|
||||
gate: 0.88,
|
||||
tailColor: "#ffa300",
|
||||
tailColor,
|
||||
}),
|
||||
[]
|
||||
// 尾迹色随主题切换时需重建材质 uniform —— tailColor 进依赖
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
[tailColor]
|
||||
);
|
||||
const fluidPass = useMemo(() => new FluidPushPass(), []);
|
||||
|
||||
@@ -124,9 +135,9 @@ export function PostFX() {
|
||||
streakScale,
|
||||
hotspotPower: 32,
|
||||
gate: 0.88,
|
||||
tailColor: "#ffa300",
|
||||
tailColor,
|
||||
});
|
||||
}, [flarePass, streakScale]);
|
||||
}, [flarePass, streakScale, tailColor]);
|
||||
|
||||
const dprRef = useRef(1);
|
||||
useEffect(() => {
|
||||
|
||||
@@ -153,10 +153,20 @@ export default function RouteTransitionOverlay() {
|
||||
// Intent → cover (original effect 1).
|
||||
useEffect(() => {
|
||||
if (targetHref && mode === "idle") {
|
||||
// startNavigation() resets readyToLoadHeavy, but the bus only notifies
|
||||
// on NEW marks. When every REQUIRED key is already done (any visit to
|
||||
// "/" after the first), no notification ever fires again, so the
|
||||
// route:wait reveal gate for a "/" target would never pass — the
|
||||
// curtain stays covering the page (dots background + header only).
|
||||
// Restore the gate immediately when the snapshot is already ready;
|
||||
// genuinely-pending assets still notify through the subscription.
|
||||
if (loadingBus.getSnapshot().ready) {
|
||||
setReadyToLoadHeavy(true);
|
||||
}
|
||||
routeFrom.current = { path: pathname, coverDone: false };
|
||||
setTransition({ mode: "route", phase: "cover" });
|
||||
}
|
||||
}, [targetHref, mode, pathname]);
|
||||
}, [targetHref, mode, pathname, setReadyToLoadHeavy]);
|
||||
|
||||
// Entry wait → reveal (original effect 2): fires as soon as the gates
|
||||
// pass — the reveal is NOT held for the progress-bar fade timers.
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
|
||||
/**
|
||||
* 访客心跳(真实在线统计埋点):
|
||||
* - visitorId 首次生成后写入 localStorage 持久化(匿名,无隐私信息);
|
||||
* - 每 60s POST /open/visitor/ping?visitorId=x&module=<module>;
|
||||
* - 页面隐藏(document.hidden)时暂停,可见时立即补一次心跳;
|
||||
* - 后端以 5 分钟滑动窗口去重统计在线数。
|
||||
* module:official=企业官网 / personal=个人站,与后端白名单一致。
|
||||
*/
|
||||
export default function VisitorHeartbeat({ module = "official" }: { module?: string }) {
|
||||
useEffect(() => {
|
||||
const KEY = "vhsys_visitor_id";
|
||||
let visitorId = "";
|
||||
try {
|
||||
visitorId = localStorage.getItem(KEY) ?? "";
|
||||
if (!visitorId) {
|
||||
visitorId =
|
||||
typeof crypto !== "undefined" && "randomUUID" in crypto
|
||||
? crypto.randomUUID()
|
||||
: `v-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
||||
localStorage.setItem(KEY, visitorId);
|
||||
}
|
||||
} catch {
|
||||
// localStorage 不可用(隐私模式等):会话级一次性 id,不影响其它功能
|
||||
visitorId = `s-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
||||
}
|
||||
|
||||
// 统计接口与内容接口同源反代:优先走同域 /api,开发环境回退后端端口
|
||||
const base =
|
||||
typeof window !== "undefined" && window.location.hostname === "localhost"
|
||||
? "http://localhost:9999/api"
|
||||
: "/api";
|
||||
|
||||
const ping = () => {
|
||||
try {
|
||||
const body = new URLSearchParams({ visitorId, module });
|
||||
// keepalive:页面卸载时请求也能发出
|
||||
fetch(`${base}/open/visitor/ping`, {
|
||||
method: "POST",
|
||||
body,
|
||||
keepalive: true,
|
||||
}).catch(() => {});
|
||||
} catch {
|
||||
/* 静默:埋点失败不影响页面 */
|
||||
}
|
||||
};
|
||||
|
||||
ping();
|
||||
const interval = window.setInterval(() => {
|
||||
if (!document.hidden) ping();
|
||||
}, 60_000);
|
||||
|
||||
const onVisible = () => {
|
||||
if (!document.hidden) ping();
|
||||
};
|
||||
document.addEventListener("visibilitychange", onVisible);
|
||||
|
||||
return () => {
|
||||
window.clearInterval(interval);
|
||||
document.removeEventListener("visibilitychange", onVisible);
|
||||
};
|
||||
}, [module]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
|---|---|
|
||||
| `CanvasSizeGuard` | 修复 R3F 首测竞态(见 §7 坑) |
|
||||
| `BackgroundFX` | 背景微噪点/渐变平面 |
|
||||
| `GlassModels` | hello.gltf 玻璃字 + cursor.glb 星标 + footer 模型,随 `scrollBus.sP` 分段入场 |
|
||||
| `GlassModels` | hello.glb 玻璃字 + cursor.glb 星标 + footer 模型,随 `scrollBus.sP` 分段入场 |
|
||||
| `ImageLayers` | 把 DOM 注册表里的图片投影成 3D 平面(作品图 + about 头像) |
|
||||
| `StickerDrop` | 贴纸雨(sticker_img 图集),滚动触发掉落 |
|
||||
| `HyperspaceModel` | hyper-space 区块的隧道箭头(cursor.glb 条纹拉伸) |
|
||||
@@ -51,7 +51,7 @@ const defs = new Map<string, ImageLayerDef>([
|
||||
## 6. 加载门(lib/loadingBus.ts + LoadingOverlay)
|
||||
|
||||
```
|
||||
REQUIRED = ["model:hello.gltf", "model:cursor.glb", "stickers", "img:about"]
|
||||
REQUIRED = ["model:hello.glb", "model:cursor.glb", "stickers", "img:about"]
|
||||
loadingBus.mark(key) → progress = done/4 → ready = 全齐
|
||||
```
|
||||
|
||||
@@ -71,8 +71,8 @@ loadingBus.mark(key) → progress = done/4 → ready = 全齐
|
||||
|
||||
> 我在克隆 haoqi.design 的 WebGL 层(React Three Fiber + drei,Next.js)。请实现:
|
||||
> 1. 单一全屏 Canvas 挂在 `top-0 left-0 -z-1 fixed w-full h-dvh lg:h-screen pointer-events-none` 容器里,`gl={{alpha:true, antialias:true}}`,dpr [1,2],容器 style 强制 pointerEvents:"none"(R3F 会强制改回 auto,必须覆盖,否则吞掉 DOM hover)。Canvas 只在首页挂载(usePathname 门控,非首页 return null——注意早退要放在所有 hooks 之后)。
|
||||
> 2. 场景含:两枚玻璃质感模型(hello.gltf 大字 + cursor.glb 星标)、作品图片层、贴纸雨、hyper-space 隧道模型、背景微噪平面、轻后期。相机进度用一个全局 scrollBus(0=页面顶,1=footer 顶,公式 clamp01((vh-bannerRect.bottom)/(vh*0.75)) * clamp01(footerRect.top/vh))每帧读取。
|
||||
> 2. 场景含:两枚玻璃质感模型(hello.glb 大字 + cursor.glb 星标)、作品图片层、贴纸雨、hyper-space 隧道模型、背景微噪平面、轻后期。相机进度用一个全局 scrollBus(0=页面顶,1=footer 顶,公式 clamp01((vh-bannerRect.bottom)/(vh*0.75)) * clamp01(footerRect.top/vh))每帧读取。
|
||||
> 3. 图片层用"DOM 注册表"模式:模块级 Map<key,{imageUrl,hoverImageUrl}>,DOM 组件(作品卡/头像占位 div)渲染后 touch 版本号;Canvas 端订阅并每帧把目标元素 getBoundingClientRect() 投影成带视差的 3D 平面。头像区 DOM 端只是 aspect-square 空占位,图片完全由 WebGL 画。
|
||||
> 4. 加载门:模块级 loadingBus,REQUIRED=["model:hello.gltf","model:cursor.glb","stickers","img:about"],mark() 计数,LoadingOverlay 显示 0→100 进度,ready 后揭幕;揭幕同时才显示十字网格(原站 useHomeLoadingGate)。
|
||||
> 4. 加载门:模块级 loadingBus,REQUIRED=["model:hello.glb","model:cursor.glb","stickers","img:about"],mark() 计数,LoadingOverlay 显示 0→100 进度,ready 后揭幕;揭幕同时才显示十字网格(原站 useHomeLoadingGate)。
|
||||
> 5. 必须处理 R3F 首测竞态:挂载后 40 帧内持续比对 canvas.style 与父容器尺寸,mismatch 时 gl.setSize + setSize 重跑尺寸管线,否则 canvas 会卡在 1440×150。
|
||||
> 验证:截图后用 PIL 断言场景区域平均色 ≠ 页面底色(251,250,244)、canvas width/height 等于视口、离开首页后 canvas 数量为 0。
|
||||
|
||||
@@ -188,7 +188,7 @@ function seed() {
|
||||
about_p2: "我相信工程塑造可靠的产品,设计赋予它们灵魂;",
|
||||
about_p2_link_label: "我的作品",
|
||||
intro_prefix:
|
||||
"我是北极新一,一名横跨设计与工程的全栈开发者:Web 前端与后端、Flutter 客户端、AI 应用开发都有实践,也从产品设计一路做到工程落地。工作之外,我常在 ",
|
||||
"我是北极新一,一名横跨设计与工程的全栈开发者:Web 前端与后端、移动端、AI 应用开发都有实践,也从产品设计一路做到工程落地。工作之外,我常在 ",
|
||||
intro_suffix: " 上记录与分享这些探索。",
|
||||
intro_brand: "小红书",
|
||||
footer_headline: "让我们|创造|一些不凡的|数字作品",
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
const REQUIRED = [
|
||||
"model:hello.gltf",
|
||||
"model:hello.glb",
|
||||
"model:cursor.glb",
|
||||
"stickers",
|
||||
"img:about",
|
||||
|
||||
|
Before Width: | Height: | Size: 438 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 173 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 256 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 516 KiB After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 124 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 261 KiB After Width: | Height: | Size: 81 KiB |
|
Before Width: | Height: | Size: 287 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 59 KiB |
|
Before Width: | Height: | Size: 115 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 487 KiB After Width: | Height: | Size: 161 KiB |
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 94 KiB |
|
Before Width: | Height: | Size: 279 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 828 KiB After Width: | Height: | Size: 212 KiB |
|
Before Width: | Height: | Size: 248 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 80 KiB |
|
Before Width: | Height: | Size: 382 KiB After Width: | Height: | Size: 123 KiB |
|
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.6 KiB |
|
Before Width: | Height: | Size: 351 KiB After Width: | Height: | Size: 128 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 592 KiB After Width: | Height: | Size: 244 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 911 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 9.4 KiB |