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 vtkSphereSource from '@kitware/vtk.js/Filters/Sources/SphereSource'; import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import controlPanel from './controlPanel.html';
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], }); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow();
const sphereSource = vtkSphereSource.newInstance(); const actor = vtkActor.newInstance(); const mapper = vtkMapper.newInstance();
actor.getProperty().setEdgeVisibility(true);
mapper.setInputConnection(sphereSource.getOutputPort()); actor.setMapper(mapper);
renderer.addActor(actor); renderer.resetCamera(); renderWindow.render();
fullScreenRenderer.addController(controlPanel);
[ 'radius', 'thetaResolution', 'startTheta', 'endTheta', 'phiResolution', 'startPhi', 'endPhi', ].forEach((propertyName) => { document.querySelector(`.${propertyName}`).addEventListener('input', (e) => { const value = Number(e.target.value); sphereSource.set({ [propertyName]: value }); renderWindow.render(); }); });
document.querySelector('.edgeVisibility').addEventListener('change', (e) => { const edgeVisibility = !!e.target.checked; actor.getProperty().setEdgeVisibility(edgeVisibility); renderWindow.render(); });
|