simple-circuit-engine 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/AGENTS.md +13 -7
  2. package/CLAUDE.md +16 -103
  3. package/README.md +8 -5
  4. package/dist/core/index.d.ts +2 -23
  5. package/dist/core/index.js +75 -2000
  6. package/dist/core/setup.d.ts +17 -0
  7. package/dist/core/simulation/CircuitRunner.d.ts +176 -0
  8. package/dist/core/simulation/DirtyTracker.d.ts +87 -0
  9. package/dist/core/simulation/EventQueue.d.ts +68 -0
  10. package/dist/core/simulation/StateManager.d.ts +100 -0
  11. package/dist/core/simulation/behaviors/BehaviorRegistry.d.ts +70 -0
  12. package/dist/core/simulation/behaviors/ComponentBehavior.d.ts +53 -0
  13. package/dist/core/simulation/behaviors/basic/BatteryBehavior.d.ts +14 -0
  14. package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
  15. package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
  16. package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
  17. package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
  18. package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
  19. package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
  20. package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
  21. package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
  22. package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
  23. package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
  24. package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
  25. package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
  26. package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
  27. package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
  28. package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
  29. package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
  30. package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
  31. package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
  32. package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
  33. package/dist/core/simulation/behaviors/index.d.ts +24 -0
  34. package/dist/core/simulation/behaviors/types.d.ts +101 -0
  35. package/dist/core/simulation/index.d.ts +18 -0
  36. package/dist/core/simulation/states/ComponentState.d.ts +57 -0
  37. package/dist/core/simulation/states/SimulationState.d.ts +46 -0
  38. package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
  39. package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
  40. package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
  41. package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
  42. package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
  43. package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
  44. package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
  45. package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
  46. package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
  47. package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
  48. package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
  49. package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
  50. package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
  51. package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
  52. package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
  53. package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
  54. package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
  55. package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
  56. package/dist/core/simulation/states/gates/index.d.ts +25 -0
  57. package/dist/core/simulation/states/index.d.ts +26 -0
  58. package/dist/core/simulation/states/types.d.ts +32 -0
  59. package/dist/core/simulation/types.d.ts +155 -0
  60. package/dist/core/topology/Circuit.d.ts +420 -0
  61. package/dist/core/topology/CircuitMetadata.d.ts +24 -0
  62. package/dist/core/topology/CircuitOptions.d.ts +14 -0
  63. package/dist/core/topology/Component.d.ts +152 -0
  64. package/dist/core/topology/ENode.d.ts +200 -0
  65. package/dist/core/topology/Wire.d.ts +130 -0
  66. package/dist/core/topology/delays.d.ts +52 -0
  67. package/dist/core/topology/index.d.ts +14 -0
  68. package/dist/core/topology/types.d.ts +175 -0
  69. package/dist/core/utils/CameraOptions.d.ts +83 -0
  70. package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
  71. package/dist/core/utils/Position.d.ts +166 -0
  72. package/dist/core/utils/Position3D.d.ts +77 -0
  73. package/dist/core/utils/Rotation.d.ts +82 -0
  74. package/dist/core/utils/index.d.ts +24 -0
  75. package/dist/core/utils/types.d.ts +35 -0
  76. package/dist/core-Bjta9Y7_.js +2707 -0
  77. package/dist/core-Bjta9Y7_.js.map +1 -0
  78. package/dist/index.d.ts +13 -6286
  79. package/dist/index.js +120 -100
  80. package/dist/scene/CircuitEngine.d.ts +270 -0
  81. package/dist/scene/index.d.ts +1 -2
  82. package/dist/scene/index.js +44 -38
  83. package/dist/scene/setup.d.ts +18 -0
  84. package/dist/scene/shared/AbstractCircuitController.d.ts +211 -0
  85. package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
  86. package/dist/scene/shared/EventEmitter.d.ts +92 -0
  87. package/dist/scene/shared/HoverManager.d.ts +151 -0
  88. package/dist/scene/shared/SelectionManager.d.ts +159 -0
  89. package/dist/scene/shared/WireVisualManager.d.ts +242 -0
  90. package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
  91. package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
  92. package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
  93. package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
  94. package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
  95. package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
  96. package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
  97. package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
  98. package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
  99. package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
  100. package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
  101. package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
  102. package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
  103. package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
  104. package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
  105. package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
  106. package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
  107. package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
  108. package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
  109. package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
  110. package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
  111. package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
  112. package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
  113. package/dist/scene/shared/components/index.d.ts +29 -0
  114. package/dist/scene/shared/components/types.d.ts +43 -0
  115. package/dist/scene/shared/types.d.ts +476 -0
  116. package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
  117. package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
  118. package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
  119. package/dist/scene/shared/utils/GeometryUtils.d.ts +261 -0
  120. package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
  121. package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
  122. package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
  123. package/dist/scene/shared/utils/Options.d.ts +16 -0
  124. package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
  125. package/dist/scene/static/CircuitController.d.ts +227 -0
  126. package/dist/scene/static/CircuitWriter.d.ts +146 -0
  127. package/dist/scene/static/PinTooltipWidget.d.ts +26 -0
  128. package/dist/scene/static/tools/BuildTool.d.ts +286 -0
  129. package/dist/scene/static/tools/ComponentPickerWidget.d.ts +82 -0
  130. package/dist/scene/static/tools/ConfigPanelWidget.d.ts +93 -0
  131. package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
  132. package/dist/scene-CVsDdySt.js +7357 -0
  133. package/dist/scene-CVsDdySt.js.map +1 -0
  134. package/package.json +24 -25
  135. package/dist/CircuitRunner-DEb7JdNf.js +0 -1809
  136. package/dist/CircuitRunner-DEb7JdNf.js.map +0 -1
  137. package/dist/core/index.js.map +0 -1
  138. package/dist/index.js.map +0 -1
  139. package/dist/scene/index.js.map +0 -1
  140. package/dist/setup-AB1vFiis.js +0 -9918
  141. package/dist/setup-AB1vFiis.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for RectangleLED components
7
+ *
8
+ * Creates:
9
+ * - LED box mesh
10
+ * - Input pin group
11
+ * - Output pin group
12
+ * - Component hitbox for raycasting
13
+ *
14
+ * Animation:
15
+ * - Smooth emissive glow transition when LED lights up or turns off
16
+ * - Uses AnimationMixer with material property tracks (emissive, emissiveIntensity)
17
+ * - Clones PRIVATE material per-instance during simulation for independent animation
18
+ */
19
+ export declare class RectangleLEDVisualFactory extends ComponentVisualFactoryBase {
20
+ /** LED lit color (yellow glow) */
21
+ private readonly LED_LIT_COLOR;
22
+ /** LED lit emissive intensity */
23
+ private readonly LED_LIT_INTENSITY;
24
+ /** Black in normalized RGB for ColorKeyframeTrack */
25
+ private readonly UNLIT_RGB;
26
+ constructor();
27
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
28
+ private createPinsVisual;
29
+ /**
30
+ * Get config form definition for RectangleLED (T027)
31
+ *
32
+ * @returns Form definition with activeColor and idleColor color fields
33
+ */
34
+ getConfigFormDefinition(): ConfigFormDefinition | null;
35
+ /**
36
+ * Map core config to form data (T027)
37
+ * Converts hex/preset strings to hex values for color picker
38
+ *
39
+ * @param config - Core component config
40
+ * @returns Form data with hex color strings
41
+ */
42
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
43
+ /**
44
+ * Map form data to core config (T027)
45
+ * Converts hex colors to preset names if they match, otherwise keeps hex
46
+ *
47
+ * @param formData - Form data with hex color strings
48
+ * @returns Core config with hex or preset name strings
49
+ */
50
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
51
+ /**
52
+ * Update visual from configuration (T022)
53
+ * Updates LED color and geometry based on config
54
+ */
55
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
56
+ /**
57
+ * Update LED animation based on simulation state.
58
+ *
59
+ * - null state / no context: restore private material, cleanup mixer
60
+ * - paused/initial: snap to target state
61
+ * - playing + transitional (goingOn/goingOff): smooth material animation
62
+ * - playing + stable (on/off): snap to final state
63
+ */
64
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
65
+ /**
66
+ * Clone the PRIVATE material for independent per-instance animation.
67
+ * Stashes the original PRIVATE material in mesh.userData.privateMat.
68
+ * No-op if already cloned.
69
+ */
70
+ private _ensureClonedMaterial;
71
+ /**
72
+ * Dispose the animation clone and restore the stashed PRIVATE material.
73
+ * No-op if not cloned.
74
+ */
75
+ private _restorePrivateMaterial;
76
+ private _snapToState;
77
+ /**
78
+ * Create a smooth material animation for goingOn / goingOff transitions.
79
+ */
80
+ private _animateLed;
81
+ /**
82
+ * Stop all animations, clean up mixer.
83
+ */
84
+ private _cleanupMixer;
85
+ private findLedMesh;
86
+ }
@@ -0,0 +1,92 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for Relay components.
7
+ *
8
+ * Animation (3 independent clip groups on a single AnimationMixer):
9
+ *
10
+ * 1. **Mechanical clip** — contactor rotation + coil bar position + bar emissive glow
11
+ * Triggered on state transition (closing/opening). Duration = transitionSpan.
12
+ *
13
+ * 2. **Coil color clip** — all coil rings share one cloned material, single color track
14
+ * Triggered on cmd param change. Deduped by target color hex.
15
+ *
16
+ * 3. **Power color clip** — contactor + powerInBar share one cloned material, single color track
17
+ * Triggered on power param change. Deduped by target color hex.
18
+ */
19
+ export declare class RelayVisualFactory extends ComponentVisualFactoryBase {
20
+ private readonly COIL_GEOM;
21
+ private readonly COIL_BAR_GEOM;
22
+ private readonly PWIN_BAR_GEOM;
23
+ private readonly CONTACTOR_GEOM;
24
+ private readonly NEGATIVE_CONTACTOR_GEOM;
25
+ private readonly COIL_BAR_Z_IDLE;
26
+ private readonly COIL_BAR_Z_ACTIVE;
27
+ private readonly IDLE_ROTATION;
28
+ private readonly ACTIVE_ROTATION;
29
+ /** Coil ring colors (from cmd.voltage / cmd.current) */
30
+ private readonly COIL_COLOR_BOTH;
31
+ private readonly COIL_COLOR_VOLTAGE;
32
+ private readonly COIL_COLOR_CURRENT;
33
+ private readonly COIL_COLOR_NONE;
34
+ /** Magnetic bar glow */
35
+ private readonly BAR_GLOW_COLOR;
36
+ private readonly BAR_GLOW_INTENSITY;
37
+ /** Power element colors (from power_in / power_out) */
38
+ private readonly POWER_COLOR_BOTH;
39
+ private readonly POWER_COLOR_VOLTAGE;
40
+ private readonly POWER_COLOR_CURRENT;
41
+ private readonly POWER_COLOR_NONE;
42
+ constructor();
43
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
44
+ private _createPinsVisual;
45
+ private _createCoilGroup;
46
+ private _createContactorGroup;
47
+ private _disposeContactorGroup;
48
+ getConfigFormDefinition(): ConfigFormDefinition | null;
49
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
50
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
51
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
52
+ /**
53
+ * Update relay animation based on simulation state.
54
+ *
55
+ * - null / no context → cleanup, restore materials, reset to idle
56
+ * - paused → snap all parts to current state values
57
+ * - playing + transitional → animate mechanical + bar effect; update color clips
58
+ * - playing + stable → snap mechanical + bar; update color clips
59
+ */
60
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
61
+ /** Is the coil magnetically active in the given state? */
62
+ private _isCmdActive;
63
+ /** Is the transition moving TOWARD the active position? */
64
+ private _isGoingActive;
65
+ private _computeCoilColor;
66
+ private _computePowerColor;
67
+ private _getColorAnimDurationSecs;
68
+ private _snapMechanical;
69
+ private _snapCoilColor;
70
+ private _snapBarEffect;
71
+ private _snapPowerColor;
72
+ /** Clone WHITE once and assign the same clone to all 7 coil rings. */
73
+ private _ensureCoilClonedMaterial;
74
+ /** Clone SHINY_SILVER for the coil bar (emissive animation). */
75
+ private _ensureBarClonedMaterial;
76
+ /** Clone WHITE once and assign to both contactor and powerInBar. */
77
+ private _ensurePowerClonedMaterial;
78
+ /** Restore all animated materials to their SHARED originals. */
79
+ private _restoreAllMaterials;
80
+ private _animateMechanical;
81
+ private _updateCoilColorAnim;
82
+ private _updatePowerColorAnim;
83
+ /** Stop only the mechanical clip (rotation + bar position + bar glow). */
84
+ private _cleanupMechanicalClip;
85
+ /** Stop all animations, dispose mixer, clear all animation userData. */
86
+ private _cleanupMixer;
87
+ /** Reset positions/rotations to idle (no coil energized). */
88
+ private _resetToDefault;
89
+ /** Find all animated sub-objects in a single traverse. */
90
+ private _findParts;
91
+ private _findContactorGroup;
92
+ }
@@ -0,0 +1,86 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for SmallLED components
7
+ *
8
+ * Creates:
9
+ * - LED cylinder mesh
10
+ * - Input pin group
11
+ * - Output pin group
12
+ * - Component hitbox for raycasting
13
+ *
14
+ * Animation:
15
+ * - Smooth emissive glow transition when LED lights up or turns off
16
+ * - Uses AnimationMixer with material property tracks (emissive, emissiveIntensity)
17
+ * - Clones PRIVATE material per-instance during simulation for independent animation
18
+ */
19
+ export declare class SmallLEDVisualFactory extends ComponentVisualFactoryBase {
20
+ /** LED lit color (yellow glow) */
21
+ private readonly LED_LIT_COLOR;
22
+ /** LED lit emissive intensity */
23
+ private readonly LED_LIT_INTENSITY;
24
+ /** Black in normalized RGB for ColorKeyframeTrack */
25
+ private readonly UNLIT_RGB;
26
+ constructor();
27
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
28
+ private createPinsVisual;
29
+ /**
30
+ * Get config form definition for SmallLED (T027)
31
+ *
32
+ * @returns Form definition with activeColor and idleColor color fields
33
+ */
34
+ getConfigFormDefinition(): ConfigFormDefinition | null;
35
+ /**
36
+ * Map core config to form data (T027)
37
+ * Converts hex/preset strings to hex values for color picker
38
+ *
39
+ * @param config - Core component config
40
+ * @returns Form data with hex color strings
41
+ */
42
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
43
+ /**
44
+ * Map form data to core config (T027)
45
+ * Converts hex colors to preset names if they match, otherwise keeps hex
46
+ *
47
+ * @param formData - Form data with hex color strings
48
+ * @returns Core config with hex or preset name strings
49
+ */
50
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
51
+ /**
52
+ * Update visual from configuration (T022)
53
+ * Updates LED color based on activeColor config
54
+ */
55
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
56
+ /**
57
+ * Update LED animation based on simulation state.
58
+ *
59
+ * - null state / no context: restore private material, cleanup mixer
60
+ * - paused/initial: snap to target state
61
+ * - playing + transitional (goingOn/goingOff): smooth material animation
62
+ * - playing + stable (on/off): snap to final state
63
+ */
64
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
65
+ /**
66
+ * Clone the PRIVATE material for independent per-instance animation.
67
+ * Stashes the original PRIVATE material in mesh.userData.privateMat.
68
+ * No-op if already cloned.
69
+ */
70
+ private _ensureClonedMaterial;
71
+ /**
72
+ * Dispose the animation clone and restore the stashed PRIVATE material.
73
+ * No-op if not cloned.
74
+ */
75
+ private _restorePrivateMaterial;
76
+ private _snapToState;
77
+ /**
78
+ * Create a smooth material animation for goingOn / goingOff transitions.
79
+ */
80
+ private _animateLed;
81
+ /**
82
+ * Stop all animations, clean up mixer.
83
+ */
84
+ private _cleanupMixer;
85
+ private findLedMesh;
86
+ }
@@ -0,0 +1,85 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for Switch components
7
+ *
8
+ * Creates:
9
+ * - Contactor (box, rotatable for animation)
10
+ * - Input pin group
11
+ * - Output pin group
12
+ * - Component hitbox for raycasting
13
+ *
14
+ * Animation:
15
+ * - Smooth rotation of contactor between open/closed via AnimationMixer
16
+ * - Supports mid-transition interruption (re-toggle during closing/opening)
17
+ */
18
+ export declare class SwitchVisualFactory extends ComponentVisualFactoryBase {
19
+ /** Rotation for closed switch (contactor aligned) */
20
+ private readonly CLOSED_ROTATION;
21
+ /** Rotation for open switch (contactor misaligned) */
22
+ private readonly OPEN_ROTATION;
23
+ private readonly CONTACTOR_GEOMETRY;
24
+ /** Contactor color when output has both voltage and current */
25
+ private readonly COLOR_VOLTAGE_CURRENT;
26
+ /** Contactor color when output has current only */
27
+ private readonly COLOR_CURRENT;
28
+ /** Contactor color when output has voltage only */
29
+ private readonly COLOR_VOLTAGE;
30
+ /** Contactor color when output has neither */
31
+ private readonly COLOR_NONE;
32
+ constructor();
33
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
34
+ private createPinsVisual;
35
+ /**
36
+ * Get config form definition for Switch
37
+ *
38
+ * @returns Form definition with initialState, transitionSpan and size
39
+ */
40
+ getConfigFormDefinition(): ConfigFormDefinition | null;
41
+ /**
42
+ * Map core config to form data
43
+ * Converts "open"/"closed" strings to boolean
44
+ */
45
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
46
+ /**
47
+ * Map form data to core config
48
+ * Converts boolean to "open"/"closed" strings
49
+ */
50
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
51
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
52
+ /**
53
+ * Update switch animation based on simulation state.
54
+ *
55
+ * - null state / no context: cleanup mixer, reset to config default
56
+ * - paused/initial + transitional: snap to start rotation
57
+ * - paused/initial + stable: snap to state rotation
58
+ * - playing + transitional: smooth rotation animation
59
+ * - playing + stable: snap to final rotation, cleanup mixer
60
+ */
61
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
62
+ /** Maps stable state → target rotation */
63
+ private _getStateRotation;
64
+ /** Maps transitional state → the rotation it came FROM */
65
+ private _getStartRotation;
66
+ /**
67
+ * Create smooth rotation + color animations for closing/opening transitions.
68
+ * Rotation clip: current → target state rotation (persists across updateAnimation calls)
69
+ * Color clip: current contactor color → white (stopped on next updateAnimation so pin state takes over)
70
+ */
71
+ private _animateContactor;
72
+ /**
73
+ * Stop the color fade animation so _updateContactorColor can set color from pin state.
74
+ */
75
+ private _stopColorAnimation;
76
+ /**
77
+ * Stop all animations, clean up mixer, reset to config default rotation.
78
+ */
79
+ private _cleanupMixer;
80
+ private _ensureClonedMaterial;
81
+ private _restoreSharedMaterial;
82
+ private _updateContactorColor;
83
+ private findContactorGroup;
84
+ private _findContactorMesh;
85
+ }
@@ -0,0 +1,104 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for Inverter/Buffer components
7
+ *
8
+ * Creates:
9
+ * - Inverter triangle or Buffer trapezoid extrude geom mesh
10
+ * - Vcc, input and output pin group
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when component is high (based on simulation state)
15
+ */
16
+ export declare class InverterVisualFactory extends ComponentVisualFactoryBase {
17
+ /** Shared Inverter envelope geometry */
18
+ private readonly INVERTER_GEOM;
19
+ /** Shared Inverter inner hole geometry */
20
+ private readonly INVERTER_HOLE_GEOM;
21
+ /** Shared Buffer envelope geometry */
22
+ private readonly BUFFER_GEOM;
23
+ /** Shared Buffer inner hole geometry */
24
+ private readonly BUFFER_HOLE_GEOM;
25
+ private readonly HOLE_COLOR_HIGH;
26
+ private readonly HOLE_COLOR_LOW;
27
+ private readonly HOLE_EMISSIVE_HIGH_INTENSITY;
28
+ private readonly HOLE_EMISSIVE_LOW_INTENSITY;
29
+ constructor();
30
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
31
+ private createPinsVisual;
32
+ private replaceEnvelope;
33
+ private replaceHole;
34
+ /**
35
+ * Get config form definition for Inverter
36
+ *
37
+ * @param config - Optional current config to determine disabled state of transitionSpan
38
+ * @returns Form definition with defaultLogicFamily dropdown, activationLogic boolean, and transitionSpan number
39
+ */
40
+ getConfigFormDefinition(config?: Map<string, string>): ConfigFormDefinition | null;
41
+ /**
42
+ * Map core config to form data
43
+ * Converts "positive"/"negative" strings to boolean
44
+ *
45
+ * @param config - Core component config
46
+ * @returns Form data with boolean activationLogic
47
+ */
48
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
49
+ /**
50
+ * Map form data to core config
51
+ * Converts boolean to "positive"/"negative" strings
52
+ *
53
+ * @param formData - Form data with boolean activationLogic
54
+ * @returns Core config with string activationLogic
55
+ */
56
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
57
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
58
+ /**
59
+ * Update Inverter animation based on simulation state
60
+ *
61
+ * @param object3D - The Object3D created by createVisual()
62
+ * @param state - The Inverter's current simulation state
63
+ */
64
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
65
+ private _setHoleColor;
66
+ private _ensureClonedHoleMaterial;
67
+ private _restoreSharedHoleMaterial;
68
+ private _cleanupMixer;
69
+ /**
70
+ * Animate the hole color between LOW and HIGH over the transition span.
71
+ * Reads current color for mid-transition support.
72
+ */
73
+ private _animateHoleColor;
74
+ /**
75
+ * Find the envelope mesh within the component group
76
+ *
77
+ * @param object3D - The Object3D group created by createVisual()
78
+ * @returns The envelope mesh if found, null otherwise
79
+ *
80
+ * @remarks
81
+ * Searches for a mesh with userData.part === 'envelope'
82
+ */
83
+ private findEnvelopeMesh;
84
+ /**
85
+ * Find the hole mesh within the component group
86
+ *
87
+ * @param object3D - The Object3D group created by createVisual()
88
+ * @returns The hole mesh if found, null otherwise
89
+ *
90
+ * @remarks
91
+ * Searches for a mesh with userData.part === 'hole'
92
+ */
93
+ private findHoleMesh;
94
+ /**
95
+ * Find the negative marker mesh within the component group
96
+ *
97
+ * @param object3D - The Object3D group created by createVisual()
98
+ * @returns The negative marker mesh if found, null otherwise
99
+ *
100
+ * @remarks
101
+ * Searches for a mesh with userData.part === 'negativeMarker'
102
+ */
103
+ protected findNegativeMarkerMesh(object3D: THREE.Object3D): THREE.Mesh | null;
104
+ }
@@ -0,0 +1,27 @@
1
+ import { Component } from '../../../../core/index.ts';
2
+ import { NandGateVisualFactory } from './NandGateVisualFactory';
3
+ import { VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for NAND gates components
7
+ *
8
+ * Creates:
9
+ * - Gate mesh
10
+ * - vcc, gnd, inputs and output pin groups
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when Gate is high (based on simulation state)
15
+ */
16
+ export declare class Nand4GateVisualFactory extends NandGateVisualFactory {
17
+ /** Shared open envelope geometry */
18
+ protected readonly ENVELOPE_GEOM: THREE.ExtrudeGeometry;
19
+ /** Shared inner hole geometry */
20
+ protected readonly HOLE_GEOM: THREE.ExtrudeGeometry;
21
+ /** Shared geometry for negative marker **/
22
+ protected readonly NEG_MARKER_GEOM: THREE.CylinderGeometry;
23
+ constructor();
24
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
25
+ protected createPinsVisual(component: Component, context: VisualContext, group: THREE.Group): void;
26
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
27
+ }
@@ -0,0 +1,27 @@
1
+ import { Component } from '../../../../core/index.ts';
2
+ import { NandGateVisualFactory } from './NandGateVisualFactory';
3
+ import { VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for NAND gates components
7
+ *
8
+ * Creates:
9
+ * - Gate mesh
10
+ * - vcc, gnd, inputs and output pin groups
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when Gate is high (based on simulation state)
15
+ */
16
+ export declare class Nand8GateVisualFactory extends NandGateVisualFactory {
17
+ /** Shared open envelope geometry */
18
+ protected readonly ENVELOPE_GEOM: THREE.ExtrudeGeometry;
19
+ /** Shared inner hole geometry */
20
+ protected readonly HOLE_GEOM: THREE.ExtrudeGeometry;
21
+ /** Shared geometry for negative marker **/
22
+ protected readonly NEG_MARKER_GEOM: THREE.CylinderGeometry;
23
+ constructor();
24
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
25
+ protected createPinsVisual(component: Component, context: VisualContext, group: THREE.Group): void;
26
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
27
+ }
@@ -0,0 +1,101 @@
1
+ import { ComponentVisualFactoryBase } from '../ComponentVisualFactory';
2
+ import { Component, ComponentState } from '../../../../core/index.ts';
3
+ import { ConfigFormDefinition, VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for NAND gates components
7
+ *
8
+ * Creates:
9
+ * - Gate mesh
10
+ * - vcc, gnd, inputs and output pin groups
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when Gate is high (based on simulation state)
15
+ */
16
+ export declare class NandGateVisualFactory extends ComponentVisualFactoryBase {
17
+ /** Shared envelope geometry */
18
+ protected readonly ENVELOPE_GEOM: THREE.ExtrudeGeometry;
19
+ /** Shared inner hole geometry */
20
+ protected readonly HOLE_GEOM: THREE.ExtrudeGeometry;
21
+ /** Shared geometry for negative marker **/
22
+ protected readonly NEG_MARKER_GEOM: THREE.CylinderGeometry;
23
+ protected readonly HOLE_COLOR_HIGH: THREE.Color;
24
+ protected readonly HOLE_COLOR_LOW: THREE.Color;
25
+ protected readonly HOLE_EMISSIVE_HIGH_INTENSITY = 0.5;
26
+ protected readonly HOLE_EMISSIVE_LOW_INTENSITY = 0.2;
27
+ constructor();
28
+ defaultRotation(): number;
29
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
30
+ protected createPinsVisual(component: Component, context: VisualContext, group: THREE.Group): void;
31
+ /**
32
+ * Get config form definition
33
+ *
34
+ * @param config - Optional current config to determine disabled state of transitionSpan
35
+ * @returns Form definition with defaultLogicFamily dropdown, activationLogic boolean, and transitionSpan number
36
+ */
37
+ getConfigFormDefinition(config?: Map<string, string>): ConfigFormDefinition | null;
38
+ /**
39
+ * Map core config to form data
40
+ * Converts "positive"/"negative" strings to boolean
41
+ *
42
+ * @param config - Core component config
43
+ * @returns Form data with boolean activationLogic
44
+ */
45
+ mapCoreConfigToForm(config: Map<string, string>): Map<string, any>;
46
+ /**
47
+ * Map form data to core config
48
+ * Converts boolean to "positive"/"negative" strings
49
+ *
50
+ * @param formData - Form data with boolean activationLogic
51
+ * @returns Core config with string activationLogic
52
+ */
53
+ mapFormToCoreConfig(formData: Map<string, any>): Map<string, string>;
54
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
55
+ /**
56
+ * Update animation based on simulation state
57
+ *
58
+ * @param object3D - The Object3D created by createVisual()
59
+ * @param state - The component current simulation state
60
+ */
61
+ updateAnimation(object3D: THREE.Object3D, state: ComponentState | null): void;
62
+ private _setHoleColor;
63
+ private _ensureClonedHoleMaterial;
64
+ private _restoreSharedHoleMaterial;
65
+ private _cleanupMixer;
66
+ /**
67
+ * Animate the hole color between LOW and HIGH over the transition span.
68
+ * Reads current color for mid-transition support.
69
+ */
70
+ private _animateHoleColor;
71
+ /**
72
+ * Find the envelope mesh within the component group
73
+ *
74
+ * @param object3D - The Object3D group created by createVisual()
75
+ * @returns The envelope mesh if found, null otherwise
76
+ *
77
+ * @remarks
78
+ * Searches for a mesh with userData.part === 'envelope'
79
+ */
80
+ protected findEnvelopeMesh(object3D: THREE.Object3D): THREE.Mesh | null;
81
+ /**
82
+ * Find the hole mesh within the component group
83
+ *
84
+ * @param object3D - The Object3D group created by createVisual()
85
+ * @returns The hole mesh if found, null otherwise
86
+ *
87
+ * @remarks
88
+ * Searches for a mesh with userData.part === 'hole'
89
+ */
90
+ protected findHoleMesh(object3D: THREE.Object3D): THREE.Mesh | null;
91
+ /**
92
+ * Find the negative marker mesh within the component group
93
+ *
94
+ * @param object3D - The Object3D group created by createVisual()
95
+ * @returns The negative marker mesh if found, null otherwise
96
+ *
97
+ * @remarks
98
+ * Searches for a mesh with userData.part === 'negativeMarker'
99
+ */
100
+ protected findNegativeMarkerMesh(object3D: THREE.Object3D): THREE.Mesh | null;
101
+ }
@@ -0,0 +1,27 @@
1
+ import { Component } from '../../../../core/index.ts';
2
+ import { NorGateVisualFactory } from './NorGateVisualFactory';
3
+ import { VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for NOR gates components
7
+ *
8
+ * Creates:
9
+ * - Gate mesh
10
+ * - vcc, gnd, inputs and output pin groups
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when Gate is high (based on simulation state)
15
+ */
16
+ export declare class Nor4GateVisualFactory extends NorGateVisualFactory {
17
+ /** Shared open envelope geometry */
18
+ protected readonly ENVELOPE_GEOM: THREE.ExtrudeGeometry;
19
+ /** Shared inner hole geometry */
20
+ protected readonly HOLE_GEOM: THREE.ExtrudeGeometry;
21
+ /** Shared geometry for negative marker **/
22
+ protected readonly NEG_MARKER_GEOM: THREE.CylinderGeometry;
23
+ constructor();
24
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
25
+ protected createPinsVisual(component: Component, context: VisualContext, group: THREE.Group): void;
26
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
27
+ }
@@ -0,0 +1,27 @@
1
+ import { Component } from '../../../../core/index.ts';
2
+ import { NorGateVisualFactory } from './NorGateVisualFactory';
3
+ import { VisualContext } from '../../types';
4
+ import * as THREE from 'three';
5
+ /**
6
+ * Visual factory for NOR gates components
7
+ *
8
+ * Creates:
9
+ * - Gate mesh
10
+ * - vcc, gnd, inputs and output pin groups
11
+ * - Component hitbox for raycasting
12
+ *
13
+ * Animation:
14
+ * - Emissive glow when Gate is high (based on simulation state)
15
+ */
16
+ export declare class Nor8GateVisualFactory extends NorGateVisualFactory {
17
+ /** Shared open envelope geometry */
18
+ protected readonly ENVELOPE_GEOM: THREE.ExtrudeGeometry;
19
+ /** Shared inner hole geometry */
20
+ protected readonly HOLE_GEOM: THREE.ExtrudeGeometry;
21
+ /** Shared geometry for negative marker **/
22
+ protected readonly NEG_MARKER_GEOM: THREE.CylinderGeometry;
23
+ constructor();
24
+ createVisual(component: Component, context: VisualContext): THREE.Object3D;
25
+ protected createPinsVisual(component: Component, context: VisualContext, group: THREE.Group): void;
26
+ updateFromConfiguration(object3D: THREE.Object3D, config: Map<string, string>): void;
27
+ }