import '@kitware/vtk.js/favicon';
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'; import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor'; import vtkPlaneSource from '@kitware/vtk.js/Filters/Sources/PlaneSource'; import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper'; import { Representation } from '@kitware/vtk.js/Rendering/Core/Property/Constants';
import controlPanel from './controlPanel.html';
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], }); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow();
const planeSource = vtkPlaneSource.newInstance(); const mapper = vtkMapper.newInstance(); const actor = vtkActor.newInstance();
actor.getProperty().setRepresentation(Representation.WIREFRAME);
mapper.setInputConnection(planeSource.getOutputPort()); actor.setMapper(mapper);
renderer.addActor(actor); renderer.resetCamera(); renderWindow.render();
fullScreenRenderer.addController(controlPanel);
['xResolution', 'yResolution'].forEach((propertyName) => { document.querySelector(`.${propertyName}`).addEventListener('input', (e) => { const value = Number(e.target.value); planeSource.set({ [propertyName]: value }); renderWindow.render(); }); });
global.planeSource = planeSource; global.mapper = mapper; global.actor = actor; global.renderer = renderer; global.renderWindow = renderWindow;
|