Vtk-js: no fullscreen. renderwindow in div

Created on 28 Feb 2017  路  2Comments  路  Source: Kitware/vtk-js

how can I set the renderwindow to a div in my DOM?

Most helpful comment

    // vtk.js code
    this.vtk = {};
    this.vtk.renderWindow = vtkRenderWindow.newInstance();
    this.vtk.renderer = vtkRenderer.newInstance();
    this.vtk.renderWindow.addRenderer(this.vtk.renderer);

    // OpenGlRenderWindow
    this.vtk.openGlRenderWindow = vtkOpenGLRenderWindow.newInstance();
    this.vtk.renderWindow.addView(this.vtk.openGlRenderWindow);

    // Interactor
    this.vtk.interactor = vtkRenderWindowInteractor.newInstance();
    this.vtk.interactor.setView(this.vtk.openGlRenderWindow);
    this.vtk.interactor.initialize();

    this.container = document.querySelector('.classToSelectYourDiv');
    this.vtk.openGlRenderWindow.setContainer(this.container);
    this.vtk.interactor.bindEvents(this.container);

All 2 comments

    // vtk.js code
    this.vtk = {};
    this.vtk.renderWindow = vtkRenderWindow.newInstance();
    this.vtk.renderer = vtkRenderer.newInstance();
    this.vtk.renderWindow.addRenderer(this.vtk.renderer);

    // OpenGlRenderWindow
    this.vtk.openGlRenderWindow = vtkOpenGLRenderWindow.newInstance();
    this.vtk.renderWindow.addView(this.vtk.openGlRenderWindow);

    // Interactor
    this.vtk.interactor = vtkRenderWindowInteractor.newInstance();
    this.vtk.interactor.setView(this.vtk.openGlRenderWindow);
    this.vtk.interactor.initialize();

    this.container = document.querySelector('.classToSelectYourDiv');
    this.vtk.openGlRenderWindow.setContainer(this.container);
    this.vtk.interactor.bindEvents(this.container);

You may have to resize it based on its container

const dims = this.container.getBoundingClientRect();
this.vtk.openGlRenderWindow.setSize(dims.width, dims.height);
Was this page helpful?
0 / 5 - 0 ratings