|
@@ -48,8 +48,8 @@ export default class RotationEvent {
|
|
const canvasHeight = this._room.options.canvas.offsetHeight
|
|
const canvasHeight = this._room.options.canvas.offsetHeight
|
|
const canvasWidth = this._room.options.canvas.offsetWidth
|
|
const canvasWidth = this._room.options.canvas.offsetWidth
|
|
|
|
|
|
-
|
|
|
|
- // 旋转中
|
|
|
|
|
|
+ if(window.initFinished){
|
|
|
|
+ // 旋转中
|
|
if(this.rotating) return
|
|
if(this.rotating) return
|
|
|
|
|
|
|
|
|
|
@@ -75,6 +75,8 @@ export default class RotationEvent {
|
|
this.offset = 0
|
|
this.offset = 0
|
|
this.rotating = false
|
|
this.rotating = false
|
|
}, 1000/32)
|
|
}, 1000/32)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
this.touchStartX = pageX;
|
|
this.touchStartX = pageX;
|
|
this.touchStartY = pageY;
|
|
this.touchStartY = pageY;
|
|
@@ -99,25 +101,53 @@ export default class RotationEvent {
|
|
const pageY = t.pageY
|
|
const pageY = t.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 pitch = 2 * offsetY / offsetHeight;
|
|
|
|
- let yaw = 2 * offsetX / offsetWidth;
|
|
|
|
|
|
+ let pitch = 2 * offsetY / canvasHeight;
|
|
|
|
+ let yaw = 2 * offsetX / canvasWidth;
|
|
|
|
|
|
pitch > 1 && (pitch = 1);
|
|
pitch > 1 && (pitch = 1);
|
|
yaw > 1 && (yaw = 1);
|
|
yaw > 1 && (yaw = 1);
|
|
/***********************************************************************xst****************************************************************/
|
|
/***********************************************************************xst****************************************************************/
|
|
- // this._room.actionsHandler.rotate({
|
|
|
|
- // pitch: pitch,
|
|
|
|
- // yaw: yaw
|
|
|
|
- // });
|
|
|
|
-
|
|
|
|
- let angle = offsetX / offsetWidth * 2 * Math.PI
|
|
|
|
- this._room.actionsHandler.rotate({
|
|
|
|
- type: 'rotate',
|
|
|
|
- angle: angle
|
|
|
|
- });
|
|
|
|
|
|
+
|
|
|
|
+ // if(window.initFinished){
|
|
|
|
+ // let angle = offsetX / offsetWidth * 2 * Math.PI
|
|
|
|
+ // this._room.actionsHandler.rotate({
|
|
|
|
+ // type: 'rotate',
|
|
|
|
+ // angle: angle
|
|
|
|
+ // });
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ if(window.initFinished){
|
|
|
|
+ // 旋转中
|
|
|
|
+ if(this.rotating) return
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // offset累计
|
|
|
|
+ if(!this.offset) this.offset = 0
|
|
|
|
+ this.offset += offsetX
|
|
|
|
+
|
|
|
|
+ // 累计超过6度
|
|
|
|
+ let angle = this.offset / (canvasWidth*10) * (2*Math.PI)
|
|
|
|
+ angle = Math.round(angle / (Math.PI/30)) * (Math.PI/30)
|
|
|
|
+ if(Math.abs(angle) < Math.PI/30) return
|
|
|
|
+
|
|
|
|
+ this.rotating = true
|
|
|
|
+
|
|
|
|
+ setTimeout(() => {
|
|
|
|
+ // 开始旋转
|
|
|
|
+ this._room.actionsHandler.rotate({
|
|
|
|
+ type: 'rotate',
|
|
|
|
+ angle: Math.PI/30 * Math.sign(angle) // angle
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 重置累计
|
|
|
|
+ this.offset = 0
|
|
|
|
+ this.rotating = false
|
|
|
|
+ }, 1000/32)
|
|
|
|
+ }
|
|
|
|
+
|
|
/********************************************************************************************************************************************/
|
|
/********************************************************************************************************************************************/
|
|
|
|
|
|
this.touchStartX = pageX;
|
|
this.touchStartX = pageX;
|