@cornerstonejs/core 1.63.2 → 1.63.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.63.2",
3
+ "version": "1.63.4",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "type": "individual",
48
48
  "url": "https://ohif.org/donate"
49
49
  },
50
- "gitHead": "315d09daf27cd6dd46d33b62a59b6cf2050116c9"
50
+ "gitHead": "752f9beba007fcbd70718545199246df03061ca2"
51
51
  }
@@ -62,6 +62,7 @@ import type { vtkSlabCamera as vtkSlabCameraType } from './vtkClasses/vtkSlabCam
62
62
  import vtkSlabCamera from './vtkClasses/vtkSlabCamera';
63
63
  import transformWorldToIndex from '../utilities/transformWorldToIndex';
64
64
  import { getTransferFunctionNodes } from '../utilities/transferFunctionUtils';
65
+ import { getColormap, getColormapNames } from '../utilities/colormap';
65
66
  /**
66
67
  * Abstract base class for volume viewports. VolumeViewports are used to render
67
68
  * 3D volumes from which various orientations can be viewed. Since VolumeViewports
@@ -859,9 +860,11 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
859
860
  acc.push(node.x, node.r, node.g, node.b);
860
861
  return acc;
861
862
  }, []);
862
- const colormaps = vtkColorMaps.rgbPresetNames.map((presetName) =>
863
+ const colormapsVTK = vtkColorMaps.rgbPresetNames.map((presetName) =>
863
864
  vtkColorMaps.getPresetByName(presetName)
864
865
  );
866
+ const colormapsCS3D = getColormapNames().map((colormapName) => getColormap(colormapName));
867
+ const colormaps = colormapsVTK.concat(colormapsCS3D);
865
868
  const matchedColormap = colormaps.find((colormap) => {
866
869
  const { RGBPoints: presetRGBPoints } = colormap;
867
870
  if (presetRGBPoints.length !== RGBPoints.length) {
@@ -54,7 +54,7 @@ export default class CanvasActor implements ICanvasActor {
54
54
  const baseOffset = (y * width) << 2;
55
55
  let indicesToDelete;
56
56
  for (const run of row) {
57
- const { start: start, end, value: segmentIndex } = run;
57
+ const { start, end, value: segmentIndex } = run;
58
58
  if (segmentIndex === 0) {
59
59
  indicesToDelete ||= [];
60
60
  indicesToDelete.push(row.indexOf(run));
@@ -85,10 +85,10 @@ export default class CanvasActor implements ICanvasActor {
85
85
  imageData,
86
86
  0,
87
87
  0,
88
- dirtyX,
89
- dirtyY,
90
- dirtyWidth,
91
- dirtyHeight
88
+ dirtyX - 1,
89
+ dirtyY - 1,
90
+ dirtyWidth + 2,
91
+ dirtyHeight + 2
92
92
  );
93
93
  context.drawImage(
94
94
  canvas,
@@ -59,6 +59,13 @@ class VideoViewport extends Viewport implements IVideoViewport {
59
59
  private playbackRate = 1;
60
60
  private scalarData: CanvasScalarData;
61
61
 
62
+ /**
63
+ * This is used to pause initially so that we get at least one render to allow
64
+ * navigating frames. Otherwise the viewport is blank initially until the user
65
+ * hits play manually.
66
+ */
67
+ private initialRender: () => void;
68
+
62
69
  /**
63
70
  * The range is the set of frames to play
64
71
  */
@@ -119,6 +126,7 @@ class VideoViewport extends Viewport implements IVideoViewport {
119
126
  this.videoElement = document.createElement('video');
120
127
  this.videoElement.muted = this.mute;
121
128
  this.videoElement.loop = this.loop;
129
+ this.videoElement.autoplay = true;
122
130
  this.videoElement.crossOrigin = 'anonymous';
123
131
 
124
132
  this.addEventListeners();
@@ -235,16 +243,22 @@ class VideoViewport extends Viewport implements IVideoViewport {
235
243
  this.numberOfFrames = numberOfFrames;
236
244
  // 1 based range setting
237
245
  this.setFrameRange([1, numberOfFrames]);
238
- this.play();
246
+ // The initial render allows us to set the frame position - rendering needs
247
+ // to start already playing
248
+ this.initialRender = () => {
249
+ this.initialRender = null;
250
+ this.pause();
251
+ this.setFrameNumber(frameNumber || 1);
252
+ };
253
+
239
254
  // This is ugly, but without it, the video often fails to render initially
240
255
  // so having a play, followed by a pause fixes things.
241
- // 100 ms is a tested value that seems to work to prevent exceptions
256
+ // 25 ms is a tested value that seems to work to prevent exceptions
242
257
  return new Promise((resolve) => {
243
258
  window.setTimeout(() => {
244
- this.pause();
245
259
  this.setFrameNumber(frameNumber || 1);
246
260
  resolve(this);
247
- }, 100);
261
+ }, 25);
248
262
  });
249
263
  });
250
264
  }
@@ -646,6 +660,7 @@ class VideoViewport extends Viewport implements IVideoViewport {
646
660
  ];
647
661
  }
648
662
 
663
+ this.canvasContext.fillStyle = 'rgba(0,0,0,1)';
649
664
  this.canvasContext.fillRect(0, 0, this.canvas.width, this.canvas.height);
650
665
 
651
666
  if (this.isPlaying === false) {
@@ -1045,6 +1060,8 @@ class VideoViewport extends Viewport implements IVideoViewport {
1045
1060
  duration: this.videoElement.duration,
1046
1061
  });
1047
1062
 
1063
+ this.initialRender?.();
1064
+
1048
1065
  const frame = this.getFrameNumber();
1049
1066
  if (this.isPlaying) {
1050
1067
  if (frame < this.frameRange[0]) {