Hi, I am using vtk in my NPM VUE project.
After I create a simple example, I can’t interact the window with my mouse click.
I have tried to follow the documentation but it still seems doesn’t work.
Anyone who have idea if I am missing anything?
export default class Scene{
constructor() {
this.canvas = document.createElement('div');
this.renderer = vtkRenderer.newInstance();
this.window = vtkRenderWindow.newInstance();
this.control = InteractorStyle.newInstance();
this.interactor = vtkRenderWindowInteractor.newInstance();
this.openGL = vtkOpenGLRenderWindow.newInstance();
this.settings();
this.testMesh();
this.render();
}
settings(){
document.querySelector('body').appendChild(this.canvas);
this.window.addRenderer(this.renderer);
this.window.addView(this.openGL);
this.openGL.setContainer(this.canvas);
const { width, height } = this.canvas.getBoundingClientRect();
this.openGL.setSize(width, height);
this.interactor.setInteractorStyle(this.control);
this.interactor.setInteractorStyle(InteractorStyle.newInstance());
this.interactor.setView(this.openGL);
this.renderer.setBackground2(102, 51, 0)
this.renderer.setBackground(0, 102, 104)
}
render(){
this.interactor.initialize();
this.interactor.bindEvents(this.canvas);
}
testMesh(){
const coneSource = vtkConeSource.newInstance({ height: 1.0 });
const mapper = vtkMapper.newInstance();
mapper.setInputConnection(coneSource.getOutputPort());
const actor = vtkActor.newInstance();
actor.setMapper(mapper);
this.renderer.addActor(actor);
this.renderer.resetCamera();
}
}