|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|