@cornerstonejs/core 3.12.0 → 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.
- package/dist/esm/RenderingEngine/StackViewport.js +9 -11
- package/dist/esm/RenderingEngine/Viewport.js +3 -3
- package/dist/esm/utilities/adjustInitialViewUp.d.ts +2 -0
- package/dist/esm/utilities/adjustInitialViewUp.js +14 -0
- package/dist/esm/utilities/reflectVector.d.ts +2 -0
- package/dist/esm/utilities/reflectVector.js +6 -0
- package/package.json +2 -2
|
@@ -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
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
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
|
|
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:
|
|
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,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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "3.12.
|
|
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": "
|
|
94
|
+
"gitHead": "1078f671cf67a8f38f561887940ac91b33756719"
|
|
95
95
|
}
|