Skip to content

Commit

Permalink
fix(Coordinate): Incorrect coordinate calculation for multiple view p…
Browse files Browse the repository at this point in the history
…orts.
  • Loading branch information
yarous224 committed Jul 20, 2021
1 parent 3b816b9 commit 133c485
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
28 changes: 24 additions & 4 deletions Sources/Rendering/Core/Coordinate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,12 @@ function vtkCoordinate(publicAPI, model) {
val = renderer.viewToProjection(val[0], val[1], val[2], aspect);

val = renderer.projectionToNormalizedViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(
val[0],
val[1],
val[2],
renderer
);
val = view.viewportToNormalizedDisplay(
val[0],
val[1],
Expand All @@ -441,7 +446,12 @@ function vtkCoordinate(publicAPI, model) {
case Coordinate.VIEW: {
val = renderer.viewToProjection(val[0], val[1], val[2], aspect);
val = renderer.projectionToNormalizedViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(
val[0],
val[1],
val[2],
renderer
);
val = view.viewportToNormalizedDisplay(
val[0],
val[1],
Expand All @@ -453,7 +463,12 @@ function vtkCoordinate(publicAPI, model) {
}
case Coordinate.PROJECTION: {
val = renderer.projectionToNormalizedViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(
val[0],
val[1],
val[2],
renderer
);
val = view.viewportToNormalizedDisplay(
val[0],
val[1],
Expand All @@ -464,7 +479,12 @@ function vtkCoordinate(publicAPI, model) {
break;
}
case Coordinate.NORMALIZED_VIEWPORT: {
val = view.normalizedViewportToViewport(val[0], val[1], val[2]);
val = view.normalizedViewportToViewport(
val[0],
val[1],
val[2],
renderer
);

if (model.referenceCoordinate) {
const refValue = model.referenceCoordinate.getComputedDoubleViewportValue(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Rendering/SceneGraph/RenderWindowViewNode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ function vtkRenderWindowViewNode(publicAPI, model) {
return [x, y, z];
};

publicAPI.normalizedViewportToViewport = (x, y, z) => {
const size = publicAPI.getFramebufferSize();
publicAPI.normalizedViewportToViewport = (x, y, z, renderer) => {
const size = publicAPI.getViewportSize(renderer);
return [x * (size[0] - 1.0), y * (size[1] - 1.0), z];
};

Expand Down

0 comments on commit 133c485

Please sign in to comment.