# vtk-easy: a nice js-like veneer over vtkjs syntax

**URL:** https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326
**Category:** Development
**Tags:** vtkjs
**Created:** [March 13, 2026, 6:11pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326 "2026-03-13T18:11:39Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![mhalle](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mhalle](https://discourse.vtk.org/u/mhalle)
#### Post date: [March 13, 2026, 6:11pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/1 "2026-03-13T18:11:39Z")

</div>

Hi there,

Ever since the earliest VTK days I’ve had both respect for and aggravation with VTK’s verbose syntax, specifically the getter and setter syntax and the fact that operations aren’t chainable in languages like Python and JavaScript that support it. Vtkjs, leaning on this syntax style, buzzes in my ear the same way.

I finally too a stab at addressing this issue with `vtk-easy` ( [GitHub - mhalle/vtk-easy: Ergonomic veneer over vtk.js — property-style access, fluent pipelines, auto-unwrapping · GitHub](https://github.com/mhalle/vtk-easy) ) .

`vtk-easy` wraps vtkjs objects with proxies that provide getter and setters and other nice properties. It’s non-invasive (sitting completely above vtkjs) and optional (you can drop down to vtkjs at any time).

It seems to work all with the vtkjs examples (some are included in the package).

Here’s an example:

```javascript
/* vtkjs imports omitted, same between versions */
import ez from 'vtk-easy';

const view = ez.create(vtkFullScreenRenderWindow, { 
    background: [0, 0, 0] 
});

const pointSource = ez.create(vtkPointSource, { 
    numberOfPoints: 25, radius: 0.25 
});

const pointsActor = ez.pipeline(pointSource)
  .actor({ property: { pointSize: 5 } });

const outlineActor = ez.pipeline(pointSource)
  .filter(vtkOutlineFilter)
  .actor({ property: { lineWidth: 5 } });

view.add(pointsActor, outlineActor);

view.renderer.resetCamera();
view.renderWindow.render();

```

compared to:

```javascript

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0] });

const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const pointSource = vtkPointSource.newInstance({ numberOfPoints: 25, radius: 0.25 });

const outline = vtkOutlineFilter.newInstance();
outline.setInputConnection(pointSource.getOutputPort());

const pointMapper = vtkMapper.newInstance();
pointMapper.setInputConnection(pointSource.getOutputPort());

const pointActor = vtkActor.newInstance();
pointActor.setMapper(pointMapper);
pointActor.getProperty().setPointSize(5);

renderer.addActor(pointActor);

const outlineMapper = vtkMapper.newInstance();
outlineMapper.setInputConnection(outline.getOutputPort());
const outlineActor = vtkActor.newInstance();
outlineActor.setMapper(outlineMapper);
outlineActor.getProperty().setLineWidth(5);

renderer.addActor(outlineActor);
renderer.resetCamera();
renderWindow.render();

```

Please let me know what you think of it.

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [March 13, 2026, 10:47pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/2 "2026-03-13T22:47:22Z")

</div>

this looks nice.

I also want to mention that in the sci-viz team, there are rumblings of an ‘express’ api for python users. I am thinking to enable such an API in the JavaScript world through VTK.wasm.

---

<div class="post-metadata">

### Author: ![mhalle](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mhalle](https://discourse.vtk.org/u/mhalle)
#### Post date: [March 13, 2026, 10:57pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/3 "2026-03-13T22:57:48Z")

</div>

Thanks.

Since I wrote this post, I’ve added two more features: a way to write a source or filter with almost no boilerplate, and a polydata construction helper.

It’s lovely that these features can bolt on top so cleanly.

---

<div class="post-metadata">

### Author: ![amaclean](https://discourse.vtk.org/user_avatar/discourse.vtk.org/amaclean/32/224_2.png) [@amaclean](https://discourse.vtk.org/u/amaclean)
#### Post date: [March 14, 2026, 7:32am UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/4 "2026-03-14T07:32:09Z")

</div>

Actually in Python, this is aldready working, thanks to Berk Geveci, please see: [PythonicAPIComments](https://examples.vtk.org/site/PythonicAPIComments/) also [VTK 9.4: A Step Closer to the Ways of Python](https://www.kitware.com/vtk-9-4-a-step-closer-to-the-ways-of-python/).

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [March 14, 2026, 12:10pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/5 "2026-03-14T12:10:16Z")

</div>

@amaclean no there’s even more in the works. I can’t find the gist link at the moment

---

<div class="post-metadata">

### Author: ![jaswantp](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jaswantp/32/10046_2.png) [@jaswantp](https://discourse.vtk.org/u/jaswantp)
#### Post date: [March 14, 2026, 1:15pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/6 "2026-03-14T13:15:37Z")

</div>

> <https://gist.github.com/berkgeveci/f4043474380084debbf2cde0b4f6ea9c>

---

<div class="post-metadata">

### Author: ![mhalle](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mhalle](https://discourse.vtk.org/u/mhalle)
#### Post date: [March 14, 2026, 3:26pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/7 "2026-03-14T15:26:26Z")

</div>

I appreciate the brainstorming that went into the design. However, I think that it’s gone too far and lost some of the good design decisions of VTK.

In my opinion, object constructors should be Capitalized to stand out. Lowercase is unpythonic.

”\*” imports (e.g., `vtkmodules.simple_api import *`) are an anti-pattern, because as in this case they push `read` and `write` into the default namespace where they conflict with builtins.

It also looks like data sources are evaluated eagerly, which conflicts with VTK’s pipeline model.

Maybe there’s a standard pipeline under there, but it’s hard to see how lazy evaluation happens from the example.

---

<div class="post-metadata">

### Author: ![mhalle](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mhalle](https://discourse.vtk.org/u/mhalle)
#### Post date: [March 14, 2026, 4:33pm UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/8 "2026-03-14T16:33:02Z")

</div>

It’s great to have the python version to look at to help develop new features.

Javascript doesn’t have operator overloading ( `>>` in the python syntax ) so I used the `.pipe()` convention used in other JS pipeline packages. I borrowed the idea that pipeline building can be either eager with instances or deferred like a template. It’s a neat idea.

Optionally, the pipeline can be terminated with `actor()` to get an actor..

I added a `merge` function that allows multiple pipeline segments to be merged together with AddInputConnection and SetInputConnection.

I also added `defineFilter` and `defineSource` functions that allow new, fully vtkjs compliant filters and data sources to be created at runtime with less boilerplating.

Finally, I like the idea of using string color names, especially to work with a web environment. I added `ez.rgb()` and `ez.rgba()` functions that take any compliant web color – including from other color spaces – and convert them into number arrays for vtkjs. These colors are in srgb space just like the underlying libraries expect.

Finally, I added a `view.show(actorlist)` convenience method on RenderWindow wrappers.

Everything here is pretty lightweight, and again, it reflects well on vtkjs that this is possible without monkeypatching.

---

<div class="post-metadata">

### Author: ![PaulHax](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulhax/32/2748_2.png) [@PaulHax](https://discourse.vtk.org/u/PaulHax)
#### Post date: [March 17, 2026, 2:11am UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/9 "2026-03-17T02:11:23Z")

</div>

Neat stuff Michael

I’m curous, what other JS pipeline libraries are you looking at? Does it make sense to use their APIs directly with utilities to wire VTK.js inputs/outputs?

---

<div class="post-metadata">

### Author: ![mhalle](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/50afbb/32.png) [@mhalle](https://discourse.vtk.org/u/mhalle)
#### Post date: [March 17, 2026, 3:19am UTC](https://discourse.vtk.org/t/vtk-easy-a-nice-js-like-veneer-over-vtkjs-syntax/16326/10 "2026-03-17T03:19:35Z")

</div>

There are only generic patterns (like node streams with .pipe()).

VTK’s syntax if sufficiently unique that a tailored design makes the most sense. Using properties to avoid get/set and making pipelines work use well-understood mechanisms.

And that’s just the pipelines. Being able to write a filter simply is exciting in itself.
