|
@@ -87,7 +87,7 @@ export class FirstPersonControls extends THREE.EventDispatcher {
|
|
|
if(e.touches.length == 1){
|
|
|
mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'rotate' : 'pan'
|
|
|
}else if(e.touches.length == 2){
|
|
|
- mode = Potree.settings.displayMode == 'showPanos' ? 'scale' : 'pan-scale'
|
|
|
+ mode = Potree.settings.displayMode == 'showPanos' ? 'scale' : 'pan-scale'
|
|
|
}else{
|
|
|
mode = (!e.dragViewport || e.dragViewport.name == 'MainView') ? 'pan' : 'scale'
|
|
|
}
|
|
@@ -315,7 +315,8 @@ export class FirstPersonControls extends THREE.EventDispatcher {
|
|
|
|
|
|
|
|
|
if(mode.includes('scale')){//触屏缩放
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
this.dollyEnd.subVectors(e.touches[0].pointer, e.touches[1].pointer);
|
|
|
//if(!this.dollyStart)return
|
|
|
var scale = this.dollyEnd.length() / this.dollyStart.length()
|
|
@@ -325,9 +326,9 @@ export class FirstPersonControls extends THREE.EventDispatcher {
|
|
|
dolly({
|
|
|
pointer,
|
|
|
scale, camera, drag:e.drag
|
|
|
- })
|
|
|
+ })
|
|
|
this.dollyStart.copy(this.dollyEnd);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
//最好按ctrl可以变为dollhouse的那种旋转
|
|
|
};
|
|
@@ -343,7 +344,7 @@ export class FirstPersonControls extends THREE.EventDispatcher {
|
|
|
|
|
|
if(Potree.settings.displayMode == 'showPanos' && this.currentViewport == viewer.mainViewport/* this.currentViewport.unableChangePos */){//全景时
|
|
|
this.dispatchEvent({type:'dollyStopCauseUnable',delta:e.delta, scale:e.scale})
|
|
|
- return
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
let camera = e.camera
|
|
@@ -404,28 +405,43 @@ export class FirstPersonControls extends THREE.EventDispatcher {
|
|
|
this.useAttenuation = true
|
|
|
}else{//触屏缩放
|
|
|
direction = this.viewer.inputHandler.getMouseDirection(e.pointer).direction //定点缩放
|
|
|
-
|
|
|
+
|
|
|
if(e.drag.intersectStart){//和intersect的墙越接近,速度越慢,便于focus细节
|
|
|
let dis = camera.position.distanceTo(e.drag.intersectStart.location);
|
|
|
|
|
|
+
|
|
|
let r = 1-1/e.scale
|
|
|
let closeMin = 0.1, standardMin = 0.001, disBound1 = 2, disBound2 = 5
|
|
|
+
|
|
|
+ if(math.closeTo(e.scale,1,0.03)){//如果偏差小于0.01,就不限制最小值,因为平移容易正负抖动,近距离有最小值的话抖动明显
|
|
|
+ closeMin = 0 //所以若缩放不明显(双指滑动慢),就不设置最低值。(这时候穿越障碍物会比较困难。)
|
|
|
+ }
|
|
|
+ //console.log('closeMin',closeMin)
|
|
|
let min = math.linearClamp(dis, disBound1, disBound2, closeMin, standardMin) //触屏和滚轮不一样,触发较为连续,所以最小值设低一点。若要保持双指相对点云位置不变,理想最小值是0,但那样就无法穿越点云(最小值太小的话穿越密集点云如树丛很困难;太大会打滑)所以当离点云近时增大最小值
|
|
|
speed = Math.sign(r) * THREE.Math.clamp(dis * Math.abs(r), min, speed)
|
|
|
|
|
|
//console.log(speed, dis, e.scale)
|
|
|
|
|
|
}else{
|
|
|
- const constantDis = this.currentViewport.getMoveSpeed() * 200 //constantDis = 10;//常量系数,当放大一倍时前进的距离。可以调整
|
|
|
+
|
|
|
+ this.useAttenuation = true
|
|
|
+ let accelerate = 80;
|
|
|
+ if(math.closeTo(e.scale,1,0.02)){//缩放小的时候很可能是双指平移时,容易抖动,所以降低移动速度
|
|
|
+ accelerate *= Math.min(40*Math.abs(e.scale-1), 0.8)
|
|
|
+ }
|
|
|
+ // console.log('accelerate',accelerate)
|
|
|
+ const constantDis = this.currentViewport.getMoveSpeed() * accelerate //constantDis = 10;//常量系数,当放大一倍时前进的距离。可以调整
|
|
|
speed = (e.scale-1)*constantDis
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
var vec = direction.multiplyScalar(speed )
|
|
|
//this.translationWorldDelta.copy(vec)
|
|
|
this.translationWorldDelta.add(vec)
|
|
|
- //console.log(vec, speed)
|
|
|
+ //console.log(direction.toArray(), speed, e.scale)
|
|
|
}
|
|
|
+ return true
|
|
|
}
|
|
|
|
|
|
let scroll = (e) => {
|