Skip to content

Commit 218bf9d

Browse files
committed
fix(DataArray): scalar data implies index 0
getRange(0) should cache in the same slot as getRange() when dealing with scalar data.
1 parent 86b1dc4 commit 218bf9d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/Common/Core/DataArray/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,13 @@ function vtkDataArray(publicAPI, model) {
231231
: model.values.subarray(0, model.size);
232232

233233
publicAPI.getRange = (componentIndex = -1) => {
234-
const rangeIdx =
235-
componentIndex < 0 ? model.numberOfComponents : componentIndex;
234+
let rangeIdx = componentIndex;
235+
if (rangeIdx < 0) {
236+
// If scalar data, then store in slot 0 (same as componentIndex = 0).
237+
// If vector data, then store in last slot.
238+
rangeIdx = model.numberOfComponents === 1 ? 0 : model.numberOfComponents;
239+
}
240+
236241
let range = null;
237242

238243
if (!model.ranges) {

0 commit comments

Comments
 (0)