|
@@ -159,7 +159,7 @@ var Clip = {
|
|
|
//为了方便缩放操作,直接使用box中心作为target
|
|
|
|
|
|
|
|
|
- let duration = 1000
|
|
|
+ let duration = e.duration == void 0 ? 1000 : e.duration
|
|
|
viewer.scene.view.setView({position, duration, target})
|
|
|
|
|
|
},
|
|
@@ -169,10 +169,27 @@ var Clip = {
|
|
|
setTimeout(()=>{
|
|
|
let boundingBox = Clip.box.boundingBox.clone().applyMatrix4(Clip.box.matrixWorld)
|
|
|
if(mapVisi){//切换地图
|
|
|
- if(Clip.switchMapCount == 0 || !Potree.Utils.isInsideFrustum(boundingBox, viewer.mapViewer.camera)){
|
|
|
- let size = boundingBox.getSize(new THREE.Vector3)
|
|
|
+
|
|
|
+ if(viewer.fpVisiDatasets.length == 0){//不会显示任何一个floorplan图,就要就近移动到一个可见数据集里
|
|
|
+ let clouds = viewer.scene.pointclouds.filter(e=>e.visible)
|
|
|
+ if(clouds.length == 0)clouds = viewer.scene.pointclouds
|
|
|
+ let scores = clouds.map((e,i)=>{
|
|
|
+ return [ -viewer.scene.view.position.distanceToSquared(e.bound2) , i]
|
|
|
+ })
|
|
|
+ scores = scores.sort((a,b)=> a[0] - b[0])
|
|
|
+ let neareast = clouds[scores[0][1]]
|
|
|
+ viewer.flyToDataset({ pointcloud : neareast, duration:0})
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(Clip.switchMapCount == 0 || !Potree.Utils.getPos2d(viewer.scene.view.position, viewer.mapViewer.camera, viewer.mapViewer.renderArea, viewer.mapViewer.viewports[0]).inSight
|
|
|
+ || !Potree.Utils.isInsideFrustum(boundingBox, viewer.mapViewer.camera)){ //要使box框和游标都在屏幕内。因为游标是3d的当前位置,很可能是准备去框住的位置
|
|
|
+ let bound = boundingBox.clone()
|
|
|
+ bound.expandByPoint(viewer.scene.view.position)
|
|
|
+ let size = bound.getSize(new THREE.Vector3)
|
|
|
+ let center = bound.getCenter(new THREE.Vector3)
|
|
|
let margin = viewer.mainViewport.resolution.clone().multiplyScalar(0.3)
|
|
|
- viewer.mapViewer.moveTo(Clip.box.position, size, 100, margin)
|
|
|
+ viewer.mapViewer.moveTo(center, size, 100, margin)
|
|
|
}
|
|
|
Clip.switchMapCount++
|
|
|
//关于究竟是focus box还是dataset有点纠结,又或是两个的union。box和数据集可能离得很远,且无法确定当前想选择的数据集,且数据集可能无floorplan, 即使有可能也不展示……
|