@kitware/vtk.js 26.8.1 → 26.9.0

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.
Files changed (36) hide show
  1. package/BREAKING_CHANGES.md +6 -1
  2. package/Common/Core/DataArray.js +9 -10
  3. package/Common/Core/ScalarsToColors.d.ts +9 -1
  4. package/Common/Core/ScalarsToColors.js +22 -0
  5. package/Rendering/Core/AxesActor.js +85 -7
  6. package/Rendering/Core/Mapper.js +10 -1
  7. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +5 -0
  8. package/Rendering/Misc/SynchronizableRenderWindow.d.ts +32 -24
  9. package/Rendering/Misc/SynchronizableRenderWindow.js +15 -0
  10. package/Rendering/OpenGL/Actor.js +12 -2
  11. package/Rendering/OpenGL/Camera.js +1 -0
  12. package/Rendering/OpenGL/ForwardPass.js +6 -3
  13. package/Rendering/OpenGL/ImageMapper.js +5 -1
  14. package/Rendering/OpenGL/ImageSlice.js +17 -1
  15. package/Rendering/OpenGL/OrderIndependentTranslucentPass.js +1 -0
  16. package/Rendering/OpenGL/PolyDataMapper.js +5 -1
  17. package/Rendering/OpenGL/RenderWindow.js +24 -8
  18. package/Rendering/OpenGL/Renderer.js +5 -1
  19. package/Rendering/OpenGL/VolumeMapper.js +5 -1
  20. package/Widgets/Core/AbstractWidget.js +1 -5
  21. package/Widgets/Core/AbstractWidgetFactory.d.ts +5 -0
  22. package/Widgets/Core/AbstractWidgetFactory.js +4 -0
  23. package/Widgets/Core/StateBuilder/color3Mixin.js +3 -1
  24. package/Widgets/Core/StateBuilder/originMixin.js +34 -3
  25. package/Widgets/Core/WidgetManager.d.ts +8 -0
  26. package/Widgets/Core/WidgetManager.js +27 -5
  27. package/Widgets/Representations/CroppingOutlineRepresentation.js +1 -1
  28. package/Widgets/Representations/GlyphRepresentation.js +10 -5
  29. package/Widgets/Representations/ImplicitPlaneRepresentation.js +2 -1
  30. package/Widgets/Representations/PolyLineRepresentation.js +2 -1
  31. package/Widgets/Representations/WidgetRepresentation.js +3 -26
  32. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +19 -7
  33. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +9 -20
  34. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +2 -23
  35. package/Widgets/Widgets3D/ResliceCursorWidget.js +40 -39
  36. package/package.json +1 -1
@@ -3,7 +3,12 @@
3
3
  - **ResliceCursorWidget**: vtkResliceCursorContextRepresentation is deprecated and removed.
4
4
  Instead, a `vtkSphereHandleRepresentation` is used for `rotation` and `center` handles,
5
5
  and a `vtkLineHandleRepresenttion` is used for the axes. `rotateLineInView()` now
6
- takes an axis name (string, e.g. 'XinY') instead of a substate.
6
+ takes an axis name (string, e.g. 'XinY') instead of a substate. `enableRotation`, `enableTranslation` and `keepOrthogonality` in widgetState are replaced by widget behavior accessors (e.g. `widgetInView.setEnableRotation(false)`). See RCW example.
7
+ - `widgetState.setShowCenter()` is replaced by `widgetState.getCenterHandle.setVisible()`
8
+ - `widgetState.setSphereRadius()` is replaced by `widgetState.getCenterHandle().setScale1()` and `widgetState.getStatesWithLabel('rotation').forEach((handle) => handle.setScale1())`
9
+ - `widgetState.setLineThickness(t)` is replaced by `widgetState.getStatesWithLabel('line').forEach((handle) => handle.setScale3(t,t,t))`
10
+ - `setScaleInPixels()` should now be set on the widget instead of the `widgetInView`.
11
+ - `widgetState.setOpacity()` is replaced by `widgetState.getStatesWithLabel('handles').forEach((handle) => handle.setOpacity())`
7
12
  - SVGRepresentation and SVG widget support has been fully removed.
8
13
 
9
14
  ## From 24.x to 25
@@ -161,18 +161,12 @@ var STATIC = {
161
161
  function vtkDataArray(publicAPI, model) {
162
162
  // Set our className
163
163
  model.classHierarchy.push('vtkDataArray');
164
-
165
- function dataChange() {
166
- model.ranges = null;
167
- publicAPI.modified();
168
- }
169
164
  /**
170
165
  * Resize model.values and copy the old values to the new array.
171
166
  * @param {Number} requestedNumTuples Final expected number of tuples; must be >= 0
172
167
  * @returns {Boolean} True if a resize occured, false otherwise
173
168
  */
174
169
 
175
-
176
170
  function resize(requestedNumTuples) {
177
171
  if (requestedNumTuples < 0) {
178
172
  return false;
@@ -198,19 +192,24 @@ function vtkDataArray(publicAPI, model) {
198
192
 
199
193
  if (model.size > requestedNumTuples * numComps) {
200
194
  model.size = requestedNumTuples * numComps;
201
- dataChange();
195
+ publicAPI.dataChange();
202
196
  }
203
197
 
204
198
  return true;
205
199
  }
206
200
 
201
+ publicAPI.dataChange = function () {
202
+ model.ranges = null;
203
+ publicAPI.modified();
204
+ };
205
+
207
206
  publicAPI.resize = function (requestedNumTuples) {
208
207
  resize(requestedNumTuples);
209
208
  var newSize = requestedNumTuples * publicAPI.getNumberOfComponents();
210
209
 
211
210
  if (model.size !== newSize) {
212
211
  model.size = newSize;
213
- dataChange();
212
+ publicAPI.dataChange();
214
213
  return true;
215
214
  }
216
215
 
@@ -243,7 +242,7 @@ function vtkDataArray(publicAPI, model) {
243
242
  publicAPI.setComponent = function (tupleIdx, compIdx, value) {
244
243
  if (value !== model.values[tupleIdx * model.numberOfComponents + compIdx]) {
245
244
  model.values[tupleIdx * model.numberOfComponents + compIdx] = value;
246
- dataChange();
245
+ publicAPI.dataChange();
247
246
  }
248
247
  };
249
248
 
@@ -448,7 +447,7 @@ function vtkDataArray(publicAPI, model) {
448
447
  model.numberOfComponents = 1;
449
448
  }
450
449
 
451
- dataChange();
450
+ publicAPI.dataChange();
452
451
  }; // Override serialization support
453
452
 
454
453
 
@@ -124,10 +124,18 @@ export interface vtkScalarsToColors extends vtkObject {
124
124
  getVectorSize(): number;
125
125
 
126
126
  /**
127
- *
127
+ * @see areScalarsOpaque
128
128
  */
129
129
  isOpaque(): boolean;
130
130
 
131
+ /**
132
+ * Returns false if scalars are Uint8 LA or RGBA with A < 255,
133
+ * otherwise rely on getAlpha() in case of direct mapping,
134
+ * otherwise return isOpaque()
135
+ * @see isOpaque, getAlpha
136
+ */
137
+ areScalarsOpaque(scalars, colorMode, componentIn): boolean;
138
+
131
139
  /**
132
140
  *
133
141
  * @param newColors
@@ -504,6 +504,28 @@ function vtkScalarsToColors(publicAPI, model) {
504
504
  publicAPI.getRange = function () {
505
505
  return publicAPI.getMappingRange();
506
506
  };
507
+
508
+ publicAPI.areScalarsOpaque = function (scalars, colorMode, componentIn) {
509
+ if (!scalars) {
510
+ return publicAPI.isOpaque();
511
+ }
512
+
513
+ var numberOfComponents = scalars.getNumberOfComponents(); // map scalars through lookup table only if needed
514
+
515
+ if (colorMode === ColorMode.DEFAULT && scalars.getDataType() === VtkDataTypes.UNSIGNED_CHAR || colorMode === ColorMode.DIRECT_SCALARS) {
516
+ // we will be using the scalars directly, so look at the number of
517
+ // components and the range
518
+ if (numberOfComponents === 3 || numberOfComponents === 1) {
519
+ return model.alpha >= 1.0;
520
+ } // otherwise look at the range of the alpha channel
521
+
522
+
523
+ var range = scalars.getRange(numberOfComponents - 1);
524
+ return range[0] === 255;
525
+ }
526
+
527
+ return true;
528
+ };
507
529
  } // ----------------------------------------------------------------------------
508
530
  // Object factory
509
531
  // ----------------------------------------------------------------------------
@@ -19,6 +19,16 @@ function centerDataSet(ds) {
19
19
  var center = [-(bounds[0] + bounds[1]) * 0.5, -(bounds[2] + bounds[3]) * 0.5, -(bounds[4] + bounds[5]) * 0.5];
20
20
 
21
21
  (_vtkMatrixBuilder$bui = vtkMatrixBuilder.buildFromDegree()).translate.apply(_vtkMatrixBuilder$bui, center).apply(ds.getPoints().getData());
22
+ }
23
+
24
+ function shiftDataset(ds, axis) {
25
+ var _vtkMatrixBuilder$bui2;
26
+
27
+ var bounds = ds.getPoints().getBounds();
28
+ var center = [0, 0, 0];
29
+ center[axis] = -bounds[axis * 2];
30
+
31
+ (_vtkMatrixBuilder$bui2 = vtkMatrixBuilder.buildFromDegree()).translate.apply(_vtkMatrixBuilder$bui2, center).apply(ds.getPoints().getData());
22
32
  } // ----------------------------------------------------------------------------
23
33
 
24
34
 
@@ -47,33 +57,100 @@ function vtkAxesActor(publicAPI, model) {
47
57
  // Set our className
48
58
  model.classHierarchy.push('vtkAxesActor');
49
59
 
60
+ var _mapper = vtkMapper.newInstance();
61
+
62
+ publicAPI.setMapper(_mapper);
63
+
50
64
  publicAPI.update = function () {
51
65
  var xAxis = vtkArrowSource.newInstance(_objectSpread({
52
66
  direction: [1, 0, 0]
53
67
  }, model.config)).getOutputData();
54
- centerDataSet(xAxis);
68
+
69
+ if (model.config.recenter) {
70
+ centerDataSet(xAxis);
71
+ } else {
72
+ shiftDataset(xAxis, 0);
73
+ }
74
+
55
75
  addColor.apply(void 0, [xAxis].concat(_toConsumableArray(model.xAxisColor)));
56
76
  var yAxis = vtkArrowSource.newInstance(_objectSpread({
57
77
  direction: [0, 1, 0]
58
78
  }, model.config)).getOutputData();
59
- centerDataSet(yAxis);
79
+
80
+ if (model.config.recenter) {
81
+ centerDataSet(yAxis);
82
+ } else {
83
+ shiftDataset(yAxis, 1);
84
+ }
85
+
60
86
  addColor.apply(void 0, [yAxis].concat(_toConsumableArray(model.yAxisColor)));
61
87
  var zAxis = vtkArrowSource.newInstance(_objectSpread({
62
88
  direction: [0, 0, 1]
63
89
  }, model.config)).getOutputData();
64
- centerDataSet(zAxis);
90
+
91
+ if (model.config.recenter) {
92
+ centerDataSet(zAxis);
93
+ } else {
94
+ shiftDataset(zAxis, 2);
95
+ }
96
+
65
97
  addColor.apply(void 0, [zAxis].concat(_toConsumableArray(model.zAxisColor)));
66
98
  var source = vtkAppendPolyData.newInstance();
67
99
  source.setInputData(xAxis);
68
100
  source.addInputData(yAxis);
69
- source.addInputData(zAxis); // set mapper
101
+ source.addInputData(zAxis);
70
102
 
71
- var mapper = vtkMapper.newInstance();
72
- mapper.setInputConnection(source.getOutputPort());
73
- publicAPI.setMapper(mapper);
103
+ _mapper.setInputConnection(source.getOutputPort());
74
104
  };
75
105
 
76
106
  publicAPI.update();
107
+
108
+ var _debouncedUpdate = macro.debounce(publicAPI.update, 0);
109
+
110
+ var setConfig = publicAPI.setConfig,
111
+ setXAxisColor = publicAPI.setXAxisColor,
112
+ setYAxisColor = publicAPI.setYAxisColor,
113
+ setZAxisColor = publicAPI.setZAxisColor;
114
+
115
+ publicAPI.setConfig = function (c) {
116
+ if (setConfig(c)) {
117
+ _debouncedUpdate();
118
+
119
+ return true;
120
+ }
121
+
122
+ return false;
123
+ };
124
+
125
+ publicAPI.setXAxisColor = function (c) {
126
+ if (setXAxisColor(c)) {
127
+ _debouncedUpdate();
128
+
129
+ return true;
130
+ }
131
+
132
+ return false;
133
+ };
134
+
135
+ publicAPI.setYAxisColor = function (c) {
136
+ if (setYAxisColor(c)) {
137
+ _debouncedUpdate();
138
+
139
+ return true;
140
+ }
141
+
142
+ return false;
143
+ };
144
+
145
+ publicAPI.setZAxisColor = function (c) {
146
+ if (setZAxisColor(c)) {
147
+ _debouncedUpdate();
148
+
149
+ return true;
150
+ }
151
+
152
+ return false;
153
+ };
77
154
  } // ----------------------------------------------------------------------------
78
155
  // Object factory
79
156
  // ----------------------------------------------------------------------------
@@ -81,6 +158,7 @@ function vtkAxesActor(publicAPI, model) {
81
158
 
82
159
  var DEFAULT_VALUES = {
83
160
  config: {
161
+ recenter: true,
84
162
  tipResolution: 60,
85
163
  tipRadius: 0.1,
86
164
  tipLength: 0.2,
@@ -375,12 +375,21 @@ function vtkMapper(publicAPI, model) {
375
375
  };
376
376
 
377
377
  publicAPI.getIsOpaque = function () {
378
+ var input = publicAPI.getInputData();
379
+ var gasResult = publicAPI.getAbstractScalars(input, model.scalarMode, model.arrayAccessMode, model.arrayId, model.colorByArrayName);
380
+ var scalars = gasResult.scalars;
381
+
382
+ if (!model.scalarVisibility || scalars == null) {
383
+ // No scalar colors.
384
+ return true;
385
+ }
386
+
378
387
  var lut = publicAPI.getLookupTable();
379
388
 
380
389
  if (lut) {
381
390
  // Ensure that the lookup table is built
382
391
  lut.build();
383
- return lut.isOpaque();
392
+ return lut.areScalarsOpaque(scalars, model.colorMode, -1);
384
393
  }
385
394
 
386
395
  return true;
@@ -27,6 +27,7 @@ import vtkImageProperty from '../../Core/ImageProperty.js';
27
27
  import vtkPiecewiseFunction from '../../../Common/DataModel/PiecewiseFunction.js';
28
28
  import vtkCubeAxesActor from '../../Core/CubeAxesActor.js';
29
29
  import vtkScalarBarActor from '../../Core/ScalarBarActor.js';
30
+ import vtkAxesActor from '../../Core/AxesActor.js';
30
31
 
31
32
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
32
33
 
@@ -583,6 +584,10 @@ var DEFAULT_ALIASES = {
583
584
  }; // ----------------------------------------------------------------------------
584
585
 
585
586
  var DEFAULT_MAPPING = {
587
+ vtkAxesActor: {
588
+ build: vtkAxesActor.newInstance,
589
+ update: genericUpdater
590
+ },
586
591
  vtkRenderWindow: {
587
592
  build: vtkRenderWindow.newInstance,
588
593
  update: vtkRenderWindowUpdater
@@ -54,42 +54,42 @@ export interface IViewState {
54
54
  export interface vtkSynchronizableRenderWindow extends vtkRenderWindow {
55
55
 
56
56
  /**
57
- *
57
+ *
58
58
  */
59
59
  getSynchronizerContext(): ISynchronizerContext;
60
60
 
61
61
  // methods added by createSyncFunction
62
62
 
63
63
  /**
64
- *
65
- * @param {IViewState} state
64
+ *
65
+ * @param {IViewState} state
66
66
  */
67
67
  synchronize(state: IViewState): Promise<boolean>;
68
68
 
69
69
  /**
70
- *
71
- * @param {String} viewId
70
+ *
71
+ * @param {String} viewId
72
72
  */
73
73
  setSynchronizedViewId(viewId: string): void;
74
74
 
75
75
  /**
76
- *
76
+ *
77
77
  */
78
78
  getSynchronizedViewId(): string;
79
79
 
80
80
  /**
81
- *
82
- * @param {Number} v
81
+ *
82
+ * @param {Number} v
83
83
  */
84
84
  updateGarbageCollectorThreshold(v: number): void;
85
85
 
86
86
  /**
87
- *
87
+ *
88
88
  */
89
89
  getManagedInstanceIds(): string[];
90
90
 
91
91
  /**
92
- *
92
+ *
93
93
  */
94
94
  clearOneTimeUpdaters(): void;
95
95
  }
@@ -110,52 +110,60 @@ export function extend(publicAPI: object, model: object, initialValues?: ISynchr
110
110
  export function newInstance(initialValues?: ISynchronizableRenderWindowInitialValues): vtkSynchronizableRenderWindow;
111
111
 
112
112
  /**
113
- *
114
- * @param {String} [name]
113
+ *
114
+ * @param {String} [name]
115
115
  */
116
116
  export function getSynchronizerContext(name?: string): ISynchronizerContext;
117
117
 
118
118
  /**
119
- *
120
- * @param {String} name
121
- * @param {ISynchronizerContext} ctx
119
+ *
120
+ * @param {String} name
121
+ * @param {Nullable<ISynchronizerContext>} ctx
122
122
  */
123
- export function setSynchronizerContext(name: string, ctx: ISynchronizerContext): ISynchronizerContext;
123
+ export function setSynchronizerContext(name: string, ctx: Nullable<ISynchronizerContext>);
124
+
124
125
 
125
126
  /**
126
- *
127
- * @param {vtkRenderWindow} renderWindow
128
- * @param {String} [name]
127
+ *
128
+ * @param name of the context to remove and if nothing provided clear them all.
129
+ */
130
+ export function clearSynchronizerContext(name: Nullable<string>);
131
+
132
+ /**
133
+ *
134
+ * @param {vtkRenderWindow} renderWindow
135
+ * @param {String} [name]
129
136
  */
130
137
  export function decorate(renderWindow: vtkRenderWindow, name?: string): object;
131
138
 
132
139
  /**
133
- *
140
+ *
134
141
  */
135
142
  export function createInstanceMap(): object;
136
143
 
137
144
  /**
138
- *
145
+ *
139
146
  */
140
147
  export function createArrayHandler(): object;
141
148
 
142
149
  /**
143
- *
150
+ *
144
151
  */
145
152
  export function createProgressHandler(): object;
146
153
 
147
154
  /**
148
- *
155
+ *
149
156
  */
150
157
  export function createSceneMtimeHandler(): object;
151
158
 
152
159
  /**
153
- *
160
+ *
154
161
  */
155
162
  export declare const vtkSynchronizableRenderWindow: {
156
163
  newInstance: typeof newInstance;
157
164
  getSynchronizerContext: typeof getSynchronizerContext;
158
165
  setSynchronizerContext: typeof setSynchronizerContext;
166
+ clearSynchronizerContext: typeof clearSynchronizerContext;
159
167
  decorate: typeof decorate,
160
168
  createInstanceMap: typeof createInstanceMap,
161
169
  createArrayHandler: typeof createArrayHandler,
@@ -220,6 +220,20 @@ function getSynchronizerContext() {
220
220
 
221
221
  function setSynchronizerContext(name, ctx) {
222
222
  SYNCHRONIZER_CONTEXTS[name] = ctx;
223
+ }
224
+
225
+ function clearSynchronizerContext(name) {
226
+ if (name && SYNCHRONIZER_CONTEXTS[name]) {
227
+ delete SYNCHRONIZER_CONTEXTS[name];
228
+ }
229
+
230
+ if (!name) {
231
+ var keys = Object.keys(SYNCHRONIZER_CONTEXTS);
232
+
233
+ for (var i = 0; i < keys.length; i++) {
234
+ delete SYNCHRONIZER_CONTEXTS[keys[i]];
235
+ }
236
+ }
223
237
  } // ----------------------------------------------------------------------------
224
238
 
225
239
 
@@ -346,6 +360,7 @@ var vtkSynchronizableRenderWindow$1 = {
346
360
  extend: extend,
347
361
  getSynchronizerContext: getSynchronizerContext,
348
362
  setSynchronizerContext: setSynchronizerContext,
363
+ clearSynchronizerContext: clearSynchronizerContext,
349
364
  decorate: decorate,
350
365
  createInstanceMap: createInstanceMap,
351
366
  createArrayHandler: createArrayHandler,
@@ -37,9 +37,10 @@ function vtkOpenGLActor(publicAPI, model) {
37
37
  }
38
38
  }
39
39
  }
40
- };
40
+ }; // render both opaque and translucent actors
41
41
 
42
- publicAPI.traverseOpaqueZBufferPass = function (renderPass) {
42
+
43
+ publicAPI.traverseZBufferPass = function (renderPass) {
43
44
  if (!model.renderable || !model.renderable.getNestedVisibility() || model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) {
44
45
  return;
45
46
  }
@@ -47,6 +48,11 @@ function vtkOpenGLActor(publicAPI, model) {
47
48
  publicAPI.apply(renderPass, true);
48
49
  model.oglmapper.traverse(renderPass);
49
50
  publicAPI.apply(renderPass, false);
51
+ }; // only render opaque actors
52
+
53
+
54
+ publicAPI.traverseOpaqueZBufferPass = function (renderPass) {
55
+ return publicAPI.traverseOpaquePass(renderPass);
50
56
  }; // we draw textures, then mapper, then post pass textures
51
57
 
52
58
 
@@ -103,6 +109,10 @@ function vtkOpenGLActor(publicAPI, model) {
103
109
  }
104
110
  };
105
111
 
112
+ publicAPI.zBufferPass = function (prepass, renderPass) {
113
+ return publicAPI.opaquePass(prepass, renderPass);
114
+ };
115
+
106
116
  publicAPI.opaqueZBufferPass = function (prepass, renderPass) {
107
117
  return publicAPI.opaquePass(prepass, renderPass);
108
118
  };
@@ -29,6 +29,7 @@ function vtkOpenGLCamera(publicAPI, model) {
29
29
  };
30
30
 
31
31
  publicAPI.translucentPass = publicAPI.opaquePass;
32
+ publicAPI.zBufferPass = publicAPI.opaquePass;
32
33
  publicAPI.opaqueZBufferPass = publicAPI.opaquePass;
33
34
  publicAPI.volumePass = publicAPI.opaquePass;
34
35
 
@@ -40,7 +40,7 @@ function vtkForwardPass(publicAPI, model) {
40
40
  publicAPI.setCurrentOperation('queryPass');
41
41
  renNode.traverse(publicAPI); // do we need to capture a zbuffer?
42
42
 
43
- if (model.opaqueActorCount > 0 && model.volumeCount > 0 || model.depthRequested) {
43
+ if ((model.opaqueActorCount > 0 || model.translucentActorCount > 0) && model.volumeCount > 0 || model.depthRequested) {
44
44
  var size = viewNode.getFramebufferSize(); // make sure the framebuffer is setup
45
45
 
46
46
  if (model.framebuffer === null) {
@@ -56,8 +56,11 @@ function vtkForwardPass(publicAPI, model) {
56
56
  model.framebuffer.populateFramebuffer();
57
57
  }
58
58
 
59
- model.framebuffer.bind();
60
- publicAPI.setCurrentOperation('opaqueZBufferPass');
59
+ model.framebuffer.bind(); // opaqueZBufferPass only renders opaque actors
60
+ // zBufferPass renders both translucent and opaque actors
61
+ // we want to be able to pick translucent actors
62
+
63
+ publicAPI.setCurrentOperation('zBufferPass');
61
64
  renNode.traverse(publicAPI);
62
65
  model.framebuffer.restorePreviousBindingsAndBuffers(); // reset now that we have done it
63
66
 
@@ -68,7 +68,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
68
68
  }
69
69
  };
70
70
 
71
- publicAPI.opaqueZBufferPass = function (prepass) {
71
+ publicAPI.zBufferPass = function (prepass) {
72
72
  if (prepass) {
73
73
  model.haveSeenDepthRequest = true;
74
74
  model.renderDepth = true;
@@ -77,6 +77,10 @@ function vtkOpenGLImageMapper(publicAPI, model) {
77
77
  }
78
78
  };
79
79
 
80
+ publicAPI.opaqueZBufferPass = function (prepass) {
81
+ return publicAPI.zBufferPass(prepass);
82
+ };
83
+
80
84
  publicAPI.opaquePass = function (prepass) {
81
85
  if (prepass) {
82
86
  publicAPI.render();
@@ -29,8 +29,20 @@ function vtkOpenGLImageSlice(publicAPI, model) {
29
29
  }
30
30
  };
31
31
 
32
+ publicAPI.traverseZBufferPass = function (renderPass) {
33
+ if (!model.renderable || !model.renderable.getNestedVisibility() || model._openGLRenderer.getSelector() && !model.renderable.getNestedPickable()) {
34
+ return;
35
+ }
36
+
37
+ publicAPI.apply(renderPass, true);
38
+ model.children.forEach(function (child) {
39
+ child.traverse(renderPass);
40
+ });
41
+ publicAPI.apply(renderPass, false);
42
+ };
43
+
32
44
  publicAPI.traverseOpaqueZBufferPass = function (renderPass) {
33
- publicAPI.traverseOpaquePass(renderPass);
45
+ return publicAPI.traverseOpaquePass(renderPass);
34
46
  }; // we draw textures, then mapper, then post pass textures
35
47
 
36
48
 
@@ -73,6 +85,10 @@ function vtkOpenGLImageSlice(publicAPI, model) {
73
85
  }
74
86
  };
75
87
 
88
+ publicAPI.zBufferPass = function (prepass, renderPass) {
89
+ return publicAPI.opaquePass(prepass, renderPass);
90
+ };
91
+
76
92
  publicAPI.opaqueZBufferPass = function (prepass, renderPass) {
77
93
  return publicAPI.opaquePass(prepass, renderPass);
78
94
  }; // Renders myself
@@ -151,6 +151,7 @@ function vtkOpenGLOrderIndependentTranslucentPass(publicAPI, model) {
151
151
  // have the forward pass use a texture backed zbuffer
152
152
 
153
153
  if (forwardPass.getOpaqueActorCount() > 0) {
154
+ // Don't use zBufferPass as it will also render the depth of translucent actors
154
155
  forwardPass.setCurrentOperation('opaqueZBufferPass');
155
156
  renNode.traverse(forwardPass);
156
157
  }
@@ -72,7 +72,7 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
72
72
  }
73
73
  };
74
74
 
75
- publicAPI.opaqueZBufferPass = function (prepass) {
75
+ publicAPI.zBufferPass = function (prepass) {
76
76
  if (prepass) {
77
77
  model.haveSeenDepthRequest = true;
78
78
  model.renderDepth = true;
@@ -81,6 +81,10 @@ function vtkOpenGLPolyDataMapper(publicAPI, model) {
81
81
  }
82
82
  };
83
83
 
84
+ publicAPI.opaqueZBufferPass = function (prepass) {
85
+ return publicAPI.zBufferPass(prepass);
86
+ };
87
+
84
88
  publicAPI.opaquePass = function (prepass) {
85
89
  if (prepass) {
86
90
  publicAPI.render();
@@ -911,7 +911,26 @@ function vtkOpenGLRenderWindow(publicAPI, model) {
911
911
  model.canvas.removeEventListener('webglcontextrestored', publicAPI.restoreContext);
912
912
  }
913
913
 
914
- publicAPI.delete = macro.chain(clearEvents, publicAPI.delete, publicAPI.setViewStream, deleteGLContext);
914
+ publicAPI.delete = macro.chain(clearEvents, publicAPI.delete, publicAPI.setViewStream, deleteGLContext); // Do not trigger modified for performance reasons
915
+
916
+ publicAPI.setActiveFramebuffer = function (newActiveFramebuffer) {
917
+ model.activeFramebuffer = newActiveFramebuffer;
918
+ };
919
+
920
+ var superSetSize = publicAPI.setSize;
921
+
922
+ publicAPI.setSize = function (width, height) {
923
+ var modified = superSetSize(width, height);
924
+
925
+ if (modified) {
926
+ publicAPI.invokeWindowResizeEvent({
927
+ width: width,
928
+ height: height
929
+ });
930
+ }
931
+
932
+ return modified;
933
+ };
915
934
  } // ----------------------------------------------------------------------------
916
935
  // Object factory
917
936
  // ----------------------------------------------------------------------------
@@ -979,13 +998,10 @@ function extend(publicAPI, model) {
979
998
  macro.event(publicAPI, model, 'imageReady');
980
999
  macro.event(publicAPI, model, 'haveVRDisplay'); // Build VTK API
981
1000
 
982
- macro.get(publicAPI, model, ['shaderCache', 'textureUnitManager', 'webgl2', 'vrDisplay', 'useBackgroundImage', 'xrSupported']);
983
- macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'renderPasses', 'notifyStartCaptureImage', 'defaultToWebgl2', 'cursor', 'useOffScreen', // might want to make this not call modified as
984
- // we change the active framebuffer a lot. Or maybe
985
- // only mark modified if the size or depth
986
- // of the buffer has changed
987
- 'activeFramebuffer']);
988
- macro.setGetArray(publicAPI, model, ['size'], 2); // Object methods
1001
+ macro.get(publicAPI, model, ['shaderCache', 'textureUnitManager', 'webgl2', 'vrDisplay', 'useBackgroundImage', 'xrSupported', 'activeFramebuffer']);
1002
+ macro.setGet(publicAPI, model, ['initialized', 'context', 'canvas', 'renderPasses', 'notifyStartCaptureImage', 'defaultToWebgl2', 'cursor', 'useOffScreen']);
1003
+ macro.setGetArray(publicAPI, model, ['size'], 2);
1004
+ macro.event(publicAPI, model, 'windowResizeEvent'); // Object methods
989
1005
 
990
1006
  vtkOpenGLRenderWindow(publicAPI, model);
991
1007
  } // ----------------------------------------------------------------------------
@@ -44,7 +44,7 @@ function vtkOpenGLRenderer(publicAPI, model) {
44
44
  return count;
45
45
  };
46
46
 
47
- publicAPI.opaqueZBufferPass = function (prepass) {
47
+ publicAPI.zBufferPass = function (prepass) {
48
48
  if (prepass) {
49
49
  var clearMask = 0;
50
50
  var gl = model.context;
@@ -72,6 +72,10 @@ function vtkOpenGLRenderer(publicAPI, model) {
72
72
 
73
73
  gl.enable(gl.DEPTH_TEST);
74
74
  }
75
+ };
76
+
77
+ publicAPI.opaqueZBufferPass = function (prepass) {
78
+ return publicAPI.zBufferPass(prepass);
75
79
  }; // Renders myself
76
80
 
77
81