|
@@ -48,22 +48,33 @@ export default class RotationEvent {
|
|
|
const canvasHeight = this._room.options.canvas.offsetHeight
|
|
|
const canvasWidth = this._room.options.canvas.offsetWidth
|
|
|
|
|
|
+
|
|
|
+ // 旋转中
|
|
|
+ if(this.rotating) return
|
|
|
+
|
|
|
+
|
|
|
// offset累计
|
|
|
if(!this.offset) this.offset = 0
|
|
|
this.offset += offsetX
|
|
|
|
|
|
// 累计超过6度
|
|
|
- let angle = Math.round(this.offset / (canvasWidth*10) * 2 * Math.PI / (Math.PI/30)) * (Math.PI/30)
|
|
|
+ let angle = this.offset / (canvasWidth*2) * (2*Math.PI)
|
|
|
+ angle = Math.round(angle / (Math.PI/30)) * (Math.PI/30)
|
|
|
if(Math.abs(angle) < Math.PI/30) return
|
|
|
|
|
|
- // 开始旋转
|
|
|
- this._room.actionsHandler.rotate({
|
|
|
- type: 'rotate',
|
|
|
- angle: angle
|
|
|
- });
|
|
|
+ this.rotating = true
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ // 开始旋转
|
|
|
+ this._room.actionsHandler.rotate({
|
|
|
+ type: 'rotate',
|
|
|
+ angle: Math.PI/30 * Math.sign(angle) // angle
|
|
|
+ });
|
|
|
|
|
|
- // 重置累计
|
|
|
- this.offset = 0
|
|
|
+ // 重置累计
|
|
|
+ this.offset = 0
|
|
|
+ this.rotating = false
|
|
|
+ }, 1000/32)
|
|
|
|
|
|
this.touchStartX = pageX;
|
|
|
this.touchStartY = pageY;
|