Add component carousel toolbox for creating optical elements - #2
Merged
Merged
Conversation
Replace hardcoded demo scene with an interactive carousel sidebar that lets users create any optical component by clicking its icon. The carousel (from SceneryStack's sun library) displays icons for all 16 component types organized by category: light sources, mirrors, lenses/glass, and blockers. - Add ComponentCarousel with miniature icons and factory functions for all element types (point source, beam, single ray, flat/arc/ parabolic/ideal mirrors, beam splitter, ideal lens, circle/spherical lens, prism, half-plane glass, line/circle blockers, aperture) - Add blocker view classes (LineBlockerView, CircleBlockerView, ApertureView) so blockers are now rendered and interactive - Update OpticalElementViewFactory to include blocker views - Update SimScreenView to host carousel and support dynamic element creation via callback - Simplify SimModel to start with empty scene; reset clears all https://claude.ai/code/session_01QvNN5qX7o5FmGAtweEQyaZ
veillette
pushed a commit
that referenced
this pull request
Apr 12, 2026
#1 – Centralize element labels in ElementRegistry Add a `label: TReadOnlyProperty<string>` field to ElementDescriptor so the registry is the single source of truth for element display names. Export `getElementLabel()`. Remove the duplicate `buildTypeLabels()`/`TYPE_LABELS` map from EditContainerNode and the now-unused StringManager import there. #2 – Rename continuousSpectrumSource → ContinuousSpectrumSource Fix the lone camelCase type key to match the PascalCase convention used by all other element types. Add a `case "continuousSpectrumSource":` fall-through shim in elementSerialization.ts so scenes saved by older versions continue to load without data loss. #3 – Replace 4-arg buildEditControls signature with EditControlContext bag Introduce `EditControlContext { signConvention, useCurvatureDisplay }` in EditControlsResult.ts. Update ElementDescriptor, the exported buildEditControls() functions in ElementRegistry/EditControlFactory, and the call site in EditContainerNode. Registry entries that previously prefixed unused params with `_` now destructure only what they need from the bag. Adding a new display preference requires a single interface change, not touching every builder signature. #4 – Replace instanceof checks in OpticsScene.simulate() with interfaces Add IAcquirable and ICompound to OpticsTypes.ts, with corresponding type guards (isAcquirable, isCompound). DetectorElement implements IAcquirable; FiberOpticElement implements ICompound. OpticsScene.simulate() uses the guards instead of `instanceof DetectorElement` / `instanceof FiberOpticElement`, removing its dependency on those concrete classes. #5 – Make OpticsScene.getElement() O(1) Add a `_elementById: Map<string, OpticalElement>` maintained by addElement / removeElement / clearElements. getElement() is now a single Map lookup instead of a full array scan. #6 – Fix SpatialIndex.getAllElements() O(n²) dedup Replace the `all.includes(el)` linear scan inside a loop with a `Set<OpticalElement>` accumulator, reducing the fast-path dedup from O(n²) to O(n). #7 – Extract syncBidirectional helper in SimScreenView Replace three near-identical `let blockXSync = false` bidirectional-sync patterns with a single generic `syncBidirectional(propA, propB)` helper. The helper also writes propA's initial value to propB, removing the separate initialization lines that preceded two of the three blocks. https://claude.ai/code/session_01H65WqMzMK88Jkra4gAjhE7
veillette
pushed a commit
that referenced
this pull request
Jul 21, 2026
Finding #1: optical-element screen-reader names were generated from the English class name via regex, bypassing i18n and never updating on locale change. Add StringManager.getElementTypeNameProperty(type) mapping each ELEMENT_TYPE_* to its localized component StringProperty; RayTracingCommonView assigns that Property to accessibleName, falling back to the generated name only for internal types (e.g. FiberCoreGlass). Finding #2: the "∫I =" detector readout label was a hardcoded literal next to a localized sibling. Add a detectorIntegratedIntensity key to en/fr/es, expose it via getUIStrings(), and use it in DetectorChartPanel. Mark both findings fixed in doc/scenerystack-review.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01US7abq5we9ZiLQ8j5YbUYK
veillette
pushed a commit
that referenced
this pull request
Jul 21, 2026
Finding #1: optical-element screen-reader names were generated from the English class name via regex, bypassing i18n and never updating on locale change. Add StringManager.getElementTypeNameProperty(type) mapping each ELEMENT_TYPE_* to its localized component StringProperty; RayTracingCommonView assigns that Property to accessibleName, falling back to the generated name only for internal types (e.g. FiberCoreGlass). Finding #2: the "∫I =" detector readout label was a hardcoded literal next to a localized sibling. Add a detectorIntegratedIntensity key to en/fr/es, expose it via getUIStrings(), and use it in DetectorChartPanel. Mark both findings fixed in doc/scenerystack-review.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01US7abq5we9ZiLQ8j5YbUYK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace hardcoded demo scene with an interactive carousel sidebar that lets users create any optical component by clicking its icon. The carousel (from SceneryStack's sun library) displays icons for all 16 component types organized by category: light sources, mirrors, lenses/glass, and blockers.
https://claude.ai/code/session_01QvNN5qX7o5FmGAtweEQyaZ