Skip to content

Commit f472e9b

Browse files
authored
Merge pull request #141 from Kitware/beta
Update react-vtk-js to v2
2 parents b7d8861 + 0264852 commit f472e9b

File tree

124 files changed

+17911
-18522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+17911
-18522
lines changed

.eslintrc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2-
"parser": "babel-eslint",
2+
"parser": "@typescript-eslint/parser",
3+
"plugins": ["@typescript-eslint"],
34
"extends": [
45
"standard",
5-
"standard-react",
6+
"prettier",
67
"plugin:prettier/recommended",
7-
"prettier/standard",
8-
"prettier/react"
8+
"plugin:react/recommended",
9+
"plugin:react/jsx-runtime",
10+
"plugin:react-hooks/recommended",
11+
"plugin:@typescript-eslint/eslint-recommended",
12+
"plugin:@typescript-eslint/recommended"
913
],
1014
"env": {
1115
"browser": true
@@ -28,6 +32,8 @@
2832
"react/jsx-handler-names": 0,
2933
"react/jsx-fragments": 0,
3034
"react/no-unused-prop-types": 0,
31-
"import/export": 0
35+
"import/export": 0,
36+
"n/no-callback-literal": 0,
37+
"@typescript-eslint/no-explicit-any": 0
3238
}
3339
}

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
publish:
1010
name: Publish
11-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v2
@@ -17,7 +17,7 @@ jobs:
1717
- name: Setup node
1818
uses: actions/setup-node@v1
1919
with:
20-
node-version: 12
20+
node-version: 22
2121
- name: Install dependencies
2222
run: npm ci
2323
- name: Build

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"bracketSpacing": true,
77
"jsxBracketSameLine": false,
88
"arrowParens": "always",
9-
"trailingComma": "es5"
9+
"trailingComma": "es5",
10+
"plugins": ["prettier-plugin-organize-imports"]
1011
}

BREAKING_CHANGES.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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.

babel.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"]
3+
}

0 commit comments

Comments
 (0)