[]3D模型旋转问题,鼠标移动之后,根据按下移动的X坐标差值判断左右旋转,但是会越转越快,请问是什么问题?
private mouseMove(state: Laya.RenderState):void{
// console.log(mX + "移动");
// console.log(this.lastMouseX + "按下");
let mX:number = Laya.stage.mouseX;
let mY:number = Laya.stage.mouseY;
let vec:Laya.Vector3 ;
if(this.isDown){
if(this.lastMouseX - mX > 0)
{
vec = new Laya.Vector3(0,-1,0);
}
else
{
vec = new Laya.Vector3(0,1,0);
}
this.rotate(vec);
}
}
监听的鼠标移动事件
Laya.stage.on(Laya.Event.MOUSE_UP,this,this.mouseUp);
Laya.stage.on(Laya.Event.MOUSE_DOWN,this,this.mouseDown);
Laya.stage.on(Laya.Event.MOUSE_MOVE,this,this.mouseMove);
private mouseDown():void{
let mX:number = Laya.stage.mouseX;
this.lastMouseX = mX;
this.isDown = true;
}
private mouseUp():void{
this.isDown = false;
}
public rotate(vec:Laya.Vector3):void{
this.entity.transform.rotate(vec,true,false);
}
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
Aar0n
赞同来自:
君昊
赞同来自: