import '@kitware/vtk.js/favicon';
import '@kitware/vtk.js/Rendering/Profiles/All';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'; import vtkImplicitPlaneRepresentation from '@kitware/vtk.js/Widgets/Representations/ImplicitPlaneRepresentation';
import controlPanel from './controlPanel.html';
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], }); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow();
const representation = vtkImplicitPlaneRepresentation.newInstance();
const state = vtkImplicitPlaneRepresentation.generateState(); representation.setInputData(state);
representation.getActors().forEach(renderer.addActor);
renderer.resetCamera(); renderer.resetCameraClippingRange(); renderWindow.render();
fullScreenRenderer.addController(controlPanel);
function updateValue(e) { const value = Number(e.target.value); const name = e.currentTarget.dataset.name; const index = Number(e.currentTarget.dataset.index); const array = state.get(name)[name].slice(); array[index] = value; state.set({ [name]: array }); renderWindow.render(); }
const elems = document.querySelectorAll('.slider'); for (let i = 0; i < elems.length; i++) { elems[i].addEventListener('input', updateValue); }
|