feat: add VolumeViewport rotation (#3776)
This commit is contained in:
parent
9575a6f54c
commit
442f99d5eb
@ -3,6 +3,8 @@ import {
|
|||||||
StackViewport,
|
StackViewport,
|
||||||
VolumeViewport,
|
VolumeViewport,
|
||||||
utilities as csUtils,
|
utilities as csUtils,
|
||||||
|
Types as CoreTypes,
|
||||||
|
BaseVolumeViewport,
|
||||||
} from '@cornerstonejs/core';
|
} from '@cornerstonejs/core';
|
||||||
import {
|
import {
|
||||||
ToolGroupManager,
|
ToolGroupManager,
|
||||||
@ -11,6 +13,7 @@ import {
|
|||||||
ReferenceLinesTool,
|
ReferenceLinesTool,
|
||||||
} from '@cornerstonejs/tools';
|
} from '@cornerstonejs/tools';
|
||||||
import { Types as OhifTypes } from '@ohif/core';
|
import { Types as OhifTypes } from '@ohif/core';
|
||||||
|
import { vec3, mat4 } from 'gl-matrix';
|
||||||
|
|
||||||
import CornerstoneViewportDownloadForm from './utils/CornerstoneViewportDownloadForm';
|
import CornerstoneViewportDownloadForm from './utils/CornerstoneViewportDownloadForm';
|
||||||
import callInputDialog from './utils/callInputDialog';
|
import callInputDialog from './utils/callInputDialog';
|
||||||
@ -391,8 +394,16 @@ function commandsModule({
|
|||||||
|
|
||||||
const { viewport } = enabledElement;
|
const { viewport } = enabledElement;
|
||||||
|
|
||||||
if (viewport instanceof StackViewport) {
|
if (viewport instanceof BaseVolumeViewport) {
|
||||||
const { rotation: currentRotation } = viewport.getProperties();
|
const camera = viewport.getCamera();
|
||||||
|
const rotAngle = (rotation * Math.PI) / 180;
|
||||||
|
const rotMat = mat4.identity(new Float32Array(16));
|
||||||
|
mat4.rotate(rotMat, rotMat, rotAngle, camera.viewPlaneNormal);
|
||||||
|
const rotatedViewUp = vec3.transformMat4(vec3.create(), camera.viewUp, rotMat);
|
||||||
|
viewport.setCamera({ viewUp: rotatedViewUp as CoreTypes.Point3 });
|
||||||
|
viewport.render();
|
||||||
|
} else if (viewport.getRotation !== undefined) {
|
||||||
|
const currentRotation = viewport.getRotation();
|
||||||
const newRotation = (currentRotation + rotation) % 360;
|
const newRotation = (currentRotation + rotation) % 360;
|
||||||
viewport.setProperties({ rotation: newRotation });
|
viewport.setProperties({ rotation: newRotation });
|
||||||
viewport.render();
|
viewport.render();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user