|
@@ -22,9 +22,20 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
- laser暂时做成这样: 全景模式时不跟踪pos,跟踪点位变化。点云模式时无论是否在漫游点上,都跟踪pos,不跟踪点位,所以会有左边marker在脚下,右边marker不在脚下的情况。
|
|
|
|
|
|
+ laser暂时做成这样: 全景模式时不跟踪pos,跟踪pano变化。点云模式时也跟踪pano变化,但移动时完全跟踪位置变化 ,所以会有左边marker在脚下,右边marker不在脚下的情况。
|
|
|
|
|
|
*/
|
|
*/
|
|
|
|
+
|
|
|
|
+ getCameraData(app){
|
|
|
|
+ let camera = app.viewer.mainViewport.camera
|
|
|
|
+ return {
|
|
|
|
+ position: camera.position.clone(),
|
|
|
|
+ quaternion: camera.quaternion.clone(),
|
|
|
|
+ fov: camera.fov,
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
bindWithSameType(sourceApp,targetApp){
|
|
bindWithSameType(sourceApp,targetApp){
|
|
this.sourceApp = sourceApp
|
|
this.sourceApp = sourceApp
|
|
this.targetApp = targetApp
|
|
this.targetApp = targetApp
|
|
@@ -37,24 +48,49 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
if(sourceApp.sceneType == 'laser'){
|
|
if(sourceApp.sceneType == 'laser'){
|
|
sourceApp.viewer.images360.addEventListener('endChangeMode',e=>{//只监听左边
|
|
sourceApp.viewer.images360.addEventListener('endChangeMode',e=>{//只监听左边
|
|
- sourceApp.Potree.settings.displayMode = e.mode
|
|
|
|
|
|
+ targetApp.Potree.settings.displayMode = e.mode
|
|
})
|
|
})
|
|
|
|
|
|
let bind = (master, customer)=>{ //相互都能带动对方
|
|
let bind = (master, customer)=>{ //相互都能带动对方
|
|
- let flyToPano = (e)=>{
|
|
|
|
- customer.viewer.images360.flyToPano({pano: customer.viewer.images360.panos[e.toPano.id]} )
|
|
|
|
|
|
+ let flyToPano = (e)=>{//同步点位
|
|
|
|
+ customer.viewer.images360.flyToPano({pano: customer.viewer.images360.panos[e.toPano.pano.id]} )
|
|
}
|
|
}
|
|
master.viewer.images360.addEventListener('flyToPano',flyToPano)
|
|
master.viewer.images360.addEventListener('flyToPano',flyToPano)
|
|
|
|
|
|
- let cameraMove = (e)=>{
|
|
|
|
- //if(e.changeInfo && e.changeInfo.positionChanged){
|
|
|
|
|
|
+ let cameraMove = (e)=>{
|
|
|
|
+ if(master != this.masterApp )return
|
|
|
|
+
|
|
|
|
+ if(master.Potree.settings.displayMode == 'showPanos'){ //转换朝向
|
|
|
|
+ if(e.changeInfo && e.changeInfo.quaternionChanged){
|
|
|
|
+ let data = this.getCameraData(master)
|
|
|
|
+ let diffQua = master == this.sourceApp ? this.diffQuaternion : this.diffQuaternionInvert
|
|
|
|
+ let quaternion = data.quaternion.premultiply(diffQua)
|
|
|
|
+ let rotation = new THREE.Euler().setFromQuaternion(quaternion)
|
|
|
|
+ customer.viewer.mainViewport.view.rotation = rotation
|
|
|
|
+ console.log('cameraMove',customer == this.targetApp)
|
|
|
|
+ }
|
|
|
|
+ }else{//转换朝向和位置
|
|
|
|
+ let data = this.getCameraData(master)
|
|
|
|
+ this.receive(data, customer )
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
master.viewer.addEventListener('camera_changed',cameraMove)
|
|
master.viewer.addEventListener('camera_changed',cameraMove)
|
|
|
|
|
|
|
|
+ let changeMaster = ()=>{
|
|
|
|
+ this.masterApp = master
|
|
|
|
+ }
|
|
|
|
+ let dom = master.viewer.inputHandler.domElement
|
|
|
|
+ dom.addEventListener('mousedown',changeMaster)
|
|
|
|
+ dom.addEventListener('mousewheel',changeMaster)
|
|
this.addEventListener('clearBind-sameType',()=>{
|
|
this.addEventListener('clearBind-sameType',()=>{
|
|
master.viewer.images360.removeEventListener('flyToPano',flyToPano)
|
|
master.viewer.images360.removeEventListener('flyToPano',flyToPano)
|
|
-
|
|
|
|
|
|
+ master.viewer.removeEventListener('camera_changed',cameraMove)
|
|
|
|
+ dom.removeEventListener('mousedown',changeMaster)
|
|
|
|
+ dom.removeEventListener('mousewheel',changeMaster)
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
bind(sourceApp, targetApp)
|
|
bind(sourceApp, targetApp)
|
|
@@ -62,17 +98,18 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ this.loaded = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- bindWithBim(sourceApp, targetApp, sourceDom , sourcePano, targetPano, cameraData ) {
|
|
|
|
|
|
+ bindWithBim(sourceApp, targetApp, sourcePano, targetPano, cameraData ) {
|
|
//if (!this.player1.model.panos.list.length || !this.player2.model.panos.list.length) return
|
|
//if (!this.player1.model.panos.list.length || !this.player2.model.panos.list.length) return
|
|
|
|
|
|
if(this.loaded || !targetApp ) return
|
|
if(this.loaded || !targetApp ) return
|
|
let needBindEvent = !this.targetApp // 若targetApp存在表明targetApp的dom未换掉,事件还存在
|
|
let needBindEvent = !this.targetApp // 若targetApp存在表明targetApp的dom未换掉,事件还存在
|
|
this.sourceApp = sourceApp
|
|
this.sourceApp = sourceApp
|
|
this.targetApp = targetApp
|
|
this.targetApp = targetApp
|
|
- this.sourceDom = sourceDom
|
|
|
|
|
|
+ this.sourceDom = this.sourceApp.viewer.inputHandler.
|
|
|
|
|
|
bimViewer = this.bimViewer = targetApp.viewer
|
|
bimViewer = this.bimViewer = targetApp.viewer
|
|
|
|
|
|
@@ -96,10 +133,13 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
this.send(info)
|
|
this.send(info)
|
|
this.lastCamStatus = info
|
|
this.lastCamStatus = info
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
})
|
|
})
|
|
|
|
|
|
-
|
|
|
|
|
|
+ sourceApp.viewer.addEventListener('camera_changed', e => {
|
|
|
|
+ targetApp && this.receive(this.getCameraData(sourceApp))
|
|
|
|
+ })
|
|
/* bimViewer.addEventListener(targetApp.Glodon.Bimface.Viewer.Viewer3DEvent.ViewAdded,
|
|
/* bimViewer.addEventListener(targetApp.Glodon.Bimface.Viewer.Viewer3DEvent.ViewAdded,
|
|
()=>{
|
|
()=>{
|
|
this.loaded = true
|
|
this.loaded = true
|
|
@@ -171,7 +211,13 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- receive(data){
|
|
|
|
|
|
+
|
|
|
|
+ laserSyncView(app,data){
|
|
|
|
+ app.viewer.mainViewport.view.position.copy(data.position)
|
|
|
|
+ app.viewer.mainViewport.view.lookAt(data.target)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ receive(data, customer){
|
|
|
|
|
|
if(!this.loaded){
|
|
if(!this.loaded){
|
|
return this.firstData = data
|
|
return this.firstData = data
|
|
@@ -181,7 +227,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
} */
|
|
} */
|
|
|
|
|
|
let position = new THREE.Vector3, target = new THREE.Vector3
|
|
let position = new THREE.Vector3, target = new THREE.Vector3
|
|
- let currStatus = this.bimViewer.getCameraStatus()
|
|
|
|
|
|
+
|
|
if(data.position){
|
|
if(data.position){
|
|
position = new THREE.Vector3().copy(data.position)
|
|
position = new THREE.Vector3().copy(data.position)
|
|
}
|
|
}
|
|
@@ -215,39 +261,42 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
position.applyMatrix4(this.convertMatrix)
|
|
position.applyMatrix4(this.convertMatrix)
|
|
target.applyMatrix4(this.convertMatrix)
|
|
target.applyMatrix4(this.convertMatrix)
|
|
|
|
|
|
|
|
+ if(customer && customer.sceneType == 'laser'){
|
|
|
|
+ this.laserSyncView(customer, {position,target})
|
|
|
|
+ }else{
|
|
|
|
+ let msg = {
|
|
|
|
+ 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()
|
|
|
|
+ }
|
|
|
|
|
|
- let msg = {
|
|
|
|
- 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
|
|
|
|
- coordinateSystem: "world"
|
|
|
|
- far: 11485.989363357028
|
|
|
|
- fov: 45
|
|
|
|
- name: "persp"
|
|
|
|
- near: 1.1852000000072447
|
|
|
|
- position: {x: -1130.0432094639486, y: -6058.569138159733, z: 2265.9284566100446}
|
|
|
|
- target: {x: 310.3968263091223, y: -66.0595010237127, z: 1477.7045866099475}
|
|
|
|
- up: {x: 0, y: 1.534753124827774e-13, z: 1}
|
|
|
|
- version: 1
|
|
|
|
- zoom: 0 */
|
|
|
|
|
|
+ //fov, near, far
|
|
|
|
+ /* aspect: 0.7879440258342304
|
|
|
|
+ coordinateSystem: "world"
|
|
|
|
+ far: 11485.989363357028
|
|
|
|
+ fov: 45
|
|
|
|
+ name: "persp"
|
|
|
|
+ near: 1.1852000000072447
|
|
|
|
+ position: {x: -1130.0432094639486, y: -6058.569138159733, z: 2265.9284566100446}
|
|
|
|
+ target: {x: 310.3968263091223, y: -66.0595010237127, z: 1477.7045866099475}
|
|
|
|
+ up: {x: 0, y: 1.534753124827774e-13, z: 1}
|
|
|
|
+ version: 1
|
|
|
|
+ zoom: 0 */
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -265,10 +314,11 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
data.position = math.convertVector.ZupToYup(data.position)
|
|
data.position = math.convertVector.ZupToYup(data.position)
|
|
data.target = math.convertVector.ZupToYup(data.target)
|
|
data.target = math.convertVector.ZupToYup(data.target)
|
|
}
|
|
}
|
|
- this.dispatchEvent({
|
|
|
|
|
|
+ /* this.dispatchEvent({
|
|
type: 'sendCameraData',
|
|
type: 'sendCameraData',
|
|
data
|
|
data
|
|
- })
|
|
|
|
|
|
+ }) */
|
|
|
|
+ this.laserSyncView(this.sourceApp, data)
|
|
}
|
|
}
|
|
|
|
|
|
computeAveDiffLon() {
|
|
computeAveDiffLon() {
|
|
@@ -332,7 +382,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
if(this.sourceApp.sceneType == this.targetApp.sceneType){
|
|
if(this.sourceApp.sceneType == this.targetApp.sceneType){
|
|
- var angle = this.diffLonAve;
|
|
|
|
|
|
+ var angle = this.diffLon;
|
|
panoPos1 = this.sourceApp.viewer.images360.panos.map(e=>{
|
|
panoPos1 = this.sourceApp.viewer.images360.panos.map(e=>{
|
|
return e.position
|
|
return e.position
|
|
})
|
|
})
|