Skip to content

Commit d19e4fe

Browse files
yarous224floryst
authored andcommitted
fix(VolumeMapper): Fixed accessing property with no valid input
1 parent 06b05f9 commit d19e4fe

File tree

1 file changed

+29
-27
lines changed
  • Sources/Rendering/OpenGL/VolumeMapper

1 file changed

+29
-27
lines changed

Sources/Rendering/OpenGL/VolumeMapper/index.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,23 +1438,36 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
14381438
model.currentValidInputs.push({ imageData, inputIndex });
14391439
}
14401440
}
1441-
const volumeProperties = actor.getProperties();
1442-
const firstValidInput = model.currentValidInputs[0];
1443-
const firstImageData = firstValidInput.imageData;
1444-
const firstScalars = firstImageData.getPointData().getScalars();
1445-
const firstVolumeProperty = volumeProperties[firstValidInput.inputIndex];
1446-
1447-
// Get the number of lights
14481441
let newNumberOfLights = 0;
1449-
if (
1450-
firstVolumeProperty.getShade() &&
1451-
model.renderable.getBlendMode() === BlendMode.COMPOSITE_BLEND
1452-
) {
1453-
ren.getLights().forEach((light) => {
1454-
if (light.getSwitch() > 0) {
1455-
newNumberOfLights++;
1456-
}
1457-
});
1442+
if (model.currentValidInputs.length > 0) {
1443+
const volumeProperties = actor.getProperties();
1444+
const firstValidInput = model.currentValidInputs[0];
1445+
const firstImageData = firstValidInput.imageData;
1446+
const firstScalars = firstImageData.getPointData().getScalars();
1447+
const firstVolumeProperty = volumeProperties[firstValidInput.inputIndex];
1448+
1449+
// Get the number of lights
1450+
if (
1451+
firstVolumeProperty.getShade() &&
1452+
model.renderable.getBlendMode() === BlendMode.COMPOSITE_BLEND
1453+
) {
1454+
ren.getLights().forEach((light) => {
1455+
if (light.getSwitch() > 0) {
1456+
newNumberOfLights++;
1457+
}
1458+
});
1459+
}
1460+
1461+
// Number of components
1462+
const numberOfValidInputs = model.currentValidInputs.length;
1463+
const multiTexturePerVolumeEnabled = numberOfValidInputs > 1;
1464+
model.numberOfComponents = multiTexturePerVolumeEnabled
1465+
? numberOfValidInputs
1466+
: firstScalars.getNumberOfComponents();
1467+
model.useIndependentComponents = getUseIndependentComponents(
1468+
firstVolumeProperty,
1469+
model.numberOfComponents
1470+
);
14581471
}
14591472
if (newNumberOfLights !== model.numberOfLights) {
14601473
model.numberOfLights = newNumberOfLights;
@@ -1467,17 +1480,6 @@ function vtkOpenGLVolumeMapper(publicAPI, model) {
14671480
return;
14681481
}
14691482

1470-
// Number of components
1471-
const numberOfValidInputs = model.currentValidInputs.length;
1472-
const multiTexturePerVolumeEnabled = numberOfValidInputs > 1;
1473-
model.numberOfComponents = multiTexturePerVolumeEnabled
1474-
? numberOfValidInputs
1475-
: firstScalars.getNumberOfComponents();
1476-
model.useIndependentComponents = getUseIndependentComponents(
1477-
firstVolumeProperty,
1478-
model.numberOfComponents
1479-
);
1480-
14811483
publicAPI.renderPieceStart(ren, actor);
14821484
publicAPI.renderPieceDraw(ren, actor);
14831485
publicAPI.renderPieceFinish(ren, actor);

0 commit comments

Comments
 (0)