|
@@ -463,6 +463,7 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
|
|
|
this.inputHandler = new InputHandler(this, this.scene.scene);
|
|
|
+ this.inputHandler.containsMouse = true//初始化,使键盘事件在mainViewer有效
|
|
|
//this.inputHandler.setScene(this.scene);
|
|
|
//this.inputHandler.addInputListener(this);//add
|
|
|
|
|
@@ -963,7 +964,7 @@ export class Viewer extends ViewerBase{
|
|
|
if(panoId != void 0){
|
|
|
let pano = this.images360.getPano(panoId)
|
|
|
if((soon || this.shelterCount.byTex<this.shelterCount.maxByTex) && pano.depthTex){
|
|
|
- ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d, margin:Potree.config.shelterMargin, useDepthTex:true, pano, viewport:this.mainViewport , viewport:this.mainViewport} )
|
|
|
+ ifShelter = !!viewer.inputHandler.ifBlockedByIntersect({pos3d, margin:Potree.config.shelterMargin, useDepthTex:true, pano, viewport:this.mainViewport } )
|
|
|
history.panos[panoId] = ifShelter
|
|
|
this.shelterCount.byTex ++ ;
|
|
|
//console.log('computeByTex direct', panoId, pos3d, ifShelter)
|
|
@@ -1221,7 +1222,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
this.updateCadVisibles(Clip.selectedDatasets)
|
|
|
|
|
|
- }else */if(this.selectedFloorplan){//平面图设置中
|
|
|
+ }else */if(this.selectedFloorplan){//平面图设置中 或 地理设置
|
|
|
let pointclouds = [this.selectedFloorplan]
|
|
|
this.updateCadVisibles(pointclouds)
|
|
|
}else if(SiteModel.editing || Alignment.editing){//只显示勾选的,也就是显示的点云的
|
|
@@ -1231,18 +1232,22 @@ export class Viewer extends ViewerBase{
|
|
|
}else{
|
|
|
let pointclouds = currentFloor ? this.findPointcloudsAtFloor(currentFloor) : []
|
|
|
|
|
|
+ if(pointclouds.length == 0){
|
|
|
+ if(this.focusDatasets){
|
|
|
+ pointclouds = this.focusDatasets
|
|
|
+ }
|
|
|
+ }
|
|
|
if(pointclouds.length == 0){//如果当前不在任何楼层或楼层中无数据集,就用当前所在数据集
|
|
|
pointclouds = this.atDatasets
|
|
|
}
|
|
|
|
|
|
-
|
|
|
this.updateCadVisibles(pointclouds)
|
|
|
//this.updatePanosVisibles(currentFloor/* , pointclouds */)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- findPointcloudsAtFloor(entity){//找当前楼层需要显示哪些数据集。
|
|
|
+ /* findPointcloudsAtFloor(entity){//找当前楼层需要显示哪些数据集。
|
|
|
//数据集的belongToEntity 在这个entity内(否则会出现点击数据集飞过去平面图却不显示)。or 如果数据集有漫游点的话,需要包含>20%的漫游点。 (防止重叠体积很大但其实一个漫游点都不包含)
|
|
|
//重叠体积>50% 或 包含>50%的漫游点
|
|
|
|
|
@@ -1263,10 +1268,8 @@ export class Viewer extends ViewerBase{
|
|
|
let panoCountRatio = insidePanos.length / e.panos.length
|
|
|
|
|
|
if(panoCountRatio > ratio2)return true
|
|
|
- if(panoCountRatio < ratio1){
|
|
|
- score += panoCountRatio//return false
|
|
|
- }
|
|
|
|
|
|
+ score += panoCountRatio
|
|
|
}
|
|
|
|
|
|
//条件3
|
|
@@ -1290,9 +1293,63 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
return pointclouds
|
|
|
- }
|
|
|
-
|
|
|
+ } */
|
|
|
|
|
|
+ findPointcloudsAtFloor(entity){//找当前楼层需要显示哪些数据集。
|
|
|
+ //数据集的belongToEntity 在这个entity内(否则会出现点击数据集飞过去平面图却不显示)。or 如果数据集有漫游点的话,需要包含>20%的漫游点。 (防止重叠体积很大但其实一个漫游点都不包含)
|
|
|
+ //重叠体积>50% 或 包含>50%的漫游点
|
|
|
+
|
|
|
+
|
|
|
+ const ratio1 = 0.2, ratio2 = 0.5, ratio3 = 0.95
|
|
|
+
|
|
|
+ var lowScores = []
|
|
|
+
|
|
|
+ var pointclouds = viewer.scene.pointclouds.filter(e=>{
|
|
|
+ let score = 0
|
|
|
+
|
|
|
+ if(e.belongToEntity && (e.belongToEntity == entity || e.belongToEntity.buildParent == entity)){//条件1 若该数据集挂载到该楼层 或 该数据集挂载到的房间属于该楼层(这样能显示该层所有房间)
|
|
|
+ return true
|
|
|
+ }
|
|
|
+
|
|
|
+ if(e.panos.length){//条件2
|
|
|
+ var insidePanos = e.panos.filter(a=>entity.ifContainsPoint(a.position));
|
|
|
+ let panoCountRatio = insidePanos.length / e.panos.length
|
|
|
+
|
|
|
+ if(panoCountRatio > ratio2)return true
|
|
|
+ score += panoCountRatio * 2
|
|
|
+ }
|
|
|
+
|
|
|
+ //条件3
|
|
|
+
|
|
|
+ let coverHeightRatio = entity.coverPointcloudHeight(e,true)//重叠高度占楼层高度的比率。
|
|
|
+ if(coverHeightRatio < 0.2) return
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let {toEntity,toPointcloud} = entity.intersectPointcloudArea(e,true); //重叠面积占比
|
|
|
+ let coverAreaRatio = Math.max(toEntity,toPointcloud);//占数据集俯视面积的比率 和 占楼层的面积比率,挑一个大的。 (有的数据集被划分多个楼层,所以每层都应该显示该数据集的图。还有的数据集比较大,可能包含多个建筑,则看占楼层面积)
|
|
|
+ if(coverAreaRatio < 0.2) return
|
|
|
+ score += coverAreaRatio * coverHeightRatio
|
|
|
+
|
|
|
+
|
|
|
+ lowScores.push({score, pointcloud:e})
|
|
|
+ })
|
|
|
+
|
|
|
+ /* if(pointclouds.length == 0){//从低分项挑一个出来。
|
|
|
+ lowScores.sort((a,b)=>{return a.score - b.score})
|
|
|
+ if(lowScores[0].score > 0.4){
|
|
|
+ pointclouds = [lowScores[0].pointcloud]
|
|
|
+ }
|
|
|
+ } */
|
|
|
+ lowScores.forEach(e=>{//一个楼层里可以包含许多个数据集 调试SG-t-ds27ym7xzjJ
|
|
|
+ if(e.score > 0.5){
|
|
|
+ pointclouds.push(e.pointcloud)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ return pointclouds
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -3102,7 +3159,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
|
|
|
- let needSResize = viewports.length > 1 || params_.resize
|
|
|
+ ///let needsResize = viewports.length > 1 || params_.resize //去掉原因:因为不需要渲染的viewport不在此中所以无法判断几个viewport
|
|
|
|
|
|
|
|
|
|
|
@@ -3152,10 +3209,10 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(needSResize){
|
|
|
+ //if(needsResize){
|
|
|
this.ifEmitResize( { viewport:view} )
|
|
|
- }
|
|
|
-
|
|
|
+ //}
|
|
|
+
|
|
|
viewer.dispatchEvent({type: "render.begin", viewer: viewer, viewport:view, params });
|
|
|
|
|
|
|
|
@@ -3422,8 +3479,8 @@ export class Viewer extends ViewerBase{
|
|
|
let SiteModel = viewer.modules.SiteModel
|
|
|
|
|
|
|
|
|
- Potree.settings.useRTPoint = !(SiteModel.editing && SiteModel.selected && SiteModel.selected.buildType == 'room' )//空间模型的房间选中材质是需要depth的,这时候需要绘制两次点云
|
|
|
-
|
|
|
+ Potree.settings.useRTPoint = !(SiteModel.editing && SiteModel.selected && (SiteModel.selected.buildType == 'room' || SiteModel.selected.buildType == 'floor'))//空间模型的房间选中材质是需要depth的,这时候需要绘制两次点云
|
|
|
+
|
|
|
Potree.settings.pointEnableRT = !this.screenshoting && (this.scene.measurements.length > 0 || !Potree.settings.useRTPoint )
|
|
|
|
|
|
|
|
@@ -3506,7 +3563,8 @@ export class Viewer extends ViewerBase{
|
|
|
}else{
|
|
|
|
|
|
//直接渲染 会改变canvas大小
|
|
|
- let canvas = this.renderArea.getElementsByTagName('canvas')[0]
|
|
|
+ let canvas = this.renderArea.getElementsByTagName('canvas')[0]
|
|
|
+ //canvas.width = width, canvas.height = height //不需要改canvas大小, 只需要 this.renderer.setSize(width, height ); 前面updateScreenSize已经执行
|
|
|
this.render({ screenshot : true, width , height, resize :true }); //需要resize
|
|
|
var dataUrl = canvas.toDataURL('image/jpeg',compressRatio)
|
|
|
}
|
|
@@ -3566,6 +3624,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
if(info.type == 'measure'){
|
|
|
this.modules.SiteModel.pauseUpdateEntity = false
|
|
|
+ this.focusDatasets = null
|
|
|
this.scene.measurements.forEach(e=>Potree.Utils.updateVisible(e, 'screenshot',true))
|
|
|
info.measurement.setSelected(false, 'screenshot')
|
|
|
}
|
|
@@ -3673,7 +3732,7 @@ export class Viewer extends ViewerBase{
|
|
|
viewer.scene.pointclouds[0].material.size *= 1.5 */
|
|
|
}
|
|
|
if(Potree.settings.displayMode == 'showPointCloud'){
|
|
|
- viewer.updateScreenSize({forceUpdateSize:true, width, height})//需要先setSize才能加载范围内的点云
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true, width, height, forTarget:info.useRenderTarget})//需要先setSize才能加载范围内的点云
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3713,7 +3772,7 @@ export class Viewer extends ViewerBase{
|
|
|
oldStates.oldSplitDir = this.mapViewer.splitDir
|
|
|
this.mapViewer.attachToMainViewer(true, 'measure', 0.5 , {dir:'leftRight'} )
|
|
|
}
|
|
|
- viewer.updateScreenSize({forceUpdateSize:true, width, height}) //更新viewports相机透视 使focusOnObject在此窗口大小下
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true, width, height, forTarget:info.useRenderTarget}) //更新viewports相机透视 使focusOnObject在此窗口大小下
|
|
|
|
|
|
let begin = ()=>{
|
|
|
useMap = this.mapViewer.attachedToViewer
|
|
@@ -3740,15 +3799,26 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
this.updateDatasetAt(true)
|
|
|
this.modules.SiteModel.updateEntityAt(true, {measure:info.measurement}) //更新测量线所在楼层,展示俯视图
|
|
|
+ if(!this.modules.SiteModel.inEntity){
|
|
|
+ this.focusDatasets = []
|
|
|
+ info.measurement.points_datasets.forEach(e=>{
|
|
|
+ let p = viewer.scene.pointclouds.find(a=>a.dataset_id == e)
|
|
|
+ if(p && !this.focusDatasets.includes(p)){
|
|
|
+ this.focusDatasets.push(p)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.updateFpVisiDatasets()
|
|
|
+ }
|
|
|
+
|
|
|
this.modules.SiteModel.pauseUpdateEntity = true
|
|
|
- //this.updateFpVisiDatasets()
|
|
|
+
|
|
|
|
|
|
//console.log('currentFloor', this.modules.SiteModel.currentFloor, 'currentDataset', this.atDatasets )
|
|
|
|
|
|
let floorplanShowed = this.mapViewer.mapLayer.maps.some(e => e.name.includes('floorplan') && e.objectGroup.visible)//如果没有floorplan展示就不分屏(如果focus时飞出数据集从而不展示怎么办。尤其是俯瞰比较长的线时容易这样,或许要根据其所在数据集强制显示)
|
|
|
if(!floorplanShowed && this.mapViewer.attachedToViewer){
|
|
|
this.mapViewer.attachToMainViewer(false) //取消分屏
|
|
|
- viewer.updateScreenSize({forceUpdateSize:true, width, height}) //更新viewports相机透视
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true, width, height, forTarget:info.useRenderTarget}) //更新viewports相机透视
|
|
|
let {promise} = this.focusOnObject(info.measurement, 'measure', 0, {basePanoSize:1024,gotoBestView:true,} )//因画面比例更改,重新focus
|
|
|
promise.done(()=>{
|
|
|
begin()
|