Skip to content

Drop the vtk.js ambient shims and treat a parallel crop plane as a miss - #928

Draft
PaulHax wants to merge 2 commits into
Kitware:mainfrom
PaulHax:crop-plane-intersection-guard
Draft

Drop the vtk.js ambient shims and treat a parallel crop plane as a miss#928
PaulHax wants to merge 2 commits into
Kitware:mainfrom
PaulHax:crop-plane-intersection-guard

Conversation

@PaulHax

@PaulHax PaulHax commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Deletes src/shims-vtk.d.ts now that vtk.js declares the modules it stubbed, and fixes intersectMouseEventWithPlane returning a truthy empty array on a parallel plane, which read back as NaN crop bounds — draft because it needs the vtk.js declaration sync released first.

src/shims-vtk.d.ts existed because vtk.js shipped no declarations for
these entry points. Upstream now declares all of them, so the file is
removed entirely and the code uses the real types.

Some of the shim was also stale and was quietly hiding drift:
- vtkWidgetManager declared updateSelectionFromXY,
  updateSelectionFromMouseEvent and useSvgLayer, none of which still
  exist upstream
- the reslice cursor state claimed setColor3/setScale1/setOpacity on the
  root state, but those live on the individual handle states; the casts
  in ResliceCursorTool now name the mixin state types they really are
- a non-generic addWidget signature masked that our own vtkPaintWidget
  and vtkCrosshairsWidget declarations extended the factory's value type
  rather than its interface

Preset metadata specific to VolView (OpacityPoints, AbsoluteRange,
EffectiveRange) moves to a local ColorMapPreset type extending vtk.js's
IColorMapPreset, instead of a shim redeclaring the whole module.
intersectMouseEventWithPlane returned whatever vtkPlane.intersectWithLine put
in its `x` field, which is an empty array when the line is parallel to the
plane and no intersection was computed. An empty array is truthy, so the
caller's `if (!coord)` guard never fired and the coordinates read back as
undefined, which propagated as NaN into the crop bounds.

Return null for that case, matching how the function already reports its other
failures, so the existing guard covers it.
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for volview-dev failed.

Name Link
🔨 Latest commit fa74ea8
🔍 Latest deploy log https://app.netlify.com/projects/volview-dev/deploys/6a85ea97fb71e200085a9772

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant