stickyflow 0.6.0 → 0.8.0

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 (62) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/binding/index.cjs +9 -9
  3. package/dist/binding/index.d.cts +4 -4
  4. package/dist/binding/index.d.ts +4 -4
  5. package/dist/binding/index.js +3 -3
  6. package/dist/{chunk-MFNUJA26.js → chunk-CZW3ARXQ.js} +156 -23
  7. package/dist/chunk-CZW3ARXQ.js.map +1 -0
  8. package/dist/{chunk-WRDVNMFS.js → chunk-EDOPENSE.js} +848 -38
  9. package/dist/chunk-EDOPENSE.js.map +1 -0
  10. package/dist/{chunk-4LENHH6C.cjs → chunk-FQ7GMLCM.cjs} +15 -15
  11. package/dist/{chunk-4LENHH6C.cjs.map → chunk-FQ7GMLCM.cjs.map} +1 -1
  12. package/dist/{chunk-4G2R7PEL.js → chunk-GLZVHUSW.js} +220 -12
  13. package/dist/chunk-GLZVHUSW.js.map +1 -0
  14. package/dist/{chunk-KTNCDNDB.cjs → chunk-IR2T47NW.cjs} +876 -66
  15. package/dist/chunk-IR2T47NW.cjs.map +1 -0
  16. package/dist/{chunk-ULQZ6CZW.js → chunk-LFEGZJWC.js} +3 -3
  17. package/dist/{chunk-ULQZ6CZW.js.map → chunk-LFEGZJWC.js.map} +1 -1
  18. package/dist/{chunk-XJ4W6TW4.cjs → chunk-LNW5VIEA.cjs} +225 -11
  19. package/dist/chunk-LNW5VIEA.cjs.map +1 -0
  20. package/dist/{chunk-FVHVOJS2.js → chunk-MAPNY7MJ.js} +872 -174
  21. package/dist/chunk-MAPNY7MJ.js.map +1 -0
  22. package/dist/{chunk-WQRT5PVT.cjs → chunk-VOYX6JMW.cjs} +1479 -780
  23. package/dist/chunk-VOYX6JMW.cjs.map +1 -0
  24. package/dist/{chunk-JIJMZMGY.cjs → chunk-XPM3E7NV.cjs} +170 -37
  25. package/dist/chunk-XPM3E7NV.cjs.map +1 -0
  26. package/dist/index.cjs +42 -34
  27. package/dist/index.d.cts +34 -6
  28. package/dist/index.d.ts +34 -6
  29. package/dist/index.js +5 -5
  30. package/dist/interaction/index.cjs +266 -235
  31. package/dist/interaction/index.cjs.map +1 -1
  32. package/dist/interaction/index.d.cts +2 -2
  33. package/dist/interaction/index.d.ts +2 -2
  34. package/dist/interaction/index.js +42 -11
  35. package/dist/interaction/index.js.map +1 -1
  36. package/dist/{render-Db0eSz_s.d.cts → render-Bp2FLEzv.d.cts} +14 -1
  37. package/dist/{render-Db0eSz_s.d.ts → render-Bp2FLEzv.d.ts} +14 -1
  38. package/dist/{runtime-n2yG-_j-.d.ts → runtime-CWIGxRcL.d.ts} +2 -2
  39. package/dist/{runtime-BhivvBeL.d.cts → runtime-DIag-XBa.d.cts} +2 -2
  40. package/dist/{runtimeTypes-DnI7mRF5.d.ts → runtimeTypes-BYODuxHk.d.cts} +2 -1
  41. package/dist/{runtimeTypes-CrkMHvVi.d.cts → runtimeTypes-C7sSLfOK.d.ts} +2 -1
  42. package/dist/stickyflow-diagram.global.js +490 -36
  43. package/dist/stickyflow-diagram.global.js.map +1 -1
  44. package/dist/{types-D4cH4f1a.d.ts → types-B9QM_H3R.d.ts} +1 -1
  45. package/dist/{types-BHfUKT4s.d.cts → types-D2w6D_wG.d.cts} +1 -1
  46. package/dist/viewer/index.cjs +9 -9
  47. package/dist/viewer/index.d.cts +5 -4
  48. package/dist/viewer/index.d.ts +5 -4
  49. package/dist/viewer/index.js +4 -4
  50. package/dist/web-component/index.cjs +6 -6
  51. package/dist/web-component/index.d.cts +2 -2
  52. package/dist/web-component/index.d.ts +2 -2
  53. package/dist/web-component/index.js +4 -4
  54. package/package.json +1 -1
  55. package/dist/chunk-4G2R7PEL.js.map +0 -1
  56. package/dist/chunk-FVHVOJS2.js.map +0 -1
  57. package/dist/chunk-JIJMZMGY.cjs.map +0 -1
  58. package/dist/chunk-KTNCDNDB.cjs.map +0 -1
  59. package/dist/chunk-MFNUJA26.js.map +0 -1
  60. package/dist/chunk-WQRT5PVT.cjs.map +0 -1
  61. package/dist/chunk-WRDVNMFS.js.map +0 -1
  62. package/dist/chunk-XJ4W6TW4.cjs.map +0 -1
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var chunkWQRT5PVT_cjs = require('./chunk-WQRT5PVT.cjs');
4
- var chunk4LENHH6C_cjs = require('./chunk-4LENHH6C.cjs');
5
- var chunkXJ4W6TW4_cjs = require('./chunk-XJ4W6TW4.cjs');
3
+ var chunkVOYX6JMW_cjs = require('./chunk-VOYX6JMW.cjs');
4
+ var chunkFQ7GMLCM_cjs = require('./chunk-FQ7GMLCM.cjs');
5
+ var chunkLNW5VIEA_cjs = require('./chunk-LNW5VIEA.cjs');
6
6
 
7
7
  // src/runtime/viewer/components/rollingNumberDom.ts
8
8
  var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
@@ -162,12 +162,12 @@ function componentDigits(surface) {
162
162
  function componentStyle(surface) {
163
163
  const encoded = surface.getAttribute("data-sf-widget-style");
164
164
  if (!encoded) {
165
- return chunkXJ4W6TW4_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
165
+ return chunkLNW5VIEA_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
166
166
  }
167
167
  try {
168
- return { ...chunkXJ4W6TW4_cjs.DEFAULT_ROLLING_NUMBER_STYLE, ...JSON.parse(encoded) };
168
+ return { ...chunkLNW5VIEA_cjs.DEFAULT_ROLLING_NUMBER_STYLE, ...JSON.parse(encoded) };
169
169
  } catch {
170
- return chunkXJ4W6TW4_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
170
+ return chunkLNW5VIEA_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
171
171
  }
172
172
  }
173
173
  function positiveInteger(value) {
@@ -191,7 +191,7 @@ function setRollingNumber(surface, value, animate) {
191
191
  return false;
192
192
  }
193
193
  const previousValue = surface.getAttribute("data-sf-widget-value") ?? "";
194
- const nextValue = chunkXJ4W6TW4_cjs.formatRollingNumber(value, positiveInteger(surface.getAttribute("data-sf-widget-digits")));
194
+ const nextValue = chunkLNW5VIEA_cjs.formatRollingNumber(value, positiveInteger(surface.getAttribute("data-sf-widget-digits")));
195
195
  if (previousValue === nextValue) {
196
196
  return true;
197
197
  }
@@ -667,7 +667,7 @@ function mountDisplay(container, svgString) {
667
667
  }
668
668
 
669
669
  // src/runtime/viewer/events.ts
670
- var Emitter2 = class extends chunk4LENHH6C_cjs.Emitter {
670
+ var Emitter2 = class extends chunkFQ7GMLCM_cjs.Emitter {
671
671
  };
672
672
 
673
673
  // src/runtime/viewer/export/raster.ts
@@ -757,11 +757,11 @@ function svgElement(document, name, attributes) {
757
757
  function readComponentStyle(surface) {
758
758
  try {
759
759
  return {
760
- ...chunkXJ4W6TW4_cjs.DEFAULT_ROLLING_NUMBER_STYLE,
760
+ ...chunkLNW5VIEA_cjs.DEFAULT_ROLLING_NUMBER_STYLE,
761
761
  ...JSON.parse(surface.getAttribute("data-sf-widget-style") ?? "{}")
762
762
  };
763
763
  } catch {
764
- return chunkXJ4W6TW4_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
764
+ return chunkLNW5VIEA_cjs.DEFAULT_ROLLING_NUMBER_STYLE;
765
765
  }
766
766
  }
767
767
  function cellsOf(box, plain, fontSize = 0) {
@@ -901,7 +901,7 @@ function serializeSvgSnapshot(svg, captures) {
901
901
  // src/runtime/viewer/interaction/changeFlash.ts
902
902
  function createChangeFlash(svg) {
903
903
  const timers = /* @__PURE__ */ new Map();
904
- const flash = (ownerIds, color2 = chunk4LENHH6C_cjs.CHANGE_COLOR) => {
904
+ const flash = (ownerIds, color2 = chunkFQ7GMLCM_cjs.CHANGE_COLOR) => {
905
905
  const ids = [...new Set(ownerIds)];
906
906
  if (ids.length === 0) {
907
907
  return;
@@ -909,7 +909,7 @@ function createChangeFlash(svg) {
909
909
  const doc = svg.ownerDocument;
910
910
  const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false;
911
911
  for (const id of ids) {
912
- const primary = chunk4LENHH6C_cjs.findOwnerNode(svg, id, chunk4LENHH6C_cjs.isPrimary);
912
+ const primary = chunkFQ7GMLCM_cjs.findOwnerNode(svg, id, chunkFQ7GMLCM_cjs.isPrimary);
913
913
  if (!primary) {
914
914
  continue;
915
915
  }
@@ -920,10 +920,10 @@ function createChangeFlash(svg) {
920
920
  for (const stale of svg.querySelectorAll(`[data-sf-change-overlay="${CSS.escape(id)}"]`)) {
921
921
  stale.remove();
922
922
  }
923
- const overlay = primary.getAttribute("data-sf-role") === "link" ? chunk4LENHH6C_cjs.linkChangeOverlay(doc, primary, id, color2) : chunk4LENHH6C_cjs.shapeChangeOverlay(doc, primary, id, color2);
923
+ const overlay = primary.getAttribute("data-sf-role") === "link" ? chunkFQ7GMLCM_cjs.linkChangeOverlay(doc, primary, id, color2) : chunkFQ7GMLCM_cjs.shapeChangeOverlay(doc, primary, id, color2);
924
924
  svg.appendChild(overlay);
925
- chunk4LENHH6C_cjs.startChangeFade(overlay, reducedMotion);
926
- const duration = reducedMotion ? chunk4LENHH6C_cjs.REDUCED_MOTION_DURATION_MS : chunk4LENHH6C_cjs.FLASH_DURATION_MS;
925
+ chunkFQ7GMLCM_cjs.startChangeFade(overlay, reducedMotion);
926
+ const duration = reducedMotion ? chunkFQ7GMLCM_cjs.REDUCED_MOTION_DURATION_MS : chunkFQ7GMLCM_cjs.FLASH_DURATION_MS;
927
927
  timers.set(
928
928
  id,
929
929
  setTimeout(() => {
@@ -1010,7 +1010,7 @@ var OwnerPointerController = class {
1010
1010
  this.#selection = selection;
1011
1011
  }
1012
1012
  hover(event) {
1013
- const owner = chunk4LENHH6C_cjs.resolveOwner(event.target);
1013
+ const owner = chunkFQ7GMLCM_cjs.resolveOwner(event.target);
1014
1014
  this.#emitter.emit(
1015
1015
  "ownerHover",
1016
1016
  owner ? { diagramId: this.#diagramId, owner, modifiers: modifiersOf(event) } : { diagramId: this.#diagramId, owner: null }
@@ -1018,7 +1018,7 @@ var OwnerPointerController = class {
1018
1018
  }
1019
1019
  select(event) {
1020
1020
  const target = event.target;
1021
- const owner = chunk4LENHH6C_cjs.resolveOwner(target);
1021
+ const owner = chunkFQ7GMLCM_cjs.resolveOwner(target);
1022
1022
  if (!owner) {
1023
1023
  this.#clearWhenOutsideOverlay(target);
1024
1024
  return;
@@ -1039,7 +1039,7 @@ var OwnerPointerController = class {
1039
1039
  owner,
1040
1040
  modifiers
1041
1041
  });
1042
- const node = chunk4LENHH6C_cjs.findOwnerNode(this.#svg, owner.id, chunk4LENHH6C_cjs.isPrimary);
1042
+ const node = chunkFQ7GMLCM_cjs.findOwnerNode(this.#svg, owner.id, chunkFQ7GMLCM_cjs.isPrimary);
1043
1043
  if (node && !node.hasAttribute("tabindex")) {
1044
1044
  node.setAttribute("tabindex", "-1");
1045
1045
  }
@@ -1067,12 +1067,12 @@ var PointerInteractionSession = class {
1067
1067
  }
1068
1068
  #onPointerDown = (event) => {
1069
1069
  const target = event.target;
1070
- const overContent = Boolean(chunk4LENHH6C_cjs.resolveOwner(target)) || isSelectionOverlayControl(target);
1070
+ const overContent = Boolean(chunkFQ7GMLCM_cjs.resolveOwner(target)) || isSelectionOverlayControl(target);
1071
1071
  this.#down = {
1072
1072
  x: event.clientX,
1073
1073
  y: event.clientY,
1074
1074
  moved: false,
1075
- panable: chunk4LENHH6C_cjs.isCameraGesture(event) || !overContent
1075
+ panable: chunkFQ7GMLCM_cjs.isCameraGesture(event) || !overContent
1076
1076
  };
1077
1077
  };
1078
1078
  #onPointerMove = (event) => {
@@ -1100,7 +1100,7 @@ var PointerInteractionSession = class {
1100
1100
  if (!this.#down.moved) {
1101
1101
  return false;
1102
1102
  }
1103
- if (this.#down.panable && chunk4LENHH6C_cjs.isCameraGesture(event)) {
1103
+ if (this.#down.panable && chunkFQ7GMLCM_cjs.isCameraGesture(event)) {
1104
1104
  this.#display.panBy(event.movementX, event.movementY);
1105
1105
  }
1106
1106
  return true;
@@ -1124,15 +1124,15 @@ function paintSelectionOverlays(svg, selectedIds, owners) {
1124
1124
  }
1125
1125
  const document = svg.ownerDocument;
1126
1126
  for (const id of selectedIds) {
1127
- const primary = chunk4LENHH6C_cjs.findOwnerNode(svg, id, chunk4LENHH6C_cjs.isPrimary);
1127
+ const primary = chunkFQ7GMLCM_cjs.findOwnerNode(svg, id, chunkFQ7GMLCM_cjs.isPrimary);
1128
1128
  if (!primary) {
1129
1129
  continue;
1130
1130
  }
1131
1131
  const owner = owners.get(id);
1132
- const overlay = owner?.role === "link" ? chunk4LENHH6C_cjs.linkSelectionOverlay(document, primary, id, svg) : owner?.role === "path" ? chunk4LENHH6C_cjs.pathSelectionOverlay(document, primary, id, svg) : owner?.role === "isometric" ? chunk4LENHH6C_cjs.isometricSelectionOverlay(document, primary, id, svg) : chunk4LENHH6C_cjs.shapeSelectionOverlay(document, primary, id, svg, owner ? chunk4LENHH6C_cjs.DERIVED_HEIGHT_ROLES.has(owner.role) : false);
1132
+ const overlay = owner?.role === "link" ? chunkFQ7GMLCM_cjs.linkSelectionOverlay(document, primary, id, svg) : owner?.role === "path" ? chunkFQ7GMLCM_cjs.pathSelectionOverlay(document, primary, id, svg) : owner?.role === "isometric" ? chunkFQ7GMLCM_cjs.isometricSelectionOverlay(document, primary, id, svg) : chunkFQ7GMLCM_cjs.shapeSelectionOverlay(document, primary, id, svg, owner ? chunkFQ7GMLCM_cjs.DERIVED_HEIGHT_ROLES.has(owner.role) : false);
1133
1133
  svg.appendChild(overlay);
1134
1134
  if (owner?.role === "shape" && selectedIds.size === 1) {
1135
- svg.appendChild(chunk4LENHH6C_cjs.quickDuplicateBubbles(document, primary, id, svg));
1135
+ svg.appendChild(chunkFQ7GMLCM_cjs.quickDuplicateBubbles(document, primary, id, svg));
1136
1136
  }
1137
1137
  }
1138
1138
  }
@@ -1171,7 +1171,7 @@ var SelectionController = class {
1171
1171
  selectIds(ids) {
1172
1172
  for (const id of ids) {
1173
1173
  const element = this.#svg.querySelector(`[data-sf-id="${CSS.escape(id)}"]`);
1174
- const owner = chunk4LENHH6C_cjs.resolveOwner(element);
1174
+ const owner = chunkFQ7GMLCM_cjs.resolveOwner(element);
1175
1175
  if (owner) {
1176
1176
  this.remember(owner);
1177
1177
  }
@@ -1183,7 +1183,7 @@ var SelectionController = class {
1183
1183
  // src/runtime/viewer/interaction/wheel.ts
1184
1184
  function bindWheelZoom(display, selection) {
1185
1185
  const onWheel = (event) => {
1186
- if (!chunk4LENHH6C_cjs.isCameraGesture(event)) {
1186
+ if (!chunkFQ7GMLCM_cjs.isCameraGesture(event)) {
1187
1187
  return;
1188
1188
  }
1189
1189
  event.preventDefault();
@@ -1767,10 +1767,136 @@ var glassRefractionProgram = {
1767
1767
  usesBackdrop: true
1768
1768
  };
1769
1769
 
1770
- // src/runtime/viewer/shaders/builtins/halftoneHalo.ts
1770
+ // src/runtime/viewer/shaders/builtins/glowCard.ts
1771
1771
  var fragmentSource8 = `
1772
1772
  precision highp float;
1773
1773
 
1774
+ uniform vec2 uResolution;
1775
+ uniform float uTime;
1776
+ uniform float uSpeed;
1777
+ uniform float uIntensity;
1778
+ uniform float uGlowHeight;
1779
+ uniform float uGlowSpread;
1780
+ uniform float uCore;
1781
+ uniform float uRim;
1782
+ uniform float uGrain;
1783
+ uniform float uWarp;
1784
+ uniform float uAngle;
1785
+ uniform float uCornerRadius;
1786
+ uniform vec3 uBaseColor;
1787
+ uniform vec3 uColorA;
1788
+ uniform vec3 uColorB;
1789
+ uniform vec3 uColorC;
1790
+ varying vec2 vUv;
1791
+
1792
+ float hash(vec2 p) {
1793
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
1794
+ }
1795
+
1796
+ float blob(vec2 p, vec2 center, vec2 size) {
1797
+ vec2 d = (p - center) / size;
1798
+ return exp(-dot(d, d));
1799
+ }
1800
+
1801
+ float noise(vec2 p) {
1802
+ vec2 i = floor(p);
1803
+ vec2 f = fract(p);
1804
+ vec2 u = f * f * (3.0 - 2.0 * f);
1805
+ return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x), mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x), u.y);
1806
+ }
1807
+
1808
+ float fbm(vec2 p) {
1809
+ return 0.5 * noise(p) + 0.25 * noise(p * 2.03 + 3.1) + 0.125 * noise(p * 4.01 + 7.7);
1810
+ }
1811
+
1812
+ void main() {
1813
+ vec2 size = max(uResolution, vec2(1.0));
1814
+ float radius = uCornerRadius * min(size.x, size.y);
1815
+ vec2 q = abs(vUv * size - size * 0.5) - size * 0.5 + radius;
1816
+ float distance = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
1817
+ float shape = 1.0 - smoothstep(-1.0, 1.0, distance);
1818
+ if (shape <= 0.0) discard;
1819
+
1820
+ // The light comes from one side. Angle 0 is the bottom edge, and it turns clockwise: 90 is the left, 180 the top, 270 the right.
1821
+ // depth is 0 at the edge the light comes from and 1 at the far side, side runs along that edge.
1822
+ float turn = radians(uAngle);
1823
+ vec2 toward = vec2(-sin(turn), -cos(turn));
1824
+ vec2 across = vec2(-toward.y, toward.x);
1825
+ vec2 offset = (vUv - 0.5) * size;
1826
+ float reachAlong = 0.5 * (abs(toward.x) * size.x + abs(toward.y) * size.y);
1827
+ float reachAcross = 0.5 * (abs(across.x) * size.x + abs(across.y) * size.y);
1828
+ float depth = clamp(0.5 - dot(offset, toward) / (2.0 * reachAlong), 0.0, 1.0);
1829
+ float side = clamp(0.5 + dot(offset, across) / (2.0 * reachAcross), 0.0, 1.0);
1830
+ float aspect = reachAcross / reachAlong;
1831
+
1832
+ float t = uTime * max(uSpeed, 0.0);
1833
+ float height = clamp(uGlowHeight, 0.05, 1.0);
1834
+ float spread = max(uGlowSpread, 0.05);
1835
+ // The body is the base color with a faint lift toward the far side, like glass that catches the light.
1836
+ vec3 color = uBaseColor + vec3(0.035) * smoothstep(0.55, 1.0, 1.0 - depth);
1837
+
1838
+ // Three soft lights sit low in the card and drift slowly; the middle one is the broadest.
1839
+ vec2 p = vec2(side * aspect, depth);
1840
+ // The lights are bent by slow noise, so their edges curl like smoke instead of staying round.
1841
+ vec2 bend = vec2(fbm(p * 2.6 + vec2(t * 0.6, 0.0)), fbm(p * 2.6 + vec2(5.2, -t * 0.5))) - 0.35;
1842
+ p += bend * max(uWarp, 0.0) * 0.45;
1843
+ float wander = 0.05 * sin(t);
1844
+ float a = blob(p, vec2((0.18 + wander) * aspect, 0.0), vec2(0.5 * spread * aspect, 0.42 * height));
1845
+ float b = blob(p, vec2((0.52 - wander) * aspect, -0.04), vec2(0.62 * spread * aspect, 0.5 * height));
1846
+ float c = blob(p, vec2((0.86 + wander * 0.6) * aspect, 0.02), vec2(0.5 * spread * aspect, 0.44 * height));
1847
+ // Each light is thicker in some places than in others, so the colors mix unevenly.
1848
+ float patchy = fbm(p * 4.0 + 11.0);
1849
+ a *= 0.55 + 0.9 * patchy;
1850
+ b *= 0.55 + 0.9 * (1.0 - patchy);
1851
+ c *= 0.55 + 0.9 * fbm(p * 4.0 + 23.0);
1852
+ vec3 glow = uColorA * a + uColorB * b + uColorC * c;
1853
+
1854
+ // A haze reaches higher than the lights, so the color fades out into the body.
1855
+ float haze = smoothstep(height, 0.0, depth);
1856
+ glow += mix(uColorB, uColorA, side) * haze * haze * 0.35;
1857
+ color += glow * max(uIntensity, 0.0);
1858
+
1859
+ // Near the exit edge the lights are so strong that they turn white.
1860
+ float hot = smoothstep(height * 0.38, 0.0, depth) * (a + b + c) * clamp(uCore, 0.0, 1.0);
1861
+ color = mix(color, vec3(0.93, 0.95, 1.0), clamp(hot, 0.0, 1.0));
1862
+
1863
+ // A thin rim along the edge, strongest on the side away from the light.
1864
+ float rim = (1.0 - smoothstep(0.0, 1.6, -distance)) * smoothstep(0.0, 1.0, -distance + 1.0);
1865
+ color += vec3(0.62, 0.66, 0.78) * rim * max(uRim, 0.0) * (0.35 + 0.65 * smoothstep(0.2, 1.0, 1.0 - depth));
1866
+
1867
+ // The grit sits in the lit parts and fades in the dark body, as on film.
1868
+ float lit = clamp(dot(glow, vec3(0.45)) * max(uIntensity, 0.0) + hot, 0.0, 1.0);
1869
+ float grit = hash(gl_FragCoord.xy) - 0.5;
1870
+ grit += 0.5 * (hash(floor(gl_FragCoord.xy * 0.5) + 17.0) - 0.5);
1871
+ color += grit * max(uGrain, 0.0) * (0.3 + 2.2 * lit * (1.0 - 0.5 * lit));
1872
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
1873
+ }
1874
+ `;
1875
+ var glowCardProgram = {
1876
+ name: "glowCard",
1877
+ fragmentSource: fragmentSource8,
1878
+ defaultParameters: {
1879
+ speed: 0.12,
1880
+ intensity: 1,
1881
+ glowHeight: 0.55,
1882
+ glowSpread: 1,
1883
+ core: 0.7,
1884
+ rim: 0.55,
1885
+ grain: 0.12,
1886
+ warp: 1,
1887
+ angle: 0,
1888
+ cornerRadius: 0.08,
1889
+ baseColor: "#0b0b12",
1890
+ colorA: "#2f6bff",
1891
+ colorB: "#9d5cff",
1892
+ colorC: "#34d3c4"
1893
+ }
1894
+ };
1895
+
1896
+ // src/runtime/viewer/shaders/builtins/halftoneHalo.ts
1897
+ var fragmentSource9 = `
1898
+ precision highp float;
1899
+
1774
1900
  uniform vec2 uResolution;
1775
1901
  uniform float uTime;
1776
1902
  uniform float uSpeed;
@@ -1847,11 +1973,11 @@ void main() {
1847
1973
  `;
1848
1974
  var halftoneHaloProgram = {
1849
1975
  name: "halftoneHalo",
1850
- fragmentSource: fragmentSource8
1976
+ fragmentSource: fragmentSource9
1851
1977
  };
1852
1978
 
1853
1979
  // src/runtime/viewer/shaders/builtins/halo.ts
1854
- var fragmentSource9 = `
1980
+ var fragmentSource10 = `
1855
1981
  precision highp float;
1856
1982
 
1857
1983
  uniform vec2 uResolution;
@@ -1926,11 +2052,235 @@ void main() {
1926
2052
  `;
1927
2053
  var haloProgram = {
1928
2054
  name: "halo",
1929
- fragmentSource: fragmentSource9
2055
+ fragmentSource: fragmentSource10
2056
+ };
2057
+
2058
+ // src/runtime/viewer/shaders/builtins/ledMatrix.ts
2059
+ var fragmentSource11 = `
2060
+ precision highp float;
2061
+
2062
+ uniform vec2 uResolution;
2063
+ uniform float uTime;
2064
+ uniform float uSpeed;
2065
+ uniform float uIntensity;
2066
+ uniform float uColumns;
2067
+ uniform float uCellAspect;
2068
+ uniform float uGap;
2069
+ uniform float uGlow;
2070
+ uniform float uDepth;
2071
+ uniform float uGrain;
2072
+ uniform float uRotation;
2073
+ uniform float uRipple;
2074
+ uniform float uWave;
2075
+ uniform float uVariation;
2076
+ uniform float uFade;
2077
+ uniform float uOriginX;
2078
+ uniform float uOriginY;
2079
+ uniform float uSpread;
2080
+ uniform float uDrift;
2081
+ uniform float uReaction;
2082
+ uniform float uPointerSize;
2083
+ uniform float uHover;
2084
+ uniform vec2 uPointer;
2085
+ uniform vec3 uWake[16];
2086
+ uniform float uCornerRadius;
2087
+ uniform vec3 uBaseColor;
2088
+ uniform vec3 uOffColor;
2089
+ uniform vec3 uColor;
2090
+ uniform vec3 uHotColor;
2091
+ varying vec2 vUv;
2092
+
2093
+ float boxMask(vec2 uv) {
2094
+ vec2 halfBox = uResolution * 0.5;
2095
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
2096
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
2097
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
2098
+ return 1.0 - smoothstep(-1.0, 1.0, d);
2099
+ }
2100
+
2101
+ float roundedBox(vec2 point, vec2 halfSize, float radius) {
2102
+ vec2 q = abs(point) - halfSize + radius;
2103
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
2104
+ }
2105
+
2106
+ float hash(vec2 p) {
2107
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
2108
+ }
2109
+
2110
+ void main() {
2111
+ float shape = boxMask(vUv);
2112
+ if (shape <= 0.0) discard;
2113
+
2114
+ float time = uTime * max(uSpeed, 0.0);
2115
+ float columns = max(uColumns, 2.0);
2116
+ vec2 cellPx = vec2(uResolution.x / columns);
2117
+ cellPx.y *= max(uCellAspect, 0.2);
2118
+ vec2 rows = uResolution / cellPx;
2119
+
2120
+ // The grid can be turned around the middle of the surface.
2121
+ float angle = radians(uRotation);
2122
+ vec2 centered = (vUv - 0.5) * uResolution;
2123
+ vec2 turned = vec2(cos(angle) * centered.x - sin(angle) * centered.y, sin(angle) * centered.x + cos(angle) * centered.y);
2124
+ vec2 turnedUv = turned / uResolution + 0.5;
2125
+ vec2 grid = vec2(turnedUv.x, 1.0 - turnedUv.y) * rows;
2126
+ vec2 cell = floor(grid);
2127
+ vec2 local = (fract(grid) - 0.5) * cellPx;
2128
+ vec2 center = (cell + 0.5) / rows;
2129
+
2130
+ // The light of the surface sits at its origin, sways to the sides, and falls off with the spread. A spread of 0 puts it out.
2131
+ float spread = max(uSpread, 0.05);
2132
+ float lit = smoothstep(0.0, 0.05, uSpread);
2133
+ vec2 p = vec2(center.x, 1.0 - center.y);
2134
+ vec2 origin = vec2(uOriginX + uDrift * sin(time * 0.7), uOriginY);
2135
+ float aspect = uResolution.x / uResolution.y;
2136
+ float blob = exp(-pow(length((p - origin) * vec2(1.0, 1.55)) / spread, 2.0) * 5.5) * lit;
2137
+ float wave = 0.5 + 0.5 * sin(p.x * 5.0 + time * 1.3 + sin(p.y * 3.0 - time));
2138
+ float rise = pow(max(1.0 - abs(p.y - uOriginY) / spread, 0.0), 3.0) * (1.0 - 0.7 * uWave + 0.7 * uWave * wave) * lit;
2139
+ float glowLevel = blob * 1.15 + rise * 0.5 + 0.03;
2140
+
2141
+ // Rings that run outward from the light, and a different brightness for every light.
2142
+ float rings = 1.0 + uRipple * 0.5 * sin(length((p - origin) * vec2(1.0, 1.55)) * 16.0 - time * 2.5);
2143
+ float jitter = 1.0 - uVariation * 0.55 * hash(cell);
2144
+ float vignette = 1.0 - clamp(uFade, 0.0, 1.0) * smoothstep(0.3, 0.8, length(p - 0.5) * 1.3);
2145
+
2146
+ // The lights near the pointer glow up while it is over the surface, and the places it has been dim down one after the other.
2147
+ float near = exp(-pow(length((p - uPointer) * vec2(aspect, 1.0)) / max(uPointerSize, 0.01), 2.0)) * uHover;
2148
+ float wake = 0.0;
2149
+ for (int i = 0; i < 16; i++) {
2150
+ wake += uWake[i].z * exp(-pow(length((p - uWake[i].xy) * vec2(aspect, 1.0)) / max(uPointerSize * 0.88, 0.01), 2.0));
2151
+ }
2152
+ float touch = min(near + wake, 1.3) * max(uReaction, 0.0);
2153
+ float level = clamp(glowLevel * rings * jitter * vignette * max(uIntensity, 0.0) + touch * 1.1, 0.0, 1.0);
2154
+
2155
+ vec3 tint = mix(uOffColor, uColor, smoothstep(0.0, 0.6, level));
2156
+ tint = mix(tint, uHotColor, smoothstep(0.55, 1.0, level));
2157
+
2158
+ vec2 halfSize = cellPx * 0.5 * (1.0 - clamp(uGap, 0.0, 0.8));
2159
+ float d = roundedBox(local, halfSize, min(halfSize.x, halfSize.y));
2160
+ float body = 1.0 - smoothstep(-0.9, 0.9, d);
2161
+ // Depth shades a light like a small bulb: bright in the upper part, darker at the rim.
2162
+ float sheen = 1.0 - smoothstep(0.0, halfSize.y * 1.2, abs(local.y + halfSize.y * 0.35));
2163
+ float rim = smoothstep(-halfSize.x * 0.7, 0.0, d);
2164
+ float depth = clamp(uDepth, 0.0, 1.0);
2165
+ vec3 cellColor = tint * (1.0 - 0.4 * depth + 0.4 * depth * sheen) * (1.0 - 0.35 * depth * rim);
2166
+
2167
+ vec3 color = uBaseColor + tint * level * max(uGlow, 0.0) * 0.18;
2168
+ color = mix(color, cellColor, body);
2169
+ color += (hash(gl_FragCoord.xy) - 0.5) * max(uGrain, 0.0) * 0.2;
2170
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
2171
+ }
2172
+ `;
2173
+ var ledMatrixProgram = {
2174
+ name: "ledMatrix",
2175
+ fragmentSource: fragmentSource11,
2176
+ defaultParameters: {
2177
+ speed: 0.25,
2178
+ intensity: 1,
2179
+ columns: 44,
2180
+ cellAspect: 1.7,
2181
+ gap: 0.3,
2182
+ originX: 0.42,
2183
+ originY: 0.04,
2184
+ spread: 1,
2185
+ drift: 0.2,
2186
+ depth: 0.5,
2187
+ glow: 1,
2188
+ grain: 0.2,
2189
+ rotation: 0,
2190
+ ripple: 0.3,
2191
+ wave: 1,
2192
+ variation: 0.2,
2193
+ fade: 0.3,
2194
+ reaction: 1,
2195
+ pointerSize: 0.17,
2196
+ trail: 1.4,
2197
+ cornerRadius: 0.025,
2198
+ baseColor: "#050505",
2199
+ offColor: "#262626",
2200
+ color: "#a3a3a3",
2201
+ hotColor: "#ffffff"
2202
+ }
2203
+ };
2204
+
2205
+ // src/runtime/viewer/shaders/builtins/lightBand.ts
2206
+ var fragmentSource12 = `
2207
+ precision highp float;
2208
+
2209
+ uniform vec2 uResolution;
2210
+ uniform float uTime;
2211
+ uniform float uSpeed;
2212
+ uniform float uIntensity;
2213
+ uniform float uThickness;
2214
+ uniform float uBloom;
2215
+ uniform float uWave;
2216
+ uniform float uGrain;
2217
+ uniform float uCornerRadius;
2218
+ uniform vec3 uBaseColor;
2219
+ uniform vec3 uColorA;
2220
+ uniform vec3 uColorB;
2221
+ uniform vec3 uColorC;
2222
+ varying vec2 vUv;
2223
+
2224
+ float boxMask(vec2 uv) {
2225
+ vec2 halfBox = uResolution * 0.5;
2226
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
2227
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
2228
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
2229
+ return 1.0 - smoothstep(-1.0, 1.0, d);
2230
+ }
2231
+
2232
+ float hash(vec2 p) {
2233
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
2234
+ }
2235
+
2236
+ void main() {
2237
+ float shape = boxMask(vUv);
2238
+ if (shape <= 0.0) discard;
2239
+
2240
+ float t = uTime * max(uSpeed, 0.0);
2241
+ float aspect = uResolution.x / uResolution.y;
2242
+ vec2 p = vec2(vUv.x, 1.0 - vUv.y);
2243
+
2244
+ // The middle of the band wanders across the surface, and its width breathes along the way.
2245
+ float middle = 0.5 + uWave * (0.11 * sin(p.x * 3.4 + t) + 0.05 * sin(p.x * 7.1 - t * 1.4));
2246
+ float width = max(uThickness, 0.002) * (0.65 + 0.35 * sin(p.x * 2.4 + t * 0.6));
2247
+ float offset = (p.y - middle) * aspect * 0.6;
2248
+ float core = exp(-pow(offset / width, 2.0));
2249
+ float halo = exp(-pow(offset / (width * (2.5 + uBloom * 5.0)), 2.0));
2250
+
2251
+ // Blue at one end, pink at the other, and the colors drift a little.
2252
+ float along = clamp(p.x + 0.12 * sin(t * 0.8), 0.0, 1.0);
2253
+ vec3 tint = along < 0.5 ? mix(uColorA, uColorB, along * 2.0) : mix(uColorB, uColorC, along * 2.0 - 1.0);
2254
+ float pulse = 0.6 + 0.4 * sin(p.x * 6.0 - t * 2.0);
2255
+
2256
+ vec3 color = uBaseColor;
2257
+ color += tint * halo * 0.55 * pulse * max(uBloom, 0.0);
2258
+ color += mix(tint, vec3(1.0), 0.55) * core * (0.55 + 0.45 * pulse);
2259
+ color *= max(uIntensity, 0.0);
2260
+ color += (hash(gl_FragCoord.xy + t) - 0.5) * max(uGrain, 0.0);
2261
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
2262
+ }
2263
+ `;
2264
+ var lightBandProgram = {
2265
+ name: "lightBand",
2266
+ fragmentSource: fragmentSource12,
2267
+ defaultParameters: {
2268
+ speed: 0.3,
2269
+ intensity: 1,
2270
+ thickness: 0.035,
2271
+ bloom: 1,
2272
+ wave: 1,
2273
+ grain: 0.02,
2274
+ cornerRadius: 0.02,
2275
+ baseColor: "#0f0e14",
2276
+ colorA: "#7ea8ff",
2277
+ colorB: "#c13fd6",
2278
+ colorC: "#ff6fb8"
2279
+ }
1930
2280
  };
1931
2281
 
1932
2282
  // src/runtime/viewer/shaders/builtins/lumenPortal.ts
1933
- var fragmentSource10 = `
2283
+ var fragmentSource13 = `
1934
2284
  precision highp float;
1935
2285
 
1936
2286
  uniform float uTime;
@@ -1988,11 +2338,11 @@ void main() {
1988
2338
  `;
1989
2339
  var lumenPortalProgram = {
1990
2340
  name: "lumenPortal",
1991
- fragmentSource: fragmentSource10
2341
+ fragmentSource: fragmentSource13
1992
2342
  };
1993
2343
 
1994
2344
  // src/runtime/viewer/shaders/builtins/lumenPortalLight.ts
1995
- var fragmentSource11 = `
2345
+ var fragmentSource14 = `
1996
2346
  precision highp float;
1997
2347
 
1998
2348
  uniform float uTime;
@@ -2051,11 +2401,11 @@ void main() {
2051
2401
  `;
2052
2402
  var lumenPortalLightProgram = {
2053
2403
  name: "lumenPortalLight",
2054
- fragmentSource: fragmentSource11
2404
+ fragmentSource: fragmentSource14
2055
2405
  };
2056
2406
 
2057
2407
  // src/runtime/viewer/shaders/builtins/orb.ts
2058
- var fragmentSource12 = `
2408
+ var fragmentSource15 = `
2059
2409
  precision highp float;
2060
2410
 
2061
2411
  uniform vec2 uResolution;
@@ -2091,11 +2441,11 @@ void main() {
2091
2441
  `;
2092
2442
  var orbProgram = {
2093
2443
  name: "orb",
2094
- fragmentSource: fragmentSource12
2444
+ fragmentSource: fragmentSource15
2095
2445
  };
2096
2446
 
2097
2447
  // src/runtime/viewer/shaders/builtins/pixelConstellation.ts
2098
- var fragmentSource13 = `
2448
+ var fragmentSource16 = `
2099
2449
  precision highp float;
2100
2450
 
2101
2451
  uniform float uTime;
@@ -2195,11 +2545,11 @@ void main() {
2195
2545
  `;
2196
2546
  var pixelConstellationProgram = {
2197
2547
  name: "pixelConstellation",
2198
- fragmentSource: fragmentSource13
2548
+ fragmentSource: fragmentSource16
2199
2549
  };
2200
2550
 
2201
2551
  // src/runtime/viewer/shaders/builtins/plasmaGauge.ts
2202
- var fragmentSource14 = `
2552
+ var fragmentSource17 = `
2203
2553
  precision highp float;
2204
2554
 
2205
2555
  uniform vec2 uResolution;
@@ -2301,12 +2651,12 @@ void main() {
2301
2651
  `;
2302
2652
  var plasmaGaugeProgram = {
2303
2653
  name: "plasmaGauge",
2304
- fragmentSource: fragmentSource14,
2654
+ fragmentSource: fragmentSource17,
2305
2655
  replacesBaseFill: true
2306
2656
  };
2307
2657
 
2308
2658
  // src/runtime/viewer/shaders/builtins/prismSlats.ts
2309
- var fragmentSource15 = `
2659
+ var fragmentSource18 = `
2310
2660
  precision highp float;
2311
2661
 
2312
2662
  uniform vec2 uResolution;
@@ -2381,11 +2731,136 @@ void main() {
2381
2731
  `;
2382
2732
  var prismSlatsProgram = {
2383
2733
  name: "prismSlats",
2384
- fragmentSource: fragmentSource15
2734
+ fragmentSource: fragmentSource18
2735
+ };
2736
+
2737
+ // src/runtime/viewer/shaders/builtins/reactivePanel.ts
2738
+ var fragmentSource19 = `
2739
+ precision highp float;
2740
+
2741
+ uniform float uTime;
2742
+ uniform float uSpeed;
2743
+ uniform float uIntensity;
2744
+ uniform float uEmission;
2745
+ uniform float uReception;
2746
+ uniform float uEmitterFill;
2747
+ uniform float uGrain;
2748
+ uniform float uGrainScale;
2749
+ uniform float uCornerRadius;
2750
+ uniform float uBorderWidth;
2751
+ uniform float uGlowRadius;
2752
+ uniform float uSurfacePadding;
2753
+ uniform float uLightX;
2754
+ uniform float uLightY;
2755
+ uniform float uLightStrength;
2756
+ uniform float uPixelScale;
2757
+ uniform vec2 uResolution;
2758
+ uniform vec3 uShapeColor;
2759
+ uniform vec3 uBaseColor;
2760
+ uniform vec3 uEdgeColor;
2761
+ uniform vec3 uLightColor;
2762
+ varying vec2 vUv;
2763
+
2764
+ float roundedBoxDistance(vec2 point, vec2 halfSize, float radius) {
2765
+ vec2 offset = abs(point) - halfSize + radius;
2766
+ return min(max(offset.x, offset.y), 0.0) + length(max(offset, 0.0)) - radius;
2767
+ }
2768
+
2769
+ float random(vec2 point) {
2770
+ vec3 value = fract(vec3(point.xyx) * 0.1031);
2771
+ value += dot(value, value.yzx + 33.33);
2772
+ return fract((value.x + value.y) * value.z);
2773
+ }
2774
+
2775
+ void main() {
2776
+ vec2 pixel = vUv * uResolution;
2777
+ float pixelScale = max(uPixelScale, 0.0001);
2778
+ float padding = clamp(uSurfacePadding * pixelScale, 0.0, min(uResolution.x, uResolution.y) * 0.45);
2779
+ vec2 panelHalfSize = max(vec2(1.0), uResolution * 0.5 - padding);
2780
+ vec2 panelPoint = pixel - uResolution * 0.5;
2781
+ float radius = min(max(uCornerRadius * pixelScale, 0.0), min(panelHalfSize.x, panelHalfSize.y));
2782
+ float distance = roundedBoxDistance(panelPoint, panelHalfSize, radius);
2783
+ float body = 1.0 - smoothstep(-1.25, 0.75, distance);
2784
+ float borderWidth = max(uBorderWidth * pixelScale, 0.5);
2785
+ float edge = exp(-pow(distance / borderWidth, 2.0));
2786
+ float innerEdge = exp(-pow((distance + borderWidth * 2.25) / (borderWidth * 2.2), 2.0)) * body;
2787
+
2788
+ vec2 lightPosition = vec2(uLightX, 1.0 - uLightY) * uResolution;
2789
+ float lightDistance = length(pixel - lightPosition);
2790
+ float lightRadius = max(uGlowRadius * pixelScale, 1.0);
2791
+ float receivedLight = exp(-pow(lightDistance / lightRadius, 2.0));
2792
+ receivedLight *= max(uReception, 0.0) * max(uLightStrength, 0.0);
2793
+
2794
+ float speed = max(uSpeed, 0.0);
2795
+ float breath = 0.88 + 0.12 * sin(uTime * speed * 6.2831853);
2796
+ float emittedLight = max(uEmission, 0.0) * breath;
2797
+ float outsideFalloff = exp(-max(distance, 0.0) / max(lightRadius * 0.22, 1.0));
2798
+ float outsideGlow = outsideFalloff * (emittedLight * 1.35 + receivedLight * 0.9);
2799
+ float frameDistance = min(min(pixel.x, uResolution.x - pixel.x), min(pixel.y, uResolution.y - pixel.y));
2800
+ float frameFade = smoothstep(0.0, max(padding * 0.65, 1.0), frameDistance);
2801
+ outsideGlow *= frameFade;
2802
+
2803
+ vec3 baseColor = dot(uBaseColor, uBaseColor) > 0.0 ? uBaseColor : uShapeColor;
2804
+ vec3 edgeColor = dot(uEdgeColor, uEdgeColor) > 0.0 ? uEdgeColor : vec3(0.22, 0.72, 1.0);
2805
+ vec3 lightColor = dot(uLightColor, uLightColor) > 0.0 ? uLightColor : edgeColor;
2806
+ vec3 color = baseColor * (0.82 + receivedLight * 0.42);
2807
+
2808
+ // Emission lights the material itself instead of leaving a dark cutout behind.
2809
+ // A soft centre bias keeps the fill dimensional while the edge remains crisp.
2810
+ vec2 normalizedPoint = panelPoint / max(panelHalfSize, vec2(1.0));
2811
+ float centreLight = 1.0 - smoothstep(0.05, 1.25, length(normalizedPoint));
2812
+ float fillLight = clamp(emittedLight * max(uEmitterFill, 0.0), 0.0, 1.0) * body;
2813
+ vec3 illuminatedFill = mix(edgeColor, lightColor, 0.62 + centreLight * 0.28);
2814
+ color = mix(color, illuminatedFill * (0.72 + centreLight * 0.62), fillLight);
2815
+
2816
+ // Fine object-space luminance grain. It is intentionally emission-gated so
2817
+ // receiver panels stay clean and the texture stays fixed on the active tile.
2818
+ float grainScale = max(uGrainScale * pixelScale, 0.75);
2819
+ vec2 grainCell = floor(pixel / grainScale);
2820
+ float grainValue = random(grainCell);
2821
+ float grainLight = (grainValue - 0.36) * max(uGrain, 0.0) * fillLight;
2822
+ color += lightColor * grainLight * (0.5 + centreLight * 0.75);
2823
+
2824
+ color += edgeColor * edge * (0.42 + emittedLight * 1.7);
2825
+ color += lightColor * edge * receivedLight * 2.5;
2826
+ color += lightColor * innerEdge * receivedLight * 1.25;
2827
+
2828
+ float intensity = max(uIntensity, 0.0);
2829
+ float halo = outsideGlow * (1.0 - body) * 0.9 * intensity;
2830
+ float alpha = body + halo;
2831
+ if (alpha < 0.002) discard;
2832
+
2833
+ vec3 haloColor = mix(edgeColor, lightColor, clamp(receivedLight * 1.5, 0.0, 1.0));
2834
+ vec3 premultiplied = color * body * intensity + haloColor * halo;
2835
+ gl_FragColor = vec4(clamp(premultiplied, 0.0, 1.0), clamp(alpha, 0.0, 1.0));
2836
+ }
2837
+ `;
2838
+ var reactivePanelProgram = {
2839
+ name: "reactivePanel",
2840
+ fragmentSource: fragmentSource19,
2841
+ defaultParameters: {
2842
+ intensity: 0.5,
2843
+ speed: 0.18,
2844
+ emission: 0,
2845
+ reception: 0.85,
2846
+ emitterFill: 0,
2847
+ grain: 0,
2848
+ grainScale: 1.5,
2849
+ cornerRadius: 18,
2850
+ borderWidth: 2,
2851
+ glowRadius: 90,
2852
+ lightX: 0.5,
2853
+ lightY: 0.5,
2854
+ lightStrength: 0,
2855
+ baseColor: "#09101c",
2856
+ edgeColor: "#33b8ff",
2857
+ lightColor: "#59d1ff"
2858
+ },
2859
+ replacesBaseFill: true
2385
2860
  };
2386
2861
 
2387
2862
  // src/runtime/viewer/shaders/builtins/ruler.ts
2388
- var fragmentSource16 = `
2863
+ var fragmentSource20 = `
2389
2864
  precision highp float;
2390
2865
 
2391
2866
  uniform vec2 uResolution;
@@ -2490,12 +2965,120 @@ void main() {
2490
2965
  `;
2491
2966
  var rulerProgram = {
2492
2967
  name: "ruler",
2493
- fragmentSource: fragmentSource16,
2968
+ fragmentSource: fragmentSource20,
2494
2969
  replacesBaseFill: true
2495
2970
  };
2496
2971
 
2972
+ // src/runtime/viewer/shaders/builtins/silkFolds.ts
2973
+ var fragmentSource21 = `
2974
+ precision highp float;
2975
+
2976
+ uniform vec2 uResolution;
2977
+ uniform float uTime;
2978
+ uniform float uSpeed;
2979
+ uniform float uIntensity;
2980
+ uniform float uScale;
2981
+ uniform float uSharpness;
2982
+ uniform float uDepth;
2983
+ uniform float uGlow;
2984
+ uniform float uGrain;
2985
+ uniform float uRotation;
2986
+ uniform float uRipple;
2987
+ uniform float uWave;
2988
+ uniform float uVariation;
2989
+ uniform float uFade;
2990
+ uniform float uReaction;
2991
+ uniform float uHover;
2992
+ uniform vec2 uPointer;
2993
+ uniform float uCornerRadius;
2994
+ uniform vec3 uBaseColor;
2995
+ uniform vec3 uColor;
2996
+ uniform vec3 uHighlightColor;
2997
+ varying vec2 vUv;
2998
+
2999
+ float boxMask(vec2 uv) {
3000
+ vec2 halfBox = uResolution * 0.5;
3001
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
3002
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
3003
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
3004
+ return 1.0 - smoothstep(-1.0, 1.0, d);
3005
+ }
3006
+
3007
+ float hash(vec2 p) {
3008
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
3009
+ }
3010
+
3011
+ vec2 turn(vec2 point, float angle) {
3012
+ float c = cos(angle);
3013
+ float s = sin(angle);
3014
+ return vec2(c * point.x - s * point.y, s * point.x + c * point.y);
3015
+ }
3016
+
3017
+ void main() {
3018
+ float shape = boxMask(vUv);
3019
+ if (shape <= 0.0) discard;
3020
+
3021
+ float t = uTime * max(uSpeed, 0.0);
3022
+ float aspect = uResolution.x / uResolution.y;
3023
+ float angle = radians(uRotation);
3024
+ float zoom = max(uScale, 0.2) * 2.0;
3025
+ vec2 p = turn((vUv - 0.5) * vec2(aspect, 1.0), angle) * zoom;
3026
+
3027
+ // An irregular, slow bend of the whole cloth, so no two folds are alike.
3028
+ p += uVariation * 1.3 * vec2(sin(p.y * 0.37 + 3.1), cos(p.x * 0.41 + 1.7));
3029
+
3030
+ // Bend the plane a few times, then lay a wave over it: the crests of the wave are the folds of the cloth.
3031
+ for (int i = 0; i < 3; i++) {
3032
+ float k = float(i);
3033
+ p += 0.22 * uWave * vec2(sin(p.y * 1.7 + t * 0.6 + k * 1.3), cos(p.x * 1.5 - t * 0.5 + k * 1.9));
3034
+ }
3035
+
3036
+ // The cloth lifts where the pointer is over it.
3037
+ vec2 touch = turn((uPointer - 0.5) * vec2(aspect, 1.0), angle) * zoom;
3038
+ float lift = exp(-pow(length(p - touch) * 0.55, 2.0)) * uHover * max(uReaction, 0.0);
3039
+
3040
+ float phase = p.x * 0.8 + p.y * 2.2 + 1.2 * sin(p.y * 0.9 - t * 0.3) + 0.8 * sin(p.x * 1.3 + t * 0.2) + lift * 2.4;
3041
+ phase += uRipple * 0.35 * sin(p.x * 7.0 + p.y * 5.0 + t * 1.1);
3042
+ float wave = 0.5 + 0.5 * sin(phase);
3043
+
3044
+ float crest = pow(wave, max(uSharpness, 0.5));
3045
+ float body = pow(wave, mix(1.0, 3.2, clamp(uDepth, 0.0, 1.0)));
3046
+ float bloom = pow(wave, 1.3) * max(uGlow, 0.0);
3047
+
3048
+ vec3 color = mix(uBaseColor, uColor, body * 0.9);
3049
+ color += uHighlightColor * (crest * (0.65 + 0.35 * lift) + bloom * 0.28);
3050
+ color *= max(uIntensity, 0.0);
3051
+ color *= 1.0 - clamp(uFade, 0.0, 1.0) * smoothstep(0.3, 0.78, length(vUv - 0.5) * 1.35);
3052
+ color += (hash(gl_FragCoord.xy) - 0.5) * max(uGrain, 0.0);
3053
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
3054
+ }
3055
+ `;
3056
+ var silkFoldsProgram = {
3057
+ name: "silkFolds",
3058
+ fragmentSource: fragmentSource21,
3059
+ defaultParameters: {
3060
+ speed: 0.2,
3061
+ intensity: 1,
3062
+ scale: 2.2,
3063
+ sharpness: 5,
3064
+ depth: 0.5,
3065
+ glow: 0.3,
3066
+ grain: 0.08,
3067
+ rotation: 0,
3068
+ ripple: 0.3,
3069
+ wave: 1,
3070
+ variation: 0,
3071
+ fade: 0.3,
3072
+ reaction: 1,
3073
+ cornerRadius: 0.02,
3074
+ baseColor: "#030303",
3075
+ color: "#4d4d4d",
3076
+ highlightColor: "#ffffff"
3077
+ }
3078
+ };
3079
+
2497
3080
  // src/runtime/viewer/shaders/builtins/smearOrb.ts
2498
- var fragmentSource17 = `
3081
+ var fragmentSource22 = `
2499
3082
  precision highp float;
2500
3083
 
2501
3084
  uniform vec2 uResolution;
@@ -2571,12 +3154,12 @@ void main() {
2571
3154
  `;
2572
3155
  var smearOrbProgram = {
2573
3156
  name: "smearOrb",
2574
- fragmentSource: fragmentSource17,
3157
+ fragmentSource: fragmentSource22,
2575
3158
  replacesBaseFill: true
2576
3159
  };
2577
3160
 
2578
3161
  // src/runtime/viewer/shaders/builtins/tickScale.ts
2579
- var fragmentSource18 = `
3162
+ var fragmentSource23 = `
2580
3163
  precision highp float;
2581
3164
 
2582
3165
  uniform vec2 uResolution;
@@ -2635,12 +3218,12 @@ void main() {
2635
3218
  `;
2636
3219
  var tickScaleProgram = {
2637
3220
  name: "tickScale",
2638
- fragmentSource: fragmentSource18,
3221
+ fragmentSource: fragmentSource23,
2639
3222
  replacesBaseFill: true
2640
3223
  };
2641
3224
 
2642
3225
  // src/runtime/viewer/shaders/builtins/violetGlass.ts
2643
- var fragmentSource19 = `
3226
+ var fragmentSource24 = `
2644
3227
  precision highp float;
2645
3228
 
2646
3229
  uniform float uTime;
@@ -2720,11 +3303,11 @@ void main() {
2720
3303
  `;
2721
3304
  var violetGlassProgram = {
2722
3305
  name: "violetGlass",
2723
- fragmentSource: fragmentSource19
3306
+ fragmentSource: fragmentSource24
2724
3307
  };
2725
3308
 
2726
3309
  // src/runtime/viewer/shaders/builtins/violetGlassLight.ts
2727
- var fragmentSource20 = `
3310
+ var fragmentSource25 = `
2728
3311
  precision highp float;
2729
3312
 
2730
3313
  uniform float uTime;
@@ -2794,7 +3377,7 @@ void main() {
2794
3377
  `;
2795
3378
  var violetGlassLightProgram = {
2796
3379
  name: "violetGlassLight",
2797
- fragmentSource: fragmentSource20
3380
+ fragmentSource: fragmentSource25
2798
3381
  };
2799
3382
 
2800
3383
  // src/runtime/viewer/shaders/programs.ts
@@ -2818,7 +3401,12 @@ var builtins = [
2818
3401
  violetGlassProgram,
2819
3402
  violetGlassLightProgram,
2820
3403
  lumenPortalProgram,
2821
- lumenPortalLightProgram
3404
+ lumenPortalLightProgram,
3405
+ reactivePanelProgram,
3406
+ ledMatrixProgram,
3407
+ lightBandProgram,
3408
+ silkFoldsProgram,
3409
+ glowCardProgram
2822
3410
  ];
2823
3411
  var programs = new Map(builtins.map((program) => [program.name, program]));
2824
3412
  function registerShaderProgram(program) {
@@ -2932,8 +3520,8 @@ function uniform2f(surface, name, value) {
2932
3520
  surface.gl.uniform2f(location, ...value);
2933
3521
  }
2934
3522
  }
2935
- function uniformName(parameter) {
2936
- return `u${parameter.charAt(0).toUpperCase()}${parameter.slice(1)}`;
3523
+ function uniformName(parameter2) {
3524
+ return `u${parameter2.charAt(0).toUpperCase()}${parameter2.slice(1)}`;
2937
3525
  }
2938
3526
  function enumParameter(name, value) {
2939
3527
  const values = {
@@ -2999,9 +3587,9 @@ function compile(gl, type, source) {
2999
3587
  }
3000
3588
  return shader;
3001
3589
  }
3002
- function linkProgram(gl, fragmentSource21) {
3590
+ function linkProgram(gl, fragmentSource26) {
3003
3591
  const vertex = compile(gl, gl.VERTEX_SHADER, VERTEX_SOURCE);
3004
- const fragment = compile(gl, gl.FRAGMENT_SHADER, fragmentSource21);
3592
+ const fragment = compile(gl, gl.FRAGMENT_SHADER, fragmentSource26);
3005
3593
  if (!vertex || !fragment) {
3006
3594
  if (vertex) {
3007
3595
  gl.deleteShader(vertex);
@@ -3051,6 +3639,10 @@ function parametersOf(owner) {
3051
3639
  return {};
3052
3640
  }
3053
3641
  }
3642
+ function surfacePaddingOf(owner) {
3643
+ const padding = Number(owner.getAttribute("data-sf-shader-padding"));
3644
+ return Number.isFinite(padding) ? Math.max(0, padding) : 0;
3645
+ }
3054
3646
  function bindFullScreenQuad(gl, program) {
3055
3647
  const buffer = gl.createBuffer();
3056
3648
  if (!buffer) {
@@ -3103,8 +3695,13 @@ function createSurface(canvas) {
3103
3695
  gl,
3104
3696
  program,
3105
3697
  buffer,
3106
- parameters: parametersOf(owner),
3698
+ parameters: { ...definition.defaultParameters, ...parametersOf(owner) },
3699
+ surfacePadding: surfacePaddingOf(owner),
3107
3700
  smoothed: /* @__PURE__ */ new Map(),
3701
+ pointer: { x: 0.5, y: 0.5 },
3702
+ hovering: false,
3703
+ hover: 0,
3704
+ trail: [],
3108
3705
  backdropTexture: usesBackdrop ? transparentTexture(gl) : void 0,
3109
3706
  backdropOrigin: [0, 0],
3110
3707
  backdropScale: [1, 1],
@@ -3130,6 +3727,108 @@ function releaseSurface(surface) {
3130
3727
  }
3131
3728
  }
3132
3729
 
3730
+ // src/runtime/viewer/shaders/reactiveLightField.ts
3731
+ function geometryOf(surface) {
3732
+ const x = Number(surface.owner.getAttribute("x"));
3733
+ const y = Number(surface.owner.getAttribute("y"));
3734
+ const width = Number(surface.owner.getAttribute("width"));
3735
+ const height = Number(surface.owner.getAttribute("height"));
3736
+ if (![x, y, width, height].every(Number.isFinite) || width <= 0 || height <= 0) {
3737
+ return void 0;
3738
+ }
3739
+ const matrix = surface.owner.getCTM?.();
3740
+ const a = matrix?.a ?? 1;
3741
+ const b = matrix?.b ?? 0;
3742
+ const c = matrix?.c ?? 0;
3743
+ const d = matrix?.d ?? 1;
3744
+ const e = matrix?.e ?? 0;
3745
+ const f = matrix?.f ?? 0;
3746
+ const determinant = a * d - b * c;
3747
+ const centerX = a * (x + width / 2) + c * (y + height / 2) + e;
3748
+ const centerY = b * (x + width / 2) + d * (y + height / 2) + f;
3749
+ const localPoint = (worldX, worldY) => {
3750
+ if (Math.abs(determinant) < 1e-6) {
3751
+ return [worldX, worldY];
3752
+ }
3753
+ const translatedX = worldX - e;
3754
+ const translatedY = worldY - f;
3755
+ return [(d * translatedX - c * translatedY) / determinant, (-b * translatedX + a * translatedY) / determinant];
3756
+ };
3757
+ return { width, height, centerX, centerY, localPoint };
3758
+ }
3759
+ function parameter(parameters3, key, fallback) {
3760
+ return number(parameters3[key], fallback);
3761
+ }
3762
+ function normalizedLightPosition(sourceX, sourceY, receiverX, receiverY, receiverWidth, receiverHeight) {
3763
+ return [(sourceX - receiverX) / receiverWidth, (sourceY - receiverY) / receiverHeight];
3764
+ }
3765
+ function updateReactiveLightFields(surfaces) {
3766
+ const reactive = surfaces.filter((surface) => surface.owner.getAttribute("data-sf-shader") === "reactivePanel").flatMap((surface) => {
3767
+ const geometry = geometryOf(surface);
3768
+ return geometry ? [{ surface, geometry }] : [];
3769
+ });
3770
+ for (const receiver of reactive) {
3771
+ const sources = [];
3772
+ for (const candidate of reactive) {
3773
+ if (candidate.surface === receiver.surface) {
3774
+ continue;
3775
+ }
3776
+ const emission = Math.max(
3777
+ 0,
3778
+ candidate.surface.smoothed.get("emission") ?? parameter(candidate.surface.parameters, "emission", 0)
3779
+ );
3780
+ if (emission <= 1e-4) {
3781
+ continue;
3782
+ }
3783
+ const distance = Math.hypot(
3784
+ candidate.geometry.centerX - receiver.geometry.centerX,
3785
+ candidate.geometry.centerY - receiver.geometry.centerY
3786
+ );
3787
+ sources.push({ candidate, emission, weight: emission / Math.max(distance, 1) });
3788
+ }
3789
+ const totalWeight = sources.reduce((sum, source) => sum + source.weight, 0);
3790
+ if (totalWeight <= 0) {
3791
+ receiver.surface.reactiveLight = void 0;
3792
+ continue;
3793
+ }
3794
+ let worldX = 0;
3795
+ let worldY = 0;
3796
+ let sourceEmission = 0;
3797
+ let radius = 0;
3798
+ const lightColor = [0, 0, 0];
3799
+ for (const source of sources) {
3800
+ const influence = source.weight / totalWeight;
3801
+ worldX += source.candidate.geometry.centerX * influence;
3802
+ worldY += source.candidate.geometry.centerY * influence;
3803
+ sourceEmission += source.emission;
3804
+ radius += Math.max(1, parameter(source.candidate.surface.parameters, "glowRadius", 90)) * influence;
3805
+ const sourceColor = color(source.candidate.surface.parameters.lightColor, [0.35, 0.82, 1]);
3806
+ lightColor[0] += sourceColor[0] * influence;
3807
+ lightColor[1] += sourceColor[1] * influence;
3808
+ lightColor[2] += sourceColor[2] * influence;
3809
+ }
3810
+ const receiverStrength = Math.max(0, parameter(receiver.surface.parameters, "lightStrength", 1));
3811
+ const [sourceX, sourceY] = receiver.geometry.localPoint(worldX, worldY);
3812
+ const receiverX = Number(receiver.surface.owner.getAttribute("x"));
3813
+ const receiverY = Number(receiver.surface.owner.getAttribute("y"));
3814
+ const [lightX, lightY] = normalizedLightPosition(
3815
+ sourceX,
3816
+ sourceY,
3817
+ receiverX,
3818
+ receiverY,
3819
+ receiver.geometry.width,
3820
+ receiver.geometry.height
3821
+ );
3822
+ receiver.surface.reactiveLight = {
3823
+ x: lightX,
3824
+ y: lightY,
3825
+ strength: sourceEmission * receiverStrength * 1.8,
3826
+ radius,
3827
+ color: lightColor
3828
+ };
3829
+ }
3830
+ }
3831
+
3133
3832
  // src/runtime/viewer/shaders/renderSurface.ts
3134
3833
  function syncBackdropBounds(surface) {
3135
3834
  const svg = surface.canvas.closest("svg");
@@ -3158,6 +3857,7 @@ function applyBackdrop(surface, backdrop) {
3158
3857
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, backdrop.image);
3159
3858
  }
3160
3859
  var MAX_SURFACE_PIXELS = 2560;
3860
+ var TRAIL_LENGTH = 16;
3161
3861
  function renderSurface(surface, seconds) {
3162
3862
  const { canvas, gl, parameters: parameters3 } = surface;
3163
3863
  const shown = canvas.getBoundingClientRect();
@@ -3177,6 +3877,12 @@ function renderSurface(surface, seconds) {
3177
3877
  if (resolution) {
3178
3878
  gl.uniform2f(resolution, width, height);
3179
3879
  }
3880
+ const logicalWidth = Number(surface.owner.getAttribute("width"));
3881
+ uniform1f(
3882
+ surface,
3883
+ "uPixelScale",
3884
+ Number.isFinite(logicalWidth) && logicalWidth > 0 ? width / logicalWidth : density * fit
3885
+ );
3180
3886
  uniform1f(surface, "uTime", seconds);
3181
3887
  if (surface.backdropTexture) {
3182
3888
  syncBackdropBounds(surface);
@@ -3199,6 +3905,28 @@ function renderSurface(surface, seconds) {
3199
3905
  const elapsed = surface.lastSeconds === void 0 ? 0 : Math.max(0, Math.min(seconds - surface.lastSeconds, 0.1));
3200
3906
  surface.lastSeconds = seconds;
3201
3907
  applyParameters(surface, elapsed);
3908
+ surface.hover += ((surface.hovering ? 1 : 0) - surface.hover) * (1 - Math.exp(-elapsed / 0.18));
3909
+ uniform2f(surface, "uPointer", [surface.pointer.x, surface.pointer.y]);
3910
+ uniform1f(surface, "uHover", surface.hover);
3911
+ const fade = number(parameters3.trail, 0);
3912
+ const places = new Float32Array(TRAIL_LENGTH * 3);
3913
+ if (fade > 0) {
3914
+ surface.trail.slice(-TRAIL_LENGTH).forEach((place, index) => {
3915
+ places.set([place.x, place.y, Math.exp(-Math.max(seconds - place.at, 0) / fade)], index * 3);
3916
+ });
3917
+ }
3918
+ const trail = gl.getUniformLocation(surface.program, "uWake[0]");
3919
+ if (trail) {
3920
+ gl.uniform3fv(trail, places);
3921
+ }
3922
+ if (surface.reactiveLight) {
3923
+ uniform1f(surface, "uLightX", surface.reactiveLight.x);
3924
+ uniform1f(surface, "uLightY", surface.reactiveLight.y);
3925
+ uniform1f(surface, "uLightStrength", surface.reactiveLight.strength);
3926
+ uniform1f(surface, "uGlowRadius", surface.reactiveLight.radius);
3927
+ uniform3f(surface, "uLightColor", surface.reactiveLight.color);
3928
+ }
3929
+ uniform1f(surface, "uSurfacePadding", surface.surfacePadding);
3202
3930
  gl.drawArrays(gl.TRIANGLES, 0, 6);
3203
3931
  }
3204
3932
 
@@ -3224,6 +3952,8 @@ function createSurfaceClock(view) {
3224
3952
 
3225
3953
  // src/runtime/viewer/shaders/surface.ts
3226
3954
  var RECAPTURE_DELAY_MS = 120;
3955
+ var TRAIL_SPACING = 0.055;
3956
+ var TRAIL_LENGTH2 = 16;
3227
3957
  function capturePngs(svg, surfaces, seconds) {
3228
3958
  const surfaceByCanvas = new Map(surfaces.map((surface) => [surface.canvas, surface]));
3229
3959
  return [...svg.querySelectorAll("canvas[data-sf-shader-canvas]")].map((canvas) => {
@@ -3247,9 +3977,14 @@ function updateParameters(surfaces, ownerId, parameters3, seconds) {
3247
3977
  }
3248
3978
  Object.assign(surface.parameters, parameters3);
3249
3979
  surface.owner.setAttribute("data-sf-shader-params", JSON.stringify(surface.parameters));
3250
- renderSurface(surface, seconds);
3251
3980
  changed = true;
3252
3981
  }
3982
+ if (changed) {
3983
+ updateReactiveLightFields(surfaces);
3984
+ for (const surface of surfaces) {
3985
+ renderSurface(surface, seconds);
3986
+ }
3987
+ }
3253
3988
  return changed;
3254
3989
  }
3255
3990
  function watchSvgChanges(svg, view, onChange) {
@@ -3274,6 +4009,7 @@ function mountShaderSurfaces(svg) {
3274
4009
  const clock = createSurfaceClock(view);
3275
4010
  const draw = (milliseconds) => {
3276
4011
  if (!clock.paused()) {
4012
+ updateReactiveLightFields(surfaces);
3277
4013
  for (const surface of surfaces) {
3278
4014
  renderSurface(surface, milliseconds / 1e3 - clock.spent());
3279
4015
  }
@@ -3317,12 +4053,41 @@ function mountShaderSurfaces(svg) {
3317
4053
  frame = view.requestAnimationFrame(draw);
3318
4054
  };
3319
4055
  const refresh = () => {
4056
+ const previousState = new Map(
4057
+ surfaces.flatMap((surface) => {
4058
+ const ownerId = surface.owner.getAttribute("data-sf-id");
4059
+ return ownerId ? [
4060
+ [
4061
+ ownerId,
4062
+ {
4063
+ smoothed: new Map(surface.smoothed),
4064
+ reactiveLight: surface.reactiveLight,
4065
+ pointer: surface.pointer,
4066
+ hover: surface.hover,
4067
+ hovering: surface.hovering,
4068
+ trail: surface.trail
4069
+ }
4070
+ ]
4071
+ ] : [];
4072
+ })
4073
+ );
3320
4074
  stop();
3321
4075
  const generation = ++backdropGeneration;
3322
4076
  surfaces = [...svg.querySelectorAll("canvas[data-sf-shader-canvas]")].flatMap((canvas) => {
3323
4077
  const surface = createSurface(canvas);
4078
+ const ownerId = surface?.owner.getAttribute("data-sf-id");
4079
+ const previous = ownerId ? previousState.get(ownerId) : void 0;
4080
+ if (surface && previous) {
4081
+ surface.smoothed = previous.smoothed;
4082
+ surface.reactiveLight = previous.reactiveLight;
4083
+ surface.pointer = previous.pointer;
4084
+ surface.hover = previous.hover;
4085
+ surface.hovering = previous.hovering;
4086
+ surface.trail = previous.trail;
4087
+ }
3324
4088
  return surface ? [surface] : [];
3325
4089
  });
4090
+ updateReactiveLightFields(surfaces);
3326
4091
  captureBackdrops(generation);
3327
4092
  if (surfaces.length > 0) {
3328
4093
  startFrames();
@@ -3338,10 +4103,37 @@ function mountShaderSurfaces(svg) {
3338
4103
  }, RECAPTURE_DELAY_MS);
3339
4104
  };
3340
4105
  const unwatch = watchSvgChanges(svg, view, scheduleRecapture);
4106
+ const track = (event) => {
4107
+ for (const surface of surfaces) {
4108
+ const box = surface.canvas.getBoundingClientRect();
4109
+ const inside = box.width > 0 && box.height > 0 && event.clientX >= box.left && event.clientX <= box.right && event.clientY >= box.top && event.clientY <= box.bottom;
4110
+ surface.hovering = inside;
4111
+ if (inside) {
4112
+ surface.pointer = { x: (event.clientX - box.left) / box.width, y: 1 - (event.clientY - box.top) / box.height };
4113
+ const now = clock.now();
4114
+ const last = surface.trail[surface.trail.length - 1];
4115
+ if (!last || now - last.at >= TRAIL_SPACING) {
4116
+ surface.trail.push({ ...surface.pointer, at: now });
4117
+ if (surface.trail.length > TRAIL_LENGTH2) {
4118
+ surface.trail.shift();
4119
+ }
4120
+ }
4121
+ }
4122
+ }
4123
+ };
4124
+ const leave = () => {
4125
+ for (const surface of surfaces) {
4126
+ surface.hovering = false;
4127
+ }
4128
+ };
4129
+ svg.addEventListener("pointermove", track);
4130
+ svg.addEventListener("pointerleave", leave);
3341
4131
  refresh();
3342
4132
  const destroy = () => {
3343
4133
  backdropGeneration += 1;
3344
4134
  unwatch();
4135
+ svg.removeEventListener("pointermove", track);
4136
+ svg.removeEventListener("pointerleave", leave);
3345
4137
  if (recapture !== void 0) {
3346
4138
  view?.clearTimeout(recapture);
3347
4139
  }
@@ -3358,21 +4150,21 @@ function mountShaderSurfaces(svg) {
3358
4150
 
3359
4151
  // src/runtime/viewer/source.ts
3360
4152
  function renderViewerSource(next, defaultRenderOptions) {
3361
- const svg = next.svg ?? (next.source != null ? chunkWQRT5PVT_cjs.render(next.source, { ...next.renderOptions ?? defaultRenderOptions, linkHitAreas: true }).svg : null);
4153
+ const svg = next.svg ?? (next.source != null ? chunkVOYX6JMW_cjs.render(next.source, { ...next.renderOptions ?? defaultRenderOptions, linkHitAreas: true }).svg : null);
3362
4154
  if (svg == null) {
3363
4155
  throw new Error("createViewer: provide either `source` (SFL) or `svg`.");
3364
4156
  }
3365
4157
  return svg;
3366
4158
  }
3367
4159
  function assertCreateViewerContract(svg) {
3368
- const version = chunk4LENHH6C_cjs.parseContractVersion(svg);
3369
- if (!chunk4LENHH6C_cjs.isContractCompatible(version)) {
4160
+ const version = chunkFQ7GMLCM_cjs.parseContractVersion(svg);
4161
+ if (!chunkFQ7GMLCM_cjs.isContractCompatible(version)) {
3370
4162
  throw new Error(`createViewer: incompatible DOM contract (svg=${version}). Renderer and viewer versions differ.`);
3371
4163
  }
3372
4164
  }
3373
4165
  function assertViewerUpdateContract(svg) {
3374
- const version = chunk4LENHH6C_cjs.parseContractVersion(svg);
3375
- if (!chunk4LENHH6C_cjs.isContractCompatible(version)) {
4166
+ const version = chunkFQ7GMLCM_cjs.parseContractVersion(svg);
4167
+ if (!chunkFQ7GMLCM_cjs.isContractCompatible(version)) {
3376
4168
  throw new Error(`viewer.update: incompatible DOM contract (svg=${version}). Renderer and viewer versions differ.`);
3377
4169
  }
3378
4170
  }
@@ -3604,6 +4396,22 @@ function trackScales(wiring, event) {
3604
4396
  }
3605
4397
  }
3606
4398
  }
4399
+ function driveValue(wiring, id, event) {
4400
+ const { runtime, svg } = wiring;
4401
+ const kind = chunkLNW5VIEA_cjs.getComponentDescriptor(runtime.graph.elements.get(id)?.componentType)?.interaction;
4402
+ if (kind !== "slide" && kind !== "pick" && kind !== "turn" && kind !== "range") {
4403
+ return;
4404
+ }
4405
+ const node = svg.querySelector(`[data-sf-primary][data-sf-id="${CSS.escape(id)}"]`);
4406
+ if (!node) {
4407
+ return;
4408
+ }
4409
+ const box = node.getBoundingClientRect();
4410
+ if (box.width > 0 && box.height > 0) {
4411
+ const within = (value) => Math.min(1, Math.max(0, value));
4412
+ runtime.slide(id, within((event.clientX - box.left) / box.width), within((event.clientY - box.top) / box.height));
4413
+ }
4414
+ }
3607
4415
  function updateHover(wiring, event) {
3608
4416
  const { runtime, svg, options, session } = wiring;
3609
4417
  const over = options.enabled?.() === false ? null : hit(svg, runtime.interactive.pressable, event.clientX, event.clientY);
@@ -3635,6 +4443,7 @@ function pressStart(wiring, event) {
3635
4443
  session.active = id;
3636
4444
  trackScales(wiring, event);
3637
4445
  runtime.press(id);
4446
+ driveValue(wiring, id, event);
3638
4447
  runtime.drag(id);
3639
4448
  }
3640
4449
  function pressMove(wiring, event) {
@@ -3644,6 +4453,7 @@ function pressMove(wiring, event) {
3644
4453
  return;
3645
4454
  }
3646
4455
  trackScales(wiring, event);
4456
+ driveValue(wiring, session.active, event);
3647
4457
  runtime.drag(session.active);
3648
4458
  }
3649
4459
  function pressEnd(wiring, event, tapOnElement) {
@@ -3727,5 +4537,5 @@ exports.connectInteraction = connectInteraction;
3727
4537
  exports.createViewer = createViewer;
3728
4538
  exports.registerShaderProgram = registerShaderProgram;
3729
4539
  exports.shaderProgram = shaderProgram;
3730
- //# sourceMappingURL=chunk-KTNCDNDB.cjs.map
3731
- //# sourceMappingURL=chunk-KTNCDNDB.cjs.map
4540
+ //# sourceMappingURL=chunk-IR2T47NW.cjs.map
4541
+ //# sourceMappingURL=chunk-IR2T47NW.cjs.map