simple-circuit-engine 0.0.11 → 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 +10 -7
  2. package/CLAUDE.md +4 -6
  3. package/README.md +5 -2
  4. package/dist/core/index.d.ts +0 -1
  5. package/dist/core/index.js +74 -2114
  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 -6306
  79. package/dist/index.js +117 -110
  80. package/dist/scene/CircuitEngine.d.ts +270 -0
  81. package/dist/scene/index.d.ts +0 -1
  82. package/dist/scene/index.js +43 -39
  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-BQQlhwjD.js +0 -1981
  136. package/dist/CircuitRunner-BQQlhwjD.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-CIq_kgaw.js +0 -10230
  141. package/dist/setup-CIq_kgaw.js.map +0 -1
@@ -0,0 +1,476 @@
1
+ import { MapControls } from 'three/addons/controls/MapControls.js';
2
+ import { Line2 } from 'three/examples/jsm/lines/Line2.js';
3
+ import { LineGeometry } from 'three/examples/jsm/lines/LineGeometry.js';
4
+ import { LineMaterial } from 'three/examples/jsm/lines/LineMaterial.js';
5
+ import { IUserCommand, IRunnerOptions, UUID, ComponentType, ENode } from '../../core/index.ts';
6
+ import { IFactoryRegistry } from './components/ComponentVisualFactory';
7
+ import { BranchingPointVisualFactory } from './BranchingPointVisualFactory';
8
+ import { WireVisualManager } from './WireVisualManager';
9
+ import { HoverManager } from './HoverManager';
10
+ /**
11
+ * Shared types for 3D Circuit Renderers
12
+ * @module scene/shared/types
13
+ */
14
+ import type * as THREE from 'three';
15
+ export type { Line2, LineGeometry, LineMaterial };
16
+ /**
17
+ * Simulation status for animation-aware factories
18
+ */
19
+ export type SimulationStatus = 'initial' | 'playing' | 'paused';
20
+ /**
21
+ * Shared mutable context injected into visual factories during simulation.
22
+ * Controller mutates the same object reference; all factories see changes immediately.
23
+ * null represents "not in simulation".
24
+ */
25
+ export interface AnimationContext {
26
+ ticksPerSecond: number;
27
+ simulationStatus: SimulationStatus;
28
+ }
29
+ /**
30
+ * Lightweight context passed to visual factories so they can access
31
+ * ENode data (subtype, source, wires…) when creating pin visuals.
32
+ *
33
+ * Circuit satisfies this interface structurally — controllers can pass
34
+ * `this._circuit` directly without a wrapper.
35
+ */
36
+ export interface VisualContext {
37
+ getENode(id: UUID): ENode | undefined;
38
+ }
39
+ /**
40
+ * Object types that can be interacted within the scene controllerType to render
41
+ */
42
+ export type CircuitSceneObjectType = 'componentGroup' | 'component' | 'componentHitbox' | 'enodeGroup' | 'enode' | 'enodeHitbox' | 'wire';
43
+ /**
44
+ * Types of circuit elements that can be hovered / selected
45
+ */
46
+ export type HoverableType = 'component' | 'enode' | 'wire';
47
+ export type ModelEditAction = 'edit' | 'add' | 'delete';
48
+ /**
49
+ * Supported scene controllerType event types (includes tool system events)
50
+ */
51
+ export type ControllerEvent = 'ready' | 'error' | 'circuitLoaded' | 'circuitCleared' | 'gridPositionMove' | 'hover' | 'unhover' | 'select' | 'deselect' | 'toolActivated' | 'toolDeactivated' | 'toolOperationStarted' | 'toolOperationCompleted' | 'toolOperationCancelled' | 'toolValidationError' | 'cursorChangeRequested' | 'circuitElementAction' | 'circuitMetadataEdition' | 'selectionChange' | 'simulationPlayed' | 'simulationPaused' | 'simulationStepped' | 'simulationTick' | 'simulationUserCommand' | 'simulationStopped' | 'simulationSpeedChanged' | 'componentHelpRequested';
52
+ /**
53
+ * Event payload map for type-safe event emission
54
+ */
55
+ export interface ControllerEventMap {
56
+ ready: {
57
+ controllerType: 'static' | 'simulation' | 'engine';
58
+ };
59
+ error: {
60
+ message: string;
61
+ error?: Error;
62
+ };
63
+ circuitLoaded: {
64
+ name: string;
65
+ };
66
+ circuitCleared: {
67
+ name: string;
68
+ };
69
+ gridPositionMove: THREE.Vector3;
70
+ hover: {
71
+ objectId: UUID;
72
+ objectType: CircuitSceneObjectType;
73
+ userData?: HitboxUserData | undefined;
74
+ };
75
+ unhover: {
76
+ objectId: UUID;
77
+ objectType: CircuitSceneObjectType;
78
+ userData?: HitboxUserData | undefined;
79
+ };
80
+ select: SelectionData;
81
+ deselect: SelectionData;
82
+ selectionChange: {
83
+ newSelection: SelectionData | null;
84
+ previousSelection: SelectionData | null;
85
+ };
86
+ dragStart: {
87
+ selection: SelectionData;
88
+ startPosition: THREE.Vector3;
89
+ };
90
+ dragMove: {
91
+ selection: SelectionData;
92
+ currentPosition: THREE.Vector3;
93
+ delta: THREE.Vector3;
94
+ };
95
+ dragEnd: {
96
+ selection: SelectionData;
97
+ finalPosition: THREE.Vector3;
98
+ };
99
+ dragCancel: {
100
+ selection: SelectionData;
101
+ };
102
+ toolActivated: {
103
+ toolType: ToolType;
104
+ };
105
+ toolDeactivated: {
106
+ toolType: ToolType;
107
+ };
108
+ toolOperationStarted: {
109
+ toolType: ToolType;
110
+ mode: unknown;
111
+ operationData: unknown;
112
+ };
113
+ toolOperationCompleted: {
114
+ toolType: ToolType;
115
+ mode: unknown;
116
+ operationData: unknown;
117
+ changedData: unknown;
118
+ };
119
+ toolOperationCancelled: {
120
+ toolType: ToolType;
121
+ mode: unknown;
122
+ };
123
+ toolValidationError: {
124
+ toolType: ToolType;
125
+ mode: unknown;
126
+ errorMessage: string;
127
+ };
128
+ cursorChangeRequested: {
129
+ cursorType: CursorType;
130
+ };
131
+ circuitElementAction: {
132
+ type: HoverableType;
133
+ action: ModelEditAction;
134
+ id?: UUID | undefined;
135
+ error?: Error | null;
136
+ data?: object | null;
137
+ };
138
+ circuitMetadataEdition: {
139
+ circuitName: string;
140
+ data?: object | null;
141
+ };
142
+ simulationPlayed: {
143
+ tick: number;
144
+ };
145
+ simulationPaused: {
146
+ tick: number;
147
+ };
148
+ simulationStepped: {
149
+ tick: number;
150
+ result: unknown;
151
+ };
152
+ simulationTick: {
153
+ tick: number;
154
+ dirty: unknown;
155
+ };
156
+ simulationUserCommand: IUserCommand;
157
+ simulationStopped: {
158
+ tick: number;
159
+ };
160
+ simulationSpeedChanged: {
161
+ previousSpeed: number;
162
+ newSpeed: number;
163
+ };
164
+ /** Emitted when user clicks a pin tooltip to request component help */
165
+ componentHelpRequested: {
166
+ componentType: ComponentType;
167
+ };
168
+ }
169
+ /**
170
+ * Callback function type for scene controllerType events
171
+ */
172
+ export type ControllerCallback<T = any> = (payload: T) => void;
173
+ /**
174
+ * Represents the currently hovered circuit element
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const hovered = hoverManager.getHoveredElement();
179
+ * if (hovered?.type === 'component') {
180
+ * highlightComponent(hovered.id);
181
+ * }
182
+ * ```
183
+ */
184
+ export interface HoveredElement {
185
+ /** Discriminated type for priority and handling */
186
+ type: HoverableType;
187
+ /** UUID of the hovered circuit element */
188
+ id: UUID;
189
+ /** Three.js object type (matches existing CircuitSceneObjectType) */
190
+ objectType: CircuitSceneObjectType;
191
+ /** Reference to the Three.js hitbox mesh */
192
+ object3D: THREE.Object3D;
193
+ }
194
+ /**
195
+ * UserData structure for enode hitbox meshes
196
+ */
197
+ export interface EnodeHitboxUserData {
198
+ type: 'enodeHitbox';
199
+ enodeId: string;
200
+ componentId: string | null;
201
+ label: string | null;
202
+ componentType: ComponentType | null;
203
+ }
204
+ /**
205
+ * UserData structure for component hitbox meshes
206
+ */
207
+ export interface ComponentHitboxUserData {
208
+ type: 'componentHitbox';
209
+ componentId: string;
210
+ componentType: ComponentType;
211
+ }
212
+ /**
213
+ * UserData structure for wire hitbox meshes
214
+ */
215
+ export interface WireHitboxUserData {
216
+ type: 'wire';
217
+ wireId: string;
218
+ }
219
+ /**
220
+ * Union of all hitbox userData types
221
+ */
222
+ export type HitboxUserData = EnodeHitboxUserData | ComponentHitboxUserData | WireHitboxUserData;
223
+ /**
224
+ * Supported wires material states for visual feedback
225
+ */
226
+ export type WireMaterialState = 'idle' | 'hovered' | 'selected' | 'voltage' | 'current' | 'vc';
227
+ /** Represents the Selection of one Hoverable Element of the scene **/
228
+ export interface MonoSelectionData {
229
+ kind: 'mono';
230
+ type: HoverableType;
231
+ id: UUID;
232
+ data?: string | null;
233
+ }
234
+ /** Represents the Selection of multiple Hoverable Elements of the scene **/
235
+ export interface MultiSelectionData {
236
+ kind: 'multi';
237
+ components?: Map<UUID, string | null>;
238
+ enodes?: Map<UUID, string | null>;
239
+ wires?: Map<UUID, string | null>;
240
+ }
241
+ export type SelectionData = MonoSelectionData | MultiSelectionData;
242
+ /**
243
+ * Tool System Types
244
+ */
245
+ /**
246
+ * Available editing tool types
247
+ *
248
+ * Note: 'build' replaces the previous tools: 'position', 'wire', 'delete', 'branchingPoint'
249
+ */
250
+ export type ToolType = 'build' | 'multiSelect';
251
+ /**
252
+ * Cursor types for tool operations
253
+ */
254
+ export type CursorType = 'default' | 'pointer' | 'crosshair' | 'move' | 'not-allowed' | 'grab' | 'grabbing';
255
+ /**
256
+ * Interface defining contract for editing tool implementations
257
+ *
258
+ * All editing tools must implement this interface to integrate with
259
+ * CircuitController's tool system.
260
+ *
261
+ * @example
262
+ * ```typescript
263
+ * class PositionTool implements IEditingTool {
264
+ * readonly type = 'position';
265
+ *
266
+ * onActivate() {
267
+ * // Setup selection mode
268
+ * }
269
+ *
270
+ * onDeactivate() {
271
+ * // Cleanup selection state
272
+ * }
273
+ *
274
+ * getCursorType() {
275
+ * return this.isOverComponent ? 'pointer' : 'default';
276
+ * }
277
+ *
278
+ * getPreviewObjects() {
279
+ * return []; // Select tool doesn't have preview objects
280
+ * }
281
+ * }
282
+ * ```
283
+ */
284
+ export interface IEditingTool {
285
+ /**
286
+ * Unique identifier for this tool type
287
+ */
288
+ readonly type: ToolType;
289
+ /**
290
+ * Called when tool becomes active
291
+ * Use this to setup tool state and initialize preview objects
292
+ */
293
+ onActivate(): void;
294
+ /**
295
+ * Called when tool is deactivated
296
+ * Use this to cleanup tool state and dispose preview objects
297
+ */
298
+ onDeactivate(): void;
299
+ /**
300
+ * Get the current cursor type for this tool
301
+ * Can change dynamically based on tool state (e.g., hovering over valid target)
302
+ *
303
+ * @returns Current cursor style
304
+ */
305
+ getCursorType(): CursorType;
306
+ /**
307
+ * Get preview objects to render in the scene
308
+ * These objects are rendered semi-transparently to indicate in-progress operations
309
+ *
310
+ * @returns Array of Three.js objects to render as previews
311
+ */
312
+ getPreviewObjects(): THREE.Object3D[];
313
+ }
314
+ /**
315
+ * Operating mode of the CircuitEngine
316
+ * - 'edit': Static circuit editing mode (tools, selection, manipulation)
317
+ * - 'simulation': Live simulation mode (playback, animation, user commands)
318
+ */
319
+ export type EngineMode = 'edit' | 'simulation';
320
+ /**
321
+ * Resources shared between edit and simulation controllers.
322
+ * Created by CircuitEngine and injected into both controllers.
323
+ */
324
+ export interface SharedResources {
325
+ /** Three.js scene containing all circuit visuals */
326
+ scene: THREE.Scene;
327
+ /** Perspective camera for rendering */
328
+ camera: THREE.PerspectiveCamera;
329
+ /** MapControls for pan/zoom/rotate interaction */
330
+ mapControls: MapControls;
331
+ /** Grid helper */
332
+ grid: THREE.GridHelper;
333
+ /** Registry of component visual factories */
334
+ factoryRegistry: IFactoryRegistry;
335
+ /** Factory for branching point visuals */
336
+ branchingPointVisualFactory: BranchingPointVisualFactory;
337
+ /** Manager for wire Line2 visuals */
338
+ wireVisualManager: WireVisualManager;
339
+ /** Manager for hover detection */
340
+ hoverManager: HoverManager;
341
+ /** Map of component UUIDs to their Object3D groups */
342
+ componentObject3Ds: Map<UUID, THREE.Object3D>;
343
+ /** Map of enode UUIDs to their Object3D groups */
344
+ enodeObject3Ds: Map<UUID, THREE.Object3D>;
345
+ /** Map of wire UUIDs to their Line2 objects */
346
+ wireObject3Ds: Map<UUID, Line2>;
347
+ }
348
+ /**
349
+ * Event emitted when controller mode changes
350
+ */
351
+ export interface ModeChangedEvent {
352
+ /** New active mode */
353
+ mode: EngineMode;
354
+ /** Previous mode before transition */
355
+ previousMode?: EngineMode;
356
+ }
357
+ /**
358
+ * Combined event map for CircuitEngine.
359
+ * Includes all controller events plus controller-specific events.
360
+ */
361
+ export interface CircuitEngineEventMap extends ControllerEventMap {
362
+ /** Emitted after mode transition completes */
363
+ modeChanged: ModeChangedEvent;
364
+ }
365
+ /**
366
+ * Configuration options for Controllers and Engine
367
+ **/
368
+ /**
369
+ * Configuration options for MapControls integration
370
+ *
371
+ * All properties are optional with sensible defaults.
372
+ *
373
+ * @example
374
+ * ```typescript
375
+ * controllerType.initialize(container, {
376
+ * mapControls: {
377
+ * enableRotate: false, // Disable rotation for 2D-only view
378
+ * maxDistance: 50, // Limit zoom out
379
+ * }
380
+ * });
381
+ * ```
382
+ */
383
+ export interface MapControlsOptions {
384
+ /** Enable click-drag panning (default: true) */
385
+ enablePan?: boolean;
386
+ /** Use screen-space panning (default: true) */
387
+ screenSpacePanning?: boolean;
388
+ /** Enable scroll wheel zooming (default: true) */
389
+ enableZoom?: boolean;
390
+ /** Enable right-click rotation (default: true) */
391
+ enableRotate?: boolean;
392
+ /** Enable smooth deceleration when releasing controls (default: true) */
393
+ enableDamping?: boolean;
394
+ /** Damping strength (0 = instant stop, 1 = very slow stop) (default: 0.05) */
395
+ dampingFactor?: number;
396
+ /** Minimum zoom distance from target (default: 1) */
397
+ minDistance?: number;
398
+ /** Maximum zoom distance from target (default: 100) */
399
+ maxDistance?: number;
400
+ /** Pan speed multiplier (default: 1.0) */
401
+ panSpeed?: number;
402
+ /** Zoom speed multiplier (default: 1.0) */
403
+ zoomSpeed?: number;
404
+ /** Rotation speed multiplier (default: 1.0) */
405
+ rotateSpeed?: number;
406
+ }
407
+ /**
408
+ * Optional configuration for scene controllerType initialization
409
+ */
410
+ export interface ControllerOptions {
411
+ /** Background color for the scene */
412
+ backgroundColor?: number;
413
+ /** Grid center line color */
414
+ colorCenterLine?: number;
415
+ /** Grid color */
416
+ colorGrid?: number;
417
+ /** tool activated by default on initialization */
418
+ defaultTool?: ToolType | null;
419
+ /** MapControls configuration options */
420
+ mapControls?: MapControlsOptions;
421
+ /** Startup CircuitRunnerController simulation speed */
422
+ simulationSpeed?: number;
423
+ /** If CircuitRunnerController plays automatically at activation */
424
+ simulationAutoPlay?: boolean;
425
+ }
426
+ /**
427
+ * Configuration options for CircuitEngine initialization
428
+ */
429
+ export interface EngineOptions {
430
+ /**
431
+ * Initial operating mode
432
+ * @default 'edit'
433
+ */
434
+ initialMode?: EngineMode;
435
+ /**
436
+ * Controller options
437
+ */
438
+ controllerOptions?: ControllerOptions;
439
+ /**
440
+ * Options passed to CircuitRunner when created
441
+ * @default { enableHistory: false }
442
+ */
443
+ runnerOptions?: IRunnerOptions;
444
+ }
445
+ /**
446
+ * Control type for config form fields
447
+ */
448
+ export type ConfigControlType = 'dropdown' | 'color' | 'number' | 'text' | 'boolean';
449
+ /**
450
+ * Definition of a single configurable field
451
+ */
452
+ export interface ConfigFieldDefinition {
453
+ /** Config map key (e.g., "activeColor", "initialState") */
454
+ key: string;
455
+ /** Human-readable label for the form field */
456
+ label: string;
457
+ /** Control type to render */
458
+ type: ConfigControlType;
459
+ /** Options for dropdown type (array or label-value object) */
460
+ options?: string[] | Record<string, string>;
461
+ /** Minimum value for number type */
462
+ min?: number;
463
+ /** Maximum value for number type */
464
+ max?: number;
465
+ /** Step increment for number type */
466
+ step?: number;
467
+ /** Whether this field is read-only in the form */
468
+ disabled?: boolean;
469
+ }
470
+ /**
471
+ * Complete form definition for a component type
472
+ */
473
+ export interface ConfigFormDefinition {
474
+ /** Array of field definitions, rendered in order */
475
+ fields: ConfigFieldDefinition[];
476
+ }
@@ -0,0 +1,23 @@
1
+ import { CameraOptions } from '../../../core/index.ts';
2
+ /**
3
+ * Camera Utilities
4
+ * @module scene/shared/utils/CameraUtils
5
+ *
6
+ * Helper functions for camera setup and management
7
+ */
8
+ import * as THREE from 'three';
9
+ /**
10
+ * Create a perspective camera with default or custom parameters
11
+ *
12
+ * @param options -
13
+ * @param aspect - Camera aspect ratio (width / height)
14
+ * @returns Configured PerspectiveCamera
15
+ */
16
+ export declare function createPerspectiveCamera(aspect?: number, options?: CameraOptions): THREE.PerspectiveCamera;
17
+ /**
18
+ * update camera position and target from options
19
+ *
20
+ * @param camera - Camera to configure
21
+ * @param options
22
+ */
23
+ export declare function updateCamera(camera: THREE.PerspectiveCamera, options: CameraOptions): void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Color utilities
3
+ * @module scene/shared/utils/ColorUtils
4
+ */
5
+ /**
6
+ * Standard color presets for hybrid color controls
7
+ */
8
+ export declare const COLOR_PRESETS: Readonly<Record<string, string>>;
9
+ /**
10
+ * Check if a color value is a hex string
11
+ * @param value - Color value to check
12
+ * @returns true if value matches #RRGGBB format
13
+ */
14
+ export declare function isHexColor(value: string): boolean;
15
+ /**
16
+ * Convert a hex color to preset name if it matches, otherwise return hex
17
+ * @param hex - Hex color string (e.g., "#ff0000")
18
+ * @returns Preset name if match found, otherwise the hex string
19
+ */
20
+ export declare function hexToPresetOrHex(hex: string): string;
21
+ /**
22
+ * Convert a preset name or hex to hex value
23
+ * @param value - Preset name (e.g., "red") or hex string (e.g., "#ff0000")
24
+ * @returns Hex color string
25
+ */
26
+ export declare function presetOrHexToHex(value: string): string;
@@ -0,0 +1,8 @@
1
+ import { MapControls } from 'three/addons/controls/MapControls.js';
2
+ import { MapControlsOptions } from '../types';
3
+ /**
4
+ * Controls utilities
5
+ * @module scene/shared/utils/ControlsUtils
6
+ */
7
+ import * as THREE from 'three';
8
+ export declare function createMapControls(camera: THREE.PerspectiveCamera, container: HTMLElement, options: MapControlsOptions): MapControls;