|
@@ -125,6 +125,10 @@ export class LevelAction extends Component {
|
|
|
easing: 'smooth',
|
|
|
onUpdate: (target: Vec3) => {
|
|
|
this.camera.node.position = target;
|
|
|
+ // 根据距离动态调整旋转限制范围
|
|
|
+ const zoomFactor = Math.abs(distance) / 30;
|
|
|
+ this.minYRotation = -70 * zoomFactor;
|
|
|
+ this.maxYRotation = 70 * zoomFactor;
|
|
|
}
|
|
|
})
|
|
|
.start();
|
|
@@ -135,6 +139,7 @@ export class LevelAction extends Component {
|
|
|
const touchPos = event.getLocation();
|
|
|
this._touchStartPos = v3(touchPos.x, touchPos.y, 0);
|
|
|
this._isDragging = true;
|
|
|
+ // 记录初始旋转角度
|
|
|
this._originalRotation = this.camera.node.eulerAngles.clone();
|
|
|
}
|
|
|
|
|
@@ -145,10 +150,18 @@ export class LevelAction extends Component {
|
|
|
const deltaX = currentPos.x - this._touchStartPos.x;
|
|
|
const deltaY = currentPos.y - this._touchStartPos.y;
|
|
|
|
|
|
- // 计算新的旋转角度
|
|
|
- const newRotation = this._originalRotation.clone();
|
|
|
- newRotation.y = this._originalRotation.y - deltaX * 0.2; // 左右滑动控制Y轴旋转
|
|
|
- newRotation.x = this._originalRotation.x + deltaY * 0.2; // 上下滑动控制X轴旋转
|
|
|
+ // 根据当前相机距离调整旋转灵敏度
|
|
|
+ const distanceFactor = Math.max(0.5, this.camera.node.position.length() / 30);
|
|
|
+ const sensitivity = 0.1 * distanceFactor;
|
|
|
+
|
|
|
+ const rotationDelta = v3(
|
|
|
+ deltaY * sensitivity,
|
|
|
+ -deltaX * sensitivity,
|
|
|
+ 0
|
|
|
+ );
|
|
|
+
|
|
|
+ // 计算新旋转角度
|
|
|
+ const newRotation = this._originalRotation.clone().add(rotationDelta);
|
|
|
|
|
|
// 添加旋转限制
|
|
|
newRotation.x = Math.max(this.minXRotation, Math.min(this.maxXRotation, newRotation.x));
|