I am trying to get the VTK.js examples to work in my Django Project and the webpack produces the js code (attached). However, when I load this code in my html template I get a blank (responsive) window. Any idea what I am missing here?
Hard to tell without seeing how you bind your view to your html and what you are doing. Having your app running somewhere could help, but having the code could be easier too.
import 'regenerator-runtime/runtime';
import vtkGenericRenderWindow from '@kitware/vtk.js/Rendering/Misc/GenericRenderWindow';
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
// --- Set up our renderer ---
const container = document.querySelector('#container');
// We use the wrapper here to abstract out manual RenderWindow/Renderer/OpenGLRenderWindow setup
const genericRenderWindow = vtkGenericRenderWindow.newInstance();
genericRenderWindow.setContainer(container);
genericRenderWindow.resize();
const renderer = genericRenderWindow.getRenderer();
const renderWindow = genericRenderWindow.getRenderWindow();
// --- Set up the cone actor ---
const actor = vtkActor.newInstance();
const mapper = vtkMapper.newInstance();
// this generates a cone
const coneSource = vtkConeSource.newInstance({
height: 1.0,
});
// the mapper reads in the cone polydata
// this sets up a pipeline: coneSource -> mapper
mapper.setInputConnection(coneSource.getOutputPort());
// tell the actor which mapper to use
actor.setMapper(mapper);
// --- Add actor to scene ---
renderer.addActor(actor);
// --- Reset camera and render the scene ---
renderer.resetCamera();
renderWindow.render();
// --- Expose globals so we can play with values in the dev console ---
global.renderWindow = renderWindow;
global.renderer = renderer;
global.coneSource = coneSource;
global.actor = actor;
global.mapper = mapper;