|
@@ -1,59 +1,249 @@
|
|
|
-export default class ConvertViews {
|
|
|
+import math from './math.js'
|
|
|
+let Bimface
|
|
|
+const belowHeight = 0.4
|
|
|
+const isEdit = true
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+let texLoader = new THREE.TextureLoader()
|
|
|
+export default class ConvertViews extends THREE.EventDispatcher{
|
|
|
constructor() {
|
|
|
+ super()
|
|
|
this.sourceApp = null
|
|
|
this.targetApp = null
|
|
|
- this.player1 = null
|
|
|
- this.player2 = null
|
|
|
- this.KanKan = null
|
|
|
+ this.sourceType = null
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- bind(options = { sourceApp: null, targetApp: null }) {
|
|
|
- if (options.sourceApp) {
|
|
|
- this.sourceApp = options.sourceApp
|
|
|
- this.player1 = this.sourceApp.core.get('Player')
|
|
|
- //this.player1.model.addEventListener('gotPanos', this.init.bind(this))
|
|
|
- } else if (options.targetApp) {
|
|
|
- this.targetApp = options.targetApp
|
|
|
- this.player2 = this.targetApp.core.get('Player')
|
|
|
- //this.player2.model.addEventListener('gotPanos', this.init.bind(this))
|
|
|
- }
|
|
|
- if (this.sourceApp && this.targetApp) {
|
|
|
- // 两个实例都加载完了,可以进行特性处理
|
|
|
- this.init()
|
|
|
- this.applyDiff(options.sourceApp || options.targetApp)
|
|
|
+
|
|
|
+ clear(o={}){
|
|
|
+ this.loaded = false;
|
|
|
+ this.sourceApp = null;
|
|
|
+ if(!o.dontClearTarget){
|
|
|
+ this.targetApp = null
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ init(sourceApp, targetApp, sourceDom, sourceType, cameraData, sourcePano) {
|
|
|
+ //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.sourceApp = sourceApp
|
|
|
+ this.targetApp = targetApp
|
|
|
+ this.sourceDom = sourceDom
|
|
|
+ this.sourceType = sourceType
|
|
|
+ this.sourcePano = sourcePano
|
|
|
+ this.targetPano = [
|
|
|
+ {position: new THREE.Vector3( -5.313605730801787, -4.889868407960505, 1.237447893355817),},
|
|
|
+ {position: new THREE.Vector3( -5.337403524084278, -2.5012228235167737, 1.2808838933558175),}
|
|
|
+ ]
|
|
|
+ let viewer = this.viewer = targetApp.viewer
|
|
|
+ //viewer.THREE = targetApp.THREE
|
|
|
+ this.needConvertAxis = sourceType == '4dkk' // Y朝上需要转换
|
|
|
+ Bimface = targetApp.Glodon.Bimface
|
|
|
+ this.lastCamStatus = viewer.getCameraStatus()
|
|
|
+ this.computeShift(sourcePano)
|
|
|
+ if(isEdit){
|
|
|
+ this.createPanoPannel()
|
|
|
}
|
|
|
+ viewer.setNavigationMode( Bimface.Viewer.NavigationMode3D.Walk)
|
|
|
+ viewer.setFlySpeedRate(5)
|
|
|
+ viewer.getViewer().setTransitionAnimationState(false) //setCameraStatus瞬间变化相机 ,or setCameraAnimation?
|
|
|
+
|
|
|
+ needBindEvent && viewer.addEventListener('Rendered', (e)=>{//反向改变左侧相机
|
|
|
+ if(this.synPaused)return
|
|
|
+ let info = viewer.getCameraStatus()
|
|
|
+ let poseChanged = !math.closeTo(this.lastCamStatus.position, info.position)
|
|
|
+ || !math.closeTo(this.lastCamStatus.target, info.target)
|
|
|
+ || !math.closeTo(this.lastCamStatus.fov, info.fov)
|
|
|
+
|
|
|
+ if(poseChanged){
|
|
|
+ if(sourceApp.canChangePos()){
|
|
|
+
|
|
|
+ this.send(info)
|
|
|
+ this.lastCamStatus = info
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ //this.addMesh(cameraData)
|
|
|
+
|
|
|
+ /* viewer.addEventListener( Bimface.Viewer.Viewer3DEvent.ViewAdded,
|
|
|
+ ()=>{
|
|
|
+ this.loaded = true
|
|
|
+ if(this.firstData){
|
|
|
+ this.receive(this.firstData)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ) */
|
|
|
+ this.loaded = true
|
|
|
+ this.receive(cameraData)
|
|
|
+ needBindEvent && this.bindCamEvent()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ receive(data){
|
|
|
+ this.dispatchEvent({type:'updateBtnState'})
|
|
|
+ if(this.synPaused)return
|
|
|
+ if(!this.loaded){
|
|
|
+ return this.firstData = data
|
|
|
+ }
|
|
|
+
|
|
|
+ let position = new THREE.Vector3, target = new THREE.Vector3
|
|
|
+ let currStatus = this.viewer.getCameraStatus()
|
|
|
+ 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{
|
|
|
+ if(this.needConvertAxis){
|
|
|
+ target = math.convertVector.YupToZup(target)
|
|
|
+ }else{
|
|
|
+ target.copy(data.target)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.needConvertAxis){
|
|
|
+ position = math.convertVector.YupToZup(position)
|
|
|
+ target = math.convertVector.YupToZup(target)
|
|
|
+ }
|
|
|
+
|
|
|
+ position.applyMatrix4(this.convertMatrix)
|
|
|
+ target.applyMatrix4(this.convertMatrix)
|
|
|
|
|
|
- init() {
|
|
|
- if (!this.player1.model.panos.list.length || !this.player2.model.panos.list.length) return
|
|
|
|
|
|
- this.diffLon = this.computeAveDiffLon()
|
|
|
- this.diffQuaternion = new this.KanKan.THREE.Quaternion().setFromAxisAngle(new this.KanKan.THREE.Vector3(0, 1, 0), this.diffLon)
|
|
|
- this.diffQuaternionInvert = this.diffQuaternion.clone().invert()
|
|
|
+ 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 */
|
|
|
+
|
|
|
+ /* this.plane.quaternion.copy(camera.quaternion)
|
|
|
+ this.plane.updateMatrix()
|
|
|
+ this.plane.updateMatrixWorld()
|
|
|
+
|
|
|
+ let matrix = new THREE.Matrix4()
|
|
|
+ matrix.makeRotationFromQuaternion(camera.quaternion)
|
|
|
+
|
|
|
+ extObjMng.setTransformation(this.plane.name, matrix)*/
|
|
|
}
|
|
|
|
|
|
- computeAveDiffLon() {
|
|
|
- //获取两个场景的lon偏差值
|
|
|
- //需要点的个数>1, 且两个场景点一一对应,位置接近且顺序一致
|
|
|
|
|
|
+ send(info){
|
|
|
+ let camera = this.viewer.getViewer().camera
|
|
|
+
|
|
|
+ let data = {
|
|
|
+ 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
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ computeShift(sourcePano) { //获取两个场景的旋转和位移偏差值
|
|
|
+ //需要点的个数>1, 且两个场景点一一对应,位置接近且顺序一致
|
|
|
+ //pick两个点来计算
|
|
|
let diffLonAve = 0,
|
|
|
diffLons = []
|
|
|
|
|
|
- let panoPos1 = this.player1.model.panos.list.map(e => e.position)
|
|
|
- let panoPos2 = this.player2.model.panos.list.map(e => e.position)
|
|
|
+ /* let panoPos1 = [//4dkk SS-t-lc5OWhZPaC
|
|
|
+ new THREE.Vector3( 2.1985836955069153, -0.7253820937020852, -0.01348725),
|
|
|
+ new THREE.Vector3( 4.07288387528266, 1.8350265362839944, 0.04772775)
|
|
|
+ ] */
|
|
|
+
|
|
|
+ let panoPos1 = this.sourcePano.map(e=>e.position)
|
|
|
+ let panoPos2 = this.targetPano.map(e=>e.position)
|
|
|
+
|
|
|
let length = panoPos1.length
|
|
|
+
|
|
|
+ if(this.needConvertAxis){
|
|
|
+ panoPos1 = panoPos1.map(e=>math.convertVector.YupToZup(e))
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var vec1 = new THREE.Vector3().subVectors(panoPos1[0], panoPos1[1]) //旧的向量
|
|
|
+ var vec2 = new THREE.Vector3().subVectors(panoPos2[0], panoPos2[1])//新的向量
|
|
|
+
|
|
|
+ var angle = math.getAngle(vec1, vec2, 'z')
|
|
|
+
|
|
|
+
|
|
|
+ //var scale = vec2.length()/vec1.length()
|
|
|
+ //var scaleMatrix = new THREE.Matrix4().makeScale(scale,scale,scale) //默认为1, 但由于坐标暂时是自己采集的,所以结果会是第一个点附近比较正确,越远偏差越大
|
|
|
+ var matrix = new THREE.Matrix4().setPosition(panoPos1[0].clone().negate())//先以点0为基准平移到000
|
|
|
+ //matrix.premultiply(scaleMatrix)//再缩放
|
|
|
+ var rotateMatrix = new THREE.Matrix4().makeRotationAxis(new THREE.Vector3(0,0,1), angle );
|
|
|
+ matrix.premultiply(rotateMatrix)//和旋转
|
|
|
+ var moveBackMatrix = new THREE.Matrix4().setPosition(panoPos2[0])
|
|
|
+ matrix.premultiply(moveBackMatrix)//再移动到realPosition的点0处
|
|
|
+
|
|
|
+ //由于是以第一个点来平移,所以只有第一个点看起来最同步,其他点若误差大,飞到这些点时会看到标记不在这个位置上。
|
|
|
+
|
|
|
+ this.convertMatrix = matrix
|
|
|
+ this.convertMatrixInvert = matrix.clone().invert()
|
|
|
+
|
|
|
+ /* var pos = panoPos1.map(e=>{
|
|
|
+ return e.clone().applyMatrix4(matrix)
|
|
|
+ })
|
|
|
+ console.log(pos) */
|
|
|
|
|
|
- //挑选连续的两个点为向量来计算,如有123个漫游点,则选取12 23 31作为向量
|
|
|
|
|
|
- let index = 0
|
|
|
+ //挑选连续的两个点为向量来计算,如有123个漫游点,则选取12 23 31作为向量
|
|
|
+
|
|
|
+ /* let index = 0
|
|
|
while (index < length) {
|
|
|
- let pos11 = new this.KanKan.THREE.Vector3().copy(panoPos1[index])
|
|
|
- let pos12 = new this.KanKan.THREE.Vector3().copy(panoPos1[(index + 1) % length])
|
|
|
- let pos21 = new this.KanKan.THREE.Vector3().copy(panoPos2[index])
|
|
|
- let pos22 = new this.KanKan.THREE.Vector3().copy(panoPos2[(index + 1) % length])
|
|
|
- let vec1 = new this.KanKan.THREE.Vector3().subVectors(pos11, pos12).setY(0)
|
|
|
- let vec2 = new this.KanKan.THREE.Vector3().subVectors(pos21, pos22).setY(0)
|
|
|
- let diffLon = this.KanKan.Utils.math.getAngle(vec1, vec2, 'z')
|
|
|
+ let pos11 = new THREE.Vector3().copy(panoPos1[index])
|
|
|
+ let pos12 = new THREE.Vector3().copy(panoPos1[(index + 1) % length])
|
|
|
+ let pos21 = new THREE.Vector3().copy(panoPos2[index])
|
|
|
+ let pos22 = new THREE.Vector3().copy(panoPos2[(index + 1) % length])
|
|
|
+ let vec1 = new THREE.Vector3().subVectors(pos11, pos12).setZ(0)
|
|
|
+ let vec2 = new THREE.Vector3().subVectors(pos21, pos22).setZ(0)
|
|
|
+ let diffLon = math.getAngle(vec1, vec2, 'z')
|
|
|
diffLons.push(diffLon)
|
|
|
diffLonAve += diffLon
|
|
|
index++
|
|
@@ -62,10 +252,278 @@ export default class ConvertViews {
|
|
|
console.log('diffLons', diffLons)
|
|
|
diffLonAve /= length
|
|
|
console.log('diffLonAve', diffLonAve)
|
|
|
- return /* KanKan.THREE.MathUtils.radToDeg( */ diffLonAve /* ) */
|
|
|
+
|
|
|
+ this.diffQuaternion = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0, 1, 0), diffLonAve)
|
|
|
+ this.diffQuaternionInvert = this.diffQuaternion.clone().invert() */
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ bindCamEvent(){//传递到另一边的dom
|
|
|
+ this.lockCamera(true)
|
|
|
+
|
|
|
+
|
|
|
+ /* this.viewer.addEventListener( Bimface.Viewer.Viewer3DEvent.MouseClicked,(e)=>{
|
|
|
+ console.log('MouseClicked',e)
|
|
|
+ }); */
|
|
|
+
|
|
|
+
|
|
|
+ let getEvent = (type, e)=>{
|
|
|
+ let dom = this.viewer.getDomElement()
|
|
|
+ let clientWidth1 = this.sourceDom.clientWidth
|
|
|
+ let clientHeight1 = this.sourceDom.clientHeight
|
|
|
+ let clientWidth2 = dom.clientWidth
|
|
|
+ let clientHeight2 = dom.clientHeight
|
|
|
+ return new MouseEvent(type, {
|
|
|
+ bubbles: false,//?
|
|
|
+ cancelable: true,
|
|
|
+ view: this.sourceApp,
|
|
|
+
|
|
|
+ /* clientX: e.clientX,
|
|
|
+ clientY: e.clientY, */
|
|
|
+ clientX: clientWidth1 * e.clientX / clientWidth2 , //鼠标在右屏的比例的左屏的相同,针对右屏全屏等左右不对称的情况
|
|
|
+ clientY: clientHeight1 * e.clientY / clientHeight2,
|
|
|
+ button: e.button, buttons: e.buttons, which: e.which,
|
|
|
+ altKey: e.altKey, ctrlKey: e.ctrlKey, shiftKey:e.shiftKey, metaKey: e.metaKey,
|
|
|
+ detail:e.detail,
|
|
|
+ //target : dom2
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ let dom1 = this.viewer.getDomElement()
|
|
|
+ //let pointerDownPos = new THREE.Vector2
|
|
|
+ dom1.addEventListener('mousedown',(e)=>{
|
|
|
+ if(this.synPaused || !this.sourceApp)return
|
|
|
+ let event = getEvent('mousedown', e)
|
|
|
+ this.sourceDom.dispatchEvent(event)
|
|
|
+ //pointerDownPos.set(e.clientX,e.clientY)
|
|
|
+ })
|
|
|
+ dom1.addEventListener('mousemove',(e)=>{
|
|
|
+ if(this.synPaused || !this.sourceApp)return
|
|
|
+ let event = getEvent('mousemove', e)
|
|
|
+ this.sourceDom.dispatchEvent(event)
|
|
|
+ })
|
|
|
+ dom1.addEventListener('mouseup',(e)=>{
|
|
|
+ if(this.synPaused || !this.sourceApp)return
|
|
|
+ let event = getEvent('mouseup', e)
|
|
|
+ event.unableClick = true //最好禁止右侧点击行走。否则和点击效果冲突
|
|
|
+ this.sourceApp.dispatchEvent(event) //mouseup 在laser中加在window上的
|
|
|
+ })
|
|
|
+ dom1.addEventListener('mousewheel',(e)=>{
|
|
|
+ if(this.synPaused || !this.sourceApp)return
|
|
|
+ let event = getEvent('mousewheel', e)
|
|
|
+ event.wheelDelta = e.wheelDelta //wheelDelta没法在getEvent参数中赋值
|
|
|
+ this.sourceDom.dispatchEvent(event)
|
|
|
+ })
|
|
|
+ let stop = (e)=>{ //drag到另一边时停止旋转, 防止转到另一边
|
|
|
+ if(/* this.synPaused || */ !this.sourceApp)return
|
|
|
+ let event = getEvent('mouseup', e)
|
|
|
+ this.sourceApp.dispatchEvent(event)
|
|
|
+ }
|
|
|
+ dom1.addEventListener('mouseout',stop)
|
|
|
+ dom1.addEventListener('mouseover',stop)
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ lockCamera(locked){//禁止操作改变相机
|
|
|
+ this.locked = locked
|
|
|
+ this.updateCtrlEnable()
|
|
|
+ }
|
|
|
+
|
|
|
+ setPanoMode(state){
|
|
|
+ this.isPanoMode = state
|
|
|
+ this.updateCtrlEnable()
|
|
|
+ }
|
|
|
+
|
|
|
+ updateCtrlEnable(){
|
|
|
+ this.viewer.camera3D.enableRotate(this.locked ? false : true)
|
|
|
+ this.viewer.enableShortcutKey((this.locked || this.isPanoMode) ? false : true) //键盘移动
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ createPanoPannel(){//修改对照pano,左侧修改选择的pano,右边修改对应的具体位置
|
|
|
+ let that = this
|
|
|
+
|
|
|
+ let createPannel = (mainIndex)=>{
|
|
|
+ let pannel = document.createElement('div')
|
|
|
+ pannel.style.top = 0
|
|
|
+ pannel.style.left = mainIndex == 0 ? 0 : "50%"
|
|
|
+ pannel.style.position = 'fixed';
|
|
|
+ pannel.style.background = 'rgba(255,255,255,0.9)';
|
|
|
+ pannel.style.color = 'black'
|
|
|
+ pannel.style['text-align'] = 'center'
|
|
|
+
|
|
|
+ let createRow = function(index){
|
|
|
+ let row = document.createElement('div')
|
|
|
+ let btnStr = mainIndex == 0 ? '选取当前漫游点' : '点击解锁'
|
|
|
+ row.innerHTML = `<div>pano${index}</div> <div name="state" style="width:100px"></div><div name="pick">${btnStr}</div> `
|
|
|
+ row.style.height = row.style['lineHeight'] = '30px';
|
|
|
+ row.style.display = 'flex'
|
|
|
+
|
|
|
+ row.children[2].style.cursor = 'pointer'
|
|
|
+ row.children[2].addEventListener('click',()=>{
|
|
|
+ if(mainIndex == 0){//左侧
|
|
|
+ //let another = this.sourcePano[(index+1)%2]
|
|
|
+ let curr = that.sourceApp.viewer.images360.currentPano
|
|
|
+ if(that.sourcePano[0] == curr || that.sourcePano[1] == curr){
|
|
|
+ return console.error('已经选择过当前点')
|
|
|
+ }
|
|
|
+ let sprite = that.sourcePano[index].sprite
|
|
|
+ that.sourcePano[index] = curr
|
|
|
+ that.sourcePano[index].sprite = sprite
|
|
|
+ sprite.position.copy(curr.position)
|
|
|
+ sprite.position.z -= belowHeight
|
|
|
+ sprite.update()
|
|
|
+ }else{//右侧
|
|
|
+ if(that.synPaused){
|
|
|
+ that.dispatchEvent({type:'addTag', index})
|
|
|
+ that.lockCamera(true)
|
|
|
+ changeWords('点击解锁')
|
|
|
+ }else{
|
|
|
+ that.synPaused = true;
|
|
|
+ that.lockCamera(false)
|
|
|
+ changeWords('点击使用此相机点作为漫游点')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ return row
|
|
|
+ }
|
|
|
+
|
|
|
+ let row0 = createRow(0)
|
|
|
+ let row1 = createRow(1)
|
|
|
+
|
|
|
+ let changeWords = function(words){
|
|
|
+ row0.children[2].innerText = words
|
|
|
+ row1.children[2].innerText = words
|
|
|
+ }
|
|
|
+ if(mainIndex == 0){
|
|
|
+ this.addEventListener('updateBtnState',()=>{
|
|
|
+ let opacity = this.sourceApp.viewer.images360.isAtPano() ? 1 : 0.5;
|
|
|
+ [row0,row1].forEach(row=>{
|
|
|
+ row.children[2].style.opacity = opacity
|
|
|
+ row.children[2].style.opacity = opacity
|
|
|
+ row.children[2].style['pointer-events'] = opacity == 1 ? 'auto' : 'none'
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ pannel.appendChild(row0)
|
|
|
+ pannel.appendChild(row1)
|
|
|
+
|
|
|
+
|
|
|
+ document.getElementById('app').appendChild(pannel);
|
|
|
+ return pannel
|
|
|
+ }
|
|
|
+
|
|
|
+ this.pannels = [createPannel(0),createPannel(1)]
|
|
|
+
|
|
|
+ this.initTagAdd()
|
|
|
+ this.sourcePano.forEach((pano,i)=>{
|
|
|
+ let sprite = this.sourceApp.viewer.addSprite({text:i})
|
|
|
+ sprite.position.copy(pano.position)
|
|
|
+ sprite.position.z -= belowHeight
|
|
|
+ this.sourceApp.viewer.scene.scene.add(sprite)
|
|
|
+ sprite.scale.set(0.4,0.4,0.4)
|
|
|
+ pano.sprite = sprite
|
|
|
+ })
|
|
|
+ this.targetPano.forEach((pano,index)=>{
|
|
|
+ that.dispatchEvent({type:'addTag', position:pano.position, index})
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ updatePanoMatch(position, index ){//更新且应用
|
|
|
+ if(this.targetPano.length == 2){
|
|
|
+ this.targetPano[index].position = position
|
|
|
+ this.computeShift()
|
|
|
+ this.synPaused = false
|
|
|
+ this.dispatchEvent({type:'needsSyn' })//使发送同步
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ initTagAdd(){
|
|
|
+ let markerConfig = new Bimface.Plugins.Marker3D.Marker3DContainerConfig();
|
|
|
+ markerConfig.viewer = this.viewer;
|
|
|
+ let tags = new Bimface.Plugins.Marker3D.Marker3DContainer(markerConfig);
|
|
|
+ console.log('tags',tags)
|
|
|
+
|
|
|
+ this.addEventListener('addTag',(e)=>{
|
|
|
+ if(this.targetPano[e.index].tag){
|
|
|
+ tags.removeItemById(this.targetPano[e.index].tag.id)
|
|
|
+ }
|
|
|
+ let position = new THREE.Vector3
|
|
|
+ if(e.position){
|
|
|
+ position.copy(e.position)
|
|
|
+ }else{
|
|
|
+ let currStatus = this.viewer.getCameraStatus()
|
|
|
+ position.copy(currStatus.position)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let marker3dConfig = new Bimface.Plugins.Marker3D.Marker3DConfig();
|
|
|
+
|
|
|
+ marker3dConfig.src = 'images/hotpoint'+ e.index +'.png'//"http://static.bimface.com/resources/3DMarker/warner/warner_red.png";
|
|
|
+
|
|
|
+ marker3dConfig.worldPosition = new THREE.Vector3().copy(position)
|
|
|
+ marker3dConfig.worldPosition.z -= belowHeight
|
|
|
+ marker3dConfig.tooltip = '此为漫游点'+e.index //三维标签的提示
|
|
|
+ let tag = new Bimface.Plugins.Marker3D.Marker3D(marker3dConfig);
|
|
|
+ tags.addItem(tag);
|
|
|
+ this.viewer.clearSelectedComponents();
|
|
|
+ this.viewer.render();
|
|
|
+ this.targetPano[e.index].tag = tag
|
|
|
+ this.updatePanoMatch(position, e.index )
|
|
|
+ })
|
|
|
+ /* this.viewer.addEventListener( Bimface.Viewer.Viewer3DEvent.MouseClicked, (objectData)=>{
|
|
|
+
|
|
|
+ if(window.forbitAddTag )return
|
|
|
+ let position = objectData.worldPosition.clone().add({x:0,y:0,z:height});
|
|
|
+ let marker3dConfig = new Bimface.Plugins.Marker3D.Marker3DConfig();
|
|
|
+
|
|
|
+ marker3dConfig.src = "http://static.bimface.com/resources/3DMarker/warner/warner_red.png";
|
|
|
+
|
|
|
+ marker3dConfig.worldPosition = position;
|
|
|
+ //三维标签的提示
|
|
|
+ marker3dConfig.tooltip = "This is 3DMarker.";
|
|
|
+ let marker3d = new Bimface.Plugins.Marker3D.Marker3D(marker3dConfig);
|
|
|
+ marker3d.onClick(function (item) {
|
|
|
+
|
|
|
+ })
|
|
|
+ marker.addItem(marker3d);
|
|
|
+ this.viewer.clearSelectedComponents();
|
|
|
+ this.viewer.render();
|
|
|
+
|
|
|
+ }); */
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /* addMesh(cameraData){
|
|
|
+
|
|
|
+ var mesh = new Bimface.Plugins.Geometry.Plane({
|
|
|
+ type:'rectangle', points:[{x:-0.1,y:-0.1,z:0},{x:0.1,y:0.1,z:0}]
|
|
|
+ });
|
|
|
+
|
|
|
+ var extObjMng = new Bimface.Plugins.ExternalObject.ExternalObjectManager(viewer2);
|
|
|
+ extObjMng.loadObject({ name: 'plane', object: mesh});//作为外部构件添加到场景中
|
|
|
+
|
|
|
+ //mesh.children[0].position.copy(cameraData.position).setZ(0.5)
|
|
|
+ mesh.children[0].up.set(0,0,1)
|
|
|
+ mesh.children[0].rotation.set(0,0,Math.PI/2)
|
|
|
+
|
|
|
+ this.plane = mesh
|
|
|
+ window.extObjMng = extObjMng
|
|
|
+
|
|
|
+
|
|
|
+ } */
|
|
|
|
|
|
- applyDiff(app) {
|
|
|
+ /* applyDiff(app) {
|
|
|
//sourcePlayer -> targetPlayer
|
|
|
if (!this.player1 || !this.player2 || this.targetApp.config.num == this.sourceApp.config.num) return //场景码相同的话返回
|
|
|
if (this.player1.mode != this.player2.mode) return
|
|
@@ -103,14 +561,14 @@ export default class ConvertViews {
|
|
|
control1.target.addVectors(player1.model.panos.list[0].position, vec)
|
|
|
player1.target.copy(control1.target)
|
|
|
//修改position,保证方向一样
|
|
|
- let dir = new this.KanKan.THREE.Vector3().subVectors(control2.camera.position /* player2.position */, control2.target)
|
|
|
+ let dir = new this.KanKan.THREE.Vector3().subVectors(control2.camera.position , control2.target)
|
|
|
dir.applyQuaternion(quaternion)
|
|
|
player1.position = new this.KanKan.THREE.Vector3().addVectors(control1.target, dir)
|
|
|
|
|
|
control1.camera.position.copy(player1.position)
|
|
|
}
|
|
|
control1.camera.quaternion.copy(player1.quaternion)
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
/* applyDiff(app, data) {
|
|
|
//sourcePlayer -> targetPlayer
|
|
@@ -147,3 +605,16 @@ export default class ConvertViews {
|
|
|
//位置参照第一个漫游点。保持相机相对第一个漫游点的位移和
|
|
|
} */
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+/*
|
|
|
+
|
|
|
+note:
|
|
|
+
|
|
|
+
|
|
|
+旋转只能通过target设置, 不能直接改camera.quaternion
|
|
|
+当且仅当发送方相机属性变化后才传递过来,就不在这里判断是否变化了。
|
|
|
+(所以只需要实时检测相机是否改变, hasChanged后发送)
|
|
|
+
|
|
|
+ */
|