xzw 2 năm trước cách đây
mục cha
commit
f7048e9ba3
1 tập tin đã thay đổi với 10 bổ sung4 xóa
  1. 10 4
      src/viewer/ExtendView.js

+ 10 - 4
src/viewer/ExtendView.js

@@ -217,15 +217,21 @@ class ExtendView extends View {
         let endPosition = new THREE.Vector3().copy(info.position)
         let startPosition = this.position.clone();
 		let startQuaternion, endQuaternion, endTarget = null,  
-            endYaw = info.endYaw, startYaw, endPitch = info.endPitch,  startPitch ;
+            endYaw, startYaw, endPitch, startPitch ;
         
         
         this.restrictPos(endPosition)
          
          
-        if(endYaw != void 0) {
-            startYaw = this.yaw  
-            startPitch = this.pitch  
+        if(info.endYaw != void 0) { 
+            startPitch = this.pitch
+            endPitch = info.endPitch;
+            startYaw = this.yaw
+            endYaw = info.endYaw 
+            if(Math.abs(startYaw - endYaw)>Math.PI){//如果差距大于半个圆,就要反个方向转(把大的那个数字减去360度)
+                startYaw > endYaw ? (startYaw -= Math.PI*2) : (endYaw -= Math.PI*2) 
+            }
+            
 		}else if(info.target ){
 			endTarget = new THREE.Vector3().copy(info.target)  
             endQuaternion = math.getQuaFromPosAim(endPosition,endTarget) //若为垂直,会自动偏向x负的方向