From 903b79dd2b40d036ac46e5a928d54233ff64573c Mon Sep 17 00:00:00 2001 From: chenchun Date: Tue, 1 Sep 2026 16:37:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=8E=BB=E7=92=83=20mesh=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BB=85=20layer=2010=EF=BC=8C=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E6=8A=98=E5=B0=84=20FBO=20=E5=8F=8D=E9=A6=88=E7=8E=AF=EF=BC=88?= =?UTF-8?q?GL=5FINVALID=5FOPERATION=20=E6=AF=8F=E5=B8=A7=E5=88=B7=E5=B1=8F?= =?UTF-8?q?=E7=9A=84=E6=A0=B9=E6=BA=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 原 enable(10) 会叠加层,mesh 仍留在 layer 0,被 layer-0 mask 的 FBO 通道画进自己采样的折射纹理 → 反馈环 - 现在 FBO 通道的 layer-0 mask 能真正排除玻璃;主相机 enable(10) 保持可见 - 验证:全组件开启 gl.getError()=0(修复前恒 1282),next build / tsc 通过 --- components/canvas/GlassModels.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/canvas/GlassModels.tsx b/components/canvas/GlassModels.tsx index 217a570..d994961 100644 --- a/components/canvas/GlassModels.tsx +++ b/components/canvas/GlassModels.tsx @@ -404,11 +404,18 @@ function GlassModel({ return merged; }, [gltf]); - // Glass renders on layers 0+10: visible in the main pass, excluded from the - // layer-0-mask FBO pass that feeds the refraction texture (no self-refraction). + // Glass renders ONLY on layer 10: the FBO refraction pass forces the camera + // mask to layer 0, so the glass mesh is excluded from its own refraction + // texture (an object with layer 0 kept enabled would pass the mask test and + // draw into the FBO it samples — a GL feedback loop, GL_INVALID_OPERATION + // every frame). The main camera enables layer 10 below, so glass stays + // visible in the normal pass. Matches the original GlassSystem. useEffect(() => { - meshLayerRef.current?.layers.enable(10); - }, [mergedGeometry]); + const mesh = meshLayerRef.current; + if (!mesh) return; + mesh.layers.set(10); + camera.layers.enable(10); + }, [mergedGeometry, camera]); const tintYRange = useMemo<[number, number]>(() => { if (!mergedGeometry) return [0, 1];