@kitware/vtk.js 33.0.0-beta.5 → 33.0.0-beta.6

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.
@@ -1,6 +1,7 @@
1
- ## From 32.x to 33
1
+ ## From 33.x to 34
2
2
 
3
3
  - **vtkMapper**: many properties have moved to `vtkVolumeProperty`. The full list of changed methods is: `getAnisotropy`, `getComputeNormalFromOpacity`, `getFilterMode`, `getFilterModeAsString`, `getGlobalIlluminationReach`, `getIpScalarRange`, `getIpScalarRangeByReference`, `getLAOKernelRadius`, `getLAOKernelSize`, `getLocalAmbientOcclusion`, `getPreferSizeOverAccuracy`, `getVolumetricScatteringBlending`, `setAnisotropy`, `setAverageIPScalarRange`, `setComputeNormalFromOpacity`, `setFilterMode`, `setFilterModeToNormalized`, `setFilterModeToOff`, `setFilterModeToRaw`, `setGlobalIlluminationReach`, `setIpScalarRange`, `setIpScalarRangeFrom`, `setLAOKernelRadius`, `setLAOKernelSize`, `setLocalAmbientOcclusion`, `setPreferSizeOverAccuracy`, `setVolumetricScatteringBlending`.
4
+ - **vtkRenderWindowInteractor**: KeyPress, KeyDown and KeyUp events are now observed on the container and no longer on the document. "tabIndex=0" is now automatically added on RWI containers to give focus on your render windows and catch key events. Check the KeyPressEvents example for usage.
4
5
  - **vtkOpenGLTexture**: The public `create2D*` and `create3D*` methods used to have positional parameters. These methods now use named parameters via passing in an object record.
5
6
 
6
7
  ## From 31.x to 32
@@ -974,6 +974,12 @@ export interface vtkRenderWindowInteractor extends vtkObject {
974
974
  /**
975
975
  * Add an HTMLElement as the new container for the interactor.
976
976
  * All events will be bound to this new container.
977
+ *
978
+ * container will gain the tabIndex=0 attribute to catch keyboard events.
979
+ * container must have focus (manually via click or tab, or programmatically
980
+ * via `.focus()`) to receive keypress events
981
+ * Outline on focus can be customized with CSS :focus pseudo-class.
982
+ *
977
983
  * Any old container will be removed along with its listeners.
978
984
  */
979
985
  setContainer(container: Nullable<HTMLElement>): boolean;
@@ -186,11 +186,13 @@ function vtkRenderWindowInteractor(publicAPI, model) {
186
186
  });
187
187
  container.addEventListener('pointerup', publicAPI.handlePointerUp);
188
188
  container.addEventListener('pointercancel', publicAPI.handlePointerCancel);
189
- document.addEventListener('keypress', publicAPI.handleKeyPress);
190
- document.addEventListener('keydown', publicAPI.handleKeyDown);
189
+ container.addEventListener('keypress', publicAPI.handleKeyPress);
190
+ container.addEventListener('keydown', publicAPI.handleKeyDown);
191
+ // Observe keyup on document in case the focus changes
192
+ // between keydown and keyup.
191
193
  document.addEventListener('keyup', publicAPI.handleKeyUp);
192
194
  document.addEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
193
-
195
+ container.tabIndex = 0; // to receive key events
194
196
  // using touchAction is more performant than preventDefault
195
197
  // in a touchstart handler.
196
198
  container.style.touchAction = 'none';
@@ -235,8 +237,8 @@ function vtkRenderWindowInteractor(publicAPI, model) {
235
237
  container.removeEventListener('pointerup', publicAPI.handlePointerUp);
236
238
  container.removeEventListener('pointercancel', publicAPI.handlePointerCancel);
237
239
  }
238
- document.removeEventListener('keypress', publicAPI.handleKeyPress);
239
- document.removeEventListener('keydown', publicAPI.handleKeyDown);
240
+ container.removeEventListener('keypress', publicAPI.handleKeyPress);
241
+ container.removeEventListener('keydown', publicAPI.handleKeyDown);
240
242
  document.removeEventListener('keyup', publicAPI.handleKeyUp);
241
243
  document.removeEventListener('pointerlockchange', publicAPI.handlePointerLockChange);
242
244
  pointerCache.clear();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kitware/vtk.js",
3
- "version": "33.0.0-beta.5",
3
+ "version": "33.0.0-beta.6",
4
4
  "description": "Visualization Toolkit for the Web",
5
5
  "keywords": [
6
6
  "3d",