|
@@ -201,7 +201,12 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
updateMap()
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+ viewer.addEventListener('shelterComputed', (e)=>{
|
|
|
+ //console.log('shelterComputed')
|
|
|
+ var camera = viewer.mainViewport.camera
|
|
|
+ var pos = camera.position
|
|
|
+ sceneBus.emit('cameraChange', { x: pos.x, y: pos.y, z: pos.z, rotate: camera.rotation })
|
|
|
+ })
|
|
|
|
|
|
//-------------------------------------
|
|
|
let modelAinB = (A,B)=>{ //B的expand(5m) bound完全包含A
|
|
@@ -736,7 +741,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
if(r){
|
|
|
requestShowPano = true
|
|
|
}else{
|
|
|
- if(!o.noViewSaved){
|
|
|
+ if(!o.noViewSaved && (o.position || o.panoId != void 0)){
|
|
|
return fly() //使用保存的视角
|
|
|
}
|
|
|
Potree.settings.displayMode = 'showPointCloud'
|
|
@@ -1154,11 +1159,21 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
let {x,y} = Potree.Utils.getPointerPosAtHeight(model.bound.min.z, pointer)
|
|
|
pos3d = new THREE.Vector3(x,y, model.bound.min.z)
|
|
|
}
|
|
|
-
|
|
|
+ MergeEditor.history.beforeChange(model)
|
|
|
MergeEditor.moveBoundCenterTo(model, pos3d) //使模型中心的xy在鼠标所在位置
|
|
|
- model.position.z += model.boundSize.z / 2
|
|
|
+ model.position.z += model.boundSize.z / 2
|
|
|
+ model.dispatchEvent({type:"position_changed", byControl:true}) //compute bound and emit
|
|
|
+ MergeEditor.history.afterChange(model)
|
|
|
+ },
|
|
|
+
|
|
|
+ putInFrontOfCam(){//首次加载放在面前,高度和相机一致。(但不保证会不会被遮挡)
|
|
|
+ let size = Math.max(1, new THREE.Vector2().copy(model.boundSize).length() * 0.7 )
|
|
|
+ let vec = viewer.mainViewport.view.direction.clone().setZ(0).multiplyScalar(size)
|
|
|
+ let pos = new THREE.Vector3().addVectors(viewer.mainViewport.view.position, vec)
|
|
|
+ MergeEditor.moveBoundCenterTo(model, pos)
|
|
|
model.dispatchEvent({type:"position_changed", byControl:true})
|
|
|
},
|
|
|
+
|
|
|
|
|
|
changeShow(show) {
|
|
|
props.show = show //for autoLoads show model
|
|
@@ -1171,8 +1186,10 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
},
|
|
|
changeSelect(state) {
|
|
|
//console.error('select', state)
|
|
|
- if (model) {
|
|
|
- let focus = true //viewer.images360.latestRequestMode != 'showPanos'
|
|
|
+ if (model) {
|
|
|
+ //window.test111 && result.putInFrontOfCam()
|
|
|
+
|
|
|
+ let focus = !(viewer.images360.currentPano.pointcloud == model && viewer.images360.isAtPano()) //viewer.images360.latestRequestMode != 'showPanos' //防止因走到漫游点后我发送panoModelChange后执行这个又飞了
|
|
|
MergeEditor.selectModel(model, state, focus, true)
|
|
|
updateCamNear()
|
|
|
|
|
@@ -1679,22 +1696,28 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
getCurrentSubtitlePixel({width , height}){// 获取当前模型字幕出现的适合位置,传入旁边dom的宽高,返回像素位置
|
|
|
|
|
|
if(!model.visible)return null
|
|
|
+
|
|
|
+ let boundPoints = Potree.Common.getBoundPoints(model.boundingBox)
|
|
|
+ boundPoints.forEach(e=>{
|
|
|
+ e.applyMatrix4(model.matrixWorld)
|
|
|
+ e.pos2d = Potree.Utils.getPos2d(e, viewer.mainViewport , viewer.renderArea, viewer.renderer )
|
|
|
+ })
|
|
|
+ boundPoints = boundPoints.filter(e=>e.pos2d.inSight && e.pos2d.trueSide )
|
|
|
+ if(boundPoints.length == 0)return
|
|
|
// let startTime = performance.now()
|
|
|
- let bound = model.boundingBox
|
|
|
- let boundPoints = [
|
|
|
- new THREE.Vector3(bound.min.x, bound.min.y, bound.min.z ),
|
|
|
- new THREE.Vector3(bound.min.x, bound.min.y, bound.max.z ),
|
|
|
- new THREE.Vector3(bound.min.x, bound.max.y, bound.min.z ),
|
|
|
- new THREE.Vector3(bound.max.x, bound.min.y, bound.min.z ),
|
|
|
- new THREE.Vector3(bound.max.x, bound.max.y, bound.min.z ),
|
|
|
- new THREE.Vector3(bound.max.x, bound.min.y, bound.max.z ),
|
|
|
- new THREE.Vector3(bound.min.x, bound.max.y, bound.max.z ),
|
|
|
- new THREE.Vector3(bound.max.x, bound.max.y, bound.max.z ),
|
|
|
- ];
|
|
|
- let pos2ds = boundPoints.map((point)=>{
|
|
|
- return Potree.Utils.getPos2d(point.applyMatrix4(model.matrixWorld), viewer.mainViewport , viewer.renderArea, viewer.renderer )
|
|
|
+ {//判断遮挡 暂时计算全部八个顶点,以后再改。如延时(不过ifPointBlockedByIntersect本身就有延迟,每帧计算一点点),每帧判断不同的点,直到全部顶点都算完都被遮挡了才隐藏。且如果离得很远,pos2d像素差距很小的话,只判断中心点即可。
|
|
|
+ //let boundingBox = model.boundingBox.
|
|
|
+ let boundPointsShrink = [...boundPoints] //Potree.Common.getBoundPoints(boundingBox) 先用这个测试
|
|
|
+ let visi = boundPointsShrink.some(p=>!viewer.ifPointBlockedByIntersect( p )) //viewer.addEventListener('shelterComputed')
|
|
|
+ if(!visi)return console.log('被遮挡')
|
|
|
+ }
|
|
|
+ //console.log('getCurrentSubtitlePixel')
|
|
|
+
|
|
|
+ /* let pos2ds = boundPoints.map((point)=>{
|
|
|
+ return Potree.Utils.getPos2d(point, viewer.mainViewport , viewer.renderArea, viewer.renderer )
|
|
|
}).filter(e=>e.inSight && e.trueSide )
|
|
|
- if(pos2ds.length == 0)return
|
|
|
+ if(pos2ds.length == 0)return */
|
|
|
+ let pos2ds = boundPoints.map(e=>e.pos2d)
|
|
|
|
|
|
pos2ds.sort((a,b)=>{return a.vector.y - b.vector.y})
|
|
|
let top = pos2ds[0], btm = pos2ds[pos2ds.length - 1]
|
|
@@ -1714,6 +1737,9 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
}else{
|
|
|
x = right.pos.x + margin
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//console.log('获取字幕位置', performance.now() - startTime )
|
|
|
return {x,y}
|
|
|
},
|
|
@@ -1730,6 +1756,14 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
|
|
|
},
|
|
|
|
|
|
+ enterEditPannel(){
|
|
|
+ MergeEditor.history.clear() //清除普通模型的
|
|
|
+ },
|
|
|
+ exitEditPannel(){
|
|
|
+ MergeEditor.history.clear() //清除动画模型的
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2211,7 +2245,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
|
|
|
if(!tag.parent)return new THREE.Vector3
|
|
|
tag.titleLabel.sprite.update()
|
|
|
let pos = tag.onMesh ? tag.position : tag.titleLabel.parent.position.clone().applyMatrix4(tag.matrixWorld).applyMatrix4(tag.root.matrixWorld.clone().invert())
|
|
|
- console.log(props.title, 'getImageCenter', pos.toArray(), tag.lineLength)
|
|
|
+ //console.log(props.title, 'getImageCenter', pos.toArray(), tag.lineLength)
|
|
|
return pos
|
|
|
|
|
|
},
|