From ea45b7fbc50ef72f456105e8764cc163f9a86b35 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 11 Jan 2026 11:26:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=203D=20=E7=9B=B8?= =?UTF-8?q?=E6=9C=BA=E8=A7=86=E5=9C=BA=E8=A7=92=E5=92=8C=20Resize=20?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E9=98=B2=E6=AD=A2=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/qwen-camera-widget.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/components/qwen-camera-widget.tsx b/components/qwen-camera-widget.tsx index 72fd1bd..ec5a889 100644 --- a/components/qwen-camera-widget.tsx +++ b/components/qwen-camera-widget.tsx @@ -178,8 +178,8 @@ export function QwenCameraWidget({ sceneRef.current = scene; // 相机 - const camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 1000); - camera.position.set(4, 3.5, 4); + const camera = new THREE.PerspectiveCamera(50, width / height, 0.1, 1000); + camera.position.set(4.5, 4, 4.5); camera.lookAt(0, 0.3, 0); cameraRef.current = camera; @@ -330,11 +330,26 @@ export function QwenCameraWidget({ }; animate(); + // 监听容器大小变化 + const resizeObserver = new ResizeObserver((entries) => { + for (const entry of entries) { + const { width, height } = entry.contentRect; + if (width && height && cameraRef.current && rendererRef.current) { + cameraRef.current.aspect = width / height; + cameraRef.current.updateProjectionMatrix(); + rendererRef.current.setSize(width, height); + } + } + }); + + resizeObserver.observe(container); + // 清理 return () => { if (animationIdRef.current) { cancelAnimationFrame(animationIdRef.current); } + resizeObserver.disconnect(); renderer.dispose(); scene.clear(); };