how to scroll SDL2 canvas smoothly by mouse wheel with Escripten/WASM

How to scroll SDL2 canvas smoothly by mouse wheel with Escripten/WASM, Especially when zoom in on a actor appear stuck, not smooth.

Are you using a VTK-wasm build? I’m not quite following what you are trying to achieve here.

AFAIK, in general, smoothness in the scroll action would depend on the amount of “delta” (amount of change applied to an operation, e.g. camera dolly) assigned to each tick of the scroll event.

Yes. I use vtk-wasm. I guess if the default vtk mouseWheel event callback below matchs with the SDL2(canvas).

void vtkInteractorStyleTrackballCamera::OnMouseWheelBackward()
{
  this->FindPokedRenderer(
    this->Interactor->GetEventPosition()[0], this->Interactor->GetEventPosition()[1]);
  if (this->CurrentRenderer == nullptr)
  {
    return;
  }

  this->GrabFocus(this->EventCallbackCommand);
  this->StartDolly();
  double factor = this->MotionFactor * -0.2 * this->MouseWheelMotionFactor;
  this->Dolly(pow(1.1, factor));
  this->EndDolly();
  this->ReleaseFocus();
}

You’re correct. This is a bug with SDL2 Render window interactor. It uses an integer event->wheel.y instead of event->wheel.preciseY. On most browsers which tend to use floating point for scroll deltas, the integer holds zero most of the time. Hence the stutter (back and forth)

This should be fixed with https://gitlab.kitware.com/vtk/vtk/-/merge_requests/9993