性能优化:精简便签每帧计算、地理视图跳过 Three.js 每帧逻辑

This commit is contained in:
2026-09-19 14:02:47 +08:00
parent 37b7923849
commit b94abe32fa
2 changed files with 27 additions and 13 deletions
+15 -2
View File
@@ -252,8 +252,11 @@ export class App {
window.addEventListener('resize', () => this._onResize());
window.addEventListener('keydown', (e) => {
if (e.key === 'ArrowRight') this._step(1);
else if (e.key === 'ArrowLeft') this._step(-1);
if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
const dir = e.key === 'ArrowRight' ? 1 : -1;
if (this.view === 'timeline') this._stepTimeline(dir);
else this._step(dir);
}
else if (e.key === '1') this.switchView('binder');
else if (e.key === '2') this.switchView('timeline');
else if (e.key === '3') this.switchView('globe');
@@ -357,6 +360,15 @@ export class App {
else this.binder.flipBackward();
}
// 时间轴:左右键选择上一张/下一张,动画与点击一致(居中 + 翻面)
_stepTimeline(dir) {
const next = clamp(this.selected + dir, 0, ENTRIES.length - 1);
if (next === this.selected) return;
this._select(next, { syncBinder: true });
this._centerTimeline(next);
this.timeline.flip(next);
}
_select(index, { syncBinder = false } = {}) {
this.selected = clamp(index, 0, ENTRIES.length - 1);
const entry = ENTRIES[this.selected];
@@ -492,6 +504,7 @@ export class App {
_animate() {
requestAnimationFrame(this._animate);
if (this.view === 'globe') return; // 地理视图由 Cesium 渲染,跳过 Three.js 每帧逻辑
const dt = Math.min(this.clock.getDelta(), 0.05);
// 是否有进行中的动画(决定本帧是否需要重绘)