Convert Plotly to VTK.js and remove dist folder#64
Convert Plotly to VTK.js and remove dist folder#64sridhar-mani wants to merge 13 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates FEAScript’s visualization layer from Plotly-based plotting to vtk.js-based scientific rendering, while also reorganizing and expanding the public visualization exports and removing committed build artifacts from dist/.
Changes:
- Replaced the Plotly visualization implementation with a vtk.js-based renderer and added VTK/ML/VTP transformation utilities.
- Updated public exports to expose the new visualization/utility API from
vtkSolutionScript.js. - Updated documentation and package metadata to reflect vtk.js usage and removed committed
dist/outputs from the repository.
Reviewed changes
Copilot reviewed 5 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/visualization/vtkSolutionScript.js | New vtk.js rendering + data transformation utilities (VTK polydata, VTP XML, ML buffers), replacing Plotly plotting logic. |
| src/visualization/plotSolutionScript.js | Removed old Plotly-based plotting implementation. |
| src/index.js | Re-exports visualization API from the new vtk.js module (and adds new exported helpers). |
| package.json | Swaps Plotly peer dep for @kitware/vtk.js and adds vtk.js to devDependencies. |
| README.md | Updates visualization description and install instructions to use vtk.js. |
| dist/feascript.umd.js | Deleted committed build artifact. |
| dist/feascript.esm.js | Deleted committed build artifact. |
| dist/feascript.cjs.js | Deleted committed build artifact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import "@kitware/vtk.js/Rendering/Profiles/Geometry"; | ||
| import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor"; | ||
| import vtkColorTransferFunction from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction"; | ||
| import vtkColorMaps from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps"; | ||
| import vtkDataArray from "@kitware/vtk.js/Common/Core/DataArray"; |
There was a problem hiding this comment.
vtkSolutionScript.js imports vtk.js rendering modules at the top level, and src/index.js re-exports from this file. That makes vtk.js (and any browser/WebGL side effects it has) load whenever consumers import FEAScript, even if they only need the solvers (e.g., Node examples / workers). Consider splitting visualization into a separate entrypoint or lazy-loading vtk.js inside the rendering functions so non-browser consumers don’t pay the dependency/side-effect cost.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
| const minX = Math.min(...nodesXCoordinates); | ||
| const maxX = Math.max(...nodesXCoordinates); | ||
| const minY = Math.min(...nodesYCoordinates); | ||
| const maxY = Math.max(...nodesYCoordinates); |
There was a problem hiding this comment.
Math.min(...nodesXCoordinates) / Math.max(...nodesXCoordinates) (and the same for Y) will throw or become very slow for large meshes because it spreads the entire coordinate array into function arguments. Use a simple loop to compute bounds (or a typed-array reduction) to avoid RangeError: too many arguments and reduce memory churn.
| "peerDependencies": { | ||
| "mathjs": "^11.12.0", | ||
| "plotly.js": "^2.35.3" | ||
| "@kitware/vtk.js": "^32.12.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@kitware/vtk.js": "^32.12.0", | ||
| "@rollup/plugin-commonjs": "^28.0.3", |
There was a problem hiding this comment.
This PR removes the committed dist/ artifacts, but main/module/exports still point at ./dist/* and the test script runs the Node examples without building first. With dist/ absent, npm test (and local dev installs from Git) will fail unless a build is run beforehand. Consider adding a prepare (and/or pretest) script to run rollup -c, or adjusting dev-time exports so the repo works without committed build output.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
src/index.js
Outdated
| export { | ||
| plotSolution, | ||
| plotInterpolatedSolution, | ||
| createColorScale, | ||
| createContourLineOptions, | ||
| transformSolverOutputToVtkData, |
There was a problem hiding this comment.
The new export block uses tab indentation, while the rest of the file (and most JS in this repo) uses spaces. This can create noisy diffs and may fail formatting/linting if enforced; consider converting these lines to the repository’s standard indentation.
|
@sridhar-mani I've opened a new pull request, #65, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 12 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import "@kitware/vtk.js/Rendering/Profiles/Geometry"; | ||
| import vtkActor from "@kitware/vtk.js/Rendering/Core/Actor"; | ||
| import vtkColorTransferFunction from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction"; | ||
| import vtkColorMaps from "@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps"; | ||
| import vtkDataArray from "@kitware/vtk.js/Common/Core/DataArray"; | ||
| import vtkImageData from "@kitware/vtk.js/Common/DataModel/ImageData"; | ||
| import vtkImageMarchingSquares from "@kitware/vtk.js/Filters/General/ImageMarchingSquares"; | ||
| import vtkGenericRenderWindow from "@kitware/vtk.js/Rendering/Misc/GenericRenderWindow"; | ||
| import vtkMapper from "@kitware/vtk.js/Rendering/Core/Mapper"; | ||
| import vtkPolyData from "@kitware/vtk.js/Common/DataModel/PolyData"; | ||
| import vtkScalarBarActor from "@kitware/vtk.js/Rendering/Core/ScalarBarActor"; | ||
|
|
There was a problem hiding this comment.
Top-level imports from vtk.js Rendering modules (Profiles/Geometry, Actor, Mapper, GenericRenderWindow, ScalarBarActor) will be executed whenever consumers import the main package (because src/index.js re-exports from this module). This is likely to break Node.js usage (including the repo’s npm test examples) if vtk.js touches DOM/WebGL globals at import time. Consider moving rendering-only imports behind a browser-only code path (dynamic import inside renderVtkScene), and/or splitting this file into a pure data-transform module (no Rendering imports) plus a browser-render module so Node can still import FEAScript safely.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
|
@sridhar-mani I've opened a new pull request, #66, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@sridhar-mani I've opened a new pull request, #67, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
@sridhar-mani I've opened a new pull request, #68, to work on those changes. Once the pull request is ready, I'll request review from you. |
This reverts commit 888a7f08b9da7f4081af7b441fcf71a65fd561f5.
|
Thanks for the input @sridhar-mani. I think it's better to also keep the previous visualization module (with Plotly.js) in case users want only basic visualization, and also for compatibility reasons. For example in 'FEAScript-core/src/visualization', rename plotSolutionScript.js to plotSolutionPlotlyScript and create also the plotSolutionVtkScript (based on vtkSolutionScript.js). Also, I've added some HTML examples in the 'FEAScript-core/examples' directory (see e.g. https://core.feascript.com/examples/frontPropagationScript/solidificationFront2D/solidificationFront2D.html) so we can test the VTK visualization before merging with the main branch. |
This pull request updates FEAScript’s visualization functionality to use vtk.js for scientific rendering instead of Plotly, and reorganizes the visualization exports. It also updates the documentation and dependencies to reflect this change.
Visualization library migration:
README.md) and the package dependencies (package.json). [1] [2]@kitware/vtk.jsinstead ofplotly.js. [1] [2]Codebase reorganization:
src/index.jsto use the newvtkSolutionScript.jsmodule, adding new exports for color scales, contour line options, and various data transformation utilities for vtk.js.