Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | import { MPR_CAMERA_VALUES } from '../../../constants';
import { OrientationAxis } from '../../../enums';
import type { IImageVolume, Point3 } from '../../../types';
import getAcquisitionPlaneOrientation from '../../../utilities/getAcquisitionPlaneOrientation';
import { isPlanarOrientationVectors } from './planarLegacyCompatibility';
import type { PlanarViewState } from './PlanarViewportTypes';
type PlanarViewStateVectors = {
viewPlaneNormal: Point3;
viewUp: Point3;
};
export function getAcquisitionCameraVectors(
imageVolume: IImageVolume
): PlanarViewStateVectors {
const { viewPlaneNormal, viewUp } =
getAcquisitionPlaneOrientation(imageVolume);
return {
viewPlaneNormal,
viewUp: viewUp as Point3,
};
}
export function getPlanarViewStateVectors(args: {
imageVolume: IImageVolume;
orientation?: PlanarViewState['orientation'];
}): PlanarViewStateVectors | undefined {
const { imageVolume, orientation } = args;
if (!orientation) {
return;
}
if (orientation === OrientationAxis.ACQUISITION) {
return getAcquisitionCameraVectors(imageVolume);
}
if (isPlanarOrientationVectors(orientation)) {
return {
viewPlaneNormal: [...orientation.viewPlaneNormal] as Point3,
viewUp: [
...(orientation.viewUp ||
getAcquisitionCameraVectors(imageVolume).viewUp),
] as Point3,
};
}
const cameraValues = MPR_CAMERA_VALUES[orientation];
if (!cameraValues) {
return;
}
return {
viewPlaneNormal: [...cameraValues.viewPlaneNormal] as Point3,
viewUp: [...cameraValues.viewUp] as Point3,
};
}
|