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

Improve handling of movements in 3rd dimension #5801

Merged
merged 11 commits into from
Nov 3, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,27 @@ function createDelayAwareMoveHandler(multiplier: number) {
const state = Store.getState();
let direction = Math.sign(multiplier);

const moveDistanceIn1Second =
state.userConfiguration.moveValue / getBaseVoxel(state.dataset.dataSource.scale);
const { activeViewport } = state.viewModeData.plane;
const thirdDim = dimensions.thirdDimensionForPlane(activeViewport);
const voxelPerSecond =
state.userConfiguration.moveValue / state.dataset.dataSource.scale[thirdDim];
philippotto marked this conversation as resolved.
Show resolved Hide resolved

if (activeViewport === OrthoViews.TDView) {
// Nothing should happen then, anyway.
return 0;
}

const thirdDim = dimensions.thirdDimensionForPlane(activeViewport);

if (state.userConfiguration.dynamicSpaceDirection) {
// Change direction of the value connected to space, based on the last direction
direction *= state.flycam.spaceDirectionOrtho[thirdDim];
}
const fraction = getPosition(state.flycam)[thirdDim] % 1;
const passedFraction = direction === 1 ? fraction : 1 - fraction;

// todo: remove
console.log({ moveDistanceIn1Second, passedFraction });

// Note that a passed fraction of 0 (e.g., z=11.0 and the direction
// goes towards 12), means that no additional delay is needed.
// The 1000 factor converts to ms.
return (1000 / moveDistanceIn1Second) * passedFraction;
return (1000 / voxelPerSecond) * passedFraction;
};

return fn;
Expand Down