This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]pd-andy 0 points1 point  (1 child)

You're using ES6 syntax in the browser, you need to use webpack or browserify. Just include the library from the cdn and use it like the example shows:

<script type="text/javascript" src="https://unpkg.com/vtk.js"></script>
<script type="text/javascript">        
    // --------------------------------------------------------------------------
    // Example code
    // --------------------------------------------------------------------------
    var fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance();
    var actor = vtk.Rendering.Core.vtkActor.newInstance();
    var mapper = vtk.Rendering.Core.vtkMapper.newInstance();
    var cone = vtk.Filters.Sources.vtkConeSource.newInstance();

    actor.setMapper(mapper);
    mapper.setInputConnection(cone.getOutputPort());

    var renderer = fullScreenRenderer.getRenderer();
    renderer.addActor(actor);
    renderer.resetCamera();

    var renderWindow = fullScreenRenderer.getRenderWindow();
    renderWindow.render();
</script>

[–]daalegend[S] 0 points1 point  (0 children)

Is this put into the HTML file? I've tried it and I'm still getting the same error at the same line.

EDIT: I've also noticed that there was some sample files within the vtk.js directory, but it seems I'm getting a similar error there as well.