|
@@ -78343,6 +78343,7 @@
|
|
|
this.yawDelta += ndrag.x * this.rotationSpeed;
|
|
|
this.pitchDelta += ndrag.y * this.rotationSpeed;
|
|
|
} else if (mode == 'pan') {
|
|
|
+ if (!this.dragStarted) this.updateRadius('startPan');
|
|
|
this.panDelta.x += ndrag.x;
|
|
|
this.panDelta.y += ndrag.y;
|
|
|
} else if (mode == 'scale-pan') {
|
|
@@ -78364,9 +78365,11 @@
|
|
|
//console.log('scale ',scale, this.radiusDelta)
|
|
|
}
|
|
|
this.stopTweens();
|
|
|
+ this.dragStarted = true;
|
|
|
};
|
|
|
var drop = e => {
|
|
|
if (!this.enabled) return;
|
|
|
+ this.dragStarted = false;
|
|
|
this.dispatchEvent({
|
|
|
type: 'end'
|
|
|
});
|
|
@@ -78376,7 +78379,7 @@
|
|
|
var resolvedRadius = this.currentViewport.view.radius + this.radiusDelta;
|
|
|
this.radiusDelta += -e.delta * resolvedRadius * 0.1;
|
|
|
this.stopTweens();
|
|
|
- this.updateRadius();
|
|
|
+ this.updateRadius('scroll');
|
|
|
};
|
|
|
var dblclick = e => {
|
|
|
if (!this.enabled) return;
|
|
@@ -78463,8 +78466,7 @@
|
|
|
var distance = o.position.distanceTo(o.CamTarget);
|
|
|
//if(distance < minRadius) minRadius = distance * 0.5 //融合页面当focus一个很小的物体时,需要将minRadius也调小
|
|
|
this.minRadius = Math.min(standartMinRadius, distance * 0.5);
|
|
|
- console.log('focus dis', distance);
|
|
|
- //console.log('minRadius',this.minRadius)
|
|
|
+ //console.log('focus dis', distance)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -78488,72 +78490,6 @@
|
|
|
this.radiusDelta = 0;
|
|
|
this.panDelta.set(0, 0);
|
|
|
}
|
|
|
-
|
|
|
- /* zoomToLocation(mouse){
|
|
|
- if(!this.enabled)return
|
|
|
- let camera = this.scene.getActiveCamera();
|
|
|
-
|
|
|
- let I = Utils.getMousePointCloudIntersection(
|
|
|
- null, mouse, this.viewer.inputHandler.pointer,
|
|
|
- camera,
|
|
|
- this.viewer,
|
|
|
- this.scene.pointclouds,
|
|
|
- {pickClipped: true});
|
|
|
-
|
|
|
- if (I === null) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- let targetRadius = 0;
|
|
|
- {
|
|
|
- let minimumJumpDistance = 0.2;
|
|
|
-
|
|
|
- let domElement = this.renderer.domElement;
|
|
|
- let ray = Utils.mouseToRay(this.viewer.inputHandler.pointer , camera, domElement.clientWidth, domElement.clientHeight);
|
|
|
-
|
|
|
- let nodes = I.pointcloud.nodesOnRay(I.pointcloud.visibleNodes, ray);
|
|
|
- let lastNode = nodes[nodes.length - 1];
|
|
|
- let radius = lastNode.getBoundingSphere(new THREE.Sphere()).radius;
|
|
|
- targetRadius = Math.min(this.currentViewport.view.radius, radius);
|
|
|
- targetRadius = Math.max(minimumJumpDistance, targetRadius);
|
|
|
- }
|
|
|
-
|
|
|
- let d = this.currentViewport.view.direction.multiplyScalar(-1);
|
|
|
- let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius));
|
|
|
- // TODO Unused: let controlsTargetPosition = I.location;
|
|
|
-
|
|
|
- let animationDuration = 600;
|
|
|
- let easing = TWEEN.Easing.Quartic.Out;
|
|
|
-
|
|
|
- { // animate
|
|
|
- let value = {x: 0};
|
|
|
- let tween = new TWEEN.Tween(value).to({x: 1}, animationDuration);
|
|
|
- tween.easing(easing);
|
|
|
- this.tweens.push(tween);
|
|
|
-
|
|
|
- let startPos = this.currentViewport.view.position.clone();
|
|
|
- let targetPos = cameraTargetPosition.clone();
|
|
|
- let startRadius = this.currentViewport.view.radius;
|
|
|
- let targetRadius = cameraTargetPosition.distanceTo(I.location);
|
|
|
-
|
|
|
- tween.onUpdate(() => {
|
|
|
- let t = value.x;
|
|
|
- this.currentViewport.view.position.x = (1 - t) * startPos.x + t * targetPos.x;
|
|
|
- this.currentViewport.view.position.y = (1 - t) * startPos.y + t * targetPos.y;
|
|
|
- this.currentViewport.view.position.z = (1 - t) * startPos.z + t * targetPos.z;
|
|
|
-
|
|
|
- this.currentViewport.view.radius = (1 - t) * startRadius + t * targetRadius;
|
|
|
- this.viewer.setMoveSpeed(this.currentViewport.view.radius);
|
|
|
- });
|
|
|
-
|
|
|
- tween.onComplete(() => {
|
|
|
- this.tweens = this.tweens.filter(e => e !== tween);
|
|
|
- });
|
|
|
-
|
|
|
- tween.start();
|
|
|
- }
|
|
|
- } */
|
|
|
-
|
|
|
zoomToLocation(mouse) {
|
|
|
var I = viewer.inputHandler.intersect;
|
|
|
var object;
|
|
@@ -78574,7 +78510,7 @@
|
|
|
distance = this.updateRadiusByModel(object, dis);
|
|
|
} else {
|
|
|
distance = Math.min(dis, 50); //方便从高空回到地面
|
|
|
- this.updateRadius();
|
|
|
+ this.updateRadius('focus');
|
|
|
}
|
|
|
viewer.focusOnObject({
|
|
|
position: I
|
|
@@ -78591,23 +78527,51 @@
|
|
|
var distance = MathUtils.clamp(dis, 0.8 * object.scale.x, Math.max(len * 0.1, 3 * object.scale.x));
|
|
|
this.minRadius = Math.min(distance, standartMinRadius);
|
|
|
this.maxRadius = dis * 2;
|
|
|
- console.log('maxRadius hasIntersect', this.maxRadius);
|
|
|
+ //console.log('maxRadius hasIntersect', this.maxRadius)
|
|
|
return distance;
|
|
|
}
|
|
|
- updateRadius() {
|
|
|
- var _viewer$inputHandler$, _viewer$inputHandler$2;
|
|
|
- var model = ((_viewer$inputHandler$ = viewer.inputHandler.intersect) === null || _viewer$inputHandler$ === void 0 ? void 0 : _viewer$inputHandler$.object) || ((_viewer$inputHandler$2 = viewer.inputHandler.intersect) === null || _viewer$inputHandler$2 === void 0 ? void 0 : _viewer$inputHandler$2.pointcloud);
|
|
|
+ updateRadius(type) {
|
|
|
+ var _viewer$inputHandler$2, _viewer$inputHandler$3;
|
|
|
+ if (type == 'startPan') {
|
|
|
+ var _viewer$inputHandler$;
|
|
|
+ //以drag的point为target, 使drag跟手
|
|
|
+ var I = (_viewer$inputHandler$ = viewer.inputHandler.intersect) === null || _viewer$inputHandler$ === void 0 ? void 0 : _viewer$inputHandler$.location;
|
|
|
+ if (!I) {
|
|
|
+ var {
|
|
|
+ x,
|
|
|
+ y
|
|
|
+ } = Potree.Utils.getPointerPosAtHeight(0, viewer.inputHandler.pointer);
|
|
|
+ I = new Vector3(x, y, 0); //地面交点
|
|
|
+ }
|
|
|
+ var dis = this.currentViewport.view.position.distanceTo(I);
|
|
|
+ this.currentViewport.view.radius = dis;
|
|
|
+ //console.log('radius',dis)
|
|
|
+ }
|
|
|
+ var model = ((_viewer$inputHandler$2 = viewer.inputHandler.intersect) === null || _viewer$inputHandler$2 === void 0 ? void 0 : _viewer$inputHandler$2.object) || ((_viewer$inputHandler$3 = viewer.inputHandler.intersect) === null || _viewer$inputHandler$3 === void 0 ? void 0 : _viewer$inputHandler$3.pointcloud);
|
|
|
if (model) {
|
|
|
this.updateRadiusByModel(model, viewer.inputHandler.intersect.location.distanceTo(this.currentViewport.view.position));
|
|
|
} else {
|
|
|
- if (!viewer.bound || viewer.bound.boundSize.x == 0) return;
|
|
|
- var boundFloor = viewer.bound.boundingBox.clone();
|
|
|
- boundFloor.max.z = boundFloor.min.z;
|
|
|
- var dis2 = boundFloor.distanceToPoint(viewer.mainViewport.view.position);
|
|
|
- this.maxRadius = Math.max(4, dis2 * 5);
|
|
|
- console.log('maxRadius noIntersect', this.maxRadius);
|
|
|
+ if (!viewer.bound || viewer.bound.boundSize.x == 0) {
|
|
|
+ this.maxRadius = viewer.mainViewport.view.position.length() * 2;
|
|
|
+ } else {
|
|
|
+ var boundFloor = viewer.bound.boundingBox.clone();
|
|
|
+ boundFloor.max.z = boundFloor.min.z;
|
|
|
+ var dis2 = boundFloor.distanceToPoint(viewer.mainViewport.view.position); //靠近模型底部时变慢
|
|
|
+ this.maxRadius = Math.max(4, dis2 * 5);
|
|
|
+ //console.log('maxRadius noIntersect', this.maxRadius)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ /* 增加maxRadius限制是因为2024.12有人提单说在离模型区域bound很远的地方scroll和drag多次之后回来,radius会过大。
|
|
|
+ 所以只能稍微加一个影响radius的因素。但是当没有intersect时,效果可能欠佳。
|
|
|
+ 没有完美的方法,想象下,在bound外也有物体需要focusPoint, 如path, 此时虽然离bound很远但也需要小radius。
|
|
|
+ 而当转向朝bound飞去却很慢,虽然可以根据intersect提高minRadius来加速,但如果是focus一个四周都有模型的target,就会被intersect干扰,无法focus。
|
|
|
+
|
|
|
+ 现在存在的现象就是容易出现radius过小,游不到终点的情况,所以我让双击可以focus地面,通过这个办法攀到终点。
|
|
|
+ *没办法直接更改radius,而是通过minRadius和maxRadius, 是因为情况太多了,直接更改不能满足所有情况,还会造成突变。
|
|
|
+ *minRadius一般不超过standardMinRadius
|
|
|
+ */
|
|
|
+
|
|
|
stopTweens() {
|
|
|
this.tweens.forEach(e => e.stop());
|
|
|
this.tweens = [];
|
|
@@ -78665,11 +78629,11 @@
|
|
|
/* let progression = Math.min(1, this.fadeFactor * delta);
|
|
|
let panDistance = progression * view.radius * 3; */
|
|
|
|
|
|
- var panDistance = 2 * view.radius * Math.tan(MathUtils.degToRad(camera.fov / 2)); //参照4dkk。 平移target(也就是平移镜头位置),但还是难以保证跟手(navvis也不一定跟手,但是很奇怪在居中时中心点居然是跟手的,可能计算方式不同)
|
|
|
- //计算了下确实是这么算的。 平移pivot。
|
|
|
+ var panDistance = 2 * view.radius * Math.tan(MathUtils.degToRad(camera.fov / 2)) / 1850; //参照4dkk。 平移target(也就是平移镜头位置),但还是难以保证跟手(navvis也不一定跟手,但是很奇怪在居中时中心点居然是跟手的,可能计算方式不同)
|
|
|
+ //计算了下确实是这么算的。 平移pivot。 尽量跟手
|
|
|
|
|
|
- var _px = -this.panDelta.x * panDistance;
|
|
|
- var _py = this.panDelta.y * panDistance;
|
|
|
+ var _px = -this.panDelta.x * panDistance * this.renderer.domElement.clientWidth;
|
|
|
+ var _py = this.panDelta.y * panDistance * this.renderer.domElement.clientHeight;
|
|
|
view.pan(_px, _py);
|
|
|
}
|
|
|
{
|