display profile window pick sphere in regular 3D scene too
This commit is contained in:
parent
62eb46f802
commit
5235d41a32
@ -159,9 +159,10 @@ class ProfilePointCloudEntry{
|
||||
ProfilePointCloudEntry.materialPool = new Set();
|
||||
|
||||
Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
constructor () {
|
||||
constructor (viewer) {
|
||||
super();
|
||||
|
||||
this.viewer = viewer;
|
||||
this.elRoot = $('#profile_window');
|
||||
this.renderArea = this.elRoot.find('#profileCanvasContainer');
|
||||
this.svg = d3.select('svg#profileSVG');
|
||||
@ -199,6 +200,20 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
this.mouseIsDown = false;
|
||||
});
|
||||
|
||||
let viewerPickSphereSizeHandler = () => {
|
||||
let pr = 0;
|
||||
let camera = this.viewer.scene.getActiveCamera();
|
||||
let domElement = this.viewer.renderer.domElement;
|
||||
if(this.viewer.scene.cameraMode == Potree.CameraMode.PERSPECTIVE) {
|
||||
let distance = this.viewerPickSphere.position.distanceTo(camera.position);
|
||||
pr = Potree.utils.projectedRadius(1, camera.fov * Math.PI / 180, distance, domElement.clientHeight);
|
||||
} else {
|
||||
pr = Potree.utils.projectedRadiusOrtho(1, camera.projectionMatrix, domElement.clientWidth, domElement.clientHeight);
|
||||
}
|
||||
let scale = (10 / pr);
|
||||
this.viewerPickSphere.scale.set(scale, scale, scale);
|
||||
};
|
||||
|
||||
this.renderArea.mousemove(e => {
|
||||
if (this.pointclouds.size === 0) {
|
||||
return;
|
||||
@ -224,7 +239,7 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
this.render();
|
||||
} else if (this.pointclouds.size > 0) {
|
||||
// FIND HOVERED POINT
|
||||
let radius = Math.abs(this.scaleX.invert(0) - this.scaleX.invert(10));
|
||||
let radius = Math.abs(this.scaleX.invert(0) - this.scaleX.invert(40));
|
||||
let mileage = this.scaleX.invert(newMouse.x);
|
||||
let elevation = this.scaleY.invert(newMouse.y);
|
||||
let point = this.selectPoint(mileage, elevation, radius);
|
||||
@ -235,6 +250,16 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
this.pickSphere.scale.set(0.5 * radius, 0.5 * radius, 0.5 * radius);
|
||||
this.pickSphere.position.set(point.mileage, point.position[2], 0);
|
||||
|
||||
this.viewerPickSphere.position.set(...point.position);
|
||||
|
||||
if(!this.viewer.scene.scene.children.includes(this.viewerPickSphere)){
|
||||
this.viewer.scene.scene.add(this.viewerPickSphere);
|
||||
if(!this.viewer.hasEventListener("update", viewerPickSphereSizeHandler)){
|
||||
this.viewer.addEventListener("update", viewerPickSphereSizeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let info = this.elRoot.find('#profileSelectionProperties');
|
||||
let html = '<table>';
|
||||
for (let attribute of Object.keys(point)) {
|
||||
@ -283,6 +308,16 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
} else {
|
||||
// this.pickSphere.visible = false;
|
||||
// this.selectedPoint = null;
|
||||
|
||||
this.viewer.scene.scene.add(this.viewerPickSphere);
|
||||
|
||||
let index = this.viewer.scene.scene.children.indexOf(this.viewerPickSphere);
|
||||
if(index >= 0){
|
||||
this.viewer.scene.scene.children.splice(index, 1);
|
||||
}
|
||||
this.viewer.removeEventListener("update", viewerPickSphereSizeHandler);
|
||||
|
||||
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
@ -491,6 +526,8 @@ Potree.ProfileWindow = class ProfileWindow extends THREE.EventDispatcher {
|
||||
//this.pickSphere.visible = false;
|
||||
this.scene.add(this.pickSphere);
|
||||
|
||||
this.viewerPickSphere = new THREE.Mesh(sg, sm);
|
||||
|
||||
this.pointCloudRoot = new THREE.Object3D();
|
||||
this.scene.add(this.pointCloudRoot);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user