@kitware/vtk.js 28.2.3 → 28.2.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.
@@ -202,27 +202,59 @@ function vtkLookupTable(publicAPI, model) {
202
202
  };
203
203
 
204
204
  publicAPI.setTable = function (table) {
205
+ // Handle JS array (assume 2D array)
206
+ if (Array.isArray(table)) {
207
+ var nbComponents = table[0].length;
208
+ model.numberOfColors = table.length;
209
+ var colorOffset = 4 - nbComponents;
210
+ var offset = 0; // fill table
211
+
212
+ for (var i = 0; i < model.numberOfColors; i++) {
213
+ model.table[i * 4] = 255;
214
+ model.table[i * 4 + 1] = 255;
215
+ model.table[i * 4 + 2] = 255;
216
+ model.table[i * 4 + 3] = 255;
217
+ } // extract colors
218
+
219
+
220
+ for (var _i2 = 0; _i2 < table.length; _i2++) {
221
+ var color = table[_i2];
222
+
223
+ for (var j = 0; j < nbComponents; j++) {
224
+ model.table[offset++] = color[j];
225
+ }
226
+
227
+ offset += colorOffset;
228
+ }
229
+
230
+ publicAPI.buildSpecialColors();
231
+ model.insertTime.modified();
232
+ publicAPI.modified();
233
+ return true;
234
+ }
235
+
205
236
  if (table.getNumberOfComponents() !== 4) {
206
237
  vtkErrorMacro('Expected 4 components for RGBA colors');
207
- return;
238
+ return false;
208
239
  }
209
240
 
210
241
  if (table.getDataType() !== VtkDataTypes.UNSIGNED_CHAR) {
211
242
  vtkErrorMacro('Expected unsigned char values for RGBA colors');
212
- return;
243
+ return false;
213
244
  }
214
245
 
215
246
  model.numberOfColors = table.getNumberOfTuples();
216
247
  var data = table.getData();
217
248
  model.table.length = data.length;
218
249
 
219
- for (var i = 0; i < data.length; i++) {
220
- model.table[i] = data[i];
250
+ for (var _i3 = 0; _i3 < data.length; _i3++) {
251
+ model.table[_i3] = data[_i3];
221
252
  }
222
253
 
223
254
  publicAPI.buildSpecialColors();
224
255
  model.insertTime.modified();
225
256
  publicAPI.modified();
257
+ return true;
226
258
  };
227
259
 
228
260
  publicAPI.buildSpecialColors = function () {
@@ -275,8 +307,10 @@ function vtkLookupTable(publicAPI, model) {
275
307
  };
276
308
 
277
309
  if (model.table.length > 0) {
278
- // ensure insertTime is more recently modified than buildTime if
310
+ // Ensure that special colors are properly included in the table
311
+ publicAPI.buildSpecialColors(); // ensure insertTime is more recently modified than buildTime if
279
312
  // a table is provided via the constructor
313
+
280
314
  model.insertTime.modified();
281
315
  }
282
316
  } // ----------------------------------------------------------------------------
@@ -432,51 +432,61 @@ function vtkRenderWindowUpdater(instance, state, context) {
432
432
  function colorTransferFunctionUpdater(instance, state, context) {
433
433
  context.start(); // -> start(colorTransferFunctionUpdater)
434
434
 
435
- var nodes = state.properties.nodes.map(function (_ref) {
436
- var _ref2 = _slicedToArray(_ref, 6),
437
- x = _ref2[0],
438
- r = _ref2[1],
439
- g = _ref2[2],
440
- b = _ref2[3],
441
- midpoint = _ref2[4],
442
- sharpness = _ref2[5];
443
-
444
- return {
445
- x: x,
446
- r: r,
447
- g: g,
448
- b: b,
449
- midpoint: midpoint,
450
- sharpness: sharpness
451
- };
452
- });
453
- instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
454
- nodes: nodes
455
- }), true);
435
+ if (!state.properties.nodes) {
436
+ instance.set(state.properties);
437
+ } else {
438
+ var nodes = state.properties.nodes.map(function (_ref) {
439
+ var _ref2 = _slicedToArray(_ref, 6),
440
+ x = _ref2[0],
441
+ r = _ref2[1],
442
+ g = _ref2[2],
443
+ b = _ref2[3],
444
+ midpoint = _ref2[4],
445
+ sharpness = _ref2[5];
446
+
447
+ return {
448
+ x: x,
449
+ r: r,
450
+ g: g,
451
+ b: b,
452
+ midpoint: midpoint,
453
+ sharpness: sharpness
454
+ };
455
+ });
456
+ instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
457
+ nodes: nodes
458
+ }), true);
459
+ }
460
+
456
461
  context.end(); // -> end(colorTransferFunctionUpdater)
457
462
  }
458
463
 
459
464
  function piecewiseFunctionUpdater(instance, state, context) {
460
465
  context.start(); // -> start(piecewiseFunctionUpdater)
461
466
 
462
- var nodes = state.properties.nodes.map(function (_ref3) {
463
- var _ref4 = _slicedToArray(_ref3, 4),
464
- x = _ref4[0],
465
- y = _ref4[1],
466
- midpoint = _ref4[2],
467
- sharpness = _ref4[3];
468
-
469
- return {
470
- x: x,
471
- y: y,
472
- midpoint: midpoint,
473
- sharpness: sharpness
474
- };
475
- });
476
- instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
477
- nodes: nodes
478
- }), true);
479
- instance.sortAndUpdateRange(); // instance.modified();
467
+ if (!state.properties.nodes) {
468
+ instance.set(state.properties);
469
+ } else {
470
+ var nodes = state.properties.nodes.map(function (_ref3) {
471
+ var _ref4 = _slicedToArray(_ref3, 4),
472
+ x = _ref4[0],
473
+ y = _ref4[1],
474
+ midpoint = _ref4[2],
475
+ sharpness = _ref4[3];
476
+
477
+ return {
478
+ x: x,
479
+ y: y,
480
+ midpoint: midpoint,
481
+ sharpness: sharpness
482
+ };
483
+ });
484
+ instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
485
+ nodes: nodes
486
+ }), true);
487
+ instance.sortAndUpdateRange();
488
+ } // instance.modified();
489
+
480
490
 
481
491
  context.end(); // -> end(piecewiseFunctionUpdater)
482
492
  } // ----------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "28.2.3",
3
+ "version": "28.2.4",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",