Hello,
I’m developing an application using Electron and one of the key features is being able to read/display vtk/vtu files. Playing around with VTK.js and react and I think I’m close to doing it but I’m not sure what exactly to return.
import React from 'react';
import { useState, useRef, useEffect } from 'react';
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper';
import vtkPolyDataReader from '@kitware/vtk.js/IO/Legacy/PolyDataReader';
// eslint-disable-next-line react/prefer-stateless-function
class LoadVTK extends React.Component {
render() {
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance();
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
const resetCamera = renderer.resetCamera;
const render = renderWindow.render;
const reader = vtkPolyDataReader.newInstance();
reader.setUrl('skin.vtk').then(() => {
const polydata = reader.getOutputData(0);
const mapper = vtkMapper.newInstance();
const actor = vtkActor.newInstance();
actor.setMapper(mapper);
mapper.setInputData(polydata);
renderer.addActor(actor);
resetCamera();
render();
});
return (
<div></div>
);
}
}
export default LoadVTK;
Not exactly sure what tags/information to return.
Followed this post: reactjs - VTK.js, React, JavaScript: Load VTK files - Stack Overflow
And also following this doc: Using vtk.js with React | vtk.js
The issue is probably very simple but I’m not well versed with these tags. Any help or points to the right direction would be greatly appreciated.