import '@kitware/vtk.js/favicon';
import '@kitware/vtk.js/Rendering/Profiles/Geometry'; import '@kitware/vtk.js/Rendering/Profiles/Molecule';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow'; import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor'; import vtkPDBReader from '@kitware/vtk.js/IO/Misc/PDBReader'; import vtkSphereMapper from '@kitware/vtk.js/Rendering/Core/SphereMapper'; import vtkStickMapper from '@kitware/vtk.js/Rendering/Core/StickMapper'; import vtkMoleculeToRepresentation from '@kitware/vtk.js/Filters/General/MoleculeToRepresentation';
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({ background: [0, 0, 0], }); const renderer = fullScreenRenderer.getRenderer(); const renderWindow = fullScreenRenderer.getRenderWindow();
const reader = vtkPDBReader.newInstance(); const filter = vtkMoleculeToRepresentation.newInstance(); const sphereMapper = vtkSphereMapper.newInstance(); const stickMapper = vtkStickMapper.newInstance(); const sphereActor = vtkActor.newInstance(); const stickActor = vtkActor.newInstance();
filter.setInputConnection(reader.getOutputPort()); filter.setHideElements(['H']);
sphereMapper.setInputConnection(filter.getOutputPort(0)); sphereMapper.setScaleArray(filter.getSphereScaleArrayName()); sphereActor.setMapper(sphereMapper);
stickMapper.setInputConnection(filter.getOutputPort(1)); stickMapper.setScaleArray('stickScales'); stickMapper.setOrientationArray('orientation'); stickActor.setMapper(stickMapper);
reader.setUrl(`${__BASE_PATH__}/data/molecule/pdb/2LYZ.pdb`).then(() => { renderer.resetCamera(); renderWindow.render(); });
renderer.addActor(sphereActor); renderer.addActor(stickActor); renderer.resetCamera(); renderWindow.render();
global.reader = reader; global.filter = filter; global.sphereMapper = sphereMapper; global.stickMapper = stickMapper; global.sphereActor = sphereActor; global.stickActor = stickActor; global.renderer = renderer; global.renderWindow = renderWindow;
|