This is a quickstart tutorial for using vtk.js with vue.js.
Initialize your project
Install the vue-cli as per the vue-cli docs. Then, create and initialize your project with vue create. For this example, we will be using Vue 3 and npm.
$ vue create my-vtkjs-app > Select Vue 3 defaults
$ cd my-vtkjs-app
Now install vtk.js as a dependency.
$ npm install @kitware/vtk.js
Configure your project
@kitware/vtk.js targets ES6+ output, which means if you are intending to target ES5 browsers, you must tell vue-cli to transpile @kitware/vtk.js. Update your vue.config.js file to look like the following snippet below. Visit the vue-cli documentation for more info.
module.exports = defineConfig({ ... // If you want to transpile all dependencies: transpileDependencies: true,
// If you selectively transpile dependencies: transpileDependencies: ["@kitware/vtk.js"], });
Using vtk.js in your app
To add a minimal vtk.js example to your app, replace src/components/HelloWorld.vue with the following contents.
You can run the app using the project’s built-in dev server.
$ npm run start
Navigate to http://localhost:8080, and you should have an interactive 3D visualization of a cone, similar to the SimpleCone example.
Where to go next
Check out the tutorials, or if you know what you want but need API docs, check out the API.