|
@@ -45,23 +45,26 @@ export default class RotationEvent {
|
|
const pageY = e.pageY
|
|
const pageY = e.pageY
|
|
const offsetX = pageX - this.touchStartX
|
|
const offsetX = pageX - this.touchStartX
|
|
const offsetY = pageY - this.touchStartY
|
|
const offsetY = pageY - this.touchStartY
|
|
- const offsetHeight = this._room.options.canvas.offsetHeight
|
|
|
|
- const offsetWidth = this._room.options.canvas.offsetWidth
|
|
|
|
|
|
+ const canvasHeight = this._room.options.canvas.offsetHeight
|
|
|
|
+ const canvasWidth = this._room.options.canvas.offsetWidth
|
|
|
|
|
|
- let angle = offsetX / offsetWidth * 2 * Math.PI
|
|
|
|
- // this._room.actionsHandler.rotate({
|
|
|
|
- // type: 'rotate',
|
|
|
|
- // // angle: angle
|
|
|
|
- // pitch: 0,
|
|
|
|
- // yaw: angle
|
|
|
|
- // });
|
|
|
|
|
|
+ // offset累计
|
|
|
|
+ if(!this.offset) this.offset = 0
|
|
|
|
+ this.offset += offsetX
|
|
|
|
+
|
|
|
|
+ // 累计超过6度
|
|
|
|
+ let angle = Math.round(this.offset / canvasWidth * 2 * Math.PI / (Math.PI/30)) * (Math.PI/30)
|
|
|
|
+ if(angle < Math.PI/30) return
|
|
|
|
|
|
|
|
+ // 开始旋转
|
|
this._room.actionsHandler.rotate({
|
|
this._room.actionsHandler.rotate({
|
|
type: 'rotate',
|
|
type: 'rotate',
|
|
- offsetX: offsetX,
|
|
|
|
- width: this._room.options.canvas.offsetWidth
|
|
|
|
|
|
+ angle: angle
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // 重置累计
|
|
|
|
+ this.offset = 0
|
|
|
|
+
|
|
this.touchStartX = pageX;
|
|
this.touchStartX = pageX;
|
|
this.touchStartY = pageY;
|
|
this.touchStartY = pageY;
|
|
}
|
|
}
|