InsightSoftwareConsortium / InsightSoftwareConsortium/ITK-Wasm
Picking operation is not working in Emscripten + vtkSDL2OpenGLRenderWindow
- Dominant language
- Python
- Stars
- 235
- Forks
- 61
- Avg merge
- 4d 19h
- Merged PRs (30d)
- 4
Description
I am trying several operations for newly updated VTK with emscripten rendering.
I found that [Picking Example](https://vtk.org/Wiki/VTK/Examples/Cxx/Interaction/Picking) seems not working for now.
Getting 2D coordinates works fine, but `vtkPropPicker->Pick(...)` returns warning and wrong results.
```
virtual void OnLeftButtonDown() override
{
int* clickPos = this->GetInteractor()->GetEventPosition();
// Pick from this location.
vtkSmartPointer picker = vtkSmartPointer::New();
picker->Pick(clickPos[0], clickPos[1], 0, this->GetDefaultRenderer());
double* pos = picker->GetPickPosition();
std::cout << "Pick position (world coordinates) is: " << pos[0] << " " << pos[1] << " " << pos[2] << std::endl;
std::cout << "Picked actor: " << picker->GetActor() << std::endl;
```
The picked position in world coordinates is always 0 0 0, and the browser shows warning saying :
```
WebGL: INVALID_ENUM: readPixels: invalid format
| _glReadPixels | @ | Picking.js:11102 -- | -- | -- | --
| vtkOpenGLRenderWindow::GetZbufferData(int, int, int, int, float*) | @ | 018741d6:1
| vtkOpenGLRenderWindow::GetZbufferData(int, int, int, int) | @ | 018741d6:1
| vtkHardwareSelector::BuildPropHitList(unsigned char*) | @ | 018741d6:1
| vtkHardwareSelector::ProcessPixelBuffers() | @ | 018741d6:1
| vtkHardwareSelector::Render(vtkRenderer*, vtkProp**, int) | @ | 018741d6:1
| vtkOpenGLRenderer::UpdateGeometry(vtkFrameBufferObjectBase*) | @ | 018741d6:1
| vtkOpenGLRenderer::DeviceRender() | @ | 018741d6:1
| vtkRenderer::Render() | @ | 018741d6:1
| vtkRendererCollection::Render() | @ | 018741d6:1
| vtkRenderWindow::DoStereoRender() | @ | 018741d6:1
| vtkRenderWindow::Render() | @ | 018741d6:1
| vtkOpenGLRenderWindow::Render() | @ | 018741d6:1
| vtkHardwareSelector::CaptureBuffers() | @ | 018741d6:1
| vtkHardwareSelector::Select() | @ | 018741d6:1
| vtkRenderer::PickProp(double, double, double, double) | @ | 018741d6:1
| vtkRenderer::PickProp(double, double) | @ | 018741d6:1
| vtkViewport::PickPropFrom(double, double, vtkPropCollection*) | @ | 018741d6:1
| vtkPropPicker::PickProp(double, double, vtkRenderer*) | @ | 018741d6:1
| vtkPropPicker::Pick(double, double, double, vtkRenderer*) | @ | 018741d6:1
| MouseInteractorStyle2::OnLeftButtonDown() | @ | 018741d6:1
```
```
[.WebGL-000001CEB1519F40] GL_INVALID_OPERATION: Invalid format and type combination.
```
Contributor guide
Assessment
This issue has not been assessed yet.