|
@@ -21,7 +21,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
bindWithSameFakeType(sourceFakeApp, targetApp){//for mobile 实际只有一个场景,未分屏,和上一个场景相比
|
|
|
let sourceApp = {sceneType: sourceFakeApp.sceneType, fakeApp:sourceFakeApp}
|
|
|
|
|
|
- this.createTempApp(targetApp, true)
|
|
|
+ this.createFakeApp(targetApp, true)
|
|
|
|
|
|
let convertInfo = this.computeAveDiffLon(sourceFakeApp, targetApp.fakeApp)
|
|
|
|
|
@@ -52,12 +52,12 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- bindWithSameType(sourceApp,targetApp, isSwitchScene){
|
|
|
+ bindWithSameType(sourceApp,targetApp, isSwitchScene){ //左右分屏 同类型
|
|
|
|
|
|
this.sourceApp = sourceApp
|
|
|
this.targetApp = targetApp
|
|
|
- this.createTempApp(sourceApp)
|
|
|
- this.createTempApp(targetApp)
|
|
|
+ this.createFakeApp(sourceApp)
|
|
|
+ this.createFakeApp(targetApp)
|
|
|
|
|
|
this.convertInfo = this.computeAveDiffLon(sourceApp.fakeApp, targetApp.fakeApp)
|
|
|
|
|
@@ -98,7 +98,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
var cameraMove = (e)=>{
|
|
|
if(master != this.masterApp || !customer.viewer )return
|
|
|
|
|
|
- this.addViewInfo(master)
|
|
|
+ this.fakeAppUpdateView(master)
|
|
|
|
|
|
master.fakeApp.viewInfo.quaternionChanged = e.changeInfo && e.changeInfo.quaternionChanged
|
|
|
this.syncView(master, customer)
|
|
@@ -131,7 +131,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
var cameraMove = (e)=>{//暂时只有漫游模式
|
|
|
if(!e.hasChanged.cameraChanged || !customer.app || !customer.app.core)return
|
|
|
|
|
|
- this.addViewInfo(master)
|
|
|
+ this.fakeAppUpdateView(master)
|
|
|
this.syncView(master, customer)
|
|
|
}
|
|
|
player1.on("update",cameraMove)
|
|
@@ -180,7 +180,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
let customer = isSwitchScene == 'target' ? targetApp : sourceApp
|
|
|
this.masterApp = master
|
|
|
|
|
|
- this.addViewInfo(master)
|
|
|
+ this.fakeAppUpdateView(master)
|
|
|
this.syncView(master, customer)
|
|
|
|
|
|
|
|
@@ -215,7 +215,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
let sourceApp = {sceneType: sourceFakeApp.sceneType, fakeApp:sourceFakeApp}
|
|
|
|
|
|
- this.createTempApp(targetApp)
|
|
|
+ this.createFakeApp(targetApp)
|
|
|
let {sourcePano, targetPano} = this.bimGetPanoData(sourceApp, targetApp, panoData)
|
|
|
|
|
|
let convertAxis = sourceApp.sceneType == 'kankan' ? 'YupToZup' : targetApp.sceneType == 'kankan' ? 'ZupToYup' : null
|
|
@@ -280,18 +280,15 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- laserCancelFly(app){
|
|
|
- app.viewer.images360.cancelFlyToPano()
|
|
|
- app.viewer.mainViewport.view.cancelFlying()
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
bindWithBim(sourceApp, targetApp, panoData ) {
|
|
|
//if (!this.player1.model.panos.list.length || !this.player2.model.panos.list.length) return
|
|
|
|
|
|
if(this.loaded || !targetApp ) return
|
|
|
let needBindEvent = !this.targetApp // 若targetApp存在表明targetApp的dom未换掉,事件还存在
|
|
|
- this.createTempApp(sourceApp)
|
|
|
- this.createTempApp(targetApp)
|
|
|
+ this.createFakeApp(sourceApp)
|
|
|
+ this.createFakeApp(targetApp)
|
|
|
let {sourcePano, targetPano} = this.bimGetPanoData(sourceApp, targetApp, panoData)
|
|
|
|
|
|
this.sourceApp = sourceApp
|
|
@@ -469,58 +466,6 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- syncPosRot(data, customer, convertInfo ){//同步 自由位置和朝向(不被漫游点束缚时)
|
|
|
- /*
|
|
|
- if(!this.loaded){
|
|
|
- return this.firstData = data
|
|
|
- } */
|
|
|
- convertInfo = convertInfo || this.convertInfo
|
|
|
- let {position,target} = this.getTranPosData(data, convertInfo )
|
|
|
-
|
|
|
-
|
|
|
- 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 无效
|
|
|
- }
|
|
|
-
|
|
|
- bimViewer.setCameraStatus(msg)
|
|
|
- this.lastCamStatus = msg //记录下来,防止反向传输
|
|
|
-
|
|
|
- let camera = bimViewer.getViewer().camera
|
|
|
- if(camera.fov != data.fov){
|
|
|
- camera.fov = data.fov
|
|
|
- camera.updateProjectionMatrix()
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- ifCanChangePos(app){
|
|
|
- return app.sceneType == 'laser' && app.Potree.settings.displayMode != 'showPanos' //app.fakeApp.viewInfo.displayMode != 'showPanos'
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- send(info){
|
|
|
- //let camera = bimViewer.getViewer().camera
|
|
|
- let data = this.getTranPosData(info, this.convertInfo, true )
|
|
|
-
|
|
|
- this.laserSyncView(this.sourceApp, data) //左侧只有laser点云模式才能接收到
|
|
|
- }
|
|
|
-
|
|
|
computeAveDiffLon(sourceFakeApp, targetFakeApp) {
|
|
|
//获取两个场景的lon偏差值
|
|
|
//需要点的个数>1, 且两个场景点一一对应,位置接近且顺序一致
|
|
@@ -608,13 +553,122 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+ syncPosRot(data, customer, convertInfo ){//同步 自由位置和朝向(不被漫游点束缚时)
|
|
|
+ /*
|
|
|
+ if(!this.loaded){
|
|
|
+ return this.firstData = data
|
|
|
+ } */
|
|
|
+ convertInfo = convertInfo || this.convertInfo
|
|
|
+ let {position,target} = this.getTranPosData(data, convertInfo )
|
|
|
+
|
|
|
+
|
|
|
+ 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 无效
|
|
|
+ }
|
|
|
+
|
|
|
+ bimViewer.setCameraStatus(msg)
|
|
|
+ this.lastCamStatus = msg //记录下来,防止反向传输
|
|
|
+
|
|
|
+ let camera = bimViewer.getViewer().camera
|
|
|
+ if(camera.fov != data.fov){
|
|
|
+ camera.fov = data.fov
|
|
|
+ camera.updateProjectionMatrix()
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ ifCanChangePos(app){
|
|
|
+ return app.sceneType == 'laser' && app.Potree.settings.displayMode != 'showPanos' //app.fakeApp.viewInfo.displayMode != 'showPanos'
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ send(info){
|
|
|
+ //let camera = bimViewer.getViewer().camera
|
|
|
+ let data = this.getTranPosData(info, this.convertInfo, true )
|
|
|
+
|
|
|
+ this.laserSyncView(this.sourceApp, data) //左侧只有laser点云模式才能接收到
|
|
|
+ }
|
|
|
|
|
|
/*
|
|
|
laser暂时做成这样: 全景模式时不跟踪pos,跟踪pano变化。点云模式时也跟踪pano变化,但移动时完全跟踪位置变化 ,所以会有左边marker在脚下,右边marker不在脚下的情况。
|
|
|
|
|
|
*/
|
|
|
|
|
|
+ bimGetPanoData(sourceApp, targetApp, panoData){
|
|
|
+ if(panoData){
|
|
|
+ let sourcePano,targetPano
|
|
|
+ let pano1 = [{position:new THREE.Vector3().copy(panoData.p1.position)},{position:new THREE.Vector3().copy(panoData.p2.position)}]
|
|
|
+
|
|
|
+ let getPano2 = (app)=>{
|
|
|
+ return [app.fakeApp.panos.find(e=>e.id == panoData.p1.id), app.fakeApp.panos.find(e=>e.id == panoData.p2.id)]
|
|
|
+ }
|
|
|
+
|
|
|
+ if(targetApp.sceneType == 'bim'){
|
|
|
+ targetPano = pano1
|
|
|
+ sourcePano = getPano2(sourceApp)
|
|
|
+ }else{
|
|
|
+ targetPano = getPano2(targetApp)
|
|
|
+ sourcePano = pano1
|
|
|
+ }
|
|
|
+
|
|
|
+ if( !sourcePano[0] || !sourcePano[1] || !targetPano[0] || !targetPano[1] ){
|
|
|
+ console.error('!sourcePano[0] || !sourcePano[1] || !targetPano[0] || !targetPano[1]')
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return {sourcePano, targetPano}
|
|
|
+ }else return {}
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ getTranPosData(data, convertInfo, ifRevert ){
|
|
|
+ let position = new THREE.Vector3, target = new THREE.Vector3
|
|
|
+
|
|
|
+ if(data.position){
|
|
|
+ position = new THREE.Vector3().copy(data.position)
|
|
|
+ }
|
|
|
+ if(!data.target){
|
|
|
+ if(data.quaternion){
|
|
|
+ let dir = new THREE.Vector3(0, 0, -1).applyQuaternion(data.quaternion)
|
|
|
+ target.copy(position).add(dir)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ target.copy(data.target)
|
|
|
+ }
|
|
|
+
|
|
|
+ if(ifRevert){
|
|
|
+ position.applyMatrix4(convertInfo.convertMatrixInvert)
|
|
|
+ target.applyMatrix4(convertInfo.convertMatrixInvert)
|
|
|
+ if(convertInfo.convertAxis){
|
|
|
+ position = math.convertVector[convertInfo.convertAxis](position)
|
|
|
+ target = math.convertVector[convertInfo.convertAxis](target)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ if(convertInfo.convertAxis){
|
|
|
+ position = math.convertVector[convertInfo.convertAxis](position)
|
|
|
+ target = math.convertVector[convertInfo.convertAxis](target)
|
|
|
+ }
|
|
|
+
|
|
|
+ position.applyMatrix4(convertInfo.convertMatrix)
|
|
|
+ target.applyMatrix4(convertInfo.convertMatrix)
|
|
|
+ }
|
|
|
+ return {position, target}
|
|
|
+ }
|
|
|
+
|
|
|
getCameraData(app){
|
|
|
if(app.sceneType == 'laser'){
|
|
|
let camera = app.viewer.mainViewport.camera
|
|
@@ -642,7 +696,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- createTempApp(app, addsubInfo){//for mobile
|
|
|
+ createFakeApp(app, addsubInfo){//for mobile
|
|
|
|
|
|
let fakeApp = {
|
|
|
isFake : true, //标志是虚拟的app。每个真实的app都要带一个这个。在移动端如果大的销毁了还有小的
|
|
@@ -658,12 +712,12 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
app.fakeApp = fakeApp
|
|
|
|
|
|
if(addsubInfo){
|
|
|
- this.addViewInfo(app)
|
|
|
+ this.fakeAppUpdateView(app)
|
|
|
}
|
|
|
return fakeApp
|
|
|
}
|
|
|
|
|
|
- addViewInfo(app){
|
|
|
+ fakeAppUpdateView(app){
|
|
|
let viewInfo
|
|
|
let cameraData = this.getCameraData(app)
|
|
|
if(app.sceneType == 'laser'){
|
|
@@ -738,68 +792,18 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ laserSyncView(app,data){
|
|
|
+ app.viewer.mainViewport.view.position.copy(data.position)
|
|
|
+ app.viewer.mainViewport.view.lookAt(data.target)
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- bimGetPanoData(sourceApp, targetApp, panoData){
|
|
|
- if(panoData){
|
|
|
- let sourcePano,targetPano
|
|
|
- let pano1 = [{position:new THREE.Vector3().copy(panoData.p1.position)},{position:new THREE.Vector3().copy(panoData.p2.position)}]
|
|
|
-
|
|
|
- let getPano2 = (app)=>{
|
|
|
- return [app.fakeApp.panos.find(e=>e.id == panoData.p1.id), app.fakeApp.panos.find(e=>e.id == panoData.p2.id)]
|
|
|
- }
|
|
|
-
|
|
|
- if(targetApp.sceneType == 'bim'){
|
|
|
- targetPano = pano1
|
|
|
- sourcePano = getPano2(sourceApp)
|
|
|
- }else{
|
|
|
- targetPano = getPano2(targetApp)
|
|
|
- sourcePano = pano1
|
|
|
- }
|
|
|
-
|
|
|
- if( !sourcePano[0] || !sourcePano[1] || !targetPano[0] || !targetPano[1] ){
|
|
|
- console.error('!sourcePano[0] || !sourcePano[1] || !targetPano[0] || !targetPano[1]')
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return {sourcePano, targetPano}
|
|
|
- }else return {}
|
|
|
+ laserCancelFly(app){
|
|
|
+ app.viewer.images360.cancelFlyToPano()
|
|
|
+ app.viewer.mainViewport.view.cancelFlying()
|
|
|
}
|
|
|
|
|
|
|
|
|
- getTranPosData(data, convertInfo, ifRevert ){
|
|
|
- let position = new THREE.Vector3, target = new THREE.Vector3
|
|
|
-
|
|
|
- if(data.position){
|
|
|
- position = new THREE.Vector3().copy(data.position)
|
|
|
- }
|
|
|
- if(!data.target){
|
|
|
- if(data.quaternion){
|
|
|
- let dir = new THREE.Vector3(0, 0, -1).applyQuaternion(data.quaternion)
|
|
|
- target.copy(position).add(dir)
|
|
|
- }
|
|
|
- }else{
|
|
|
- target.copy(data.target)
|
|
|
- }
|
|
|
-
|
|
|
- if(ifRevert){
|
|
|
- position.applyMatrix4(convertInfo.convertMatrixInvert)
|
|
|
- target.applyMatrix4(convertInfo.convertMatrixInvert)
|
|
|
- if(convertInfo.convertAxis){
|
|
|
- position = math.convertVector[convertInfo.convertAxis](position)
|
|
|
- target = math.convertVector[convertInfo.convertAxis](target)
|
|
|
- }
|
|
|
- }else{
|
|
|
- if(convertInfo.convertAxis){
|
|
|
- position = math.convertVector[convertInfo.convertAxis](position)
|
|
|
- target = math.convertVector[convertInfo.convertAxis](target)
|
|
|
- }
|
|
|
-
|
|
|
- position.applyMatrix4(convertInfo.convertMatrix)
|
|
|
- target.applyMatrix4(convertInfo.convertMatrix)
|
|
|
- }
|
|
|
- return {position, target}
|
|
|
- }
|
|
|
bimFlyTo(data){
|
|
|
let info = bimViewer.getCameraStatus()
|
|
|
|
|
@@ -845,11 +849,6 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- laserSyncView(app,data){
|
|
|
- app.viewer.mainViewport.view.position.copy(data.position)
|
|
|
- app.viewer.mainViewport.view.lookAt(data.target)
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
lockCamera(locked){//禁止操作改变相机
|
|
|
this.locked = locked
|
|
@@ -865,6 +864,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
this.bimViewer.camera3D.enableRotate(this.locked ? false : true)
|
|
|
this.bimViewer.enableShortcutKey((this.locked || this.isPanoMode) ? false : true) //键盘移动
|
|
|
}
|
|
|
+
|
|
|
bindCamEvent(){//传递到另一边的dom
|
|
|
this.lockCamera(true)
|
|
|
|
|
@@ -943,7 +943,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
if(o.dontClearTarget){
|
|
|
if(this.sourceApp){
|
|
|
this.lastFakeApp = this.sourceApp.fakeApp //记住当前左屏
|
|
|
- this.addViewInfo(this.sourceApp)
|
|
|
+ this.fakeAppUpdateView(this.sourceApp)
|
|
|
}
|
|
|
}else{
|
|
|
this.targetApp = null
|