I’ve been messing around with VTK.js proxies for quite some time and still don’t feel I have a great handle on them, so I decided to try making the world’s simplest proxy / proxymanager - unfortunately it doesn’t work. Hoping someone can give me a hand in getting this working.
Repo:
Goal:
Render a simple cone using VTK.js proxies and a proxy manager.
Process
First I created a really simple cone without using proxies (this works).
Then I attempted to follow the instructions in this thread on VTK.js proxies on the current forum.
The instructions are:
- Create a proxy config (VolView/main/src/vtk/proxy.js)
- Result: proxyConfig.js
- Try a single volume representation (this points to same file as above, specifically line 59):
- Result: Remains the same as above
- Create a ProxyManager that consumes the config (paraview-medical/master/src/main.js)
- This is a little hard to follow, the repository has been renamed from
paraview-medical
toVolView
and line 28 is blank. - I went back through the git history and found a version from before the post was made, strangely this one’s line 28 doesn’t seem relevant either.
- But I think it may be line 26 (in the old version) we want or line 43 (in the new version)
- Result: main.js
- This is a little hard to follow, the repository has been renamed from
- Need to add a
vtkImageData
to aTrivialProducer
proxy.- Unfortunately the linked to file no longer exists. I think I found an equivalent old version.
- But I’m not sure the code here is what we need, there is no reference to a
TrivialProducer
proxy.
- Create a ViewProxy:
proxyMaager.createProxy('Views', 'View3D', { name: 'my3DView' })
- Create a representation of source proxy and add it to the view.
So I got stuck on step 4 but jumping ahead past step 6 I see that @Forrest provided some sample code but this still leaves me a bit confused. I’ve added the sample code into main.js.
But this doesn’t leave me quite with a finished product, I need to display the view.
The only example of using a proxy manager I can find is for the AnimationProxyManager
and unfortunately it diverges enough due to the animation that I can’t translate it into something I can use.
So here is what I have: main.js
And here is what I think I still need:
- A way to create a cone using
vtkGeometryRepresentationProxy
instead of a straight non-proxy render as shown in index-geometry.js - A way to actually render and display the view.
Any help is appreciated
Thanks,
Dave
You can find the example in the vtk.js source code at Sources/Proxy/Animation/AnimationProxyManager/example
. I don’t recommend trying to use the code presented on the VTK.js example page because it shows only the JS, it doesn’t include the also necessary controller.html
and proxyConfiguration.js
files.[1]
[1]: Note that you’ll have difficulty running this example outside of the VTK.js source as it imports directly from the source, not using node modules. You can fix it to work stand-alone by installing VTK.js (npm i @kitware/vtk.js
) and changing the imports from the form:
import 'vtk.js/Sources/Rendering/Profiles/All'
to:
import '@kitware/vtk.js/Rendering/Profiles/All'
Essentially, prepending the import with @kitware
and removing /Sources
following vtk.js
.