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.
- package/AGENTS.md +10 -7
- package/CLAUDE.md +4 -6
- package/README.md +5 -2
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +74 -2114
- package/dist/core/setup.d.ts +17 -0
- package/dist/core/simulation/CircuitRunner.d.ts +176 -0
- package/dist/core/simulation/DirtyTracker.d.ts +87 -0
- package/dist/core/simulation/EventQueue.d.ts +68 -0
- package/dist/core/simulation/StateManager.d.ts +100 -0
- package/dist/core/simulation/behaviors/BehaviorRegistry.d.ts +70 -0
- package/dist/core/simulation/behaviors/ComponentBehavior.d.ts +53 -0
- package/dist/core/simulation/behaviors/basic/BatteryBehavior.d.ts +14 -0
- package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
- package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
- package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
- package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
- package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
- package/dist/core/simulation/behaviors/index.d.ts +24 -0
- package/dist/core/simulation/behaviors/types.d.ts +101 -0
- package/dist/core/simulation/index.d.ts +18 -0
- package/dist/core/simulation/states/ComponentState.d.ts +57 -0
- package/dist/core/simulation/states/SimulationState.d.ts +46 -0
- package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
- package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
- package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
- package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
- package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
- package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
- package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
- package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
- package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
- package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
- package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/index.d.ts +25 -0
- package/dist/core/simulation/states/index.d.ts +26 -0
- package/dist/core/simulation/states/types.d.ts +32 -0
- package/dist/core/simulation/types.d.ts +155 -0
- package/dist/core/topology/Circuit.d.ts +420 -0
- package/dist/core/topology/CircuitMetadata.d.ts +24 -0
- package/dist/core/topology/CircuitOptions.d.ts +14 -0
- package/dist/core/topology/Component.d.ts +152 -0
- package/dist/core/topology/ENode.d.ts +200 -0
- package/dist/core/topology/Wire.d.ts +130 -0
- package/dist/core/topology/delays.d.ts +52 -0
- package/dist/core/topology/index.d.ts +14 -0
- package/dist/core/topology/types.d.ts +175 -0
- package/dist/core/utils/CameraOptions.d.ts +83 -0
- package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
- package/dist/core/utils/Position.d.ts +166 -0
- package/dist/core/utils/Position3D.d.ts +77 -0
- package/dist/core/utils/Rotation.d.ts +82 -0
- package/dist/core/utils/index.d.ts +24 -0
- package/dist/core/utils/types.d.ts +35 -0
- package/dist/core-Bjta9Y7_.js +2707 -0
- package/dist/core-Bjta9Y7_.js.map +1 -0
- package/dist/index.d.ts +13 -6306
- package/dist/index.js +117 -110
- package/dist/scene/CircuitEngine.d.ts +270 -0
- package/dist/scene/index.d.ts +0 -1
- package/dist/scene/index.js +43 -39
- package/dist/scene/setup.d.ts +18 -0
- package/dist/scene/shared/AbstractCircuitController.d.ts +211 -0
- package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
- package/dist/scene/shared/EventEmitter.d.ts +92 -0
- package/dist/scene/shared/HoverManager.d.ts +151 -0
- package/dist/scene/shared/SelectionManager.d.ts +159 -0
- package/dist/scene/shared/WireVisualManager.d.ts +242 -0
- package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
- package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
- package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
- package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
- package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
- package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
- package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
- package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
- package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
- package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
- package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
- package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
- package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
- package/dist/scene/shared/components/index.d.ts +29 -0
- package/dist/scene/shared/components/types.d.ts +43 -0
- package/dist/scene/shared/types.d.ts +476 -0
- package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
- package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
- package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
- package/dist/scene/shared/utils/GeometryUtils.d.ts +261 -0
- package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
- package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
- package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
- package/dist/scene/shared/utils/Options.d.ts +16 -0
- package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
- package/dist/scene/static/CircuitController.d.ts +227 -0
- package/dist/scene/static/CircuitWriter.d.ts +146 -0
- package/dist/scene/static/PinTooltipWidget.d.ts +26 -0
- package/dist/scene/static/tools/BuildTool.d.ts +286 -0
- package/dist/scene/static/tools/ComponentPickerWidget.d.ts +82 -0
- package/dist/scene/static/tools/ConfigPanelWidget.d.ts +93 -0
- package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
- package/dist/scene-CVsDdySt.js +7357 -0
- package/dist/scene-CVsDdySt.js.map +1 -0
- package/package.json +24 -25
- package/dist/CircuitRunner-BQQlhwjD.js +0 -1981
- package/dist/CircuitRunner-BQQlhwjD.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scene/index.js.map +0 -1
- package/dist/setup-CIq_kgaw.js +0 -10230
- package/dist/setup-CIq_kgaw.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,115 +1,122 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { d as va, i as ga, f as Ea, B as ma, a as La, C as Ta, b as Ia, e as Va, c as da, D as Da, n as Ra, F as Ma, G as ba, g as Oa, H as Aa, I as _a, L as Pa, j as wa, M as Xa, o as fa, p as xa, N as Ua, s as Wa, t as ka, q as Ha, R as ja, k as za, S as Ya, l as qa, m as Qa, W as Ja, u as Ka, v as Za, X as $a, x as at, y as tt, w as et, r as ot, h as rt } from "./setup-CIq_kgaw.js";
|
|
1
|
+
import { $ as t, A as s, B as e, C as o, D as r, E as i, F as n, G as l, H as c, I as u, J as S, K as y, L as h, M as C, N as G, O as p, P as N, Q as B, R as F, S as m, T as v, U as g, V as E, W as T, X as V, Y as L, Z as I, _ as d, _t as D, a as M, at as R, b as _, bt as A, c as O, ct as b, d as P, dt as w, et as X, f, ft as U, g as k, gt as x, h as W, ht as H, i as z, it as Y, j, k as Q, l as q, lt as J, m as K, mt as Z, n as $, nt as aa, o as ta, ot as sa, p as ea, pt as oa, q as ra, r as ia, rt as na, s as la, st as ca, t as ua, tt as Sa, u as ya, ut as ha, v as Ca, vt as Ga, w as pa, x as Na, y as Ba, yt as Fa, z as ma } from "./core-Bjta9Y7_.js";
|
|
2
|
+
import { A as ga, B as Ea, C as Ta, D as Va, E as La, F as Ia, H as da, I as Da, L as Ma, M as Ra, N as _a, O as Aa, P as Oa, R as ba, S as Pa, T as wa, U as Xa, V as fa, W as Ua, _ as ka, a as xa, b as Wa, c as Ha, d as za, f as Ya, g as ja, h as Qa, i as qa, j as Ja, k as Ka, l as Za, m as $a, n as at, o as tt, p as st, r as et, s as ot, t as rt, u as it, v as nt, w as lt, x as ct, y as ut, z as St } from "./scene-CVsDdySt.js";
|
|
4
3
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
D as
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
4
|
+
R as ALL_LOGIC_FAMILIES,
|
|
5
|
+
Xa as BRANCHING_POINT_SENTINEL,
|
|
6
|
+
pa as BatteryBehavior,
|
|
7
|
+
T as BatteryState,
|
|
8
|
+
ct as BatteryVisualFactory,
|
|
9
|
+
i as BehaviorRegistry,
|
|
10
|
+
Da as BranchingPointVisualFactory,
|
|
11
|
+
da as BuildTool,
|
|
12
|
+
sa as CIRCUIT_FILE_VERSION,
|
|
13
|
+
wa as CMP_MATERIALS,
|
|
14
|
+
ca as COMPONENT_TYPE_METADATA,
|
|
15
|
+
D as CameraOptions,
|
|
16
|
+
V as Circuit,
|
|
17
|
+
Ja as CircuitController,
|
|
18
|
+
Ka as CircuitEngine,
|
|
19
|
+
X as CircuitMetadata,
|
|
20
|
+
Sa as CircuitOptions,
|
|
21
|
+
ia as CircuitRunner,
|
|
22
|
+
ga as CircuitRunnerController,
|
|
23
|
+
St as CircuitWriter,
|
|
24
|
+
d as ClockBehavior,
|
|
25
|
+
h as ClockState,
|
|
26
|
+
st as ClockVisualFactory,
|
|
27
|
+
La as CmpMatCategory,
|
|
28
|
+
Va as CmpMatType,
|
|
29
|
+
Aa as CmpMatVariant,
|
|
30
|
+
aa as Component,
|
|
31
|
+
Ua as ComponentPickerWidget,
|
|
32
|
+
l as ComponentState,
|
|
33
|
+
b as ComponentType,
|
|
34
|
+
J as DEFAULT_LOGIC_FAMILY,
|
|
35
|
+
Ta as DefaultVisualFactory,
|
|
36
|
+
M as DirtyTracker,
|
|
37
|
+
Ca as DoubleThrowSwitchBehavior,
|
|
38
|
+
F as DoubleThrowSwitchState,
|
|
39
|
+
$a as DoubleThrowSwitchVisualFactory,
|
|
40
|
+
Y as ENode,
|
|
41
|
+
ha as ENodeSourceType,
|
|
42
|
+
w as ENodeType,
|
|
43
|
+
ta as EventQueue,
|
|
44
|
+
lt as FactoryRegistry,
|
|
45
|
+
Pa as GroupedFactoryRegistry,
|
|
46
|
+
ba as HitboxLayers,
|
|
47
|
+
Ma as HoverManager,
|
|
48
|
+
k as InverterBehavior,
|
|
49
|
+
u as InverterState,
|
|
50
|
+
Ya as InverterVisualFactory,
|
|
51
|
+
Wa as LabelVisualFactory,
|
|
52
|
+
o as LightbulbBehavior,
|
|
53
|
+
g as LightbulbState,
|
|
54
|
+
ut as LightbulbVisualFactory,
|
|
55
|
+
Fa as Memoize,
|
|
56
|
+
A as MemoizeExpiring,
|
|
57
|
+
fa as MultiSelectTool,
|
|
58
|
+
K as Nand4GateBehavior,
|
|
59
|
+
N as Nand4GateState,
|
|
60
|
+
it as Nand4GateVisualFactory,
|
|
61
|
+
ea as Nand8GateBehavior,
|
|
62
|
+
G as Nand8GateState,
|
|
63
|
+
Za as Nand8GateVisualFactory,
|
|
64
|
+
W as NandGateBehavior,
|
|
65
|
+
n as NandGateState,
|
|
66
|
+
za as NandGateVisualFactory,
|
|
67
|
+
P as Nor4GateBehavior,
|
|
68
|
+
j as Nor4GateState,
|
|
69
|
+
ot as Nor4GateVisualFactory,
|
|
70
|
+
ya as Nor8GateBehavior,
|
|
71
|
+
s as Nor8GateState,
|
|
72
|
+
tt as Nor8GateVisualFactory,
|
|
73
|
+
f as NorGateBehavior,
|
|
74
|
+
C as NorGateState,
|
|
69
75
|
Ha as NorGateVisualFactory,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
Z as Position,
|
|
77
|
+
Ga as Position3D,
|
|
78
|
+
m as RectangleLEDBehavior,
|
|
79
|
+
E as RectangleLEDState,
|
|
80
|
+
nt as RectangleLEDVisualFactory,
|
|
81
|
+
Na as RelayBehavior,
|
|
82
|
+
e as RelayState,
|
|
83
|
+
ka as RelayVisualFactory,
|
|
84
|
+
oa as Rotation,
|
|
85
|
+
S as SIMULATION_SPEED,
|
|
86
|
+
Ea as SelectionManager,
|
|
87
|
+
y as SimulationState,
|
|
88
|
+
_ as SmallLEDBehavior,
|
|
89
|
+
c as SmallLEDState,
|
|
90
|
+
ja as SmallLEDVisualFactory,
|
|
91
|
+
z as StateManager,
|
|
92
|
+
Ba as SwitchBehavior,
|
|
93
|
+
ma as SwitchState,
|
|
88
94
|
Qa as SwitchVisualFactory,
|
|
89
|
-
|
|
95
|
+
L as TRANSITION_DEFAULTS,
|
|
90
96
|
na as Wire,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
Ia as WireVisualManager,
|
|
98
|
+
O as Xor4GateBehavior,
|
|
99
|
+
p as Xor4GateState,
|
|
100
|
+
qa as Xor4GateVisualFactory,
|
|
101
|
+
la as Xor8GateBehavior,
|
|
102
|
+
r as Xor8GateState,
|
|
103
|
+
et as Xor8GateVisualFactory,
|
|
104
|
+
q as XorGateBehavior,
|
|
105
|
+
Q as XorGateState,
|
|
106
|
+
xa as XorGateVisualFactory,
|
|
107
|
+
I as classifyGate,
|
|
108
|
+
B as computeGateDelay,
|
|
109
|
+
t as computeTransitionSpan,
|
|
110
|
+
Ra as controllerOptions,
|
|
111
|
+
_a as engineOptions,
|
|
112
|
+
H as findPositionBestIndex,
|
|
113
|
+
U as generateUUID,
|
|
114
|
+
v as getTransitionSpan,
|
|
115
|
+
Oa as mapControlsOptions,
|
|
116
|
+
ua as registerBasicComponentsBehaviors,
|
|
117
|
+
rt as registerBasicComponentsFactories,
|
|
118
|
+
$ as registerGatesComponentsBehaviors,
|
|
119
|
+
at as registerGatesComponentsFactories,
|
|
120
|
+
x as simplifyPositions,
|
|
121
|
+
ra as unionElectricalStates
|
|
114
122
|
};
|
|
115
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { MapControls } from 'three/addons/controls/MapControls.js';
|
|
2
|
+
import { EventEmitter } from './shared/EventEmitter';
|
|
3
|
+
import { Circuit, BehaviorRegistry } from '../core/index.ts';
|
|
4
|
+
import { CircuitController } from './static/CircuitController';
|
|
5
|
+
import { CircuitRunnerController } from './simulation/CircuitRunnerController';
|
|
6
|
+
import { IFactoryRegistry } from './shared/components/ComponentVisualFactory';
|
|
7
|
+
import { EngineMode, CircuitEngineEventMap, EngineOptions, ToolType } from './shared/types';
|
|
8
|
+
/**
|
|
9
|
+
* CircuitEngine - Unified Facade for Circuit Editing and Simulation
|
|
10
|
+
* @module scene/CircuitEngine
|
|
11
|
+
*
|
|
12
|
+
* Provides a unified API for both static circuit editing and live simulation,
|
|
13
|
+
* managing mode transitions and resource sharing between controllers.
|
|
14
|
+
*/
|
|
15
|
+
import * as THREE from 'three';
|
|
16
|
+
/**
|
|
17
|
+
* CircuitEngine - Unified Facade for Circuit Editing and Simulation
|
|
18
|
+
*
|
|
19
|
+
* Manages two internal controllers:
|
|
20
|
+
* - CircuitController: Static editing with tools, selection, and manipulation
|
|
21
|
+
* - CircuitRunnerController: Live simulation with playback and animation
|
|
22
|
+
*
|
|
23
|
+
* Both controllers share the same Three.js scene, camera, and visual objects,
|
|
24
|
+
* enabling seamless transitions between edit and simulation modes.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const engine = new CircuitEngine(factoryRegistry, behaviorRegistry);
|
|
29
|
+
* engine.initialize(container);
|
|
30
|
+
* engine.setCircuit(circuit);
|
|
31
|
+
*
|
|
32
|
+
* // Edit mode (default)
|
|
33
|
+
* engine.setEditModeEnabled(true);
|
|
34
|
+
* engine.setActiveTool('build');
|
|
35
|
+
*
|
|
36
|
+
* // Switch to simulation
|
|
37
|
+
* engine.setMode('simulation');
|
|
38
|
+
* engine.play();
|
|
39
|
+
*
|
|
40
|
+
* // Switch back to edit
|
|
41
|
+
* engine.setMode('edit');
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare class CircuitEngine extends EventEmitter<CircuitEngineEventMap> {
|
|
45
|
+
private readonly _factoryRegistry;
|
|
46
|
+
private readonly _behaviorRegistry;
|
|
47
|
+
private _sharedResources;
|
|
48
|
+
private _container;
|
|
49
|
+
private _editController;
|
|
50
|
+
private _simulationController;
|
|
51
|
+
private _mode;
|
|
52
|
+
private _initialized;
|
|
53
|
+
private _options;
|
|
54
|
+
private _disposed;
|
|
55
|
+
private _editControllerCleanup;
|
|
56
|
+
private _simulationControllerCleanup;
|
|
57
|
+
/**
|
|
58
|
+
* Create a new CircuitEngine instance.
|
|
59
|
+
*
|
|
60
|
+
* @param factoryRegistry - Registry of component visual factories
|
|
61
|
+
* @param behaviorRegistry - Registry of component simulation behaviors
|
|
62
|
+
* @throws {TypeError} If factoryRegistry or behaviorRegistry is null/undefined
|
|
63
|
+
*/
|
|
64
|
+
constructor(factoryRegistry: IFactoryRegistry, behaviorRegistry: BehaviorRegistry);
|
|
65
|
+
/**
|
|
66
|
+
* Check if engine is initialized
|
|
67
|
+
*/
|
|
68
|
+
get isInitialized(): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Check if engine is disposed
|
|
71
|
+
*/
|
|
72
|
+
get isDisposed(): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the engine with a DOM container.
|
|
75
|
+
* Creates shared Three.js resources and both controllers.
|
|
76
|
+
*
|
|
77
|
+
* @param container - HTMLElement to mount the scene
|
|
78
|
+
* @param options - Configuration options
|
|
79
|
+
* @throws {TypeError} If container is not a valid HTMLElement
|
|
80
|
+
* @throws {Error} If already initialized
|
|
81
|
+
*/
|
|
82
|
+
initialize(container: HTMLElement, options?: EngineOptions): void;
|
|
83
|
+
/**
|
|
84
|
+
* Create shared resources for both controllers.
|
|
85
|
+
*/
|
|
86
|
+
private _createSharedResources;
|
|
87
|
+
/**
|
|
88
|
+
* Setup event forwarding from both controllers to engine.
|
|
89
|
+
*/
|
|
90
|
+
private _setupEventForwarding;
|
|
91
|
+
/**
|
|
92
|
+
* Teardown event forwarding cleanup.
|
|
93
|
+
*/
|
|
94
|
+
private _teardownEventForwarding;
|
|
95
|
+
/**
|
|
96
|
+
* Dispose all resources and clean up.
|
|
97
|
+
*
|
|
98
|
+
* @throws {Error} If not initialized or already disposed
|
|
99
|
+
*/
|
|
100
|
+
dispose(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Current operating mode
|
|
103
|
+
*/
|
|
104
|
+
get mode(): EngineMode;
|
|
105
|
+
/**
|
|
106
|
+
* Switch between edit and simulation modes.
|
|
107
|
+
*
|
|
108
|
+
* @param mode - Target mode to switch to
|
|
109
|
+
* @throws {Error} If not initialized
|
|
110
|
+
* @throws {Error} If switching to simulation without a circuit loaded
|
|
111
|
+
*/
|
|
112
|
+
setMode(mode: EngineMode): void;
|
|
113
|
+
/**
|
|
114
|
+
* Transition from edit mode to simulation mode.
|
|
115
|
+
*/
|
|
116
|
+
private _transitionToSimulation;
|
|
117
|
+
/**
|
|
118
|
+
* Transition from simulation mode to edit mode.
|
|
119
|
+
*/
|
|
120
|
+
private _transitionToEdit;
|
|
121
|
+
/**
|
|
122
|
+
* Load a circuit for editing/simulation.
|
|
123
|
+
*
|
|
124
|
+
* @param circuit - Circuit to load, or null to clear
|
|
125
|
+
* @throws {Error} If not initialized
|
|
126
|
+
*/
|
|
127
|
+
setCircuit(circuit: Circuit | null): void;
|
|
128
|
+
/**
|
|
129
|
+
* Get the currently loaded circuit
|
|
130
|
+
*/
|
|
131
|
+
getCircuit(): Circuit | null;
|
|
132
|
+
/**
|
|
133
|
+
* Get the edit controller for advanced operations.
|
|
134
|
+
*
|
|
135
|
+
* @throws {Error} If not initialized
|
|
136
|
+
*/
|
|
137
|
+
getEditController(): CircuitController;
|
|
138
|
+
/**
|
|
139
|
+
* Get the simulation controller for advanced operations.
|
|
140
|
+
*
|
|
141
|
+
* @throws {Error} If not initialized
|
|
142
|
+
*/
|
|
143
|
+
getSimulationController(): CircuitRunnerController;
|
|
144
|
+
/**
|
|
145
|
+
* Activate an editing tool.
|
|
146
|
+
*
|
|
147
|
+
* @param toolType - Tool to activate
|
|
148
|
+
* @throws {Error} If not in edit mode
|
|
149
|
+
*/
|
|
150
|
+
setActiveTool(toolType: ToolType): void;
|
|
151
|
+
/**
|
|
152
|
+
* Get the currently active tool
|
|
153
|
+
*
|
|
154
|
+
* @throws {Error} If not in edit mode
|
|
155
|
+
*/
|
|
156
|
+
getActiveTool(): ToolType | null;
|
|
157
|
+
/**
|
|
158
|
+
* Enable or disable edit mode (tool system).
|
|
159
|
+
*
|
|
160
|
+
* @param enabled - True to enable, false to disable
|
|
161
|
+
* @throws {Error} If not in edit mode
|
|
162
|
+
*/
|
|
163
|
+
setEditModeEnabled(enabled: boolean): void;
|
|
164
|
+
/**
|
|
165
|
+
* Start automatic simulation playback.
|
|
166
|
+
*
|
|
167
|
+
* @throws {Error} If not in simulation mode
|
|
168
|
+
*/
|
|
169
|
+
play(): void;
|
|
170
|
+
/**
|
|
171
|
+
* Pause automatic simulation playback.
|
|
172
|
+
*
|
|
173
|
+
* @throws {Error} If not in simulation mode
|
|
174
|
+
*/
|
|
175
|
+
pause(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Execute a single simulation tick.
|
|
178
|
+
*
|
|
179
|
+
* @throws {Error} If not in simulation mode
|
|
180
|
+
*/
|
|
181
|
+
step(): void;
|
|
182
|
+
/**
|
|
183
|
+
* Stop simulation and reset to initial state.
|
|
184
|
+
*
|
|
185
|
+
* @throws {Error} If not in simulation mode
|
|
186
|
+
*/
|
|
187
|
+
stop(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Check if simulation is currently playing
|
|
190
|
+
*/
|
|
191
|
+
get isPlaying(): boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Get current simulation tick
|
|
194
|
+
*/
|
|
195
|
+
get currentTick(): number;
|
|
196
|
+
/**
|
|
197
|
+
* Tick interval in milliseconds
|
|
198
|
+
*/
|
|
199
|
+
get tickInterval(): number;
|
|
200
|
+
set tickInterval(value: number);
|
|
201
|
+
/**
|
|
202
|
+
* Simulation speed in ticks per second.
|
|
203
|
+
* Range: 1-20 TPS. Works in both edit and simulation modes.
|
|
204
|
+
*/
|
|
205
|
+
get simulationSpeed(): number;
|
|
206
|
+
set simulationSpeed(tps: number);
|
|
207
|
+
/**
|
|
208
|
+
* Minimum allowed simulation speed in ticks per second.
|
|
209
|
+
*/
|
|
210
|
+
get minSimulationSpeed(): number;
|
|
211
|
+
/**
|
|
212
|
+
* Maximum allowed simulation speed in ticks per second.
|
|
213
|
+
*/
|
|
214
|
+
get maxSimulationSpeed(): number;
|
|
215
|
+
/**
|
|
216
|
+
* Update active animations. Call once per frame from the render loop.
|
|
217
|
+
* No-op if not initialized, disposed, or not in simulation mode.
|
|
218
|
+
*
|
|
219
|
+
* @param delta - Time in seconds since last frame (from THREE.Clock.getDelta())
|
|
220
|
+
*/
|
|
221
|
+
update(delta: number): void;
|
|
222
|
+
/**
|
|
223
|
+
* Get the Three.js scene for external rendering.
|
|
224
|
+
*
|
|
225
|
+
* @throws {Error} If not initialized
|
|
226
|
+
*/
|
|
227
|
+
getScene(): THREE.Scene;
|
|
228
|
+
/**
|
|
229
|
+
* Get the camera for external rendering.
|
|
230
|
+
*
|
|
231
|
+
* @throws {Error} If not initialized
|
|
232
|
+
*/
|
|
233
|
+
getCamera(): THREE.PerspectiveCamera;
|
|
234
|
+
/**
|
|
235
|
+
* Get the MapControls for external manipulation.
|
|
236
|
+
*
|
|
237
|
+
* @throws {Error} If not initialized
|
|
238
|
+
*/
|
|
239
|
+
getControls(): MapControls;
|
|
240
|
+
/**
|
|
241
|
+
* Hook called before exporting the circuit visualization.
|
|
242
|
+
* Saves world informations such as camera position, in the circuit metadata.
|
|
243
|
+
*/
|
|
244
|
+
beforeExport(): void;
|
|
245
|
+
/**
|
|
246
|
+
* Handle container resize.
|
|
247
|
+
*
|
|
248
|
+
* @param width - New width (optional, uses container if omitted)
|
|
249
|
+
* @param height - New height (optional, uses container if omitted)
|
|
250
|
+
*/
|
|
251
|
+
onContainerResize(width?: number, height?: number): void;
|
|
252
|
+
/**
|
|
253
|
+
* Check that controller is initialized and not disposed.
|
|
254
|
+
*
|
|
255
|
+
* @throws {Error} If not initialized or disposed
|
|
256
|
+
*/
|
|
257
|
+
private _checkInitialized;
|
|
258
|
+
/**
|
|
259
|
+
* Check that controller is in edit mode.
|
|
260
|
+
*
|
|
261
|
+
* @throws {Error} If not in edit mode
|
|
262
|
+
*/
|
|
263
|
+
private _checkEditMode;
|
|
264
|
+
/**
|
|
265
|
+
* Check that engine is in simulation mode.
|
|
266
|
+
*
|
|
267
|
+
* @throws {Error} If not in simulation mode
|
|
268
|
+
*/
|
|
269
|
+
private _checkSimulationMode;
|
|
270
|
+
}
|
package/dist/scene/index.d.ts
CHANGED
|
@@ -41,4 +41,3 @@ export { HitboxLayers } from './shared/utils/LayerConstants';
|
|
|
41
41
|
export type { HitboxLayerValue } from './shared/utils/LayerConstants';
|
|
42
42
|
export * from './shared/utils/Options';
|
|
43
43
|
export { registerBasicComponentsFactories, registerGatesComponentsFactories } from './setup';
|
|
44
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/scene/index.js
CHANGED
|
@@ -1,43 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as s, B as t, C as r, D as o, E as i, F as e, H as l, I as c, L as u, M as n, N as y, O as F, P as V, R as C, S as g, T as p, U as G, V as N, W as m, _ as M, a as L, b as R, c as S, d as T, f as d, g as E, h as b, i as h, j as B, k as I, l as D, m as O, n as P, o as w, p as A, r as H, s as W, t as _, u as f, v as k, w as v, x, y as X, z as j } from "../scene-CVsDdySt.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
3
|
+
G as BRANCHING_POINT_SENTINEL,
|
|
4
|
+
x as BatteryVisualFactory,
|
|
5
|
+
c as BranchingPointVisualFactory,
|
|
6
|
+
l as BuildTool,
|
|
7
|
+
p as CMP_MATERIALS,
|
|
8
|
+
B as CircuitController,
|
|
9
|
+
I as CircuitEngine,
|
|
10
|
+
s as CircuitRunnerController,
|
|
11
|
+
j as CircuitWriter,
|
|
12
|
+
A as ClockVisualFactory,
|
|
13
|
+
i as CmpMatCategory,
|
|
14
|
+
o as CmpMatType,
|
|
15
|
+
F as CmpMatVariant,
|
|
16
|
+
m as ComponentPickerWidget,
|
|
17
|
+
r as DefaultVisualFactory,
|
|
18
|
+
O as DoubleThrowSwitchVisualFactory,
|
|
19
|
+
v as FactoryRegistry,
|
|
15
20
|
g as GroupedFactoryRegistry,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
C as HitboxLayers,
|
|
22
|
+
u as HoverManager,
|
|
23
|
+
d as InverterVisualFactory,
|
|
24
|
+
R as LabelVisualFactory,
|
|
25
|
+
X as LightbulbVisualFactory,
|
|
26
|
+
N as MultiSelectTool,
|
|
27
|
+
f as Nand4GateVisualFactory,
|
|
28
|
+
D as Nand8GateVisualFactory,
|
|
29
|
+
T as NandGateVisualFactory,
|
|
30
|
+
W as Nor4GateVisualFactory,
|
|
31
|
+
w as Nor8GateVisualFactory,
|
|
32
|
+
S as NorGateVisualFactory,
|
|
33
|
+
k as RectangleLEDVisualFactory,
|
|
34
|
+
M as RelayVisualFactory,
|
|
35
|
+
t as SelectionManager,
|
|
36
|
+
E as SmallLEDVisualFactory,
|
|
37
|
+
b as SwitchVisualFactory,
|
|
38
|
+
e as WireVisualManager,
|
|
39
|
+
h as Xor4GateVisualFactory,
|
|
40
|
+
H as Xor8GateVisualFactory,
|
|
41
|
+
L as XorGateVisualFactory,
|
|
42
|
+
n as controllerOptions,
|
|
43
|
+
y as engineOptions,
|
|
44
|
+
V as mapControlsOptions,
|
|
45
|
+
_ as registerBasicComponentsFactories,
|
|
41
46
|
P as registerGatesComponentsFactories
|
|
42
47
|
};
|
|
43
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IGroupedFactoryRegistry } from './shared/components';
|
|
2
|
+
/**
|
|
3
|
+
* Register all basic components visual factories in the basic group
|
|
4
|
+
* Basic components are : Battery, Clock, Label, Switches, Lightbulb, RectangleLED, Relay, SmallLED
|
|
5
|
+
* @public
|
|
6
|
+
* @param registry - A grouped factory registry to populate
|
|
7
|
+
* @returns The input registry for chaining
|
|
8
|
+
*/
|
|
9
|
+
export declare function registerBasicComponentsFactories(registry: IGroupedFactoryRegistry): IGroupedFactoryRegistry;
|
|
10
|
+
/**
|
|
11
|
+
* Register all logic gates components visual factories in the gates group
|
|
12
|
+
* gates are : Inverter, NAND (2,4,8 inputs), NOR (2,4,8 inputs) and XOR (2,4,8 inputs)
|
|
13
|
+
* AND/OR are gotten by changing the activationLogic of NAND/NOR
|
|
14
|
+
* @public
|
|
15
|
+
* @param registry - A grouped factory registry to populate
|
|
16
|
+
* @returns The input registry for chaining
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerGatesComponentsFactories(registry: IGroupedFactoryRegistry): IGroupedFactoryRegistry;
|