Developing with vtk.js
Acknowledgments
Funding Sources
Course Outline
Requirements (basic)
WebGL2 ✓
(recommended)
WebGL 1 ✗
(not recommended)
Requirements (development)
Source Files for this Demo
The super simple example
Only browser + text editor needed
Import VTK.js
Set up the VTK.js RenderWindow and Renderer
Attach WebGL RenderWindow implementation
Attach interactive trackball controls
Construct our rendering pipeline for a cone
Center camera on cone and trigger the render pipeline
Super simple example
Project Creation Example
node + npm + everything else
Project Creation: Application Structure
Project Creation
� $ npm init
Installing tooling + dependencies
$ npm install --save vtk.js�$ npm install --save-dev kw-web-suite
Brings in:�
Creating initial files
Creating files: dist/index.html
Creating files: src/index.js
Creating files: webpack.config.js
Creating files: webpack.config.js
vtk.js webpack rules required
Building our example
Two ways:
Build results
You should now have a file: dist/app.js
Open index.html in your browser, open devtools (F12 on most browsers):
Success!
Cone Example: revisited
Let’s “rewrite” our old code
Rewriting our Cone Example
Rewriting our Cone Example
Rewriting our Cone Example
Explanation: Rendering Pipeline
Explanation: Rendering Pipeline
Examining ConeSource
VTK.js Filters: Example
VTK Filters: Example
VTK Filters: Pipelines
VTK Filters: Example Result
Volumes and Images
3D volumes and 2D slices
Volume and Slice Rendering
Volume Rendering Example
Three steps:
Volume Rendering Pipeline
Loading a Remote Dataset
Fetch Example
Loading a Remote Volume
Volume Rendering: 1st result
Volume Rendering: Opacity and Color
Volume Rendering: Opacity
Volume Rendering: Color Transfer Function
Volume Rendering: 2nd result
Source file: volume-transfer.js
Piecewise Gaussian Widget
Volume Rendering
Volume Slicing
Volume Slicing
Volume Slicing
Use image slicing interactivity (slice scroll and mouse window/level)
Volume Slicing
Need to set slice at focal point
Volume Slicing
Sets default window/level
Volume Slicing
Source file: image-slicing.js
Widgets and Interactions
Widget Example: Cropping Widget
Widgets Overview
Adding Crop Widget
Adding Crop Widget
Attaches renderer to widget manager
Adding Crop Widget
A view widget is an instance of a widget in a renderer.
Adding Crop Widget
When the crop widget updates, we crop our image.
Adding Crop Widget
Initialize the crop filter with the volume
Crop Widget
Source file: widgets.js
Conclusion
Next Time
Next course (#3):
Digging into vtk.js: Architecture and more