Spline widget appears behind image mapper
See original GitHub issueI mixed the SplineWidget example with the ImageMapper example:
See code
import 'vtk.js/Sources/favicon';
import vtkFullScreenRenderWindow from 'vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow';
import vtkSplineWidget from 'vtk.js/Sources/Widgets/Widgets3D/SplineWidget';
import vtkWidgetManager from 'vtk.js/Sources/Widgets/Core/WidgetManager';
import { SlicingMode } from 'vtk.js/Sources/Rendering/Core/ImageMapper/Constants';
import vtkRTAnalyticSource from 'vtk.js/Sources/Filters/Sources/RTAnalyticSource';
import vtkImageMapper from 'vtk.js/Sources/Rendering/Core/ImageMapper';
import vtkImageSlice from 'vtk.js/Sources/Rendering/Core/ImageSlice';
import vtkInteractorStyleImage from 'vtk.js/Sources/Interaction/Style/InteractorStyleImage';
import vtkColorTransferFunction from 'vtk.js/Sources/Rendering/Core/ColorTransferFunction';
import vtkPiecewiseFunction from 'vtk.js/Sources/Common/DataModel/PiecewiseFunction';
import controlPanel from './controlPanel.html';
// ----------------------------------------------------------------------------
// Standard rendering code setup
// ----------------------------------------------------------------------------
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
background: [0, 0, 0],
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
// ----------------------------------------------------------------------------
// ImageMapper example
// ----------------------------------------------------------------------------
const rtSource = vtkRTAnalyticSource.newInstance();
rtSource.setWholeExtent(0, 200, 0, 200, 0, 200);
rtSource.setCenter(100, 100, 100);
rtSource.setStandardDeviation(0.3);
const mapper = vtkImageMapper.newInstance();
mapper.setInputConnection(rtSource.getOutputPort());
mapper.setSliceAtFocalPoint(true);
mapper.setSlicingMode(SlicingMode.Z);
// mapper.setZSlice(5);
const rgb = vtkColorTransferFunction.newInstance();
global.rgb = rgb;
rgb.addRGBPoint(0, 0, 0, 0);
rgb.addRGBPoint(255, 1, 1, 1);
const ofun = vtkPiecewiseFunction.newInstance();
global.ofun = ofun;
ofun.addPoint(0, 1);
ofun.addPoint(150, 1);
ofun.addPoint(180, 0);
ofun.addPoint(255, 0);
const actor = vtkImageSlice.newInstance();
actor.getProperty().setColorWindow(255);
actor.getProperty().setColorLevel(127);
// Uncomment this if you want to use a fixed colorwindow/level
// actor.getProperty().setRGBTransferFunction(rgb);
actor.getProperty().setPiecewiseFunction(ofun);
actor.setMapper(mapper);
renderer.addActor(actor);
const iStyle = vtkInteractorStyleImage.newInstance();
iStyle.setInteractionMode('IMAGE_SLICING');
renderWindow.getInteractor().setInteractorStyle(iStyle);
const camera = renderer.getActiveCamera();
const position = camera.getFocalPoint();
// offset along the slicing axis
const normal = mapper.getSlicingModeNormal();
position[0] += normal[0];
position[1] += normal[1];
position[2] += normal[2];
camera.setPosition(...position);
switch (mapper.getSlicingMode()) {
case SlicingMode.X:
camera.setViewUp([0, 1, 0]);
break;
case SlicingMode.Y:
camera.setViewUp([1, 0, 0]);
break;
case SlicingMode.Z:
camera.setViewUp([0, 1, 0]);
break;
default:
}
camera.setParallelProjection(true);
renderer.resetCamera();
renderWindow.render();
// ----------------------------------------------------------------------------
// SplineWidget example
// ----------------------------------------------------------------------------
const widgetManager = vtkWidgetManager.newInstance();
widgetManager.setRenderer(renderer);
const widget = vtkSplineWidget.newInstance();
widgetManager.addWidget(widget);
renderer.resetCamera();
widgetManager.enablePicking();
// -----------------------------------------------------------
// UI control handling
// -----------------------------------------------------------
fullScreenRenderer.addController(controlPanel);
document.querySelector('button').addEventListener('click', () => {
widgetManager.grabFocus(widget);
});
The spline handles don’t stick on the actor surface here (the spline doesn’t look curvy because I had to press Shift to take a screenshot, which modifies the spline representation):

cc: @RemiCecchinato, @finetjul
Thank you
Edit: second issue moved to #1423
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:14 (13 by maintainers)
Top Results From Across the Web
vtkSplineWidget Class Reference - VTK
Force the spline widget to be projected onto one of the orthogonal planes. More... virtual void, ProjectToPlaneOn (). Force the spline widget to...
Read more >Compound Blur filter in Motion - Apple Support
In Motion, the Compound Blur filter (effect) blurs an object using another image channel as the blur shape (a map image).
Read more >Background Blur Widget - Unreal Engine Documentation
Use this widget to provide an opportunity to surround its content with adjustable padding and apply a post-process Gaussian blur to all backgroun...
Read more >Adding Images - Foundry Learn
Once you create the image file, Modo opens a panel where you designate the ... Creates a new, blank Image Map texture layer...
Read more >Plugins - Leaflet - a JavaScript library for interactive maps
Thanks to the awesome community behind Leaflet, there are literally hundreds ... Basemap providers; Basemap formats; Non-map base layers; Tile/image display ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I believe the first issue is the same as in the ShapeWidget example.
I do not know when this has been broken (@boucaud could it be your recent changes ?)
This can be solved (in ShapeWidget example at least) with:
However, I do not think it is the right solution. I think Widgets should have coincidentTopolyogy parameters set. What do you think @floryst @boucaud ?
Fixed by #1430, thank you @boucaud @finetjul