Conversation
There was a problem hiding this comment.
Pull request overview
This pull request introduces a flip feature for paper folding simulation and consolidates UI controls. The implementation includes substantial refactoring of the polygon clipping and geometry handling code, along with new animation logic for the flip operation.
Changes:
- Adds Flip button and animation with 3D rotation effect around vertical axis
- Consolidates Style panel controls into main Settings panel with support for custom aspect ratios and separate front/back paper colors
- Refactors polygon clipping logic with improved numerical stability through vertex collapsing and collinear point removal
- Enhances fold animation rendering with better layer sorting and documentation
- Adds keyboard shortcuts (F for flip, R for reset, Space/Enter for fold)
- Introduces debug section in Info panel for development diagnostics
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| index.html | Removes Style panel, integrates controls into Settings with custom aspect ratio inputs, adds Flip button and debug spoiler section |
| src/style.css | Updates input-row layout from space-between to flex with gap, adds section-header and reset-inline-btn styles, adds custom aspect and debug spoiler styles |
| src/main.ts | Adds flip animation runtime and handlers, updates keyboard shortcuts, adds custom aspect ratio logic, refactors color picker for front/back colors, updates debug status display |
| src/paper/model.ts | Adds outer field to Face interface, adds unused flipPaper function (duplicate of commitFlip) |
| src/paper/fold.ts | Updates commitFold to invert layers and set outer flag, refactors normalizeVerts into clearer helper functions |
| src/paper/flip.ts | New file implementing flip animation building and commit logic |
| src/render/paper.ts | Refactors fold animation with improved layer sorting and documentation, adds drawFlippingPaper function, extracts lighting calculations into separate functions, adds constants for magic numbers |
| src/geom/polygon.ts | Refactors cleanup into separate collapseNearbyVertices and removeCollinearVertices functions, extracts signedPolyArea, improves documentation |
| src/device/posture.ts | Updates help text to reflect new controls (Space/F/R shortcuts) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| window.addEventListener("keydown", (e) => { | ||
| if ((e.code === "KeyF" || e.code === "Enter" || e.code === "Space") && !e.repeat) { | ||
| if (e.repeat) return; | ||
| if (e.code === "Space" || e.code === "Enter") { |
There was a problem hiding this comment.
The global keyboard shortcut handler for Space/Enter keys (lines 384-386) may conflict with the conditional Space key listener added earlier in the code at lines 321-327 (when postureSupport === PostureSupport.Unavailable). If both listeners are active, pressing Space will trigger the fold action twice. Verify that this doesn't cause duplicate fold animations or consider consolidating the keyboard shortcuts into a single listener.
| if (e.code === "Space" || e.code === "Enter") { | |
| if ( | |
| (e.code === "Space" && postureSupport !== PostureSupport.Unavailable) || | |
| e.code === "Enter" | |
| ) { |
This pull request introduces several significant UI and code improvements to the paper folding app. The most notable changes include a major reorganization and enhancement of the Style controls (now integrated into the main Settings panel), the addition of a Flip feature with corresponding UI and animation logic, and substantial improvements to the polygon clipping and cleanup algorithms for more robust geometry handling. Additionally, the codebase is now better documented, and several UI elements have been refined for clarity and accessibility.
UI and Feature Enhancements:
Polygon Clipping and Geometry Improvements:
clipPolyHalfPlanehas been refactored for clarity, with new utility functions to collapse near-coincident vertices and remove collinear points, reducing rendering artifacts and improving numerical stability. [1] [2]UI Polish and Accessibility:
Help and Documentation Updates:
Summary of Most Important Changes:
UI and Feature Enhancements
Geometry and Algorithm Improvements
UI Polish and Documentation