diff --git a/docs/acceptance/2026-12-02-hero-scene/asset-farm-s2.png b/docs/acceptance/2026-12-02-hero-scene/asset-farm-s2.png new file mode 100644 index 00000000..16987dae Binary files /dev/null and b/docs/acceptance/2026-12-02-hero-scene/asset-farm-s2.png differ diff --git a/docs/acceptance/qa-tracker.md b/docs/acceptance/qa-tracker.md index 85be1fea..80e428f7 100644 --- a/docs/acceptance/qa-tracker.md +++ b/docs/acceptance/qa-tracker.md @@ -2328,3 +2328,13 @@ S1 首版镜头朝下看地板 ⇒ 改为朝走廊深处看,纵深才立起来 读数:最低 **5.04:1**(1440 副标 `/75`),角标 detail 5.14;海报帧重生成 **20KB**(真实机柜)。 性能:32 台 ≈ 383k 面 / 6 draw call;**headless 是 SwiftShader(1.6–2fps),不能作为产品结论**, 真机必须复测 —— 这是唯一未闭合项。 + +### 31.12 真机帧率 + 阵列换真机(2026-12-02 16:45) + +- **headless ≠ 产品性能**:SwiftShader 1.6–2fps 只是「在跑」。改 `headless:false`(真实 GPU)后: + S1 60fps/390,206 面/12 call、S2 60fps/726,476 面/17 call、S3 60fps/390,206 面/12 call。 +- 阵列换真实机柜:格点 8×15/0.95 → **6×10/1.15**(真机深 1.07m,0.95 会互相穿插); + 灰盒阵列 `visible=false`。 +- **TDZ 事故**:阵列实例化插在 `farm` 声明之前 ⇒ `tsc` 报 used before being assigned, + 而 dev server 仍按旧产物服务,帧率探针照样报「60fps/390,206」(旧读数)。 + ⇒ **type-check 红时任何运行时读数都不作数**,先让编译面干净再测。 diff --git a/docs/adr/0016-hero-full-bleed-3d-scene.md b/docs/adr/0016-hero-full-bleed-3d-scene.md index c4b967de..1c3ad3c2 100644 --- a/docs/adr/0016-hero-full-bleed-3d-scene.md +++ b/docs/adr/0016-hero-full-bleed-3d-scene.md @@ -435,3 +435,34 @@ InstancedMesh,只处理其一就会留下悬空的发光片。这类"半替换 这个数字不是产品结论。真机 GPU 上 383k 静态三角面属常规量级,但**必须在真实设备上复测**, 这也是本 ADR 唯一仍未闭合的性能项。 - 视觉基线未重采:flag 默认关,场景不参与默认路径(§4.3 的 mask 已就位)。 + +## 15. 真实 GPU 帧率与阵列接入(2026-12-02 16:45) + +### 15.1 为什么之前的「1.6fps」不是结论 + +`headless: true` 下 Chromium 走 **SwiftShader 软件光栅化**,383k 三角面会掉到 1.6–2 fps。 +这不是产品性能,只说明「在跑」。改用 **`headless: false`**(有头,走 Metal/真实 GPU)后: + +| 镜头 | 帧率 | 三角面 | draw call | +|---|---|---|---| +| S1 走廊 | **60.0** | 390,206 | 12 | +| S2 俯视阵列 | **60.0** | 726,476 | 17 | +| S3 柜排斜看 | **60.0** | 390,206 | 12 | + +(1440×900,Apple Silicon,垂直同步锁 60 ⇒ 「60」= 稳定 60,不代表无上限余量。) + +### 15.2 阵列也换成真实机柜 + +- 格点从 8×15 / 0.95 改为 **6×10 / 1.15**:真实机柜深 1.07m,0.95 的间距会让相邻柜体互相穿插 + (灰盒 0.7m 时看不出来,换真机后就穿模了)。 +- 灰盒阵列整组 `visible = false`(阵列是一整块网格,不像走廊要逐台替换)。 +- 代价:719k → 帧率仍是 60(上表)。 + +### 15.3 一个 TDZ 事故(记录,防复犯) + +阵列实例化代码被插在 `farm` / `farmRacks` 声明**之前**,`tsc` 报 +`used before being assigned`。当时 dev server 仍按上一份产物提供服务,帧率探针照样报 +「60fps / 390,206」—— 读数是旧的,看起来完全正常。 + +**教训**:type-check 红的时候,任何运行时读数都不作数;先让编译面干净,再测。 +这条与本仓已有的「假绿」家族同源(用旁观者的正常冒充被测对象的正常)。 diff --git a/src/components/home/hero-scene.tsx b/src/components/home/hero-scene.tsx index d3b6b2bd..79547f4a 100644 --- a/src/components/home/hero-scene.tsx +++ b/src/components/home/hero-scene.tsx @@ -301,6 +301,56 @@ export function HeroScene({ className }: { className?: string }) { } disposables.push(skirtGeo, skirtMat); + + /* ── S2 的舞台:另一个楼层的俯视阵列(y = -40) ── + 单独一层而非另建 scene:换 scene 要重建渲染器状态与光照,代价更大; + 两层之间相距 40m,加雾之后互不可见,等同隔离。 */ + const FARM_Y = -40; + const farm = new THREE.Group(); + farm.position.y = FARM_Y; + scene.add(farm); + + const farmFloorGeo = new THREE.PlaneGeometry(30, 30); + const farmFloor = new THREE.Mesh(farmFloorGeo, floorMat); + farmFloor.rotation.x = -Math.PI / 2; + farm.add(farmFloor); + disposables.push(farmFloorGeo); + + const COL = 6; + const ROW = 10; + // 真实机柜深 1.07m,间距 0.95 会让相邻柜体互相穿插(灰盒 0.7 时看不出来) + const GAP = 1.15; + const FARM_RACK = 0.7; + // 俯视阵列单独用一档更亮的材质:与地面同色时,从 12m 高空看下去只剩一片黑, + // 「阵列」这个构图就没了(首轮实测)。这一档亮度只在 S2 里被看到,不影响 S1/S3。 + const farmRackMat = new THREE.MeshStandardMaterial({ color: 0x2b333d, roughness: 0.55, metalness: 0.3 }); + disposables.push(farmRackMat); + const farmRacks = new THREE.InstancedMesh(rackGeo, farmRackMat, COL * ROW); + let fi = 0; + for (let c = 0; c < COL; c += 1) { + for (let r = 0; r < ROW; r += 1) { + const x = (c - (COL - 1) / 2) * GAP; + const z = -8 - r * GAP; + m4.makeTranslation(x, RACK_H / 2, z); + // 用统一缩放把柜体收窄一点,让俯视时列与列之间留出通道 + m4.scale(new THREE.Vector3(FARM_RACK, 1, FARM_RACK)); + farmRacks.setMatrixAt(fi, m4); + fi += 1; + } + } + farmRacks.instanceMatrix.needsUpdate = true; + farm.add(farmRacks); + + /* 通道灯带:俯视构图里唯一的高光线,把「矩阵」切成一条条通道 */ + const aisleGeo = new THREE.BoxGeometry(0.05, 0.02, ROW * GAP + 0.6); + const aisleMat = new THREE.MeshBasicMaterial({ color: 0x2a4c6e, toneMapped: false }); + for (let c = 0; c <= COL; c += 1) { + const aisle = new THREE.Mesh(aisleGeo, aisleMat); + aisle.position.set((c - COL / 2) * GAP, 0.03, -8 - ((ROW - 1) * GAP) / 2); + farm.add(aisle); + } + disposables.push(aisleGeo, aisleMat); + /* ── 真实资产:把近景灰盒换成 CC0 机柜 ── 三个刻意的取舍: ① **灰盒先跑,模型后到**:GLB 是异步的,先让画面立起来,到位后再无缝替换近景; @@ -410,61 +460,31 @@ export function HeroScene({ className }: { className?: string }) { racks.instanceMatrix.needsUpdate = true; leds.instanceMatrix.needsUpdate = true; + // 俯视阵列同样换成真实机柜:60 台 × 11,982 面 ≈ 719k 三角面, + // 实测真机仍稳 60fps(见 ADR §15)。阵列在另一个楼层,与走廊不同时入画的。 + const farmCount = COL * ROW; + for (const part of parts) { + const inst = new THREE.InstancedMesh(part.geometry, part.material, farmCount); + let n = 0; + for (let c = 0; c < COL; c += 1) { + for (let r = 0; r < ROW; r += 1) { + m4.makeTranslation((c - (COL - 1) / 2) * GAP, 0, -8 - r * GAP); + inst.setMatrixAt(n, m4); + n += 1; + } + } + inst.instanceMatrix.needsUpdate = true; + farm.add(inst); + } + // 灰盒阵列整组让位(阵列是一整块网格,不像走廊要逐台替换) + farmRacks.visible = false; + host.dataset.asset = 'grab3d-rack-cc0'; renderer.render(scene, camera); } catch { host.dataset.asset = 'graybox'; } })(); - - /* ── S2 的舞台:另一个楼层的俯视阵列(y = -40) ── - 单独一层而非另建 scene:换 scene 要重建渲染器状态与光照,代价更大; - 两层之间相距 40m,加雾之后互不可见,等同隔离。 */ - const FARM_Y = -40; - const farm = new THREE.Group(); - farm.position.y = FARM_Y; - scene.add(farm); - - const farmFloorGeo = new THREE.PlaneGeometry(30, 30); - const farmFloor = new THREE.Mesh(farmFloorGeo, floorMat); - farmFloor.rotation.x = -Math.PI / 2; - farm.add(farmFloor); - disposables.push(farmFloorGeo); - - const COL = 8; - const ROW = 15; - const GAP = 0.95; - const FARM_RACK = 0.7; - // 俯视阵列单独用一档更亮的材质:与地面同色时,从 12m 高空看下去只剩一片黑, - // 「阵列」这个构图就没了(首轮实测)。这一档亮度只在 S2 里被看到,不影响 S1/S3。 - const farmRackMat = new THREE.MeshStandardMaterial({ color: 0x2b333d, roughness: 0.55, metalness: 0.3 }); - disposables.push(farmRackMat); - const farmRacks = new THREE.InstancedMesh(rackGeo, farmRackMat, COL * ROW); - let fi = 0; - for (let c = 0; c < COL; c += 1) { - for (let r = 0; r < ROW; r += 1) { - const x = (c - (COL - 1) / 2) * GAP; - const z = -8 - r * GAP; - m4.makeTranslation(x, RACK_H / 2, z); - // 用统一缩放把柜体收窄一点,让俯视时列与列之间留出通道 - m4.scale(new THREE.Vector3(FARM_RACK, 1, FARM_RACK)); - farmRacks.setMatrixAt(fi, m4); - fi += 1; - } - } - farmRacks.instanceMatrix.needsUpdate = true; - farm.add(farmRacks); - - /* 通道灯带:俯视构图里唯一的高光线,把「矩阵」切成一条条通道 */ - const aisleGeo = new THREE.BoxGeometry(0.05, 0.02, ROW * GAP + 0.6); - const aisleMat = new THREE.MeshBasicMaterial({ color: 0x2a4c6e, toneMapped: false }); - for (let c = 0; c <= COL; c += 1) { - const aisle = new THREE.Mesh(aisleGeo, aisleMat); - aisle.position.set((c - COL / 2) * GAP, 0.03, -8 - ((ROW - 1) * GAP) / 2); - farm.add(aisle); - } - disposables.push(aisleGeo, aisleMat); - /* ── 光 ── S1 沿用沿走廊五点光;S2 在阵列上方补一盏,否则俯视只剩灯带、柜体全黑。 色温:0xdce4ee(中性偏暖)——站点底色是暖黑 #0B0A08,纯冷蓝场景读作「贴上去的一层」;