@descix/frqtl-web 0.6.1-p3.3 → 0.6.1

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 (47) hide show
  1. package/CLAUDE.md +11 -13
  2. package/LICENSE.md +63 -79
  3. package/README.md +7 -9
  4. package/dist/artifact/double-slit.html +1 -1
  5. package/dist/dist-manifest.json +37 -42
  6. package/dist/frqtl/compat/providers/wasm-load-browser.js +1 -2
  7. package/dist/frqtl/compat/renderer/providers/godrays-layer.js +12 -301
  8. package/dist/frqtl/compat/renderer/providers/p5-provider.js +0 -6
  9. package/dist/frqtl/compat/renderer/providers/three-provider.js +17 -66
  10. package/dist/frqtl/objects/FrqtlApp.js +1 -17
  11. package/dist/frqtl/objects/RecipeContext.js +41 -38
  12. package/dist/frqtl/objects/objects/QuantumEmitter.js +1 -1
  13. package/dist/frqtl/objects/objects/sustainedSource.js +2 -2
  14. package/dist/frqtl/objects/record/Record.js +9 -4
  15. package/dist/frqtl/objects/setup/setupConeEmitter3D.js +3 -3
  16. package/dist/frqtl/objects/setup/setupSphereEmitter3D.js +6 -8
  17. package/dist/frqtl/parts/FrqtlVision.js +27 -158
  18. package/dist/frqtl/parts/GraphingDetectorWall.js +1 -1
  19. package/dist/frqtl/parts/LiveChart.js +1 -1
  20. package/dist/frqtl/parts/SphereEmitter.js +2 -2
  21. package/dist/frqtl/parts/Tunnel.js +1 -1
  22. package/dist/frqtl/parts/Wall.js +10 -97
  23. package/dist/frqtl/scenes/dse-tunnel-rebuild.js +22 -33
  24. package/dist/frqtl/scenes/mirror-route.js +6 -10
  25. package/dist/frqtl-web.min.js +51 -56
  26. package/dist/notebooks/notebooks.json +1 -1
  27. package/dist/sdk.html +2 -3
  28. package/dist/shim/controls/index.js +2 -2
  29. package/dist/shim/engine/router.js +30 -49
  30. package/dist/shim/field-descriptor/index.js +5 -5
  31. package/dist/shim/host/host-view.js +10 -7
  32. package/dist/shim/host/index.js +1 -2
  33. package/dist/shim/project/index.js +3 -13
  34. package/dist/shim/project/record-format.js +4 -96
  35. package/dist/shim/project/specifiers.js +3 -5
  36. package/dist/shim/registry/exhibits.js +11 -11
  37. package/dist/shim/registry/index.js +0 -6
  38. package/dist/shim/registry/walkthrough.js +90 -38
  39. package/dist/shim/render/capture-envelope.js +0 -21
  40. package/dist/shim/render/sun-look.js +11 -6
  41. package/llms.txt +8 -9
  42. package/package.json +2 -3
  43. package/dist/shim/engine/site-graph.js +0 -184
  44. package/dist/shim/host/device.js +0 -42
  45. package/dist/shim/project/parts-spelling.js +0 -77
  46. package/dist/shim/registry/showcase-link.js +0 -61
  47. package/dist/shim/registry/studio-landing.js +0 -70
@@ -774,26 +774,14 @@ import { wallBehaviorV2ValuesMap as _wallBehaviorV2ValuesMap, bounceDirectionVal
774
774
  return out;
775
775
  };
776
776
 
777
- /** Does the op-program this wall's LargeObject is RUNNING remove the frame it triggers
778
- * on (`set 0.is_alive = …`)? Read off the program itself — the one statement of what
779
- * the wall does — never a hand list of behavior names (today: destroy and absorb). On
780
- * such a wall a frame's listing in `tickData.objects[handle].frames` is not one
781
- * arrival: the engine collects every frame in the mb_w-padded search rect
782
- * (ENGINE_CONTRACT §5.1), so a frame is listed alive through its approach ticks and
783
- * once more on its kill tick. */
784
- function _runningProgramRemoves(wall) {
785
- var prog = wall.lo && wall.lo.program;
786
- return !!(prog && Array.isArray(prog.ops) &&
787
- prog.ops.some(function (op) { return op && op.set === '0.is_alive'; }));
788
- }
789
-
790
777
  /**
791
- * ZONE-OCCUPANCY readout (loop-polish B): the number of frames THIS wall's
792
- * engine collect pass listed on the sampled tick — every frame in its search rect
793
- * (the rect padded by the dimension's mb_w). For a FULL-AREA background wall
794
- * (collisionBehavior 'nothing' + the count hook) that listing IS the current live
795
- * population inside the wall — the ONE canonical "how many live" authority (the
796
- * emission-cap gate and the LiveChart `liveCount` projector read it).
778
+ * LIVE-POPULATION readout (loop-polish B): the number of frames
779
+ * that collided with THIS wall on the sampled tick. For a FULL-AREA background
780
+ * wall (collisionBehavior 'nothing' + the count hook, intersects trigger) every
781
+ * live leaf inside the rect collides every tick, so this per-tick collided-frame
782
+ * count IS the current live population inside the wall — the ONE canonical
783
+ * "how many live" authority (replaces any host-side scan, e.g. an emission-cap
784
+ * thermostat's activeQuanta read).
797
785
  *
798
786
  * Layer 1 (API): dual-lane, mirroring the LiveChart PROJECTOR_SPEC shape —
799
787
  * getLiveCount(tickData) — SAMPLE lane (per tick): read
@@ -806,23 +794,12 @@ import { wallBehaviorV2ValuesMap as _wallBehaviorV2ValuesMap, bounceDirectionVal
806
794
  * COUNT increment only (bench LO7); counting never moves, kills, or recolors a
807
795
  * frame (SU1).
808
796
  *
809
- * Guards: THROWS on a REMOVING wall (destroy / absorb) — there the listing reads
810
- * (1 + approach-halo ticks) x arrivals, never the arrivals; `getArrivals` is the
811
- * reader. THROWS on a wall without the count hook (no collected-frames buffer → it
812
- * would silently report 0 forever).
797
+ * Guard: THROWS on a wall without the count hook / legacy detect behavior (no
798
+ * collected-frames buffer → it would silently report 0 forever).
813
799
  * @param {Object} [tickData] — the universe.doTick() result (sample lane).
814
800
  * @returns {number}
815
801
  */
816
802
  Wall.prototype.getLiveCount = function (tickData) {
817
- if (_runningProgramRemoves(this)) {
818
- throw new Error(
819
- '[Wall.getLiveCount] this wall REMOVES what it hits (collisionBehavior "' +
820
- this.collisionBehavior + '") — getLiveCount is the zone-occupancy reader of a ' +
821
- 'non-removing wall, and on a removing wall it would count each frame once per ' +
822
- 'approach tick plus once on its kill tick. Read arrivals with ' +
823
- 'wall.getArrivals(tickData) → { total, delta } (the engine\'s own per-wall count).'
824
- );
825
- }
826
803
  var counts = Array.isArray(this.hooks) && this.hooks.indexOf('count') !== -1;
827
804
  if (!counts) {
828
805
  throw new Error(
@@ -841,70 +818,6 @@ import { wallBehaviorV2ValuesMap as _wallBehaviorV2ValuesMap, bounceDirectionVal
841
818
  return this._liveCount || 0;
842
819
  };
843
820
 
844
- /**
845
- * ARRIVALS readout: how many frames have triggered THIS wall's collision program —
846
- * read from the engine's own per-wall counter, `tickData.objects[handle].count`, the
847
- * contract's one read authority for an LO count (ENGINE_CONTRACT §4.3). The `count`
848
- * hook compiles `set 1.count = 1.count + 1` behind the trigger, so the engine counts
849
- * one per trigger event; on a removing wall (destroy / absorb) each trigger is the
850
- * frame's removal, so the count IS the arrivals. Never derived from the collected
851
- * frame listing (that is the padded search-rect census — see getLiveCount).
852
- *
853
- * Layer 1 (API): dual-lane, the same shape as getLiveCount —
854
- * getArrivals(tickData) — SAMPLE lane: read the engine count and return
855
- * `{ total, delta }`: `total` = cumulative arrivals since the wall registered,
856
- * `delta` = the change since the previously sampled TickData (this tick's
857
- * arrivals when sampled every tick). IDEMPOTENT per TickData — sampling the same
858
- * TickData twice returns the same `{ total, delta }`.
859
- * getArrivals() — READ lane: the last sample (`{ total: 0, delta: 0 }` before the
860
- * first tick).
861
- *
862
- * Layer 2 (physics): zero physics — a pure reader of a counter the compiled program
863
- * already maintains (bench LO7); reading it moves nothing (SU1).
864
- *
865
- * Guards: THROWS on a wall without the count hook (the engine counter never moves →
866
- * it would silently report 0 forever), and on a TickData that is not the one this
867
- * wall's universe last produced (`universe._lastTickData`, the object `doTick()` returned
868
- * and every tick listener receives). LO handles restart at 0 in every universe, so a
869
- * TickData from another world indexes a different wall's count at the same handle; and
870
- * an earlier TickData of this world would yield a wrong delta.
871
- * @param {Object} [tickData] — the universe.doTick() result (sample lane).
872
- * @returns {{ total: number, delta: number }}
873
- */
874
- Wall.prototype.getArrivals = function (tickData) {
875
- var counts = Array.isArray(this.hooks) && this.hooks.indexOf('count') !== -1;
876
- if (!counts) {
877
- throw new Error(
878
- '[Wall.getArrivals] this wall does not COUNT (collisionBehavior "' +
879
- this.collisionBehavior + '", hooks ' + JSON.stringify(this.hooks || []) +
880
- ') — the engine increments a wall\'s count only through the `count` hook; ' +
881
- 'add hooks: [\'count\'] (preset \'detector-screen\' = destroy + count).'
882
- );
883
- }
884
- if (!this._arrivals) { this._arrivals = { td: null, total: 0, delta: 0 }; }
885
- var a = this._arrivals;
886
- if (tickData != null && tickData !== a.td) {
887
- if (tickData !== this.universe._lastTickData) {
888
- throw new Error('[Wall.getArrivals] "' + this.name + '": this is not the TickData its ' +
889
- 'own universe last produced (universe._lastTickData) — it is another world\'s, ' +
890
- 'where handle ' + this.lo.handle + ' is a different wall, or an earlier tick of ' +
891
- 'this one. Sample the TickData this wall\'s universe.doTick() just returned. (FAIL-LOUD.)');
892
- }
893
- var handle = this.lo.handle;
894
- var oc = tickData.objects && tickData.objects[handle];
895
- if (!oc || typeof oc.count !== 'number') {
896
- throw new Error('[Wall.getArrivals] "' + this.name + '": this world\'s TickData carries no ' +
897
- 'objects[' + handle + '].count — every registered LargeObject is marshalled each ' +
898
- 'tick, so the wall is not registered here. (FAIL-LOUD.)');
899
- }
900
- var total = oc.count;
901
- a.delta = total - a.total;
902
- a.total = total;
903
- a.td = tickData;
904
- }
905
- return { total: a.total, delta: a.delta };
906
- };
907
-
908
821
  /**
909
822
  * ABSORB v2 readout: the wall's live { stored, absorbedTotal, radiatedTotal } (the
910
823
  * REAL backing-frame mass ledger). Throws on a non-absorb wall. Call between ticks.
@@ -971,7 +884,7 @@ import { wallBehaviorV2ValuesMap as _wallBehaviorV2ValuesMap, bounceDirectionVal
971
884
  'on. Zero physics of its own.',
972
885
  // STUDIO UX presentation contract (A0 vocab, owned at lib/shim/field-descriptor).
973
886
  // A wall has a genuine draggable/resizable extent (unlike the two-radii
974
- // SphereEmitter) → resizable:true (resize zones are 2D; the 3D Hand only moves).
887
+ // SphereEmitter) → resizable:true. 2D drag only (3D reposition via the camera).
975
888
  // shellRender:'run' — a wall is a boundary you SEE during Run (not a Design-only
976
889
  // marker like an emitter), so its shell always paints.
977
890
  ux: {
@@ -44,6 +44,7 @@
44
44
  import { CameraControls, FrqtlControlOverlay, FrqtlControlsPanel, GraphingDetectorWall, SphereEmitter, Tunnel, Wall } from '@descix/frqtl-web/parts';
45
45
  import * as ControlRegistry from '@descix/frqtl-web/shim/controls/registry.js';
46
46
  import * as FrqtlDisplay from '@descix/frqtl-web/compat/renderer/display-slot.js';
47
+ import * as SunLook from '@descix/frqtl-web/shim/render/sun-look.js';
47
48
 
48
49
  const CW = 600, H = 400, WORLD_D = 600; // THE WORLD this scene states (its co-init call below)
49
50
  // GEOMETRY and WAVELENGTH are two INDEPENDENT dials, and they are kept apart on
@@ -223,45 +224,33 @@ export default function buildExperiment(exp) {
223
224
  collisionBehavior: 'destroy', name: 'zClipFar', visible: false });
224
225
  exp.addObject('Wall', { rect: [0, 0, CW, H], z: -zHalf - 40, depth: 40,
225
226
  collisionBehavior: 'destroy', name: 'zClipNear', visible: false });
226
- // PACING (wall-clock only, never the ticks): 240 ticks/s, four times the 1:1 lock on a
227
- // 60 Hz display, so the interference bands build up four times sooner in real time.
228
- exp.runner.setRateLimits({ tpsLimit: 240 });
229
- // THE SWITCH: this scene's god-ray look, computed from the light particles only (godraySource
230
- // 'leaf') with the 'field' pass (each pixel marches along the local direction of travel), and the
231
- // per-layer glow under it. The numbers are this scene's own, set by eye against a reference
232
- // STUDIO picture (godrays 2.2 of [0, 3], godrayDensity 1.5 = the top of [0.2, 1.5],
233
- // glowIntensity 0.66 of [0, 3]); the renderer declares the keys and their ranges and refuses any
234
- // other. Default ON: the scene writes ON once at build, through the same function the knob calls.
235
- // OFF restores EXACTLY what was live before the last ON (a host row, a STUDIO slider), through
236
- // the same declared door. The knob shows its last written value (a render write has no
237
- // read-back). The picture changes at the next drawn tick, so in a paused (Design) view it shows
238
- // once the scene runs.
239
- var RAYS_ON = { godrays: 2.2, godrayDensity: 1.5, godrayMode: 'field', godraySource: 'leaf', glowIntensity: 0.66 };
240
- var RAYS_DEFAULT = 1;
241
- var raysPrior = null; // the live values of RAYS_ON's keys captured at ON; written back at OFF
242
- function setRays(v) {
243
- if (v) {
244
- // Capture only on the OFF -> ON edge: an ON pressed while already ON keeps the pre-ON state.
245
- if (!raysPrior) {
246
- raysPrior = {};
247
- Object.keys(RAYS_ON).forEach(function (k) { raysPrior[k] = exp.runner.getRenderOption(k); });
248
- }
249
- exp.runner.setRenderOptions(RAYS_ON);
250
- } else if (raysPrior) {
251
- exp.runner.setRenderOptions(raysPrior);
252
- raysPrior = null;
253
- }
254
- // OFF with nothing captured: nothing was written by this switch — no write.
255
- }
227
+ // THE SWITCH: god-rays computed from the light particles only (godraySource
228
+ // 'leaf'), at the sun's settings — the ONE owner of those numbers is lib/shim/render/sun-look.js
229
+ // (SunLook); this file types none of them. Default OFF (the first-contact picture is
230
+ // unchanged). OFF restores EXACTLY what was live before the last ON (a host row, a STUDIO
231
+ // slider), through the same declared door; a value the renderer does not declare THROWS there.
232
+ // The knob shows its last written value (a render write has no read-back). The picture changes
233
+ // at the next drawn tick, so in a paused (Design) view it shows once the scene runs.
234
+ var RAYS_ON = Object.assign({}, SunLook.SUN_GODRAYS, { godraySource: 'leaf' });
235
+ var raysPrior = null; // the three live values captured at ON; written back at OFF
256
236
  var knobs = ControlRegistry.makeControlRegistry();
257
237
  knobs.registerControls('dse-tunnel-rebuild', [
258
238
  { kind: 'scalar', id: 'godrays', label: 'god rays', channel: 'render', widget: 'toggle',
259
- min: 0, max: 1, step: 1, value: RAYS_DEFAULT,
239
+ min: 0, max: 1, step: 1, value: 0,
260
240
  fmt: function (v) { return v ? 'on' : 'off'; },
261
- onChange: setRays,
241
+ onChange: function (v) {
242
+ if (v) {
243
+ raysPrior = {};
244
+ Object.keys(RAYS_ON).forEach(function (k) { raysPrior[k] = exp.runner.getRenderOption(k); });
245
+ exp.runner.setRenderOptions(RAYS_ON);
246
+ } else if (raysPrior) {
247
+ exp.runner.setRenderOptions(raysPrior);
248
+ raysPrior = null;
249
+ }
250
+ // OFF with nothing captured: the control is at its initial OFF and has written nothing — no write.
251
+ },
262
252
  place: { x: 0.02, y: 0.04 } }
263
253
  ]);
264
- setRays(RAYS_DEFAULT);
265
254
  // Chrome (a page only): expose the knob to a host frame, and mount the overlay through the
266
255
  // runner's ONE door (runner.controlHost) — before a canvas is mounted (a notebook pane) there is
267
256
  // none, so the knob stays in the exposed registry only.
@@ -32,10 +32,10 @@
32
32
  // (d) the population counter carries a z-slab covering the WHOLE universe z-band (the emitter's
33
33
  // gateCounter names it, so it stays a code declaration);
34
34
  // (e) MOVE/LOOK camera joysticks (the OMNI_3D pattern).
35
- // The 3D mode's render intent — the particles hidden so the light field alone shows, strong
36
- // 'field' god-rays computed from the light particles only (godraySource 'leaf'), a soft glow, and
37
- // a face-on camera close enough that the ring spans the canvas height — rides the registry mode's
38
- // renderState (lib/shim/registry/walkthrough.js), its one home.
35
+ // The 3D mode's render intent — god-rays at the sun's settings, computed from the light
36
+ // particles only (godraySource 'leaf'), and the 'table-top' camera — rides the registry mode's
37
+ // renderState (lib/shim/registry/walkthrough.js), whose god-ray VALUES are the sun's, owned by
38
+ // lib/shim/render/sun-look.js.
39
39
 
40
40
  import { CameraControls, SphereEmitter, Wall } from '@descix/frqtl-web/parts';
41
41
  import * as FrqtlDisplay from '@descix/frqtl-web/compat/renderer/display-slot.js';
@@ -64,9 +64,6 @@ const vpos = function (v) { var a = (v * 36 + ROT) * D2R; return [CX + R * Math.
64
64
  const pos = order.map(vpos);
65
65
  const deg = function (a) { return ((a * 180 / Math.PI) % 360 + 360) % 360; };
66
66
  const angOf = function (p, q) { return deg(Math.atan2(q[1] - p[1], q[0] - p[0])); };
67
- // Where each mirror belongs: m1..m10 by name, at its star vertex (the centre of the slot in the ring). m4 and m6
68
- // are declared off theirs below; STUDIO's "try it" reads this to know when a dragged mirror is home.
69
- export const starPoints = Object.freeze(Object.fromEntries(pos.map(function (p, i) { return ['m' + (i + 1), Object.freeze(p.slice())]; })));
70
67
  // Per-mirror IN-PLANE orientation from the in/out chords: ori = (in+out−180)/2, branch chosen
71
68
  // so the engine reflect law out = 180 + 2·ori − in reproduces the outgoing chord exactly.
72
69
  // Orientation is z-axis rotation, so the 3D slab depth adds NO new angle.
@@ -104,10 +101,9 @@ export const parts = {
104
101
  m1: [Wall, { rect: [Math.round(pos[0][0] - SW / 2), Math.round(pos[0][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[0], color: PAL[0], hooks: ['recolor'] }],
105
102
  m2: [Wall, { rect: [Math.round(pos[1][0] - SW / 2), Math.round(pos[1][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[1], color: PAL[1], hooks: ['recolor'] }],
106
103
  m3: [Wall, { rect: [Math.round(pos[2][0] - SW / 2), Math.round(pos[2][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[2], color: PAL[2], hooks: ['recolor'] }],
107
- // m4 and m6 stand OFF their star vertices (m4 5 px right, m6 67 px toward the centre): the ring opens broken, so dragging one home is the thing to try.
108
- m4: [Wall, { rect: [437, 103, SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[3], color: PAL[3], hooks: ['recolor'] }],
104
+ m4: [Wall, { rect: [Math.round(pos[3][0] - SW / 2), Math.round(pos[3][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[3], color: PAL[3], hooks: ['recolor'] }],
109
105
  m5: [Wall, { rect: [Math.round(pos[4][0] - SW / 2), Math.round(pos[4][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[4], color: PAL[4], hooks: ['recolor'] }],
110
- m6: [Wall, { rect: [215, 142, SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[5], color: PAL[5], hooks: ['recolor'] }],
106
+ m6: [Wall, { rect: [Math.round(pos[5][0] - SW / 2), Math.round(pos[5][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[5], color: PAL[5], hooks: ['recolor'] }],
111
107
  m7: [Wall, { rect: [Math.round(pos[6][0] - SW / 2), Math.round(pos[6][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[6], color: PAL[6], hooks: ['recolor'] }],
112
108
  m8: [Wall, { rect: [Math.round(pos[7][0] - SW / 2), Math.round(pos[7][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[7], color: PAL[7], hooks: ['recolor'] }],
113
109
  m9: [Wall, { rect: [Math.round(pos[8][0] - SW / 2), Math.round(pos[8][1] - SH / 2), SW, SH], z: -Math.round(SD / 2), depth: SD, collisionBehavior: 'bounce', bounceDirection: 'reflect', orientationDeg: ORI[8], color: PAL[8], hooks: ['recolor'] }],