ActorSerialization

Live example

This example convert a JSON structure into an actual vtk class hierarchy. The JSON file that get loaded can be seen [here](https://github.com/Kitware/vtk-js/blob/master/Sources/Testing/Examples/ActorSerialization/example/actor.json) 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 '@kitware/vtk.js/favicon';

// Load the rendering pieces we want to use (for both WebGL and WebGPU)
import '@kitware/vtk.js/Rendering/Profiles/All';

import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtk from '@kitware/vtk.js/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();