@cornerstonejs/core 3.11.8 → 3.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,7 @@ import { Transform } from './helpers/cpuFallback/rendering/transform';
42
42
  import uuidv4 from '../utilities/uuidv4';
43
43
  import getSpacingInNormalDirection from '../utilities/getSpacingInNormalDirection';
44
44
  import getClosestImageId from '../utilities/getClosestImageId';
45
+ import { adjustInitialViewUp } from '../utilities/adjustInitialViewUp';
45
46
  const EPSILON = 1;
46
47
  const log = coreLog.getLogger('RenderingEngine', 'StackViewport');
47
48
  class StackViewport extends Viewport {
@@ -128,12 +129,11 @@ class StackViewport extends Viewport {
128
129
  return viewport.rotation;
129
130
  };
130
131
  this.getRotationGPU = () => {
131
- const { viewUp: currentViewUp, viewPlaneNormal, flipVertical, } = this.getCameraNoRotation();
132
- const initialViewUp = flipVertical
133
- ? vec3.negate(vec3.create(), this.initialViewUp)
134
- : this.initialViewUp;
135
- const initialToCurrentViewUpAngle = (vec3.angle(initialViewUp, currentViewUp) * 180) / Math.PI;
136
- const initialToCurrentViewUpCross = vec3.cross(vec3.create(), initialViewUp, currentViewUp);
132
+ const { viewUp: currentViewUp, viewPlaneNormal, flipVertical, flipHorizontal, } = this.getCameraNoRotation();
133
+ const adjustedViewUp = adjustInitialViewUp(this.initialViewUp, flipHorizontal, flipVertical, viewPlaneNormal);
134
+ const angleRad = vec3.angle(adjustedViewUp, currentViewUp);
135
+ const initialToCurrentViewUpAngle = (angleRad * 180) / Math.PI;
136
+ const initialToCurrentViewUpCross = vec3.cross(vec3.create(), adjustedViewUp, currentViewUp);
137
137
  const normalDot = vec3.dot(initialToCurrentViewUpCross, viewPlaneNormal);
138
138
  return normalDot >= 0
139
139
  ? initialToCurrentViewUpAngle
@@ -795,12 +795,10 @@ class StackViewport extends Viewport {
795
795
  const pan = this.getPan();
796
796
  const panSub = vec2.sub([0, 0], panFit, pan);
797
797
  this.setPan(panSub, false);
798
- const { flipVertical } = this.getCamera();
799
- const initialViewUp = flipVertical
800
- ? vec3.negate(vec3.create(), this.initialViewUp)
801
- : this.initialViewUp;
798
+ const { flipVertical, flipHorizontal, viewPlaneNormal } = this.getCamera();
799
+ const adjustedViewUp = adjustInitialViewUp(this.initialViewUp, flipHorizontal, flipVertical, viewPlaneNormal);
802
800
  this.setCameraNoEvent({
803
- viewUp: initialViewUp,
801
+ viewUp: adjustedViewUp,
804
802
  });
805
803
  this.getVtkActiveCamera().roll(-rotation);
806
804
  const afterPan = this.getPan();
@@ -949,9 +949,6 @@ class Viewport {
949
949
  if (pan) {
950
950
  this.setPan(vec2.scale([0, 0], pan, zoom));
951
951
  }
952
- if (rotation >= 0) {
953
- this.setRotation(rotation);
954
- }
955
952
  if (flipHorizontal !== undefined &&
956
953
  flipHorizontal !== this.flipHorizontal) {
957
954
  this.flip({ flipHorizontal });
@@ -959,6 +956,9 @@ class Viewport {
959
956
  if (flipVertical !== undefined && flipVertical !== this.flipVertical) {
960
957
  this.flip({ flipVertical });
961
958
  }
959
+ if (rotation >= 0) {
960
+ this.setRotation(rotation);
961
+ }
962
962
  }
963
963
  _getCorners(bounds) {
964
964
  return [
@@ -0,0 +1,2 @@
1
+ import type { Point3 } from '../types';
2
+ export declare function adjustInitialViewUp(initialViewUp: Point3, flipHorizontal: boolean, flipVertical: boolean, viewPlaneNormal: Point3): Point3;
@@ -0,0 +1,14 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ import { reflectVector } from './reflectVector';
3
+ export function adjustInitialViewUp(initialViewUp, flipHorizontal, flipVertical, viewPlaneNormal) {
4
+ let adjustedInitialViewUp = vec3.clone(initialViewUp);
5
+ if (flipVertical) {
6
+ vec3.negate(adjustedInitialViewUp, adjustedInitialViewUp);
7
+ }
8
+ if (flipHorizontal) {
9
+ const screenVerticalAxis = vec3.cross(vec3.create(), viewPlaneNormal, adjustedInitialViewUp);
10
+ vec3.normalize(screenVerticalAxis, screenVerticalAxis);
11
+ adjustedInitialViewUp = reflectVector(adjustedInitialViewUp, screenVerticalAxis);
12
+ }
13
+ return adjustedInitialViewUp;
14
+ }
@@ -0,0 +1,2 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export declare function reflectVector(v: vec3, normal: vec3): vec3;
@@ -0,0 +1,6 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export function reflectVector(v, normal) {
3
+ const dotProduct = vec3.dot(v, normal);
4
+ const scaledNormal = vec3.scale(vec3.create(), normal, 2 * dotProduct);
5
+ return vec3.sub(vec3.create(), v, scaledNormal);
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "3.11.8",
3
+ "version": "3.12.1",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -91,5 +91,5 @@
91
91
  "type": "individual",
92
92
  "url": "https://ohif.org/donate"
93
93
  },
94
- "gitHead": "c4d9fd52163b0b546ed5ab5105f5e28819ba0f08"
94
+ "gitHead": "1078f671cf67a8f38f561887940ac91b33756719"
95
95
  }