添加 左键移动旋转相机的选项.

pull/7/head
ChenX 7 years ago
parent 340be443f1
commit bfefd18001

@ -1,3 +1,4 @@
import { boolean } from 'mobx-state-tree/dist/types/primitives';
//相机控制
import * as THREE from 'three';
import { Viewer } from '../GraphicsSystem/Viewer';
@ -38,6 +39,8 @@ export class CameraControls
//状态
m_State: CameraControlState = CameraControlState.Null;
m_Viewer: Viewer;
//左键使用旋转
m_LeftUseRotate: boolean = false;
constructor(viewer: Viewer)
{
@ -138,7 +141,11 @@ export class CameraControls
this.m_StartChickPoint.copy(this.m_EndChickPoint);
this.m_Viewer.m_bNeedUpdate = true;
}
beginRotate()
{
this.m_State = CameraControlState.Rotate;
this.m_Viewer.UpdateLockTarget();
}
//鼠标
onMouseDown = (event: MouseEvent) =>
{
@ -151,14 +158,17 @@ export class CameraControls
{
case MouseKey.Left:
{
if (this.m_LeftUseRotate)
{
this.beginRotate();
}
break;
}
case MouseKey.Middle:
{
if (this.m_KeyDown.get("Alt"))
{
this.m_State = CameraControlState.Rotate;
this.m_Viewer.UpdateLockTarget();
this.beginRotate();
}
else
{
@ -187,7 +197,12 @@ export class CameraControls
changeVec.subVectors(this.m_EndChickPoint, this.m_StartChickPoint);
this.m_StartChickPoint.copy(this.m_EndChickPoint);
if (this.m_KeyDown.get("Alt") && this.m_State == CameraControlState.Rotate)
if (
(this.m_LeftUseRotate ||
(this.m_KeyDown.get("Alt"))
)
&& this.m_State == CameraControlState.Rotate
)
{
this.m_Viewer.Rotate(changeVec);
}

Loading…
Cancel
Save