I am trying to hide the various elements of the implicit plane widget. There appears to be support for the properties in the widget setup (ImplicitPlaneWidget | vtk.js):
// --- Widget Requirement ---------------------------------------------------
model.methodsToLink = [
'representationStyle',
'sphereResolution',
'handleSizeRatio',
'axisScale',
'normalVisible',
'originVisible',
'planeVisible',
'outlineVisible',
];
But these properties are not affected by even the newInstance()
arguments, demonstrated here:
/* import '@kitware/vtk.js/favicon';
// Load the rendering pieces we want to use (for both WebGL and WebGPU)
import '@kitware/vtk.js/Rendering/Profiles/Geometry';
import '@kitware/vtk.js/Rendering/Profiles/Glyph';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';
import vtkImplicitPlaneWidget from '@kitware/vtk.js/Widgets/Widgets3D/ImplicitPlaneWidget';
import vtkWidgetManager from '@kitware/vtk.js/Widgets/Core/WidgetManager';
import vtkActor from '@kitware/vtk.js/Rendering/Core/Actor';
import vtkConeSource from '@kitware/vtk.js/Filters/Sources/ConeSource';
import vtkMapper from '@kitware/vtk.js/Rendering/Core/Mapper'; */
// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------
const fullScreenRenderer = vtk.Rendering.Misc.vtkFullScreenRenderWindow.newInstance({
background: [0, 0, 0],
});
const renderer = fullScreenRenderer.getRenderer();
// ----------------------------------------------------------------------------
// Add context to place widget
// ----------------------------------------------------------------------------
const cone = vtk.Filters.Sources.vtkConeSource.newInstance();
const mapper = vtk.Rendering.Core.vtkMapper.newInstance();
const actor = vtk.Rendering.Core.vtkActor.newInstance({ pickable: false });
actor.setMapper(mapper);
mapper.setInputConnection(cone.getOutputPort());
actor.getProperty().setOpacity(0.5);
renderer.addActor(actor);
// ----------------------------------------------------------------------------
// Widget manager
// ----------------------------------------------------------------------------
const widgetManager = vtk.Widgets.Core.vtkWidgetManager.newInstance();
widgetManager.setRenderer(renderer);
const widget = vtk.Widgets.Widgets3D.vtkImplicitPlaneWidget.newInstance({
normalVisible: false,
originVisible: true,
planeVisible: true,
outlineVisible: true
});
widget.getWidgetState().setNormal(0, 0, 1);
widget.placeWidget(cone.getOutputData().getBounds());
widget.setPlaceFactor(3);
widgetManager.addWidget(widget);
renderer.resetCamera();
widgetManager.enablePicking();
Is there any way to toggle visibility of the widget parts on demand? The question seems related to: