From e3de8485f2aee693a91de95256f318b146acda15 Mon Sep 17 00:00:00 2001 From: KQL Date: Thu, 4 Dec 2025 18:35:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D3D=E5=86=85=E6=8E=A8?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0UI=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84=E4=B8=A5=E9=87=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根本原因: - 在 init3DScene() 中错误地设置了父元素 uiLayer.style.opacity = '0' - 导致即使GSAP动画将子元素opacity设为1,整个UI层仍然透明 - CSS规则:父元素透明会导致所有子元素都不可见 修复方案: 1. 删除 js/main.js 中错误的 opacity 设置 2. 改用 GSAP 的 fromTo() 明确控制动画起始和结束状态 3. 不再依赖CSS或内联样式的不确定状态 修复效果: ✅ 第一次进入:文字正常淡入显示 ✅ 点击地球:正常转场到中国地图 ✅ 第二次进入:文字仍能正常淡入显示 ✅ 多次进出都能正常工作 🤖 Generated with Claude Code --- js/main.js | 5 ++--- js/scene/SceneManager.js | 42 ++++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/js/main.js b/js/main.js index 66a835d..547f98d 100644 --- a/js/main.js +++ b/js/main.js @@ -123,11 +123,10 @@ class App { this.mapInterface.style.display = 'none'; this.mapInterface.style.opacity = '0'; - // 重置UI层和提示文字的状态(确保第二次进入时能正常显示) - this.uiLayer.style.opacity = '0'; + // 重置UI层和提示文字的状态 this.uiLayer.style.display = 'flex'; - this.hint.style.opacity = '0'; this.hint.style.display = 'block'; + // 不设置 opacity,让GSAP的 fromTo() 控制 // 创建场景管理器 this.sceneManager = new SceneManager( diff --git a/js/scene/SceneManager.js b/js/scene/SceneManager.js index 26ef813..1f14d8e 100644 --- a/js/scene/SceneManager.js +++ b/js/scene/SceneManager.js @@ -111,23 +111,35 @@ export class SceneManager { }); // B. UI 淡入 (标题和提示依次出现) - tl.to('.v1-title', { - opacity: 1, - duration: 1.5, - ease: "power2.out" - }, `-=${animConfig.titleDelay}`); + tl.fromTo('.v1-title', + { opacity: 0 }, + { + opacity: 1, + duration: 1.5, + ease: "power2.out" + }, + `-=${animConfig.titleDelay}` + ); - tl.to('.v1-subtitle', { - opacity: 1, - duration: 1.2, - ease: "power2.out" - }, `-=${animConfig.subtitleDelay}`); + tl.fromTo('.v1-subtitle', + { opacity: 0 }, + { + opacity: 1, + duration: 1.2, + ease: "power2.out" + }, + `-=${animConfig.subtitleDelay}` + ); - tl.to('.instruction-hint', { - opacity: 1, - duration: 1.0, - ease: "power2.out" - }, `-=${animConfig.hintDelay}`); + tl.fromTo('.instruction-hint', + { opacity: 0 }, + { + opacity: 1, + duration: 1.0, + ease: "power2.out" + }, + `-=${animConfig.hintDelay}` + ); } // 初始化转场系统