|
@@ -14,8 +14,8 @@ import DepthBasicMaterial from "../../materials/DepthBasicMaterial.js";
|
|
|
import {BoxVolume} from '../../../utils/VolumeNew.js'
|
|
|
|
|
|
|
|
|
-let clickPanoToDisLink = false;//是否在编辑漫游点连接时,通过点击漫游点能断开连接
|
|
|
-let images360, Alignment, SiteModel
|
|
|
+const clickPanoToDisLink = false;//是否在编辑漫游点连接时,通过点击漫游点能断开连接
|
|
|
+let images360, Alignment, SiteModel, suggestCircleMat
|
|
|
|
|
|
const texLoader = new THREE.TextureLoader()
|
|
|
texLoader.crossOrigin = "anonymous"
|
|
@@ -23,6 +23,7 @@ const rotQua = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3(0,0,1),
|
|
|
const lineMats = {}
|
|
|
const circleMats = {}
|
|
|
|
|
|
+
|
|
|
const renderOrders = {
|
|
|
circleSelected:3,
|
|
|
circle:2,
|
|
@@ -72,7 +73,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
|
|
|
constructor(){
|
|
|
super()
|
|
|
- this.panoGroup = [], //分组
|
|
|
+ this.panoGroup = [], //分组
|
|
|
this.viewports = {},
|
|
|
this.panoLink = {},
|
|
|
this.panoMeshs = new THREE.Object3D,
|
|
@@ -85,6 +86,8 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.selectedGroup;
|
|
|
this.operation;
|
|
|
this.visiblePanos = []
|
|
|
+
|
|
|
+ this.suggestLines = []
|
|
|
}
|
|
|
|
|
|
init(){
|
|
@@ -106,10 +109,18 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
lineWidth: 3,
|
|
|
depthTest:false
|
|
|
})
|
|
|
-
|
|
|
+ lineMats.suggestLink = LineDraw.createFatLineMat({
|
|
|
+ color: '#ff2222',
|
|
|
+ lineWidth: 4, dashed:true,
|
|
|
+ depthTest:false
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ suggestCircleMat = new THREE.MeshBasicMaterial({
|
|
|
+ map: texLoader.load(Potree.resourcePath+'/textures/whiteCircle.png' ) ,
|
|
|
+ color:'#ff2222', transparent:true,
|
|
|
+ depthTest:false, depthWrite:false
|
|
|
+ })
|
|
|
|
|
|
this.initViews()
|
|
|
|
|
@@ -285,7 +296,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
} */
|
|
|
|
|
|
{//连接时的辅助线
|
|
|
- this.linkGuideLine = LineDraw.createLine([], {color:'#aaa', deshed:true, dashSize:0.1,gapSize:0.1,})
|
|
|
+ this.linkGuideLine = LineDraw.createLine([], {color:'#ddd', deshed:true, dashSize:0.1,gapSize:0.05, depthTest:false})
|
|
|
this.linkGuideLine.visible = false
|
|
|
this.linkGuideLine.name = 'linkGuideLine'
|
|
|
viewer.scene.scene.add(this.linkGuideLine)
|
|
@@ -298,21 +309,22 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
if(this.activeViewName == 'top' ){
|
|
|
endPos = e.intersect.orthoIntersect.clone().setZ(this.selectedPano.position.z)
|
|
|
}else if(this.activeViewName == 'mainView' ){
|
|
|
- if(!e.intersect.point)return
|
|
|
+ if(!e.intersect || !e.intersect.point)return
|
|
|
endPos = e.intersect.point.position
|
|
|
}
|
|
|
|
|
|
LineDraw.updateLine(this.linkGuideLine, [this.selectedPano.position, endPos] )
|
|
|
this.linkGuideLine.visible = true
|
|
|
+
|
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
|
|
|
|
- viewer.addEventListener('global_mousemove', (e)=>{
|
|
|
+ viewer.addEventListener('global_mousemove', (e)=>{
|
|
|
update(e)
|
|
|
})
|
|
|
|
|
|
- this.addEventListener('updateLinkGuideLine', update)
|
|
|
- //为何打开调试时移动很卡
|
|
|
+ //this.addEventListener('updateLinkGuideLine', update)
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/*
|
|
@@ -323,7 +335,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.setTranMode('translate')
|
|
|
}
|
|
|
}) */
|
|
|
- {
|
|
|
+ /* {
|
|
|
viewer.addEventListener('camera_changed', (e)=>{
|
|
|
Common.intervalTool.isWaiting('updatePointLevels', ()=>{
|
|
|
this.updatePointLevels()
|
|
@@ -333,7 +345,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
setTimeout(()=>{
|
|
|
this.updatePointLevels()
|
|
|
}, viewer.scene.pointclouds.length*150) //等待差不多updat出了正确的visibleNode时
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
|
|
|
|
|
@@ -353,6 +365,13 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
}else{
|
|
|
Alignment.switchHandle(mode)
|
|
|
}
|
|
|
+ this.updateIntersectEnable()
|
|
|
+ }
|
|
|
+
|
|
|
+ updateIntersectEnable(){
|
|
|
+ //侧面容易因intersect卡住, 如果非必要关闭intersect. 3d页面也会卡,但controls需要所以不能去掉
|
|
|
+ Potree.settings.intersectWhenHover = !!(this.activeViewName == 'mainView' || this.selectedPano && this.tranMode )
|
|
|
+
|
|
|
}
|
|
|
|
|
|
updateTranCtl(){// 设置3D页面的transformControls相关
|
|
@@ -386,7 +405,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
let view = new ExtendView()
|
|
|
this.views[prop.name] = view
|
|
|
this.cameras[prop.name] = this.orthoCamera
|
|
|
-
|
|
|
+ view.name = prop.name
|
|
|
view.direction = prop.direction
|
|
|
}
|
|
|
this.views.mainView = viewer.mainViewport.view
|
|
@@ -574,9 +593,9 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.updateTranCtl()
|
|
|
this.setTranMode(this.tranMode) // update
|
|
|
this.setZoomInState(false) //取消放大模式
|
|
|
- this.updatePointLevels()
|
|
|
+ //this.updatePointLevels()
|
|
|
|
|
|
-
|
|
|
+ this.updateIntersectEnable()
|
|
|
|
|
|
prop.openCount ++;
|
|
|
}
|
|
@@ -728,13 +747,13 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
|
|
|
informBy2d || this.dispatchEvent({type:"switchPanoVisible", pano, v})
|
|
|
|
|
|
- {
|
|
|
+ /* {
|
|
|
setTimeout(()=>{
|
|
|
Common.intervalTool.isWaiting('updatePointLevels2', ()=>{
|
|
|
this.updatePointLevels()
|
|
|
}, 50)
|
|
|
},1)//等update过visibleNodes
|
|
|
- }
|
|
|
+ } */
|
|
|
}
|
|
|
|
|
|
|
|
@@ -830,6 +849,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
initPanoLink(){
|
|
|
images360.panos.forEach((pano)=>{
|
|
|
this.panoLink[pano.id] = {}
|
|
|
+ this.panoGroup.push([pano])
|
|
|
})
|
|
|
|
|
|
images360.panos.forEach((pano)=>{
|
|
@@ -840,42 +860,8 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
|
|
|
//console.log('panoLink',this.panoLink)
|
|
|
}
|
|
|
-
|
|
|
|
|
|
-
|
|
|
- groupChange(pano0, pano1, type){//修改group (type == 'remove'时,pano1可以为空)
|
|
|
- if(type == 'add'){
|
|
|
- Common.pushToGroupAuto([pano0, pano1], this.panoGroup )
|
|
|
- }else{
|
|
|
- let atGroup = this.panoGroup.find(e=>e.includes(pano0) && (e.includes(pano1) || !pano1));//所在组
|
|
|
-
|
|
|
- if(!atGroup){
|
|
|
- if(pano1){
|
|
|
- console.log('这两个pano原本就不在一个组', pano0.id, pano1.id)
|
|
|
- }else{
|
|
|
- console.log('pano0不在任何组', pano0)
|
|
|
- }
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- //断开连接时,因为组内没有其他成员的连接信息,所以需要清除整组,并将剩余的一个个重新连接
|
|
|
- this.panoGroup.splice(this.panoGroup.indexOf(atGroup),1) //删除
|
|
|
-
|
|
|
-
|
|
|
- atGroup.forEach(pano=>{//然后再重新生成这两个和组的关系,各自分组
|
|
|
- if(pano == pano0 || pano == pano1)return
|
|
|
- for(let id in this.panoLink[pano.id]){
|
|
|
- if(this.panoLink[pano.id][id]){
|
|
|
- let pano_ = images360.getPano(id)
|
|
|
- Common.pushToGroupAuto([pano, pano_], this.panoGroup )
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
linkChange(pano0, pano1, type){//修改link (type == 'remove'时,pano1可以为空)
|
|
|
|
|
@@ -915,12 +901,13 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.selectPano(this.selectedPano, false,true) //更新选中点云显示
|
|
|
}
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
lineChange(pano0, pano1, type){//修改line
|
|
|
if(type == 'add'){
|
|
|
if(this.panoLink[pano0.id][pano1.id].line) return
|
|
|
- let line = LineDraw.createFatLine([pano0.position, pano1.position], {material:lineMats.default})
|
|
|
+ let line = LineDraw.createFatLine([pano0.position, pano1.position], {mat:lineMats.default})
|
|
|
line.name = `${pano0.id}-${pano1.id}`
|
|
|
line.renderOrder = line.pickOrder = renderOrders.line
|
|
|
this.lineMeshes.add(line)
|
|
@@ -965,6 +952,39 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
|
|
|
|
|
|
|
|
|
+ groupChange(pano0, pano1, type){//修改group (type == 'remove'时,pano1可以为空)
|
|
|
+ if(type == 'add'){
|
|
|
+ Common.pushToGroupAuto([pano0, pano1], this.panoGroup )
|
|
|
+ }else{
|
|
|
+ let atGroup = this.panoGroup.find(e=>e.includes(pano0) && (e.includes(pano1) || !pano1));//所在组
|
|
|
+
|
|
|
+ if(!atGroup){
|
|
|
+ if(pano1){
|
|
|
+ console.log('这两个pano原本就不在一个组', pano0.id, pano1.id)
|
|
|
+ }else{
|
|
|
+ console.log('pano0不在任何组', pano0)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ //断开连接时,因为组内没有其他成员的连接信息,所以需要清除整组,并将剩余的一个个重新连接
|
|
|
+ this.panoGroup.splice(this.panoGroup.indexOf(atGroup),1) //删除
|
|
|
+
|
|
|
+
|
|
|
+ atGroup.forEach(pano=>{//然后再重新生成这两个和组的关系,各自分组
|
|
|
+ this.panoGroup.push([pano])
|
|
|
+ for(let id in this.panoLink[pano.id]){
|
|
|
+ if(this.panoLink[pano.id][id]){
|
|
|
+ let pano_ = images360.getPano(id)
|
|
|
+ Common.pushToGroupAuto([pano, pano_], this.panoGroup )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
selectLine(line){
|
|
|
if(this.selectedLine == line)return
|
|
@@ -1027,6 +1047,8 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
circleMats.hovered_rtk_off.useDepth = false
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
let setPos = (circle)=>{
|
|
|
circle.position.copy(circle.pano.position)
|
|
@@ -1198,7 +1220,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
|
|
|
- {//自动切换楼层
|
|
|
+ if(this.currentFloor != 'all'){//如果原本不是展示全部楼层的话,自动切换楼层
|
|
|
|
|
|
let atFloor = SiteModel.entities.find(e=>e.buildType == 'floor' && e.panos.includes(pano))
|
|
|
if(!atFloor){
|
|
@@ -1237,19 +1259,19 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.dispatchEvent({type:'panoSelect', pano })
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ this.updateIntersectEnable()
|
|
|
viewer.dispatchEvent('content_changed')
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- updatePointLevels(){
|
|
|
+ /* updatePointLevels(){
|
|
|
if(this.pauseUpdateLevels)return
|
|
|
let maxBudget = Potree.config.pointDensity.panoEdit.pointBudget
|
|
|
let visiCount1 = viewer.scene.pointclouds.filter(e=>e.visible).length
|
|
|
let visiCount2 = viewer.scene.pointclouds.filter(e=>e.visibleNodes.length>0).length //屏幕范围内可见的个数
|
|
|
- let maxCount = 200, minCount = 1, minPer = 0.45/* 0.4 */, maxPer = 1
|
|
|
+ let maxCount = 200, minCount = 1, minPer = 0.45 , maxPer = 1
|
|
|
let percent1 = maxPer - ( maxPer - minPer) * THREE.Math.clamp((visiCount1 - minCount) / (maxCount - minCount),0,1)
|
|
|
let percent2 = maxPer - ( maxPer - minPer) * THREE.Math.clamp((visiCount2 - minCount) / (maxCount - minCount),0,1)
|
|
|
let percent = percent1*percent2
|
|
@@ -1270,7 +1292,7 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
viewer.setPointLevels()
|
|
|
//侧面容易卡顿,但和显示的点数无关,似乎是因加载点云多而卡?为何正面不会
|
|
|
//console.warn('setPointBudget', Potree.pointBudget, visiCount1,visiCount2, Potree.settings.UserDensityPercent)
|
|
|
- }
|
|
|
+ } */
|
|
|
|
|
|
getPanoRtkState(pano){
|
|
|
return pano.panosData.has_rtk ? pano.rtkState ? 'rtk_on' : 'rtk_off' : 'normal'
|
|
@@ -1287,7 +1309,8 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
this.selectedGroup = [this.selectedPano, ...this.selectedGroup.filter(e=>e != this.selectedPano)];//将选中的放第一个,便于旋转时绕其旋转。
|
|
|
}
|
|
|
|
|
|
- this.selectedClouds = this.selectedPano ? (this.selectedGroup || [this.selectedPano]).map(e=>e.pointcloud) : []
|
|
|
+ //this.selectedClouds = this.selectedPano ? (this.selectedGroup || [this.selectedPano]).map(e=>e.pointcloud) : []
|
|
|
+ this.selectedClouds = this.selectedPano ? this.selectedGroup.map(e=>e.pointcloud) : []
|
|
|
|
|
|
|
|
|
}
|
|
@@ -1325,7 +1348,68 @@ class PanoEditor extends THREE.EventDispatcher{
|
|
|
return panos.length == group.length
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ getSuggestLinkPanos(){//给出建议连接的点
|
|
|
+ let panos = [];
|
|
|
+ let startTime = Date.now()
|
|
|
+ for(let datasetId in Potree.settings.datasetsPanos ) {
|
|
|
+ if(!this.checkIfAllLinked({datasetId})){
|
|
|
+ let groups = this.panoGroup.filter(panos=>panos[0].pointcloud.dataset_id == datasetId )
|
|
|
+ groups = groups.sort((a,b)=>{return b.length - a.length})//找出个数最多的一组来连接其他组
|
|
|
+
|
|
|
+ let mainGroup = groups[0].slice(), subGroup;
|
|
|
+
|
|
|
+ for(let i=1,len=groups.length;i<len;i++){
|
|
|
+ subGroup = groups[i]
|
|
|
+
|
|
|
+ let minDis = {dis:Infinity, panos:[]}
|
|
|
+ for(let a=0, len1=mainGroup.length; a<len1; a++){
|
|
|
+ for(let b=0, len2=subGroup.length; b<len2; b++){
|
|
|
+
|
|
|
+ let dis = mainGroup[a].position.distanceToSquared(subGroup[b].position)
|
|
|
+ if(dis<minDis.dis){
|
|
|
+ minDis.dis = dis; minDis.panos = [mainGroup[a], subGroup[b]]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ panos.push(minDis.panos)
|
|
|
+
|
|
|
+ //console.log('第i次',minDis)
|
|
|
+ mainGroup.push(...subGroup)//连接后,加入集合
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //console.log('cost', Date.now() - startTime)
|
|
|
+ return panos
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ showSuggestLinkPanos(){
|
|
|
+ let groups = this.getSuggestLinkPanos()
|
|
|
+ let s = 0.7
|
|
|
+ let createCircle = (pano)=>{
|
|
|
+ let circle = new THREE.Mesh(pano.circle.geometry, suggestCircleMat)
|
|
|
+ circle.name = 'suggest-circle'
|
|
|
+ circle.scale.set(s,s,s)
|
|
|
+ circle.renderOrder = 100
|
|
|
+ pano.circle.add(circle)
|
|
|
+ }
|
|
|
+ groups.forEach(panos=>{
|
|
|
+ createCircle(panos[0])
|
|
|
+ createCircle(panos[1])
|
|
|
+ let line = LineDraw.createFatLine([panos[0].position, panos[1].position], {mat: lineMats.suggestLink})
|
|
|
+ this.suggestLines.push(line)
|
|
|
+ line.renderOrder = renderOrders.line
|
|
|
+ viewer.scene.scene.add(line)
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
getPanoPose(pano){
|
|
|
let pose = {
|