Actor

Live example


This example convert a JSON structure into an actual vtk class hierachy. The JSON file that get loaded can be seen here while the vtk() function expect an actual object not a String so you may need to convert a JSON string via the JSON.parse(string) method first.

Source

import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow';
import vtk from 'vtk.js/Sources/vtk';
import actorJSON from './actor.json';
// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
// ----------------------------------------------------------------------------
// Add actor with its pipeline into renderer
// ----------------------------------------------------------------------------
const actor = vtk(actorJSON);
renderer.addActor(actor);
renderer.resetCamera();
renderWindow.render();