|
@@ -1,8 +1,9 @@
|
|
|
import * as THREE from "../../public/static/lib/three.js/build/three.module.js";
|
|
|
import math from './math.js'
|
|
|
|
|
|
-export default class ConvertViews {
|
|
|
+export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
constructor() {
|
|
|
+ super()
|
|
|
this.sourceApp = null
|
|
|
this.targetApp = null
|
|
|
|
|
@@ -49,7 +50,7 @@ export default class ConvertViews {
|
|
|
|
|
|
this.lastCamStatus = info
|
|
|
|
|
|
- }) */
|
|
|
+ }) */
|
|
|
|
|
|
|
|
|
/* viewer.addEventListener(targetApp.Glodon.Bimface.Viewer.Viewer3DEvent.ViewAdded,
|
|
@@ -163,16 +164,19 @@ export default class ConvertViews {
|
|
|
position,
|
|
|
target,
|
|
|
up: new THREE.Vector3(0,0,1),
|
|
|
- //前三个缺一不可
|
|
|
-
|
|
|
- fov : data.fov
|
|
|
-
|
|
|
+ //前三个缺一不可
|
|
|
}
|
|
|
-
|
|
|
+ //fov 用setCameraStatus 无效
|
|
|
+
|
|
|
+
|
|
|
this.viewer.setCameraStatus(msg)
|
|
|
-
|
|
|
+ this.lastCamStatus = msg //记录下来,防止反向传输
|
|
|
|
|
|
-
|
|
|
+ let camera = this.viewer.getViewer().camera
|
|
|
+ if(camera.fov != data.fov){
|
|
|
+ camera.fov == data.fov
|
|
|
+ camera.updateProjectionMatrix()
|
|
|
+ }
|
|
|
|
|
|
//fov, near, far
|
|
|
/* aspect: 0.7879440258342304
|
|
@@ -191,15 +195,24 @@ export default class ConvertViews {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /* send(info){
|
|
|
+ send(info){
|
|
|
let camera = this.viewer.getViewer().camera
|
|
|
|
|
|
let data = {
|
|
|
- position : info.position,
|
|
|
- quaternion : camera.quaternion,
|
|
|
- target : info.target,
|
|
|
+ position : new THREE.Vector3().copy(info.position).applyMatrix4(this.convertMatrixInvert),
|
|
|
+ //quaternion : camera.quaternion.clone().applyMatrix4(this.convertMatrix),
|
|
|
+ target : new THREE.Vector3().copy(info.target).applyMatrix4(this.convertMatrixInvert),
|
|
|
}
|
|
|
- } */
|
|
|
+
|
|
|
+ if(this.needConvertAxis){
|
|
|
+ data.position = math.convertVector.ZupToYup(data.position)
|
|
|
+ data.target = math.convertVector.ZupToYup(data.target)
|
|
|
+ }
|
|
|
+ this.dispatchEvent({
|
|
|
+ type: 'sendCameraData',
|
|
|
+ data
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -231,8 +244,7 @@ export default class ConvertViews {
|
|
|
|
|
|
var vec1 = new THREE.Vector3().subVectors(panoPos1[0], panoPos1[1]) //旧的向量
|
|
|
var vec2 = new THREE.Vector3().subVectors(panoPos2[0], panoPos2[1])//新的向量
|
|
|
- /* var angle = vec1.angleTo(vec2)
|
|
|
- if(vec1.clone().cross(vec2).z < 0)angle *= -1 //这里不确定是<0还是>0 */
|
|
|
+
|
|
|
var angle = math.getAngle(vec1, vec2, 'z')
|
|
|
|
|
|
|
|
@@ -247,12 +259,13 @@ export default class ConvertViews {
|
|
|
|
|
|
|
|
|
|
|
|
- this.convertMatrix = /* matrix.invert() */ matrix
|
|
|
-
|
|
|
- var pos = panoPos1.map(e=>{
|
|
|
+ this.convertMatrix = matrix
|
|
|
+ this.convertMatrixInvert = matrix.clone().invert()
|
|
|
+
|
|
|
+ /* var pos = panoPos1.map(e=>{
|
|
|
return e.clone().applyMatrix4(matrix)
|
|
|
})
|
|
|
- console.log(pos)
|
|
|
+ console.log(pos) */
|
|
|
|
|
|
|
|
|
//挑选连续的两个点为向量来计算,如有123个漫游点,则选取12 23 31作为向量
|