How kitware/vtk-js works
Project Type and Purpose
• vtk.js is an open-source JavaScript visualization toolkit (a library), not a full-stack app. It provides core data structures, filters, IO, rendering pipelines (WebGL/WebGPU/WebXR), interaction/manipulation APIs, widgets, and remote-rendering proxies to build 3D/volume visualization in the browser.
a. Core Library (Sources/)
• Common – core data structures, math, utilities
• DataModel – PolyData, ImageData, MultiBlock, etc.
• Filters – geometry & image filters (Core, General, Sources, Texture)
• IO – file readers/writers (obj, stl, vtk, image formats) + DataAccessHelpers
• Rendering – pipeline for WebGL/OpenGL/WebGPU/WebXR + SceneGraph + Profiles
• Interaction – manipulators, gesture/keyboard/mouse handlers, UI controls
• Widgets – 3D & 2D interactive widgets & widget manager
• Proxy – remote/ParaView server proxies & data synchronization
b. Examples & Data
• Data/ – sample datasets (VTK geometry, volumes, scenes)
• Examples/ – runnable demos illustrating library use
c. Documentation
• Documentation/ – static site generator, markdown, API docs, tutorials
d. Build & Packaging
• Utilities/webpack, rollup, Babel config, test runner templates
• CI/CD (GitHub workflows)
• dist/ – generated bundles and index.html for the demo site
e. Testing
• Testing/ – unit tests, example-based testing harness
• IO → DataModel: file readers produce PolyData/ImageData
• DataModel → Filters: build and process data pipelines
• Filters → Rendering: mapped to WebGL/WebGPU primitives
• Common & System (timers, Base64, URL fetching) underpin all modules
• Interaction & Widgets → Rendering: attach behaviors to RenderWindow
• Proxy ↔ IO & Rendering: fetch remote geometry, feed into local pipeline
• Examples & Documentation consume the public API exposed by Sources/index.js
• Build & Packaging orchestrate transformation of Sources through Babel/Rollup/Webpack into dist bundles, trigger tests and publishing via CI
Architectural Patterns & Principles
• Modular ES6 structure: each feature in its own folder under Sources/
• Pipeline pattern: DataModel → Filters → Rendering
• Proxy pattern for remote rendering (WSLink)
• Factory & State-Builder for widget & representation instantiation
• Adapter/Data-Access abstractions (HTML, HTTP, JSZip) in IO/Core
• Strategy pattern: multiple rendering backends (WebGL vs WebGPU vs WebXR)
Essential Elements to Capture
• Public entry point: Sources/index.js → npm module
• Data flow: file import → pipeline → render window
• Extensibility: illustrate where to plug new readers, filters, render passes, widgets
• Build pipeline: Babel → Rollup/Webpack → dist bundles → npm publish
• CI: test suites, example-runner, GitHub Actions