|
| 1 | +# Breaking Changes & Migration |
| 2 | + |
| 3 | +## v1 to v2 |
| 4 | + |
| 5 | +V2 represents a major shift away from the class-based components towards functional components. There are several goals and reasons for this migration: |
| 6 | +- Addresses some bugs inherent in how contexts were being consumed. |
| 7 | +- Addresses a major issue with regards to parent-child unmounting order being at odds with vtk.js resource management. |
| 8 | +- Migrates the codebase to Typescript and React 18. This also means we will expose Typescript types. |
| 9 | +- Does some clean-up on props and some confusing component usage. |
| 10 | +- Addresses rendering performance via batching. |
| 11 | + |
| 12 | +Once V2 is released, V1 will be considered legacy. Bugfixes may still be made for it, but V2 will be considered current. |
| 13 | + |
| 14 | +### Picking |
| 15 | + |
| 16 | +The `View` component no longer has any of the picking modes or picking props. Instead, a new `<Picking />` component is provided. Most of the API has been moved over with no changes, except for the following: |
| 17 | + |
| 18 | +- `setProps` prop and the `*info` readonly props, which have been removed. |
| 19 | +- `onSelect` has been removed. Instead, look at the Picking example for how to get the same functionality. |
| 20 | + |
| 21 | +There is a new `onHoverDebounceWait` parameter that determines the debounce wait threshold for the onHover event. |
| 22 | + |
| 23 | +`View.pick` from before has been split into `pick` and `pickWithFrustum`, since they return different types. |
| 24 | + |
| 25 | + |
| 26 | +### GeometryRepresentation |
| 27 | + |
| 28 | +The cube axes and scalar bar have been split out into their own components. |
| 29 | + |
| 30 | +### Algorithm |
| 31 | + |
| 32 | +`<Algorithm>` can take both a vtk.js class as a string name or as the vtk.js class directly. In both cases, you must import the class in order for it to register with the vtk string constructor. |
| 33 | + |
| 34 | +### ShareDataSet |
| 35 | + |
| 36 | +ShareDataSet is no longer global. You must specify a ShareDataSetRoot as an ancestor to the subtree in which you wish to use ShareDataSet. The new API looks like the following: |
| 37 | + |
| 38 | + <ShareDataSetRoot> |
| 39 | + <RegisterDataSet id="cone"> |
| 40 | + <Algorithm vtkClass={vtkConeSource} /> |
| 41 | + </RegisterDataSet> |
| 42 | + <View> |
| 43 | + <GeometryRepresentation> |
| 44 | + <UseDataSet id="cone" /> |
| 45 | + </GeometryRepresentation> |
| 46 | + </View> |
| 47 | + </ShareDataSetRoot> |
| 48 | + |
| 49 | +### View |
| 50 | + |
| 51 | +The View imperative ref API has changed completely. Refer to the `IView` type for more info. Examples of changes needed: |
| 52 | + |
| 53 | +- `view.camera` is now `view.getCamera()` |
| 54 | +- `view.openglRenderWindow` is now `view.getOpenGLRenderWindow().get()` |
| 55 | +- `view.interactor` is now `view.getRenderWindow().getInteractor()` |
| 56 | +- `view.renderView()` is now `view.requestRender()` |
| 57 | + |
| 58 | +The `autoResetCamera` prop supercedes the `triggerResetCamera` prop. When `autoResetCamera` is true (by default), camera will now reset whenever the data in the scene changes. |
| 59 | + |
| 60 | +The `triggerRender` prop is removed in favor of using the imperative API: `viewRef.current.requestRender()`. |
| 61 | + |
| 62 | +The `camera` prop supercedes the old `camera*` prefixed props (i.e. cameraPosition, cameraFocalPoint, etc.). `camera` must be specified as a collection of camera properties to be set. |
| 63 | + |
| 64 | +The default keybinds for resetting the camera (`KeyR`) has been removed. Application developers should decide if they want this functionality back by adding a keyboard listener and calling `viewRef.current.resetCamera()`. |
| 65 | + |
| 66 | +All picking props have been removed. See the `<Picking />` component. |
| 67 | + |
| 68 | +### Contexts |
| 69 | + |
| 70 | +The exposed contexts have changed APIs and names. The following is a list of available contexts (from `contexts.ts`): |
| 71 | + |
| 72 | +- OpenGLRenderWindowContext |
| 73 | +- RenderWindowContext |
| 74 | +- RendererContext |
| 75 | +- FieldDataContext |
| 76 | +- DatasetContext |
| 77 | +- RepresentationContext |
| 78 | +- DownstreamContext |
| 79 | +- ShareDataSetContext |
| 80 | +- MultiViewRootContext |
| 81 | +- ViewContext |
| 82 | + |
| 83 | +### MultiViewRoot |
| 84 | + |
| 85 | +The `disabled` prop no longer exists. |
| 86 | + |
| 87 | +### Reader |
| 88 | + |
| 89 | +- `arrayBuffer` prop now accepts an ArrayBuffer. `base64ArrayBuffer` takes a Base64 string of an ArrayBuffer. |
| 90 | +- `vtkClass` prop now takes a vtk class. String is still supported, but you must import to register the class first. |
| 91 | +- `renderOnUpdate` and `resetCameraOnUpdate` no longer exist. This is automatic. |
| 92 | +- `options` has been renamed to `urlOptions`. |
| 93 | +- `id` is not used. |
0 commit comments