清理 CAMERA_POSES 里无效的 globe 相机配置

This commit is contained in:
2026-09-19 13:25:54 +08:00
parent 83de329750
commit b33ffd3b2d
+13 -11
View File
@@ -7,12 +7,14 @@ import { CesiumGlobe } from '../scene/CesiumGlobe.js';
import { Overlay } from '../ui/overlay.js'; import { Overlay } from '../ui/overlay.js';
import { clamp, easeInOutCubic } from '../utils/easing.js'; import { clamp, easeInOutCubic } from '../utils/easing.js';
// Three.js 相机的初始位(仅活页本/时间轴;地理视图用 Cesium 自己的相机)
const CAMERA_POSES = { const CAMERA_POSES = {
binder: { pos: new THREE.Vector3(0.2, 0.75, 2.95), target: new THREE.Vector3(0, 0.02, 0), max: 4.4, min: 2.4 }, binder: { pos: new THREE.Vector3(0.2, 0.75, 2.95), target: new THREE.Vector3(0, 0.02, 0), max: 4.4, min: 2.4 },
timeline: { pos: new THREE.Vector3(0, 1.4, 6.86), target: new THREE.Vector3(0, 0, 0), max: 8, min: 1.2 }, timeline: { pos: new THREE.Vector3(0, 1.4, 6.86), target: new THREE.Vector3(0, 0, 0), max: 8, min: 1.2 },
globe: { pos: new THREE.Vector3(0, 0.35, 3.7), target: new THREE.Vector3(0, 0, 0), max: 8, min: 2.2 },
}; };
const VIEWS = ['binder', 'timeline', 'globe'];
export class App { export class App {
constructor() { constructor() {
this.view = 'binder'; this.view = 'binder';
@@ -367,7 +369,7 @@ export class App {
} }
switchView(view) { switchView(view) {
if (view === this.view || !CAMERA_POSES[view]) return; if (view === this.view || !VIEWS.includes(view)) return;
// 地理视图尚未就绪(按钮仍置灰)时忽略切换,键盘也无法绕过 // 地理视图尚未就绪(按钮仍置灰)时忽略切换,键盘也无法绕过
if (view === 'globe' && !this.globe.viewer) return; if (view === 'globe' && !this.globe.viewer) return;
// 离开当前视图前,记住它的相机位置 // 离开当前视图前,记住它的相机位置
@@ -417,6 +419,7 @@ export class App {
// 登记卡详情在视图切换时保持显示,不隐藏 // 登记卡详情在视图切换时保持显示,不隐藏
document.getElementById('detail-card').classList.remove('hidden'); document.getElementById('detail-card').classList.remove('hidden');
if (!isGlobe) {
const pose = CAMERA_POSES[view]; const pose = CAMERA_POSES[view];
this.controls.minDistance = pose.min; this.controls.minDistance = pose.min;
this.controls.maxDistance = pose.max; this.controls.maxDistance = pose.max;
@@ -430,15 +433,6 @@ export class App {
// 左键旋转限制:以各视图初始视角为中心,各方向 ±10° // 左键旋转限制:以各视图初始视角为中心,各方向 ±10°
this._applyRotationLimits(pose); this._applyRotationLimits(pose);
// 进入时间轴时:自动定位到当前选中的活页居中
if (view === 'timeline') {
const limit = TIMELINE_SPREAD + 0.6;
this.timelineOffset = clamp(-this.timeline.getCardX(this.selected), -limit, limit);
this.timeline.group.position.x = this.timelineOffset;
this.timeline.refreshTextures();
}
if (!isGlobe) {
// 切换视图:直接定位(有记忆则恢复上次的相机位置) // 切换视图:直接定位(有记忆则恢复上次的相机位置)
this.cameraTween = null; this.cameraTween = null;
this.zoomTarget = null; this.zoomTarget = null;
@@ -451,6 +445,14 @@ export class App {
this.controls.target.copy(pose.target); this.controls.target.copy(pose.target);
} }
} }
// 进入时间轴时:自动定位到当前选中的活页居中
if (view === 'timeline') {
const limit = TIMELINE_SPREAD + 0.6;
this.timelineOffset = clamp(-this.timeline.getCardX(this.selected), -limit, limit);
this.timeline.group.position.x = this.timelineOffset;
this.timeline.refreshTextures();
}
this._needsRender = true; this._needsRender = true;
} }