Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix node picking regression #7732

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed that the Command modifier on MacOS wasn't treated correctly for some shortcuts. Also, instead of the Alt key, the ⌥ key is shown as a hint in the status bar on MacOS. [#7659](https://github.com/scalableminds/webknossos/pull/7659)
- Moving from the time tracking overview to its detail view, the selected user was not preselected in the next view. [#7722](https://github.com/scalableminds/webknossos/pull/7722)
- Fixed incorrect position of WEBKNOSSOS logo in screenshots. [#7726](https://github.com/scalableminds/webknossos/pull/7726)
- Fixed that invisible nodes could be selected when using the skeleton tool. [#7732](https://github.com/scalableminds/webknossos/pull/7732)

### Removed

Expand Down
19 changes: 11 additions & 8 deletions frontend/javascripts/oxalis/view/rendering_utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as THREE from "three";
import { saveAs } from "file-saver";
import Store from "oxalis/store";
import { OrthoView } from "oxalis/constants";
import { ARBITRARY_CAM_DISTANCE, OrthoView } from "oxalis/constants";
import constants, {
ArbitraryViewport,
OrthoViewColors,
Expand Down Expand Up @@ -59,25 +59,28 @@ export function renderToTexture(
// Don't respect withFarClipping for the TDViewport as we don't do any clipping for
// nodes there.
if (withFarClipping && plane !== OrthoViews.TDView) {
function adaptCameraToCurrentClippingDistance(
camera: THREE.OrthographicCamera | THREE.PerspectiveCamera,
) {
function adaptCameraToCurrentClippingDistance<
T extends THREE.OrthographicCamera | THREE.PerspectiveCamera,
>(camera: T): T {
const isArbitraryMode = constants.MODES_ARBITRARY.includes(
state.temporaryConfiguration.viewMode,
);
camera = camera.clone();
camera = camera.clone() as T;
// The near value is already set in the camera (done in the CameraController/ArbitraryView).
if (isArbitraryMode) {
camera.far = state.userConfiguration.clippingDistanceArbitrary;
// The far value has to be set, since in normal rendering the far clipping is
// achieved by the data plane which is not rendered during node picking
camera.far = ARBITRARY_CAM_DISTANCE;
} else {
// The near value is already set in the camera (done in the CameraController).
// The far value has to be set, since in normal rendering the far clipping is
// achieved by offsetting the plane instead of setting the far property.
camera.far = state.userConfiguration.clippingDistance;
}
camera.updateProjectionMatrix();
return camera;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the fix for the actual regression. The camera was cloned and modified (in this function that was introduced in a recent PR), but then later in the original function, the old camera was used again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argh, this explains a lot of the weirdness I experienced with the clipping distances 🙈 thanks for fixing this!

}

adaptCameraToCurrentClippingDistance(camera);
camera = adaptCameraToCurrentClippingDistance(camera);
}

clearColor = clearColor != null ? clearColor : 0x000000;
Expand Down