fix: 彻底修复GSAP动画泄漏导致的自动转场问题
关键修复: - 在 SceneManager 中保存 animationFrameId 和 introTimeline 引用 - 在 Transition 中保存 timeline 引用 - dispose() 时彻底清理所有 GSAP 动画: * 停止 requestAnimationFrame 循环 * 杀掉开场动画 timeline * 杀掉转场动画 timeline * 杀掉所有针对相机、地球的补间动画 - 添加 Transition.dispose() 方法 - 防止旧动画回调触发导致意外转场 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ export class Transition {
|
||||
this.uiElements = uiElements; // { uiLayer, hint, speedLines, cloudFog }
|
||||
this.onComplete = onComplete;
|
||||
this.isTransitioning = false;
|
||||
this.timeline = null; // 保存 timeline 引用以便清理
|
||||
}
|
||||
|
||||
// 触发超空间跳跃转场
|
||||
@@ -29,14 +30,16 @@ export class Transition {
|
||||
const clouds = this.earthModel.getClouds();
|
||||
const atmosphere = this.earthModel.getAtmosphere();
|
||||
|
||||
// 创建GSAP时间线
|
||||
const tl = gsap.timeline({
|
||||
// 创建GSAP时间线(保存引用以便清理)
|
||||
this.timeline = gsap.timeline({
|
||||
onComplete: () => {
|
||||
this.isTransitioning = false;
|
||||
if (this.onComplete) this.onComplete();
|
||||
}
|
||||
});
|
||||
|
||||
const tl = this.timeline;
|
||||
|
||||
// 转场配置
|
||||
const warpConfig = CONFIG.warp;
|
||||
const transConfig = CONFIG.animation.transition;
|
||||
@@ -101,4 +104,13 @@ export class Transition {
|
||||
isActive() {
|
||||
return this.isTransitioning;
|
||||
}
|
||||
|
||||
// 清理转场动画
|
||||
dispose() {
|
||||
if (this.timeline) {
|
||||
this.timeline.kill();
|
||||
this.timeline = null;
|
||||
}
|
||||
this.isTransitioning = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user