I can set my own normals to a polydata (lines) in vtk.js, and it works fine. But when I try to use a TubeFilter with said polydata, it doesn’t work; I can only generate the tube if I don’t set the normals. The program doesn’t run any code after calling tubeFilter.update()
.
I create my normals as so:
const numSegments = 1;
const normals = new Float32Array(3 * (numSegments + 1));
const normalArray = vtkDataArray.newInstance({
name: 'Normals',
values: normals,
numberOfComponents: 3,
});
for(let i=0; i<numSegments + 1; i++) {
normals[i*3+0] = 0;
normals[i*3+1] = 0;
normals[i*3+2] = 1;
}
And set it to the polydata as so:
polyData.getPointData().setNormals(normalArray);
I create the tube filter as so:
const tubeFilter = vtkTubeFilter.newInstance();
tubeFilter.setCapping(false);
tubeFilter.setNumberOfSides(50);
tubeFilter.setRadius(0.1);
tubeFilter.setInputData(polyData);
tubeFilter.setInputArrayToProcess(0, 'Scalars', 'PointData', 'Scalars');
tubeFilter.update(); // Program stops here
Why isn’t it working? What am I doing wrong? What do I have to do to generate a tube with my own normals?
Here’s the full code: index.js ; it’s a simplified version of this example .
Here’s an image of the line with the tube generated when no normals are set (left) and only the line when normals are set (right), as the code stops after trying to generate the tube.
Thanks to anyone who can help.