|
@@ -60,7 +60,7 @@ import {RouteGuider} from '../modules/route/RouteGuider'
|
|
|
import ParticleEditor from '../modules/Particles/ParticleEditor'
|
|
|
import CamAniEditor from '../modules/CameraAnimation/CamAniEditor'
|
|
|
import {MeshDraw} from '../utils/DrawUtil'
|
|
|
-
|
|
|
+import PanoEditor from '../modules/panoEdit/panoEditor'
|
|
|
|
|
|
import {OBJLoader} from "../../libs/three.js/loaders/OBJLoader.js";
|
|
|
import {MTLLoader} from "../../libs/three.js/loaders/MTLLoader.js";
|
|
@@ -70,8 +70,7 @@ import EffectComposer from '../materials/postprocessing/EffectComposer'
|
|
|
import {ShaderPass} from '../materials/postprocessing/ShaderPass'
|
|
|
import RenderPass from '../materials/postprocessing/RenderPass'
|
|
|
import FXAAShader from "../materials/postprocessing/FXAAShader"
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -84,16 +83,26 @@ export class Viewer extends ViewerBase{
|
|
|
constructor(domElement, mapArea_, args = {}){
|
|
|
super(domElement, $.extend(args,{name:'mainViewer'}));
|
|
|
window.viewer = this
|
|
|
- this.modules = { //add
|
|
|
- Clip,
|
|
|
- Alignment,
|
|
|
- SiteModel,
|
|
|
- RouteGuider : new RouteGuider,
|
|
|
- ParticleEditor,
|
|
|
- CamAniEditor
|
|
|
- }
|
|
|
|
|
|
- //this.testingMaxLevel = true
|
|
|
+
|
|
|
+
|
|
|
+ if(Potree.settings.editType == "pano"){
|
|
|
+ this.modules = {
|
|
|
+ Alignment,
|
|
|
+ PanoEditor,
|
|
|
+ SiteModel
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.modules = {
|
|
|
+ Clip,
|
|
|
+ Alignment,
|
|
|
+ SiteModel,
|
|
|
+ RouteGuider : new RouteGuider,
|
|
|
+ ParticleEditor,
|
|
|
+ CamAniEditor,
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
console.log('create viewer')
|
|
@@ -106,7 +115,7 @@ export class Viewer extends ViewerBase{
|
|
|
this.visible = true
|
|
|
this.fpVisiDatasets = []
|
|
|
this.atDatasets = []
|
|
|
-
|
|
|
+ this.lastPos = new THREE.Vector3(Infinity,Infinity,Infinity)
|
|
|
//-------------
|
|
|
|
|
|
var supportExtFragDepth = !!Features.EXT_DEPTH.isSupported() ;//iphoneX居然不支持
|
|
@@ -408,8 +417,9 @@ export class Viewer extends ViewerBase{
|
|
|
left:0, bottom:0, width:1, height: 1, name:'MainView'
|
|
|
})
|
|
|
this.viewports = [this.mainViewport]
|
|
|
- this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
|
|
|
-
|
|
|
+ if(Potree.settings.editType != "pano"){
|
|
|
+ this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//---------------------------
|
|
@@ -488,11 +498,15 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
//-----------
|
|
|
- CursorDeal.init(this)//ADD
|
|
|
-
|
|
|
- this.modules.SiteModel.init()
|
|
|
+ CursorDeal.init(this, this.mapViewer ? [this, this.mapViewer] : [this])//ADD
|
|
|
+ if(Potree.settings.editType == "pano"){
|
|
|
+ this.modules.PanoEditor.init()
|
|
|
+ }else{
|
|
|
+ this.modules.SiteModel.init()
|
|
|
+ this.modules.ParticleEditor.init()
|
|
|
+ }
|
|
|
this.modules.Alignment.init()
|
|
|
- this.modules.ParticleEditor.init()
|
|
|
+
|
|
|
|
|
|
|
|
|
this.images360 = new Images360(this);
|
|
@@ -590,144 +604,173 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
this.addEventListener('allLoaded', this.testPointcloudsMaxLevel.bind(this))
|
|
|
|
|
|
- {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(Potree.settings.editType != 'pano'){
|
|
|
|
|
|
- //更新所在数据集
|
|
|
- var lastPos = new THREE.Vector3(Infinity,Infinity,Infinity)
|
|
|
- this.addEventListener('camera_changed', e => {
|
|
|
- Common.intervalTool.isWaiting('atWhichDataset', ()=>{ //延时update,防止卡顿
|
|
|
- let currPos = viewer.scene.getActiveCamera().position
|
|
|
-
|
|
|
- if(!currPos.equals(lastPos)){
|
|
|
- lastPos.copy(currPos)
|
|
|
-
|
|
|
- var at = this.scene.pointclouds.filter(e=>e.ifContainsPoint(currPos))
|
|
|
-
|
|
|
- if(Common.getDifferenceSet(at, this.atDatasets).length){
|
|
|
- //console.log('atDatasets', at)
|
|
|
- this.atDatasets = at
|
|
|
- this.updateFpVisiDatasets()
|
|
|
- this.dispatchEvent({type:'pointcloudAtChange',pointclouds:at})
|
|
|
- }
|
|
|
-
|
|
|
- return true
|
|
|
- }
|
|
|
- }, 500)
|
|
|
-
|
|
|
- })
|
|
|
|
|
|
- }
|
|
|
-
|
|
|
- this.addEventListener('switchFloorplanSelect',(e)=>{//进入平面图设置后 切换选中的数据集
|
|
|
- this.selectedFloorplan = e.pointcloud; //绝对显示
|
|
|
- this.updateFpVisiDatasets()
|
|
|
- let pointclouds;
|
|
|
- if(e.pointcloud){
|
|
|
- pointclouds = [e.pointcloud]
|
|
|
- }else if(this.fpVisiDatasets.length){
|
|
|
- pointclouds = this.fpVisiDatasets
|
|
|
- }
|
|
|
|
|
|
- pointclouds && this.mapViewer.fitToDatasets(pointclouds)
|
|
|
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
- this.modules.SiteModel.bus.addEventListener('FloorChange',()=>{
|
|
|
- this.updateFpVisiDatasets()
|
|
|
- })
|
|
|
-
|
|
|
+ this.addEventListener('switchFloorplanSelect',(e)=>{//进入平面图设置后 切换选中的数据集
|
|
|
+ this.selectedFloorplan = e.pointcloud; //绝对显示
|
|
|
+ this.updateFpVisiDatasets()
|
|
|
+ let pointclouds;
|
|
|
+ if(e.pointcloud){
|
|
|
+ pointclouds = [e.pointcloud]
|
|
|
+ }else if(this.fpVisiDatasets.length){
|
|
|
+ pointclouds = this.fpVisiDatasets
|
|
|
+ }
|
|
|
+
|
|
|
+ pointclouds && this.mapViewer.fitToDatasets(pointclouds)
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.modules.SiteModel.bus.addEventListener('FloorChange',()=>{
|
|
|
+ this.updateFpVisiDatasets()
|
|
|
+ })
|
|
|
+ this.mapViewer.mapLayer.addEventListener('floorplanLoaded',()=>{
|
|
|
+ this.updateCadVisibles(this.fpVisiDatasets, true) //加载完成后重新更新下
|
|
|
+ })
|
|
|
+
|
|
|
+ /* this.modules.Clip.bus.addEventListener('updateSelectedDatasets',()=>{
|
|
|
+ this.updateFpVisiDatasets()
|
|
|
+ }) */
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- /* this.modules.Clip.bus.addEventListener('updateSelectedDatasets',()=>{
|
|
|
- this.updateFpVisiDatasets()
|
|
|
- }) */
|
|
|
|
|
|
- this.mapViewer.mapLayer.addEventListener('floorplanLoaded',()=>{
|
|
|
- this.updateCadVisibles(this.fpVisiDatasets, true) //加载完成后重新更新下
|
|
|
- })
|
|
|
-
|
|
|
-
|
|
|
+ {
|
|
|
+ //更新所在数据集
|
|
|
+ this.addEventListener('camera_changed', e => {
|
|
|
+ this.updateDatasetAt()
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ updateDatasetAt(force){//更新所在数据集
|
|
|
|
|
|
+ let fun = ()=>{
|
|
|
+ let currPos = viewer.mainViewport.view.position
|
|
|
+
|
|
|
+ if(force || !currPos.equals(this.lastPos)){
|
|
|
+ this.lastPos.copy(currPos)
|
|
|
+
|
|
|
+ var at = this.scene.pointclouds.filter(e=>e.ifContainsPoint(currPos))
|
|
|
+
|
|
|
+ if(Common.getDifferenceSet(at, this.atDatasets).length){
|
|
|
+ //console.log('atDatasets', at)
|
|
|
+ this.atDatasets = at
|
|
|
+ if(Potree.settings.editType != 'pano')this.updateFpVisiDatasets()
|
|
|
+ this.dispatchEvent({type:'pointcloudAtChange',pointclouds:at})
|
|
|
+ }
|
|
|
+ force = false
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(force)fun()
|
|
|
+ else Common.intervalTool.isWaiting('atWhichDataset', fun , 500)
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- updatePanosVisibles(currentFloor, pointclouds){//显示数据集和当前楼层的所有panos(为了显示出平面图中所有漫游点。漫游点个数>=平面图中包含的)
|
|
|
+
|
|
|
+ updatePanosVisibles(currentFloor){//显示当前楼层的所有panos
|
|
|
viewer.images360.panos.forEach(pano=>{
|
|
|
- let visible = currentFloor && currentFloor.panos.includes(pano) || pointclouds.some(e=>e.panos.includes(pano));
|
|
|
+ let visible = currentFloor && currentFloor.panos.includes(pano)
|
|
|
viewer.updateVisible(pano, 'buildingChange', visible, 2)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
|
|
|
updateFpVisiDatasets(){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
let Clip = this.modules.Clip
|
|
|
let SiteModel = this.modules.SiteModel
|
|
|
let Alignment = this.modules.Alignment
|
|
|
var currentFloor = SiteModel.currentFloor;
|
|
|
|
|
|
- /* if(Clip.editing){
|
|
|
+ /* if(Clip.editing){//下载页面已经改为和普通时一样,根据位置判断
|
|
|
|
|
|
this.updateCadVisibles(Clip.selectedDatasets)
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}else */if(this.selectedFloorplan){//平面图设置中
|
|
|
let pointclouds = [this.selectedFloorplan]
|
|
|
this.updateCadVisibles(pointclouds)
|
|
|
}else if(SiteModel.editing || Alignment.editing){//只显示勾选的,也就是显示的点云的
|
|
|
let pointclouds = this.scene.pointclouds.filter(p => this.getObjVisiByReason(p,'datasetSelection') );
|
|
|
this.updateCadVisibles(pointclouds)
|
|
|
- this.updatePanosVisibles(currentFloor, pointclouds)
|
|
|
+ this.updatePanosVisibles(currentFloor/* , pointclouds */)
|
|
|
}else{
|
|
|
let pointclouds = currentFloor ? this.findPointcloudsAtFloor(currentFloor) : []
|
|
|
|
|
|
- if(pointclouds == 0){//如果当前不在任何楼层或楼层中无数据集,就用当前所在数据集
|
|
|
+ if(pointclouds.length == 0){//如果当前不在任何楼层或楼层中无数据集,就用当前所在数据集
|
|
|
pointclouds = this.atDatasets
|
|
|
}
|
|
|
|
|
|
this.updateCadVisibles(pointclouds)
|
|
|
- this.updatePanosVisibles(currentFloor, pointclouds)
|
|
|
+ this.updatePanosVisibles(currentFloor/* , pointclouds */)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
findPointcloudsAtFloor(entity){//找当前楼层需要显示哪些数据集。
|
|
|
- //必要条件:数据集的belongToEntity 在这个entity内(否则会出现点击数据集飞过去平面图却不显示)。or 如果数据集有漫游点的话,需要包含>20%的漫游点。 (防止重叠体积很大但其实一个漫游点都不包含)
|
|
|
- //充分条件(在符合必要条件之后还应该满足至少一个充分条件): 重叠体积>50% 或 包含>50%的漫游点
|
|
|
+ //数据集的belongToEntity 在这个entity内(否则会出现点击数据集飞过去平面图却不显示)。or 如果数据集有漫游点的话,需要包含>20%的漫游点。 (防止重叠体积很大但其实一个漫游点都不包含)
|
|
|
+ //重叠体积>50% 或 包含>50%的漫游点
|
|
|
|
|
|
|
|
|
- const ratio1 = 0.2, ratio2 = 0.5, ratio3 = 0.5
|
|
|
+ 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
|
|
|
+ if(e.belongToEntity && (e.belongToEntity == entity || e.belongToEntity.buildParent == entity)){//条件1 若该数据集挂载到该楼层 或 该数据集挂载到的房间属于该楼层(这样能显示该层所有房间)
|
|
|
return true
|
|
|
}
|
|
|
|
|
|
- if(e.panos.length){//必要条件2
|
|
|
+ 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
|
|
|
if(panoCountRatio < ratio1){
|
|
|
- return false
|
|
|
+ score += panoCountRatio//return false
|
|
|
}
|
|
|
|
|
|
- if(panoCountRatio > ratio2)return true
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ //条件3
|
|
|
let volume = entity.intersectPointcloudVolume(e);
|
|
|
let volumeRatio = volume / entity.getVolume(true) //注:hole加入计算
|
|
|
- if(volumeRatio > ratio3){
|
|
|
+ if(volumeRatio > ratio3){ //ratio3要高一些,因为点云bounding可能很大,包含很多无点云的空间。即使整个数据集包含entity都不一定看起来在数据集中。(千万要防止两层楼都显示了)
|
|
|
return true
|
|
|
- }
|
|
|
+ }else{
|
|
|
+ score += volumeRatio
|
|
|
+ }
|
|
|
+
|
|
|
+ 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]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return pointclouds
|
|
|
}
|
|
|
-
|
|
|
updateCadVisibles(visiClouds, force){
|
|
|
let oldVisi = this.fpVisiDatasets
|
|
|
var visiClouds = this.fpVisiDatasets = visiClouds
|
|
@@ -736,7 +779,7 @@ export class Viewer extends ViewerBase{
|
|
|
var difference = Common.getDifferenceSet(oldVisi , visiClouds)
|
|
|
if(difference.length == 0)return
|
|
|
}
|
|
|
-
|
|
|
+ //console.log('visiClouds',visiClouds.map(e=>e.name))
|
|
|
|
|
|
viewer.scene.pointclouds.forEach(pointcloud=>{
|
|
|
var floorplan = viewer.mapViewer.mapLayer.getFloorplan(pointcloud.dataset_id)
|
|
@@ -1413,7 +1456,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
setTopView(view){
|
|
|
view = view || this.scene.view
|
|
|
- view.setCubeView("Top")
|
|
|
+ view.setCubeView("top")
|
|
|
|
|
|
this.fitToScreen();
|
|
|
};
|
|
@@ -2350,7 +2393,11 @@ export class Viewer extends ViewerBase{
|
|
|
TWEEN.update(timestamp);
|
|
|
transitions.update(delta);
|
|
|
this.transformationTool.update();
|
|
|
- this.modules.ParticleEditor.update(delta)
|
|
|
+
|
|
|
+ if(Potree.settings.editType != 'pano'){
|
|
|
+ this.modules.ParticleEditor.update(delta)
|
|
|
+ this.mapViewer.update(delta)
|
|
|
+ }
|
|
|
|
|
|
this.dispatchEvent({
|
|
|
type: 'update',
|
|
@@ -2365,7 +2412,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
//add ------
|
|
|
this.reticule.updateVisible()
|
|
|
- this.mapViewer.update(delta)
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|
|
@@ -2723,15 +2770,13 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
viewer.dispatchEvent({type: "render.begin", viewer: viewer, viewport:view, params });
|
|
|
|
|
|
+
|
|
|
if(view.render){
|
|
|
view.render($.extend({}, params, {
|
|
|
renderer:this.renderer, clear:this.clear.bind(this), resize:null,
|
|
|
- renderOverlay: this.renderOverlay.bind(this), force:!view.noPointcloud //如果要渲染点云,必须也一直渲染地图,否则地图会被覆盖(点云目前未能获取是否改变,也可能有其他动态物体,所以还是一直渲染的好)
|
|
|
+ renderOverlay: this.renderOverlay.bind(this), force:!view.noPointcloud //如果要渲染点云,必须也一直渲染地图,否则地图会被覆盖(点云目前未能获取是否改变,也可能有其他动态物体,所以还是一直渲染的好)
|
|
|
}))
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
if(!view.noPointcloud ){
|
|
|
|
|
@@ -2755,19 +2800,16 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
view.render || this.clear(params)
|
|
|
pRenderer.clearTargets(params);
|
|
|
- pRenderer.render(params);
|
|
|
-
|
|
|
+ pRenderer.render(params);
|
|
|
|
|
|
- {//渲染和地图共有的物体
|
|
|
- this.setCameraLayers(params.camera, [ 'bothMapAndScene' ] )
|
|
|
- this.renderer.render(this.scene.scene, params.camera);
|
|
|
- }
|
|
|
-
|
|
|
- this.renderOverlay(params)
|
|
|
-
|
|
|
- view.afterRender && view.afterRender()
|
|
|
}
|
|
|
+
|
|
|
|
|
|
+ view.render || this.renderOverlay(params)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ view.afterRender && view.afterRender()
|
|
|
|
|
|
this.dispatchEvent({type: "render.end", viewer: this, viewport:view });
|
|
|
|
|
@@ -2797,18 +2839,7 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
}
|
|
|
|
|
|
- /* renderDefault(){//测试 ios15.4.1
|
|
|
- //let pRenderer = this.getPRenderer();
|
|
|
- //this.clear()
|
|
|
- this.renderer.autoClear = false
|
|
|
- this.renderer.setRenderTarget(null)
|
|
|
- let camera = this.scene.getActiveCamera();
|
|
|
- this.setCameraLayers(camera, [ 'sceneObjects', 'marker' , 'reticule' ,'skybox' ])
|
|
|
- this.renderer.render(this.scene.scene, camera);
|
|
|
- // pRenderer.clearTargets( );
|
|
|
- //pRenderer.render( );
|
|
|
-
|
|
|
- } */
|
|
|
+
|
|
|
|
|
|
|
|
|
renderOverlay(params){
|
|
@@ -2823,8 +2854,8 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
if(params.cameraLayers) cameraLayers = params.cameraLayers
|
|
|
else{
|
|
|
- if(params.isMap)cameraLayers = ['reticule']
|
|
|
- else cameraLayers = ['sceneObjects','marker','reticule' /* 'bothMapAndScene' */];
|
|
|
+ if(params.isMap)cameraLayers = ['bothMapAndScene']
|
|
|
+ else cameraLayers = ['sceneObjects', 'bothMapAndScene' ];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2858,7 +2889,18 @@ export class Viewer extends ViewerBase{
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ /* renderDefault(){//测试 ios15.4.1
|
|
|
+ //let pRenderer = this.getPRenderer();
|
|
|
+ //this.clear()
|
|
|
+ this.renderer.autoClear = false
|
|
|
+ this.renderer.setRenderTarget(null)
|
|
|
+ let camera = this.scene.getActiveCamera();
|
|
|
+ this.setCameraLayers(camera, [ 'sceneObjects', 'marker' , 'reticule' ,'skybox' ])
|
|
|
+ this.renderer.render(this.scene.scene, camera);
|
|
|
+ // pRenderer.clearTargets( );
|
|
|
+ //pRenderer.render( );
|
|
|
|
|
|
+ } */
|
|
|
setLimitFar(state){//切换是否limitFar
|
|
|
viewer.mainViewport.camera.limitFar = !!state
|
|
|
if(state){
|
|
@@ -3089,15 +3131,25 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
console.log('startScreenshot: '+sid)
|
|
|
|
|
|
+ let updateCamera = ()=>{
|
|
|
+ this.viewports.forEach(e=>{
|
|
|
+ e.view.applyToCamera(e.camera) //因为fly时只更新了view所以要强制更新下camera
|
|
|
+
|
|
|
+ this.dispatchEvent({ //update map and sprite
|
|
|
+ type: "camera_changed",
|
|
|
+ camera: e.camera,
|
|
|
+ viewport : e
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
- var screenshot = ()=>{
|
|
|
+ let screenshot = ()=>{
|
|
|
|
|
|
useMap && (viewer.mapViewer.needRender = true)
|
|
|
|
|
|
|
|
|
|
|
|
- var { dataUrl } = viewerMaster.makeScreenshot( new THREE.Vector2(width,height), null, compressRatio );
|
|
|
+ let { dataUrl } = viewerMaster.makeScreenshot( new THREE.Vector2(width,height), null, compressRatio );
|
|
|
|
|
|
|
|
|
|
|
@@ -3108,6 +3160,31 @@ export class Viewer extends ViewerBase{
|
|
|
|
|
|
|
|
|
var finish = ()=>{
|
|
|
+
|
|
|
+ oldStates.viewports.forEach(old=>{//恢复相机
|
|
|
+ var viewport = [mapViewport, mainViewport].find(v=>v.name == old.name);
|
|
|
+ viewport.left = old.left;
|
|
|
+ viewport.width = old.width;
|
|
|
+ viewport.view.copy(old.view)
|
|
|
+ viewport.view.applyToCamera(viewport.camera);
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true})//更新像素
|
|
|
+
|
|
|
+ /* oldStates.viewports.forEach(old=>{//恢复相机
|
|
|
+ var viewport = [mapViewport, mainViewport].find(v=>v.name == old.name);
|
|
|
+ this.dispatchEvent({ //update map
|
|
|
+ type: "camera_changed",
|
|
|
+ camera: viewport.camera,
|
|
|
+ viewport : viewport
|
|
|
+ })
|
|
|
+ }) */
|
|
|
+ updateCamera()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
deferred.resolve(dataUrl)
|
|
|
console.log('screenshot done: '+sid)
|
|
|
}
|
|
@@ -3136,37 +3213,16 @@ export class Viewer extends ViewerBase{
|
|
|
viewer.images360.flyToPano({pano:oldStates.pano, duration:0, callback:()=>{
|
|
|
finish()
|
|
|
}})
|
|
|
+ }else{
|
|
|
+ finish()
|
|
|
}
|
|
|
|
|
|
- oldStates.viewports.forEach(old=>{//恢复相机
|
|
|
- var viewport = [mapViewport, mainViewport].find(v=>v.name == old.name);
|
|
|
- viewport.left = old.left;
|
|
|
- viewport.width = old.width;
|
|
|
- viewport.view.copy(old.view)
|
|
|
- viewport.view.applyToCamera(viewport.camera);
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- viewer.updateScreenSize({forceUpdateSize:true})//更新像素
|
|
|
-
|
|
|
- oldStates.viewports.forEach(old=>{//恢复相机
|
|
|
- var viewport = [mapViewport, mainViewport].find(v=>v.name == old.name);
|
|
|
- this.dispatchEvent({ //update map
|
|
|
- type: "camera_changed",
|
|
|
- camera: viewport.camera,
|
|
|
- viewport : viewport
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if(Potree.settings.displayMode != 'showPanos') {
|
|
|
- finish()
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- }
|
|
|
+ }// screenshot end
|
|
|
+
|
|
|
+
|
|
|
|
|
|
let mapViewport = this.mapViewer.viewports[0]
|
|
|
let mainViewport = this.mainViewport
|
|
@@ -3191,53 +3247,57 @@ export class Viewer extends ViewerBase{
|
|
|
viewer.updateVisible(this.mapViewer.cursor, 'screenshot', false)//令mapCursor不可见
|
|
|
|
|
|
|
|
|
+
|
|
|
if(info.type == 'measure'){//要截图双屏
|
|
|
this.scene.measurements.forEach(e=>this.updateVisible(e,'screenshot',e == info.measurement) )
|
|
|
info.measurement.setSelected(true, 'screenshot')
|
|
|
|
|
|
- this.mapViewer.attachToMainViewer(true, 'measure', 0.5 )//不要移动相机去适应
|
|
|
-
|
|
|
- viewer.updateScreenSize({forceUpdateSize:true, width, height}) //更新viewports相机透视
|
|
|
-
|
|
|
- //不同角度截图 得到三维的会不一样,因为focusOnObject是根据方向的
|
|
|
- let {promise}= this.focusOnObject(info.measurement, 'measure', 0, {basePanoSize:1024} )
|
|
|
- promise.done(()=>{
|
|
|
- console.log('promise.done')
|
|
|
- this.viewports.forEach(e=>{
|
|
|
- e.view.applyToCamera(e.camera)
|
|
|
-
|
|
|
- this.dispatchEvent({ //update map
|
|
|
- type: "camera_changed",
|
|
|
- camera: e.camera,
|
|
|
- viewport : e
|
|
|
- })
|
|
|
-
|
|
|
- })
|
|
|
-
|
|
|
- let waitMap = ()=>{
|
|
|
- console.log('waitMap: '+sid)
|
|
|
- this.mapViewer.waitLoadDone(screenshot.bind(this))//等待地图所有加载完
|
|
|
+
|
|
|
+ //因为分屏后位置才最终确定,才能确定是否显示出floorplan所以先分屏
|
|
|
+ if(Potree.settings.floorplanEnable){
|
|
|
+ this.mapViewer.attachToMainViewer(true, 'measure', 0.5 )
|
|
|
+ }
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true, width, height}) //更新viewports相机透视 使focusOnObject在此窗口大小下
|
|
|
+
|
|
|
+ let begin = ()=>{
|
|
|
+ useMap = this.mapViewer.attachedToViewer
|
|
|
+ updateCamera()
|
|
|
+ let waitTime = Potree.settings.displayMode == 'showPointCloud' ? 500 : 0 //等点云加载 网速差的话还是加载稀疏 是否要用最高质量点云
|
|
|
+ if(useMap){
|
|
|
+ let waitMap = ()=>{
|
|
|
+ //console.log('waitMap: '+sid)
|
|
|
+ this.mapViewer.waitLoadDone(screenshot.bind(this))//等待地图所有加载完
|
|
|
+ }
|
|
|
+ setTimeout(waitMap.bind(this), waitTime)
|
|
|
+ }else{
|
|
|
+ setTimeout(screenshot.bind(this), waitTime)
|
|
|
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ let {promise}= this.focusOnObject(info.measurement, 'measure', 0, {basePanoSize:1024} )//注意:不同角度截图 得到三维的会不一样,因为focusOnObject是根据方向的
|
|
|
+ promise.done(()=>{
|
|
|
+ //console.log('promise.done')
|
|
|
+ //根据当前位置更新floorplan显示
|
|
|
+ //console.log('view Pos ', this.mainViewport.view.position.toArray())
|
|
|
+ this.updateDatasetAt(true)
|
|
|
+ this.modules.SiteModel.updateEntityAt(true)
|
|
|
+ //this.updateFpVisiDatasets()
|
|
|
|
|
|
-
|
|
|
- /* if(Potree.settings.displayMode == 'showPanos'){//如果是全景图,要等全景的tile加载完
|
|
|
- //this.images360.checkAndWaitForTiledPanoLoad(this.images360.currentPano, this.images360.qualityManager.standardSize, ()=>{//done
|
|
|
- //loadTiledPano
|
|
|
- if(!this.images360.checkAndWaitForPanoLoad(this.images360.currentPano, this.images360.qualityManager.standardSize, ()=>{//done
|
|
|
- //standardSize maxNavPanoSize
|
|
|
- waitMap()
|
|
|
- })){
|
|
|
- waitMap()
|
|
|
- }
|
|
|
+ //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)
|
|
|
+ if(!floorplanShowed && this.mapViewer.attachedToViewer){
|
|
|
+ this.mapViewer.attachToMainViewer(false) //取消分屏
|
|
|
+ viewer.updateScreenSize({forceUpdateSize:true, width, height}) //更新viewports相机透视
|
|
|
+ let {promise} = this.focusOnObject(info.measurement, 'measure', 0, {basePanoSize:1024} )//因画面比例更改,重新focus
|
|
|
+ promise.done(()=>{
|
|
|
+ begin()
|
|
|
+ })
|
|
|
}else{
|
|
|
- waitMap()
|
|
|
- } */ //512就可以
|
|
|
-
|
|
|
+ begin()
|
|
|
+ }
|
|
|
|
|
|
- //调不通,暂时先用setTimeout
|
|
|
-
|
|
|
- setTimeout(waitMap.bind(this), 1)
|
|
|
})
|
|
|
|
|
|
}else{
|
|
@@ -3386,9 +3446,9 @@ export class Viewer extends ViewerBase{
|
|
|
position = getPosWithFullBound(object.points, null, target, cameraPos )
|
|
|
|
|
|
|
|
|
- if(this.mapViewer.attachedToViewer){
|
|
|
+ /* if(this.mapViewer.attachedToViewer) */{
|
|
|
//console.log('mapFocusOn: '+target.toArray())
|
|
|
- const minBound = new THREE.Vector2(1,1)//针对垂直线,在地图上只有一个点
|
|
|
+ const minBound = new THREE.Vector2(4,4)//针对垂直线,在地图上只有一个点
|
|
|
//原始的bound
|
|
|
let boundOri = new THREE.Box3()
|
|
|
object.points.forEach(e=>{
|
|
@@ -3513,30 +3573,54 @@ export class Viewer extends ViewerBase{
|
|
|
let duration = o.duration == void 0 ? 1000 : o.duration
|
|
|
var center = pointcloud.bound.getCenter(new THREE.Vector3);
|
|
|
let position
|
|
|
-
|
|
|
-
|
|
|
- if(Potree.settings.displayMode == 'showPanos'){
|
|
|
+ let getPano = ()=>{//获取离中心最近的pano
|
|
|
let request = []
|
|
|
let rank = [
|
|
|
Images360.scoreFunctions.distanceSquared({position: center})
|
|
|
]
|
|
|
let r = Common.sortByScore(pointcloud.panos, request, rank);
|
|
|
-
|
|
|
if(r && r.length){
|
|
|
- if(r[0].item == this.images360.currentPano) return 'posNoChange'
|
|
|
+ return r[0].item
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Potree.settings.displayMode == 'showPanos'){
|
|
|
+ let pano = getPano()
|
|
|
+
|
|
|
+ if(pano){
|
|
|
+ if(pano == this.images360.currentPano) return 'posNoChange'
|
|
|
this.images360.flyToPano({
|
|
|
- pano:r[0].item
|
|
|
+ pano
|
|
|
})
|
|
|
}else return false
|
|
|
}else{
|
|
|
+ let target
|
|
|
+ position = center
|
|
|
+ if(pointcloud.panosBound){
|
|
|
+
|
|
|
+ let panosCenter = pointcloud.panosBound.center //pano集中的地方,也就是真正有点云的地方
|
|
|
+ position = panosCenter.clone()
|
|
|
+ /* let ratio = 0.2
|
|
|
+ position.z = center.z * ratio + panosCenter.z * (1-ratio) //因为panos一般比较低,为了不让相机朝下时看不到点云,加一丢丢中心高度
|
|
|
+ */
|
|
|
+ let pano = getPano()
|
|
|
+ if(pano){
|
|
|
+ target = pano.position //针对像隧道一样的场景, 中心点还是panosCenter都在没有点云的地方,所以还是看向其中一个漫游点好。
|
|
|
+ position.z = target.z //水平, 避免朝上或朝下
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if(this.modules.Clip.editing){
|
|
|
- this.modules.Clip.bus.dispatchEvent({type:'flyToPos', position:center})
|
|
|
+ position.z = center.z //剪裁时在中心高度,因为以点云为重点
|
|
|
+ this.modules.Clip.bus.dispatchEvent({type:'flyToPos', position })
|
|
|
}else{
|
|
|
- if(math.closeTo(center, this.images360.position)) return 'posNoChange'
|
|
|
- position = center
|
|
|
- viewer.scene.view.setView({position, duration })
|
|
|
+ if(math.closeTo(position, this.images360.position)) return 'posNoChange'
|
|
|
+
|
|
|
+ viewer.scene.view.setView({position, target, duration })
|
|
|
|
|
|
- viewer.mapViewer.moveTo(position.clone(), null/* boundSizeMap */, duration)
|
|
|
+ o.dontMoveMap || viewer.mapViewer.moveTo(position.clone(), null , duration)
|
|
|
}
|
|
|
}
|
|
|
|