@fundamental-engine/core 0.9.2 → 0.9.3
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/README.md +12 -11
- package/dist/agents/event-agent.d.ts.map +1 -1
- package/dist/agents/event-agent.js +13 -9
- package/dist/agents/event-agent.js.map +1 -1
- package/dist/config/forces.config.js +2 -2
- package/dist/config/forces.config.js.map +1 -1
- package/dist/conformance/run.d.ts +2 -2
- package/dist/conformance/run.d.ts.map +1 -1
- package/dist/conformance/run.js +30 -27
- package/dist/conformance/run.js.map +1 -1
- package/dist/conformance/types.d.ts +3 -0
- package/dist/conformance/types.d.ts.map +1 -1
- package/dist/contracts/guards.d.ts +3 -1
- package/dist/contracts/guards.d.ts.map +1 -1
- package/dist/contracts/guards.js.map +1 -1
- package/dist/contracts/passport.d.ts.map +1 -1
- package/dist/contracts/passport.js +9 -0
- package/dist/contracts/passport.js.map +1 -1
- package/dist/core/accretion.d.ts +1 -1
- package/dist/core/accretion.d.ts.map +1 -1
- package/dist/core/accretion.js +1 -1
- package/dist/core/accretion.js.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/events.js +1 -1
- package/dist/core/feedback-sink.d.ts +1 -1
- package/dist/core/feedback-sink.d.ts.map +1 -1
- package/dist/core/feedback-sink.js +1 -2
- package/dist/core/feedback-sink.js.map +1 -1
- package/dist/core/field.d.ts.map +1 -1
- package/dist/core/field.js +697 -82
- package/dist/core/field.js.map +1 -1
- package/dist/core/frame-harness.d.ts +2 -2
- package/dist/core/frame-harness.d.ts.map +1 -1
- package/dist/core/frame-harness.js +2 -2
- package/dist/core/frame-harness.js.map +1 -1
- package/dist/core/geometry.d.ts +9 -0
- package/dist/core/geometry.d.ts.map +1 -1
- package/dist/core/geometry.js +16 -0
- package/dist/core/geometry.js.map +1 -1
- package/dist/core/host.d.ts +95 -21
- package/dist/core/host.d.ts.map +1 -1
- package/dist/core/host.js +53 -1
- package/dist/core/host.js.map +1 -1
- package/dist/core/integrator.d.ts +22 -0
- package/dist/core/integrator.d.ts.map +1 -1
- package/dist/core/integrator.js +118 -15
- package/dist/core/integrator.js.map +1 -1
- package/dist/core/reactions.d.ts +7 -0
- package/dist/core/reactions.d.ts.map +1 -1
- package/dist/core/reactions.js +7 -0
- package/dist/core/reactions.js.map +1 -1
- package/dist/core/render-modes.d.ts +64 -0
- package/dist/core/render-modes.d.ts.map +1 -1
- package/dist/core/render-modes.js +165 -0
- package/dist/core/render-modes.js.map +1 -1
- package/dist/core/scanner.d.ts +29 -3
- package/dist/core/scanner.d.ts.map +1 -1
- package/dist/core/scanner.js +41 -3
- package/dist/core/scanner.js.map +1 -1
- package/dist/core/spatial-hash.d.ts +8 -0
- package/dist/core/spatial-hash.d.ts.map +1 -1
- package/dist/core/spatial-hash.js +26 -3
- package/dist/core/spatial-hash.js.map +1 -1
- package/dist/core/types.d.ts +308 -13
- package/dist/core/types.d.ts.map +1 -1
- package/dist/forces/extended.d.ts.map +1 -1
- package/dist/forces/extended.js +8 -2
- package/dist/forces/extended.js.map +1 -1
- package/dist/forces/natural.d.ts.map +1 -1
- package/dist/forces/natural.js +11 -12
- package/dist/forces/natural.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/recipes/compile.d.ts.map +1 -1
- package/dist/recipes/compile.js +3 -1
- package/dist/recipes/compile.js.map +1 -1
- package/dist/recipes/schema.d.ts +1 -1
- package/dist/recipes/schema.d.ts.map +1 -1
- package/dist/recipes/schema.js +1 -0
- package/dist/recipes/schema.js.map +1 -1
- package/dist/record/record.d.ts +1 -1
- package/dist/record/record.d.ts.map +1 -1
- package/dist/semantic/layers.d.ts +16 -2
- package/dist/semantic/layers.d.ts.map +1 -1
- package/dist/semantic/layers.js +20 -3
- package/dist/semantic/layers.js.map +1 -1
- package/dist/semantic/materials.js +3 -3
- package/dist/semantic/materials.js.map +1 -1
- package/dist/semantic/states.js +1 -1
- package/dist/semantic/states.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/visual/visualization.d.ts.map +1 -1
- package/dist/visual/visualization.js +4 -0
- package/dist/visual/visualization.js.map +1 -1
- package/package.json +2 -1
|
@@ -22,7 +22,7 @@ export interface HarnessElementSpec {
|
|
|
22
22
|
* One element in the harness scan root — a hand-rolled stand-in answering the exact surface the
|
|
23
23
|
* engine reads off a DOM element. The fields the frame loop mutates (transforms via `style`, a11y
|
|
24
24
|
* via `aria-hidden`/`inert`, the `data-fx-cap` edge flag) are observable so tests can assert them,
|
|
25
|
-
* and every `field:*`
|
|
25
|
+
* and every `field:*` event the engine dispatches is recorded in {@link events}.
|
|
26
26
|
*/
|
|
27
27
|
export declare class HarnessElement {
|
|
28
28
|
/** mutable layout box; the engine reads it through `getBoundingClientRect`. Move it to relocate. */
|
|
@@ -31,7 +31,7 @@ export declare class HarnessElement {
|
|
|
31
31
|
id: string;
|
|
32
32
|
className: string;
|
|
33
33
|
isConnected: boolean;
|
|
34
|
-
/** every `dispatchEvent`'d event type, in order (e.g. `'field:captured'
|
|
34
|
+
/** every `dispatchEvent`'d event type, in order (e.g. `'field:captured'`). */
|
|
35
35
|
readonly events: string[];
|
|
36
36
|
/** every dispatched event with its detail, in order — for asserting the payload. */
|
|
37
37
|
readonly dispatched: Array<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame-harness.d.ts","sourceRoot":"","sources":["../../src/core/frame-harness.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,WAAW,CAAC;AAEzD,sGAAsG;AACtG,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AA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AC;CACxB;AAED,2DAA2D;AAC3D,MAAM,WAAW,YAAY;IAC3B,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,yGAAyG;IACzG,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,+GAA+G;IAC/G,GAAG,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAAC;IAC/C,sFAAsF;IACtF,MAAM,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,oGAAoG;IACpG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,YAAY,CA6FzE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,GAAE,mBAAmB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAM,GAC1D;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAU/C;AAED,4FAA4F;AAC5F,wBAAgB,SAAS,CAAC,IAAI,SAAI,GAAG,MAAM,MAAM,CAShD"}
|
|
@@ -36,7 +36,7 @@ const ZERO_RECT = { left: 0, top: 0, width: 0, height: 0 };
|
|
|
36
36
|
* One element in the harness scan root — a hand-rolled stand-in answering the exact surface the
|
|
37
37
|
* engine reads off a DOM element. The fields the frame loop mutates (transforms via `style`, a11y
|
|
38
38
|
* via `aria-hidden`/`inert`, the `data-fx-cap` edge flag) are observable so tests can assert them,
|
|
39
|
-
* and every `field:*`
|
|
39
|
+
* and every `field:*` event the engine dispatches is recorded in {@link events}.
|
|
40
40
|
*/
|
|
41
41
|
export class HarnessElement {
|
|
42
42
|
/** mutable layout box; the engine reads it through `getBoundingClientRect`. Move it to relocate. */
|
|
@@ -45,7 +45,7 @@ export class HarnessElement {
|
|
|
45
45
|
id;
|
|
46
46
|
className = '';
|
|
47
47
|
isConnected = true;
|
|
48
|
-
/** every `dispatchEvent`'d event type, in order (e.g. `'field:captured'
|
|
48
|
+
/** every `dispatchEvent`'d event type, in order (e.g. `'field:captured'`). */
|
|
49
49
|
events = [];
|
|
50
50
|
/** every dispatched event with its detail, in order — for asserting the payload. */
|
|
51
51
|
dispatched = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frame-harness.js","sourceRoot":"","sources":["../../src/core/frame-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAwBzC,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;AAExE;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IACzB,oGAAoG;IACpG,IAAI,CAAc;IACT,OAAO,CAAS;IACzB,EAAE,CAAS;IACX,SAAS,GAAG,EAAE,CAAC;IACf,WAAW,GAAG,IAAI,CAAC;IACnB,
|
|
1
|
+
{"version":3,"file":"frame-harness.js","sourceRoot":"","sources":["../../src/core/frame-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAwBzC,MAAM,SAAS,GAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,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,CAAC,CAAC,GAAG,UAAU,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/core/geometry.d.ts
CHANGED
|
@@ -64,4 +64,13 @@ export declare function polePair(b: AxisRect): [Pole, Pole];
|
|
|
64
64
|
* body's strength downstream) sets line density and the tracer's min-strength cutoff.
|
|
65
65
|
*/
|
|
66
66
|
export declare function dipoleField(poles: readonly Pole[], x: number, y: number): Vec2;
|
|
67
|
+
/**
|
|
68
|
+
* The radial monopole field of a single point charge at `(cx, cy)` sampled at `(x, y)`:
|
|
69
|
+
* `E = sgn · s · r̂ / (d² + …)`, straight field lines OUT of a `+` source (`sign ≥ 0`) and
|
|
70
|
+
* IN to a `−`. This is the one formula the electric-charge force radiates (`charge.field`
|
|
71
|
+
* via `bodyMonopole`) AND the charge-stage field-line diagram traces — so the diagram is
|
|
72
|
+
* the engine's real field, not a hand-rolled stand-in. `EPS` floors the distance at the
|
|
73
|
+
* core so the sample never divides by zero.
|
|
74
|
+
*/
|
|
75
|
+
export declare function monopoleField(cx: number, cy: number, sign: number, s: number, x: number, y: number): Vec2;
|
|
67
76
|
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/core/geometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGvC,qFAAqF;AACrF,eAAO,MAAM,GAAG,IAAI,CAAC;AAErB,qFAAqF;AACrF,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,gFAAgF;AAChF,MAAM,WAAW,QAAS,SAAQ,IAAI;IACpC,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAA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AiE;AACjE,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAKnE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,MAAM,CAM/D;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAWlD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAY9E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACR,IAAI,CAON"}
|
package/dist/core/geometry.js
CHANGED
|
@@ -65,4 +65,20 @@ export function dipoleField(poles, x, y) {
|
|
|
65
65
|
}
|
|
66
66
|
return { x: fx, y: fy };
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* The radial monopole field of a single point charge at `(cx, cy)` sampled at `(x, y)`:
|
|
70
|
+
* `E = sgn · s · r̂ / (d² + …)`, straight field lines OUT of a `+` source (`sign ≥ 0`) and
|
|
71
|
+
* IN to a `−`. This is the one formula the electric-charge force radiates (`charge.field`
|
|
72
|
+
* via `bodyMonopole`) AND the charge-stage field-line diagram traces — so the diagram is
|
|
73
|
+
* the engine's real field, not a hand-rolled stand-in. `EPS` floors the distance at the
|
|
74
|
+
* core so the sample never divides by zero.
|
|
75
|
+
*/
|
|
76
|
+
export function monopoleField(cx, cy, sign, s, x, y) {
|
|
77
|
+
const dx = x - cx;
|
|
78
|
+
const dy = y - cy;
|
|
79
|
+
const d = Math.max(EPS, Math.hypot(dx, dy));
|
|
80
|
+
const sgn = sign < 0 ? -1 : 1;
|
|
81
|
+
const mag = (sgn * s) / (d * d); // 1/d², signed by polarity
|
|
82
|
+
return { x: (dx / d) * mag, y: (dy / d) * mag };
|
|
83
|
+
}
|
|
68
84
|
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/core/geometry.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAElC,qFAAqF;AACrF,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AA0BrB;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU,EAAE,EAAU,EAAE,CAAO;IAC3D,OAAO;QACL,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;QACtC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;KACvC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,EAAU,EAAE,EAAU,EAAE,CAAO;IACrD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;IACtC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,gCAAgC;QACzD,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QACnB,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;AAC1B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAC3B,EAAU,EACV,EAAU,EACV,IAAY,EACZ,CAAS,EACT,CAAS,EACT,CAAS;IAET,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IAClB,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;IAClB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC5C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,2BAA2B;IAC5D,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC;AAClD,CAAC"}
|
package/dist/core/host.d.ts
CHANGED
|
@@ -20,34 +20,108 @@ export interface HostViewport {
|
|
|
20
20
|
originX?: number;
|
|
21
21
|
originY?: number;
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* `MinimalFieldHost` — the SMALLEST surface a host must supply for the engine to run. It is the
|
|
25
|
+
* required core of {@link FieldHost}; everything else (scroll, reduced-motion, visibility, the heatmap
|
|
26
|
+
* canvas, and every event subscription) is an OPTIONAL capability the engine degrades around when
|
|
27
|
+
* absent (see {@link hostCapabilities}). A host that supplies only these four members runs the full
|
|
28
|
+
* simulation + feedback pipeline headlessly — it just never scrolls, never pauses on visibility, and
|
|
29
|
+
* cannot draw a heatmap.
|
|
30
|
+
*
|
|
31
|
+
* The three things a host MUST provide:
|
|
32
|
+
* - **geometry** — `root` (the scan root) + `viewport()` (size + DPR + optional origin): *where* the
|
|
33
|
+
* field lives and in what coordinate space.
|
|
34
|
+
* - **time** — `raf()` / `cancelRaf()`: how the frame loop is scheduled (a real rAF, a manual `tick`,
|
|
35
|
+
* a native display link).
|
|
36
|
+
*/
|
|
37
|
+
export interface MinimalFieldHost {
|
|
24
38
|
/** the subtree scanned for `[data-body]` / `[data-move]` / `[data-on]` / `[data-hot]` / `[data-formation]`. */
|
|
25
39
|
root: ParentNode;
|
|
26
40
|
/** the current viewport size + DPR (read each resize). */
|
|
27
41
|
viewport(): HostViewport;
|
|
28
|
-
/** current vertical scroll offset in px. */
|
|
29
|
-
scrollY(): number;
|
|
30
|
-
/** the scrollable height of the page (cached by the caller — reading it forces reflow). */
|
|
31
|
-
scrollHeight(): number;
|
|
32
|
-
/** whether the user prefers reduced motion (freezes the sim). */
|
|
33
|
-
reducedMotion(): boolean;
|
|
34
|
-
/** whether the surface is hidden (backgrounded tab) — pauses the loop. */
|
|
35
|
-
hidden(): boolean;
|
|
36
42
|
/** schedule the next frame; returns a handle. */
|
|
37
43
|
raf(cb: (t: number) => void): number;
|
|
38
44
|
/** cancel a scheduled frame. */
|
|
39
45
|
cancelRaf(id: number): void;
|
|
40
|
-
/** an offscreen canvas for the heatmap buffer. */
|
|
41
|
-
createCanvas(): HTMLCanvasElement;
|
|
42
|
-
/** subscribe to viewport-resize; returns an unsubscribe. */
|
|
43
|
-
onResize(cb: () => void): () => void;
|
|
44
|
-
/** subscribe to scroll; returns an unsubscribe. */
|
|
45
|
-
onScroll(cb: () => void): () => void;
|
|
46
|
-
/** subscribe to surface visibility changes; returns an unsubscribe. */
|
|
47
|
-
onVisibility(cb: () => void): () => void;
|
|
48
|
-
/** subscribe to user input activity (pointer/wheel/key/touch); returns an unsubscribe. */
|
|
49
|
-
onInput(cb: () => void): () => void;
|
|
50
|
-
/** subscribe to a composed shadow-DOM body event by name; returns an unsubscribe. */
|
|
51
|
-
onBodyEvent(type: string, cb: (e: Event) => void): () => void;
|
|
52
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* `FieldHost` — the full renderer/environment SPI: the {@link MinimalFieldHost} required core plus the
|
|
49
|
+
* OPTIONAL capabilities the engine consumes when a host offers them. Absent capabilities degrade
|
|
50
|
+
* gracefully (scroll → 0, reduced-motion / hidden → false, subscriptions → no-op, and a drawing mode
|
|
51
|
+
* that needs `createCanvas` throws a clear error rather than the field silently misbehaving). Existing
|
|
52
|
+
* hosts that implement every member keep satisfying this contract unchanged; a new host only has to
|
|
53
|
+
* supply the four required members. Use {@link hostCapabilities} to detect what a given host offers,
|
|
54
|
+
* or {@link defineHost} to fill the no-op defaults from a minimal host.
|
|
55
|
+
*/
|
|
56
|
+
export interface FieldHost extends MinimalFieldHost {
|
|
57
|
+
/** current vertical scroll offset in px. Absent ⇒ the field treats scroll as 0 (never scrolls). */
|
|
58
|
+
scrollY?(): number;
|
|
59
|
+
/** the scrollable height of the page (cached by the caller — reading it forces reflow). Absent ⇒ falls back to the viewport height. */
|
|
60
|
+
scrollHeight?(): number;
|
|
61
|
+
/** whether the user prefers reduced motion (freezes the sim). Absent ⇒ `false` (motion allowed). */
|
|
62
|
+
reducedMotion?(): boolean;
|
|
63
|
+
/** whether the surface is hidden (backgrounded tab) — pauses the loop. Absent ⇒ `false` (never auto-pauses). */
|
|
64
|
+
hidden?(): boolean;
|
|
65
|
+
/** an offscreen canvas for the heatmap buffer. Absent ⇒ any drawing mode that needs it throws a clear error; signals-first (`render: 'none'`) never calls it. */
|
|
66
|
+
createCanvas?(): HTMLCanvasElement;
|
|
67
|
+
/** subscribe to viewport-resize; returns an unsubscribe. Absent ⇒ the field never re-reads its viewport on resize. */
|
|
68
|
+
onResize?(cb: () => void): () => void;
|
|
69
|
+
/** subscribe to scroll; returns an unsubscribe. Absent ⇒ no scroll-driven readouts. */
|
|
70
|
+
onScroll?(cb: () => void): () => void;
|
|
71
|
+
/** subscribe to surface visibility changes; returns an unsubscribe. Absent ⇒ the loop never auto-pauses. */
|
|
72
|
+
onVisibility?(cb: () => void): () => void;
|
|
73
|
+
/** subscribe to user input activity (pointer/wheel/key/touch); returns an unsubscribe. Absent ⇒ no input-activity signal. */
|
|
74
|
+
onInput?(cb: () => void): () => void;
|
|
75
|
+
/** subscribe to a composed shadow-DOM body event by name; returns an unsubscribe. Absent ⇒ programmatic bodies only (no DOM body-event registration). */
|
|
76
|
+
onBodyEvent?(type: string, cb: (e: Event) => void): () => void;
|
|
77
|
+
/** release host-side state when the field is destroyed — called once by `FieldHandle.destroy()`
|
|
78
|
+
* after every event subscription is unsubscribed. A contained host (`containerHost`) uses it to
|
|
79
|
+
* remove its `data-field-boundary` ownership marker so the outer/page field re-adopts the bodies
|
|
80
|
+
* on its next rescan (#980). Absent ⇒ nothing to release. Idempotent by contract. */
|
|
81
|
+
detach?(): void;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* What optional capabilities a {@link FieldHost} actually supplies — the "host conformance" read-out.
|
|
85
|
+
* A capability is present when the host provides the backing member(s); the engine degrades gracefully
|
|
86
|
+
* around any that are absent. This is the third parity/testing category alongside API-surface parity
|
|
87
|
+
* and mathematical conformance: *does this host tick time, provide geometry, feed back, project…?*
|
|
88
|
+
*/
|
|
89
|
+
export interface HostCapabilities {
|
|
90
|
+
/** always true — the required core (`root` + `viewport` + `raf`/`cancelRaf`) is present by type. */
|
|
91
|
+
geometry: boolean;
|
|
92
|
+
/** the host schedules frames (`raf`/`cancelRaf`) — always true for a valid host. */
|
|
93
|
+
time: boolean;
|
|
94
|
+
/** the host reports scroll position/height (`scrollY` and/or `scrollHeight`). */
|
|
95
|
+
scroll: boolean;
|
|
96
|
+
/** the host can create the offscreen heatmap canvas (`createCanvas`) — required for heatmap draw modes. */
|
|
97
|
+
canvas: boolean;
|
|
98
|
+
/** the host reports the reduced-motion preference (`reducedMotion`). */
|
|
99
|
+
reducedMotion: boolean;
|
|
100
|
+
/** the host reports surface visibility (`hidden` and/or `onVisibility`) so the loop can auto-pause. */
|
|
101
|
+
visibility: boolean;
|
|
102
|
+
/** the host emits at least one subscription (`onResize`/`onScroll`/`onVisibility`/`onInput`/`onBodyEvent`). */
|
|
103
|
+
events: boolean;
|
|
104
|
+
/** the host relays composed shadow-DOM body events (`onBodyEvent`) — DOM body registration. */
|
|
105
|
+
bodyEvents: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Inspect which optional capabilities a host supplies — see {@link HostCapabilities}. Pure, allocation-
|
|
109
|
+
* light, and safe on a `MinimalFieldHost` (every optional lane reads `false`). Use it to branch on host
|
|
110
|
+
* shape (e.g. only enable a heatmap mode when `caps.canvas`) or as the basis of a host-conformance check.
|
|
111
|
+
*/
|
|
112
|
+
export declare function hostCapabilities(host: FieldHost): HostCapabilities;
|
|
113
|
+
/**
|
|
114
|
+
* Build a full {@link FieldHost} from a {@link MinimalFieldHost} plus any optional capabilities you
|
|
115
|
+
* choose to override — the no-op / graceful defaults are filled for the rest. This is the sanctioned
|
|
116
|
+
* way to author a host without hand-writing the whole subscription boilerplate: supply geometry + time
|
|
117
|
+
* (and whatever else your environment offers) and the field runs. Pure; touches no globals.
|
|
118
|
+
*
|
|
119
|
+
* ```ts
|
|
120
|
+
* const host = defineHost({
|
|
121
|
+
* root, viewport, raf, cancelRaf, // the required core
|
|
122
|
+
* reducedMotion: () => prefersReducedMotion(), // one optional capability
|
|
123
|
+
* });
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function defineHost(host: MinimalFieldHost & Partial<FieldHost>): FieldHost;
|
|
53
127
|
//# sourceMappingURL=host.d.ts.map
|
package/dist/core/host.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ;;;;mCAI+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,sEAAsE;AACtE,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ;;;;mCAI+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,gBAAgB;IAC/B,+GAA+G;IAC/G,IAAI,EAAE,UAAU,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,IAAI,YAAY,CAAC;IACzB,iDAAiD;IACjD,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;IACrC,gCAAgC;IAChC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAU,SAAQ,gBAAgB;IACjD,mGAAmG;IACnG,OAAO,CAAC,IAAI,MAAM,CAAC;IACnB,uIAAuI;IACvI,YAAY,CAAC,IAAI,MAAM,CAAC;IACxB,oGAAoG;IACpG,aAA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,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAiBjF"}
|
package/dist/core/host.js
CHANGED
|
@@ -7,5 +7,57 @@
|
|
|
7
7
|
* a different document, or a test harness. This interface is pure types — no globals — so `field.ts`
|
|
8
8
|
* imports zero DOM (enforced by `dom-boundary.test.ts`).
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Inspect which optional capabilities a host supplies — see {@link HostCapabilities}. Pure, allocation-
|
|
12
|
+
* light, and safe on a `MinimalFieldHost` (every optional lane reads `false`). Use it to branch on host
|
|
13
|
+
* shape (e.g. only enable a heatmap mode when `caps.canvas`) or as the basis of a host-conformance check.
|
|
14
|
+
*/
|
|
15
|
+
export function hostCapabilities(host) {
|
|
16
|
+
return {
|
|
17
|
+
geometry: true,
|
|
18
|
+
time: typeof host.raf === 'function' && typeof host.cancelRaf === 'function',
|
|
19
|
+
scroll: typeof host.scrollY === 'function' || typeof host.scrollHeight === 'function',
|
|
20
|
+
canvas: typeof host.createCanvas === 'function',
|
|
21
|
+
reducedMotion: typeof host.reducedMotion === 'function',
|
|
22
|
+
visibility: typeof host.hidden === 'function' || typeof host.onVisibility === 'function',
|
|
23
|
+
events: typeof host.onResize === 'function' ||
|
|
24
|
+
typeof host.onScroll === 'function' ||
|
|
25
|
+
typeof host.onVisibility === 'function' ||
|
|
26
|
+
typeof host.onInput === 'function' ||
|
|
27
|
+
typeof host.onBodyEvent === 'function',
|
|
28
|
+
bodyEvents: typeof host.onBodyEvent === 'function',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const NEVER_UNSUBSCRIBE = () => { };
|
|
32
|
+
/**
|
|
33
|
+
* Build a full {@link FieldHost} from a {@link MinimalFieldHost} plus any optional capabilities you
|
|
34
|
+
* choose to override — the no-op / graceful defaults are filled for the rest. This is the sanctioned
|
|
35
|
+
* way to author a host without hand-writing the whole subscription boilerplate: supply geometry + time
|
|
36
|
+
* (and whatever else your environment offers) and the field runs. Pure; touches no globals.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const host = defineHost({
|
|
40
|
+
* root, viewport, raf, cancelRaf, // the required core
|
|
41
|
+
* reducedMotion: () => prefersReducedMotion(), // one optional capability
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function defineHost(host) {
|
|
46
|
+
return {
|
|
47
|
+
root: host.root,
|
|
48
|
+
viewport: host.viewport,
|
|
49
|
+
raf: host.raf,
|
|
50
|
+
cancelRaf: host.cancelRaf,
|
|
51
|
+
scrollY: host.scrollY,
|
|
52
|
+
scrollHeight: host.scrollHeight,
|
|
53
|
+
reducedMotion: host.reducedMotion,
|
|
54
|
+
hidden: host.hidden,
|
|
55
|
+
createCanvas: host.createCanvas,
|
|
56
|
+
onResize: host.onResize ?? (() => NEVER_UNSUBSCRIBE),
|
|
57
|
+
onScroll: host.onScroll ?? (() => NEVER_UNSUBSCRIBE),
|
|
58
|
+
onVisibility: host.onVisibility ?? (() => NEVER_UNSUBSCRIBE),
|
|
59
|
+
onInput: host.onInput ?? (() => NEVER_UNSUBSCRIBE),
|
|
60
|
+
onBodyEvent: host.onBodyEvent ?? (() => NEVER_UNSUBSCRIBE),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
11
63
|
//# sourceMappingURL=host.js.map
|
package/dist/core/host.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
1
|
+
{"version":3,"file":"host.js","sourceRoot":"","sources":["../../src/core/host.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAuGH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAe;IAC9C,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,OAAO,IAAI,CAAC,GAAG,KAAK,UAAU,IAAI,OAAO,IAAI,C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AAC,iBAAiB,CAAC;QACpD,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;QAC5D,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;QAClD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
* then integrate and damp. Under first-class mass (§21.3) each additive body force is
|
|
6
6
|
* scaled by `1/m` as it applies, while velocity-replacing (`kinematic`) forces are left
|
|
7
7
|
* untouched. Reduced motion (`dt = 0`) freezes the sim (§18).
|
|
8
|
+
*
|
|
9
|
+
* INTEGRATION SCHEMES (`Env.integrator`): the default `'legacy'` is semi-implicit Euler
|
|
10
|
+
* (forces update v, then `x += v·dt`, then a per-frame decay); `'fixed'` keeps the same order
|
|
11
|
+
* but dt-scales the decays (doc 04 §Step 3). `'velocity-verlet'` (#659) is the opt-in
|
|
12
|
+
* second-order scheme, in the stored-acceleration form:
|
|
13
|
+
*
|
|
14
|
+
* x(t+dt) = x(t) + v(t)·dt + ½·a(t)·dt² (position full-step, BEFORE the force pass)
|
|
15
|
+
* a′ = Δv/dt from the force pass (forces evaluated at x(t+dt))
|
|
16
|
+
* v(t+dt) = v(t) + ½·(a(t) + a′)·dt (velocity half-step average)
|
|
17
|
+
*
|
|
18
|
+
* Approximations, deliberate and documented (physics caveat canon): (1) the engine's force model
|
|
19
|
+
* is impulse-based and velocity-dependent (drag-like forces read the CURRENT v), so a′ is taken
|
|
20
|
+
* as the pass's net Δv/dt rather than re-evaluating forces at the averaged velocity — the
|
|
21
|
+
* standard stored-acceleration treatment; (2) the per-step `FRICTION`/`HEAT_DECAY` decays stay
|
|
22
|
+
* outside the scheme (dt-scaled, like `'fixed'`), which alone makes it NON-symplectic — this
|
|
23
|
+
* buys positional accuracy, it does NOT make energy/momentum conserved (they are non-conserved
|
|
24
|
+
* by design; particle COUNT remains the invariant); (3) a *kinematic* (velocity-REPLACING)
|
|
25
|
+
* force — `jet`/`wall`/`lens`/`gate`/`warp` — is a discontinuity, not an acceleration: when one
|
|
26
|
+
* fires, the replaced velocity stands un-averaged and the stored acceleration resets, so the
|
|
27
|
+
* next position step doesn't extrapolate across the break; (4) a pair force's equal-and-opposite
|
|
28
|
+
* leg on the NEIGHBOUR (`collide`/`link`) folds into that neighbour's own v(t) or Δv whenever
|
|
29
|
+
* its turn comes — same class of caveat the fixed-timestep note below already carries.
|
|
8
30
|
*/
|
|
9
31
|
import type { Body, ConditionRegistry, Env, FieldImpulseAccumulator, Force, ForceRegistry, Particle } from './types.ts';
|
|
10
32
|
import type { FieldStore } from './field-store.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrator.d.ts","sourceRoot":"","sources":["../../src/core/integrator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"integrator.d.ts","sourceRoot":"","sources":["../../src/core/integrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,uBAAuB,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAoC,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAK5E,eAAO,MAAM,QAAQ,OAAO,CAAC;AAC7B,eAAO,MAAM,UAAU,QAAQ,CAAC;AAGhC,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACxB,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,iBAAiB,CAAC;IAC9B,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC;IACxB,SAAS,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAClC,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAmBD;;;;;;;GAOG;AACH;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,SAAI,GAAG,IAAI,CAiEtF;AAyCD,oGAAoG;AACpG,wBAAgB,eAAe,IAAI,uBAAuB,CAEzD;AAwBD,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CA0b3C"}
|
package/dist/core/integrator.js
CHANGED
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
* then integrate and damp. Under first-class mass (§21.3) each additive body force is
|
|
6
6
|
* scaled by `1/m` as it applies, while velocity-replacing (`kinematic`) forces are left
|
|
7
7
|
* untouched. Reduced motion (`dt = 0`) freezes the sim (§18).
|
|
8
|
+
*
|
|
9
|
+
* INTEGRATION SCHEMES (`Env.integrator`): the default `'legacy'` is semi-implicit Euler
|
|
10
|
+
* (forces update v, then `x += v·dt`, then a per-frame decay); `'fixed'` keeps the same order
|
|
11
|
+
* but dt-scales the decays (doc 04 §Step 3). `'velocity-verlet'` (#659) is the opt-in
|
|
12
|
+
* second-order scheme, in the stored-acceleration form:
|
|
13
|
+
*
|
|
14
|
+
* x(t+dt) = x(t) + v(t)·dt + ½·a(t)·dt² (position full-step, BEFORE the force pass)
|
|
15
|
+
* a′ = Δv/dt from the force pass (forces evaluated at x(t+dt))
|
|
16
|
+
* v(t+dt) = v(t) + ½·(a(t) + a′)·dt (velocity half-step average)
|
|
17
|
+
*
|
|
18
|
+
* Approximations, deliberate and documented (physics caveat canon): (1) the engine's force model
|
|
19
|
+
* is impulse-based and velocity-dependent (drag-like forces read the CURRENT v), so a′ is taken
|
|
20
|
+
* as the pass's net Δv/dt rather than re-evaluating forces at the averaged velocity — the
|
|
21
|
+
* standard stored-acceleration treatment; (2) the per-step `FRICTION`/`HEAT_DECAY` decays stay
|
|
22
|
+
* outside the scheme (dt-scaled, like `'fixed'`), which alone makes it NON-symplectic — this
|
|
23
|
+
* buys positional accuracy, it does NOT make energy/momentum conserved (they are non-conserved
|
|
24
|
+
* by design; particle COUNT remains the invariant); (3) a *kinematic* (velocity-REPLACING)
|
|
25
|
+
* force — `jet`/`wall`/`lens`/`gate`/`warp` — is a discontinuity, not an acceleration: when one
|
|
26
|
+
* fires, the replaced velocity stands un-averaged and the stored acceleration resets, so the
|
|
27
|
+
* next position step doesn't extrapolate across the break; (4) a pair force's equal-and-opposite
|
|
28
|
+
* leg on the NEIGHBOUR (`collide`/`link`) folds into that neighbour's own v(t) or Δv whenever
|
|
29
|
+
* its turn comes — same class of caveat the fixed-timestep note below already carries.
|
|
8
30
|
*/
|
|
9
31
|
import { accretionTarget } from "./formations.js";
|
|
10
32
|
import { waveYat, waveSlope, waveDistance } from "./currents.js";
|
|
@@ -60,6 +82,9 @@ export function applyAndRecord(f, b, p, env, inv = 1) {
|
|
|
60
82
|
if (p.vz !== undefined)
|
|
61
83
|
p.vz = bvz + (p.vz - bvz) * inv;
|
|
62
84
|
}
|
|
85
|
+
// velocity-Verlet (#659): mirror the fast path's discontinuity mark on the capture path too.
|
|
86
|
+
if (f.kinematic && env.integrator === 'velocity-verlet' && (p.vx !== bvx || p.vy !== bvy || (p.vz ?? 0) !== bvz))
|
|
87
|
+
env.kinTouch = true;
|
|
63
88
|
const acc = env.accum;
|
|
64
89
|
if (acc !== undefined) {
|
|
65
90
|
const dvx = p.vx - bvx;
|
|
@@ -120,6 +145,18 @@ function applyForce(f, b, p, env, inv) {
|
|
|
120
145
|
// Default hot path: byte-identical to the pre-accumulator engine (zero overhead — no capture).
|
|
121
146
|
if (env.accum === undefined) {
|
|
122
147
|
if (inv === 1 || f.kinematic) {
|
|
148
|
+
// velocity-Verlet (#659): a kinematic force that actually changes velocity marks the
|
|
149
|
+
// particle's pass as a discontinuity (env.kinTouch) — the half-step average is skipped.
|
|
150
|
+
// One boolean test on the default path; the capture only runs under the opt-in mode.
|
|
151
|
+
if (f.kinematic && env.integrator === 'velocity-verlet') {
|
|
152
|
+
const bvx = p.vx;
|
|
153
|
+
const bvy = p.vy;
|
|
154
|
+
const bvz = p.vz ?? 0;
|
|
155
|
+
f.apply(b, p, env);
|
|
156
|
+
if (p.vx !== bvx || p.vy !== bvy || (p.vz ?? 0) !== bvz)
|
|
157
|
+
env.kinTouch = true;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
123
160
|
f.apply(b, p, env);
|
|
124
161
|
return;
|
|
125
162
|
}
|
|
@@ -142,15 +179,13 @@ function applyForce(f, b, p, env, inv) {
|
|
|
142
179
|
export function makeAccumulator() {
|
|
143
180
|
return { linear: { x: 0, y: 0, z: 0 }, attribution: [] };
|
|
144
181
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
// superposition of every body's field() — the same vector the streamlines view draws.
|
|
153
|
-
env.fieldAt = (x, y) => netField(bodies, forces, x, y);
|
|
182
|
+
/**
|
|
183
|
+
* Zero the per-frame density + thermodynamic accumulators on every body. Runs at the top of
|
|
184
|
+
* every step — including the frozen (`dt === 0`) path (#967) — so `b.count` never carries a
|
|
185
|
+
* stale value into `writeFeedback()`. The subsequent particle pass re-accumulates when the sim
|
|
186
|
+
* is live; when frozen, the counts stay at 0 and `--d` drains to the engagement-only baseline.
|
|
187
|
+
*/
|
|
188
|
+
function resetDensity(bodies) {
|
|
154
189
|
for (const b of bodies) {
|
|
155
190
|
b.count = 0;
|
|
156
191
|
// thermodynamic accumulators (workover v0.3 §"Metrics") share the density window/cadence.
|
|
@@ -164,6 +199,29 @@ export function step(input) {
|
|
|
164
199
|
th.sh = 0;
|
|
165
200
|
}
|
|
166
201
|
}
|
|
202
|
+
}
|
|
203
|
+
export function step(input) {
|
|
204
|
+
const { store, bodies, env, forces, conditions, waves, separation } = input;
|
|
205
|
+
const dt = env.dt;
|
|
206
|
+
if (dt === 0) {
|
|
207
|
+
// Motion is frozen (reduced-motion / maxMotionBudget 0): skip integration, but the
|
|
208
|
+
// density/thermo bookkeeping MUST still drain. `writeFeedback()` runs unconditionally
|
|
209
|
+
// every frame, easing `b.d` toward `feedbackTarget(b.count, b.on)`. If we returned before
|
|
210
|
+
// zeroing the counts, `b.count` would hold its last live value forever — `--d`/`--field-density`
|
|
211
|
+
// (and the font-weight channel) would report particle presence from a sim that is no longer
|
|
212
|
+
// running (#967). The doctrine is "motion freezes; the signals stay honest": engagement
|
|
213
|
+
// (`b.on`, dt-independent) still reads truthfully, so `b.d` eases to `feedbackTarget(0, b.on)`
|
|
214
|
+
// — the engagement-only baseline — instead of lying about frozen density.
|
|
215
|
+
resetDensity(bodies);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
// the opt-in second-order scheme (#659) — see the header doc for the math + approximations.
|
|
219
|
+
const verlet = env.integrator === 'velocity-verlet';
|
|
220
|
+
const { W, H, form } = env;
|
|
221
|
+
// expose the net structure field so field-following forces (`fieldflow`) can read the
|
|
222
|
+
// superposition of every body's field() — the same vector the streamlines view draws.
|
|
223
|
+
env.fieldAt = (x, y) => netField(bodies, forces, x, y);
|
|
224
|
+
resetDensity(bodies);
|
|
167
225
|
// visible `screen` bodies (workover v0.3): each damps OTHER bodies' forces on matter inside
|
|
168
226
|
// its range (quiet zones / text shielding). No screens on the page (the common case) ⇒ this
|
|
169
227
|
// stays null and the whole pass is skipped — zero cost and zero behavior change.
|
|
@@ -189,6 +247,10 @@ export function step(input) {
|
|
|
189
247
|
p.y += (p.cap.cy - p.y) * 0.18;
|
|
190
248
|
if (p.z)
|
|
191
249
|
p.z += -p.z * 0.18;
|
|
250
|
+
// held matter has no acceleration of its own — drop any stored Verlet lane so a later
|
|
251
|
+
// release doesn't extrapolate a stale a(t). Only ever defined under the opt-in mode.
|
|
252
|
+
if (p.ax !== undefined)
|
|
253
|
+
p.ax = p.ay = p.az = 0;
|
|
192
254
|
continue;
|
|
193
255
|
}
|
|
194
256
|
// normalize the optional lane once: after this the lane is concrete numbers for
|
|
@@ -197,6 +259,22 @@ export function step(input) {
|
|
|
197
259
|
p.z = 0;
|
|
198
260
|
if (p.vz === undefined)
|
|
199
261
|
p.vz = 0;
|
|
262
|
+
// velocity-Verlet (#659): the position FULL-STEP runs first, from last step's velocity and
|
|
263
|
+
// stored acceleration — x(t+dt) = x(t) + v(t)·dt + ½·a(t)·dt² — so the force pass below
|
|
264
|
+
// evaluates a′ at x(t+dt). v0 keeps v(t) for the half-step average after the pass.
|
|
265
|
+
let v0x = 0;
|
|
266
|
+
let v0y = 0;
|
|
267
|
+
let v0z = 0;
|
|
268
|
+
if (verlet) {
|
|
269
|
+
const h = 0.5 * dt * dt;
|
|
270
|
+
p.x += p.vx * dt + (p.ax ?? 0) * h;
|
|
271
|
+
p.y += p.vy * dt + (p.ay ?? 0) * h;
|
|
272
|
+
p.z += p.vz * dt + (p.az ?? 0) * h;
|
|
273
|
+
v0x = p.vx;
|
|
274
|
+
v0y = p.vy;
|
|
275
|
+
v0z = p.vz;
|
|
276
|
+
env.kinTouch = false;
|
|
277
|
+
}
|
|
200
278
|
const pz = p.z;
|
|
201
279
|
// wave current (§2.3): near a wave line, drift along its slope like debris.
|
|
202
280
|
if (hasWaves) {
|
|
@@ -440,6 +518,28 @@ export function step(input) {
|
|
|
440
518
|
}
|
|
441
519
|
}
|
|
442
520
|
}
|
|
521
|
+
// velocity-Verlet second half (#659): fold this step's impulse into the half-step average.
|
|
522
|
+
if (verlet) {
|
|
523
|
+
// the pass's net Δv is a′·dt — every force above evaluated at the updated position.
|
|
524
|
+
const dvx = p.vx - v0x;
|
|
525
|
+
const dvy = p.vy - v0y;
|
|
526
|
+
const dvz = p.vz - v0z;
|
|
527
|
+
if (env.kinTouch) {
|
|
528
|
+
// a kinematic (velocity-REPLACING) force fired: a discontinuity, not an acceleration.
|
|
529
|
+
// The replaced velocity stands as-is; the stored acceleration resets so the next
|
|
530
|
+
// position step doesn't extrapolate across the break.
|
|
531
|
+
p.ax = p.ay = p.az = 0;
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
// v(t+dt) = v(t) + ½·(a(t) + a′)·dt — ½·a(t)·dt from the stored lane, ½·Δv for a′.
|
|
535
|
+
p.vx = v0x + 0.5 * ((p.ax ?? 0) * dt + dvx);
|
|
536
|
+
p.vy = v0y + 0.5 * ((p.ay ?? 0) * dt + dvy);
|
|
537
|
+
p.vz = v0z + 0.5 * ((p.az ?? 0) * dt + dvz);
|
|
538
|
+
p.ax = dvx / dt;
|
|
539
|
+
p.ay = dvy / dt;
|
|
540
|
+
p.az = dvz / dt;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
443
543
|
// global safety cap (§20.10): no token or composite may drive a free particle past
|
|
444
544
|
// c (the unit system's "speed of light"). The natural primitives self-clamp; this
|
|
445
545
|
// enforces it for *every* force. A non-finite velocity slips the `> c²` test — the
|
|
@@ -467,11 +567,14 @@ export function step(input) {
|
|
|
467
567
|
// integrate, then damp (§2.2). The z lane integrates identically — inert at 0. Under the opt-in
|
|
468
568
|
// fixed-timestep integrator (doc 04 §Step 3) the per-step damping scales with `dt` (`FRICTION^dt`)
|
|
469
569
|
// so it is frame-rate independent; at `dt === 1` `Math.pow(FRICTION, 1) === FRICTION`, so the
|
|
470
|
-
// default path is byte-identical.
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
570
|
+
// default path is byte-identical. Velocity-Verlet already took its position full-step before
|
|
571
|
+
// the force pass (its decays are dt-scaled like fixed's).
|
|
572
|
+
if (!verlet) {
|
|
573
|
+
p.x += p.vx * dt;
|
|
574
|
+
p.y += p.vy * dt;
|
|
575
|
+
p.z += p.vz * dt;
|
|
576
|
+
}
|
|
577
|
+
const fr = env.integrator === 'fixed' || verlet ? Math.pow(FRICTION, dt) : FRICTION;
|
|
475
578
|
p.vx *= fr;
|
|
476
579
|
p.vy *= fr;
|
|
477
580
|
p.vz *= fr;
|
|
@@ -501,7 +604,7 @@ export function step(input) {
|
|
|
501
604
|
p.vy += Math.sin(cn) * 0.013 * form.wander;
|
|
502
605
|
}
|
|
503
606
|
}
|
|
504
|
-
p.heat *= env.integrator === 'fixed' ? Math.pow(HEAT_DECAY, dt) : HEAT_DECAY;
|
|
607
|
+
p.heat *= env.integrator === 'fixed' || verlet ? Math.pow(HEAT_DECAY, dt) : HEAT_DECAY;
|
|
505
608
|
// mortal matter ages (the class-[S] sink): spawned particles carry a finite `age`
|
|
506
609
|
// and despawn at ≤ 0, so a continuous source stays budgeted. Immortal base-field
|
|
507
610
|
// matter (age undefined) is untouched — the conserved field is unchanged.
|