|
@@ -39,9 +39,14 @@ class ExtendView extends View {
|
|
return rotation
|
|
return rotation
|
|
}
|
|
}
|
|
|
|
|
|
- set rotation(rotation){//这个在数字很小(垂直向上看)的时候水平旋转精度可能损失,导致突变到另一个角度去了,用 set quaternion比较好
|
|
|
|
- //因为 rotation的y不一定是0 , 所以不能直接逆着写。
|
|
|
|
- this.direction = new THREE.Vector3(0,0,-1).applyEuler(rotation)
|
|
|
|
|
|
+ set rotation(rotation){
|
|
|
|
+ if(rotation.y != 0){//因为 rotation的y不一定是0 , 所以不能直接逆着get rotation写。
|
|
|
|
+ //console.error('set rotation y不为0!!!!?', rotation ) //过渡时因为quaternion lerp所以不为0。没办法了orz
|
|
|
|
+ this.direction = new THREE.Vector3(0,0,-1).applyEuler(rotation) //转回direction有损耗,在俯视时的(dir.x==dir.y==0), 丢失yaw信息从而 yaw无法获取(希望不要遇到这种情况,如果有的话,考虑先计算yaw,似乎好像可以算)
|
|
|
|
+ }else{//尽量不用direction
|
|
|
|
+ this.pitch = rotation.x - Math.PI / 2
|
|
|
|
+ this.yaw = rotation.z
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -49,8 +54,8 @@ class ExtendView extends View {
|
|
return new THREE.Quaternion().setFromEuler(this.rotation)
|
|
return new THREE.Quaternion().setFromEuler(this.rotation)
|
|
}
|
|
}
|
|
|
|
|
|
- set quaternion(q){
|
|
|
|
- this.direction = new THREE.Vector3(0,0,-1).applyQuaternion(q) //注意如果得到的dir.x==dir.y==0, yaw不会变为0, 导致算的quaternion和q不一致
|
|
|
|
|
|
+ set quaternion(q){
|
|
|
|
+ this.rotation = new THREE.Euler().setFromQuaternion(q)
|
|
}
|
|
}
|
|
|
|
|
|
copy(a){
|
|
copy(a){
|