Skip to content

Refactor optical repetition: base view class, shared geometry, and control helpers - #9

Merged
veillette merged 1 commit into
mainfrom
claude/refactor-optical-repetition-yafzv
Mar 17, 2026
Merged

veillette merged 1 commit into
mainfrom
claude/refactor-optical-repetition-yafzv

Conversation

@veillette

Copy link
Copy Markdown
Collaborator

A. EditContainerNode._buildControls: extract numberControlOptions(delta, decimalPlaces)
factory and buildSegmentLengthControl(element, label, triggerRebuild) helper to
eliminate copy-pasted NumberControl options (~10 occurrences) and lenProp/lazyLink
blocks (5 occurrences for BeamSource, IdealLens, IdealCurvedMirror,
SegmentMirror/LineBlocker, TransmissionGrating/ReflectionGrating).

B. Create BaseOpticalElementView abstract base class (Node subclass) with abstract
bodyDragListener, onRebuild callback, and abstract rebuild(). Update all 19 *View
classes to extend it, removing duplicate field declarations and widening rebuild()
from private to protected override. GlassView satisfies bodyDragListener via getter;
SphericalLensView inherits through GlassView.

C. Move circumcenter and sampleArcPoints to Geometry.ts. ArcMirrorView.ts imports them
from there instead of defining them locally. ArcMirror.ts replaces its
linesIntersection-of-perpendicularBisectors approach with the shared circumcenter().

https://claude.ai/code/session_01Mm6vZucruGjT52Za6wSAQD

…ntrol helpers

A. EditContainerNode._buildControls: extract numberControlOptions(delta, decimalPlaces)
   factory and buildSegmentLengthControl(element, label, triggerRebuild) helper to
   eliminate copy-pasted NumberControl options (~10 occurrences) and lenProp/lazyLink
   blocks (5 occurrences for BeamSource, IdealLens, IdealCurvedMirror,
   SegmentMirror/LineBlocker, TransmissionGrating/ReflectionGrating).

B. Create BaseOpticalElementView abstract base class (Node subclass) with abstract
   bodyDragListener, onRebuild callback, and abstract rebuild(). Update all 19 *View
   classes to extend it, removing duplicate field declarations and widening rebuild()
   from private to protected override. GlassView satisfies bodyDragListener via getter;
   SphericalLensView inherits through GlassView.

C. Move circumcenter and sampleArcPoints to Geometry.ts. ArcMirrorView.ts imports them
   from there instead of defining them locally. ArcMirror.ts replaces its
   linesIntersection-of-perpendicularBisectors approach with the shared circumcenter().

https://claude.ai/code/session_01Mm6vZucruGjT52Za6wSAQD
@veillette
veillette merged commit 23819ae into main Mar 17, 2026
1 check failed
@veillette
veillette deleted the claude/refactor-optical-repetition-yafzv branch March 17, 2026 12:56
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.

2 participants