perf: 玻璃模型 3.18MB→1.53MB / 1.44MB→0.75MB — gltf→glb+KHR 顶点量化
gltf-transform dedup/prune/weld/quantize/sparse,几何未简化(simplify 会伤玻璃折射精度)。KHR_mesh_quantization 为 GLTFLoader 原生支持,无需 Draco/Meshopt 解码器;base64 内嵌 buffer 转 glb 二进制直接省 33% 开销。同步更新 GlassModels URL 与 loadingBus REQUIRED key。
This commit is contained in:
@@ -762,7 +762,7 @@ function GlassModel({
|
|||||||
export function HelloModel({ isMobile = false }: { isMobile?: boolean }) {
|
export function HelloModel({ isMobile = false }: { isMobile?: boolean }) {
|
||||||
return (
|
return (
|
||||||
<GlassModel
|
<GlassModel
|
||||||
url="/model/hello.gltf"
|
url="/model/hello.glb"
|
||||||
position={[-0.1, 0, 2]}
|
position={[-0.1, 0, 2]}
|
||||||
beforeRotation={[0, 240, 0]}
|
beforeRotation={[0, 240, 0]}
|
||||||
afterRotation={[0, 90, 0]}
|
afterRotation={[0, 90, 0]}
|
||||||
@@ -805,7 +805,7 @@ export function CursorStar({ isMobile = false }: { isMobile?: boolean }) {
|
|||||||
export function FooterModel() {
|
export function FooterModel() {
|
||||||
return (
|
return (
|
||||||
<GlassModel
|
<GlassModel
|
||||||
url="/model/cnt.gltf"
|
url="/model/cnt.glb"
|
||||||
position={[0, 0, 0]}
|
position={[0, 0, 0]}
|
||||||
beforeRotation={[-180, 0, 0]}
|
beforeRotation={[-180, 0, 0]}
|
||||||
rotation={[0, 0, 0]}
|
rotation={[0, 0, 0]}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|---|---|
|
|---|---|
|
||||||
| `CanvasSizeGuard` | 修复 R3F 首测竞态(见 §7 坑) |
|
| `CanvasSizeGuard` | 修复 R3F 首测竞态(见 §7 坑) |
|
||||||
| `BackgroundFX` | 背景微噪点/渐变平面 |
|
| `BackgroundFX` | 背景微噪点/渐变平面 |
|
||||||
| `GlassModels` | hello.gltf 玻璃字 + cursor.glb 星标 + footer 模型,随 `scrollBus.sP` 分段入场 |
|
| `GlassModels` | hello.glb 玻璃字 + cursor.glb 星标 + footer 模型,随 `scrollBus.sP` 分段入场 |
|
||||||
| `ImageLayers` | 把 DOM 注册表里的图片投影成 3D 平面(作品图 + about 头像) |
|
| `ImageLayers` | 把 DOM 注册表里的图片投影成 3D 平面(作品图 + about 头像) |
|
||||||
| `StickerDrop` | 贴纸雨(sticker_img 图集),滚动触发掉落 |
|
| `StickerDrop` | 贴纸雨(sticker_img 图集),滚动触发掉落 |
|
||||||
| `HyperspaceModel` | hyper-space 区块的隧道箭头(cursor.glb 条纹拉伸) |
|
| `HyperspaceModel` | hyper-space 区块的隧道箭头(cursor.glb 条纹拉伸) |
|
||||||
@@ -51,7 +51,7 @@ const defs = new Map<string, ImageLayerDef>([
|
|||||||
## 6. 加载门(lib/loadingBus.ts + LoadingOverlay)
|
## 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 = 全齐
|
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)。请实现:
|
> 我在克隆 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 之后)。
|
> 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 画。
|
> 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。
|
> 5. 必须处理 R3F 首测竞态:挂载后 40 帧内持续比对 canvas.style 与父容器尺寸,mismatch 时 gl.setSize + setSize 重跑尺寸管线,否则 canvas 会卡在 1440×150。
|
||||||
> 验证:截图后用 PIL 断言场景区域平均色 ≠ 页面底色(251,250,244)、canvas width/height 等于视口、离开首页后 canvas 数量为 0。
|
> 验证:截图后用 PIL 断言场景区域平均色 ≠ 页面底色(251,250,244)、canvas width/height 等于视口、离开首页后 canvas 数量为 0。
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const REQUIRED = [
|
const REQUIRED = [
|
||||||
"model:hello.gltf",
|
"model:hello.glb",
|
||||||
"model:cursor.glb",
|
"model:cursor.glb",
|
||||||
"stickers",
|
"stickers",
|
||||||
"img:about",
|
"img:about",
|
||||||
|
|||||||
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user