|
@@ -2,7 +2,7 @@ import math from './math.js'
|
|
|
|
|
|
let bimViewer
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
constructor( ) {
|
|
@@ -12,6 +12,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
checkModeDelay : 1000,
|
|
|
}
|
|
|
this.convertInfo //包含转换信息
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -178,7 +179,21 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
- bindFakeWithBim(sourceFakeApp, targetApp, panoData ){// bim和其他类型互转(mobile)
|
|
|
+ bindFakeWithBim(sourceFakeApp, targetApp, panoData ){// bim和其他类型互转(mobile), bim不一定是target
|
|
|
+ if(targetApp.sceneType == 'bim'){
|
|
|
+ bimViewer = targetApp.viewer
|
|
|
+ bimViewer.getViewer().setTransitionAnimationState(false)
|
|
|
+ targetApp.CLOUD.GlobalData.WalkRotationSpeed = -0.2 //反向一下
|
|
|
+ }
|
|
|
+ if(sourceFakeApp.sceneType == 'bim' && targetApp.sceneType == 'bim' ){
|
|
|
+ console.log('还是bim')
|
|
|
+ this.syncPosRot(sourceFakeApp.viewInfo, targetApp )
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if(!panoData)return
|
|
|
|
|
|
|
|
@@ -220,11 +235,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
}
|
|
|
|
|
|
- if(targetApp.sceneType == 'bim'){
|
|
|
- bimViewer = targetApp.viewer
|
|
|
- bimViewer.getViewer().setTransitionAnimationState(false)
|
|
|
- targetApp.CLOUD.GlobalData.WalkRotationSpeed = -0.2 //反向一下
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
|
|
|
if(targetApp.sceneType == 'bim' ){
|
|
@@ -233,7 +244,9 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
}else if(targetApp.sceneType == 'laser' ){
|
|
|
selectBestPose() //刚好在点位上的话这句设置完就正确了
|
|
|
- setTimeout(()=>{ //刚开始总是showPointCloud (且稍后会自动飞到某点)所以需要延时
|
|
|
+ let currFakeApp = targetApp.fakeApp
|
|
|
+ setTimeout(()=>{ //刚开始总是showPointCloud (且稍后会自动飞到某点)所以需要延时
|
|
|
+ if(targetApp.fakeApp != currFakeApp)return //已经加载别的场景
|
|
|
this.laserCancelFly(targetApp)
|
|
|
if(this.ifCanChangePos(targetApp)){//点云模式的话
|
|
|
this.syncPosRot(sourceFakeApp.viewInfo, targetApp, convertInfo)
|
|
@@ -550,7 +563,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
if(!this.loaded){
|
|
|
return this.firstData = data
|
|
|
} */
|
|
|
- convertInfo = convertInfo || this.convertInfo
|
|
|
+ convertInfo = convertInfo || this.convertInfo || {}
|
|
|
let {position,target} = this.getTranPosData(data, convertInfo, customer && customer.fakeApp == convertInfo.sourceFakeApp )
|
|
|
|
|
|
|
|
@@ -619,7 +632,7 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- getTranPosData(data, convertInfo, ifRevert ){//根据convertInfo获得转换的数据
|
|
|
+ getTranPosData(data, convertInfo={}, ifRevert ){//根据convertInfo获得转换的数据
|
|
|
let position = new THREE.Vector3, target = new THREE.Vector3
|
|
|
|
|
|
if(data.position){
|
|
@@ -634,21 +647,24 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
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)
|
|
|
- }
|
|
|
+
|
|
|
+ if(convertInfo.convertMatrix){
|
|
|
+ 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)
|
|
|
+ position.applyMatrix4(convertInfo.convertMatrix)
|
|
|
+ target.applyMatrix4(convertInfo.convertMatrix)
|
|
|
+ }
|
|
|
}
|
|
|
return {position, target}
|
|
|
}
|
|
@@ -681,22 +697,27 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- createFakeApp(app, addsubInfo){ //为每个app创建fakeApp, 里面包含了基本信息。
|
|
|
- if(!app.fakeApp){//不能重复建立,因为可能绑定在了convertInfo里
|
|
|
+ createFakeApp(app, addsubInfo){ //为每个app创建fakeApp, 里面包含了场景基本信息。
|
|
|
+ if(!app.fakeApp){//不能重复建立,作为唯一标识
|
|
|
let fakeApp = {
|
|
|
isFake : true, //标志是虚拟的app。每个真实的app都要带一个这个。在移动端如果大的销毁了还有小的
|
|
|
- sceneType : app.sceneType
|
|
|
+ sceneType : app.sceneType,
|
|
|
+ id : getId(),
|
|
|
+
|
|
|
}
|
|
|
if(app.sceneType != 'bim'){
|
|
|
function getPanos(panos){ // only data
|
|
|
return panos.map(e=>{return {id:e.id, position:e.position, quaternion:e.quaternion}})
|
|
|
}
|
|
|
fakeApp.panos = app.sceneType == 'laser' ? getPanos(app.viewer.images360.panos) : getPanos(app.app.core.get('Player').model.panos.list)
|
|
|
- }
|
|
|
-
|
|
|
- app.fakeApp = fakeApp
|
|
|
+ }
|
|
|
+
|
|
|
+ Object.defineProperty(app,'fakeApp',{
|
|
|
+ value: fakeApp,
|
|
|
+ Configurable : false, //不可替换和删除
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
if(addsubInfo){
|
|
|
this.fakeAppUpdateInfo(app)
|
|
|
}
|
|
@@ -979,13 +1000,19 @@ export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
|
|
|
}
|
|
|
|
|
|
+let num = 0
|
|
|
+function getId(){
|
|
|
+ return num++
|
|
|
+}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/*
|
|
|
|
|
|
note:
|
|
|
|
|
|
|
|
|
+访问:window[0].fakeApp, window[1].fakeApp
|
|
|
+
|
|
|
旋转只能通过target设置, 不能直接改camera.quaternion
|
|
|
当且仅当发送方相机属性变化后才传递过来,就不在这里判断是否变化了。
|
|
|
(所以只需要实时检测相机是否改变, hasChanged后发送)
|