stickyflow 0.5.0 → 0.7.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 +43 -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-ZMLQIMJK.cjs → chunk-A73UJ5AQ.cjs} +1537 -738
  7. package/dist/chunk-A73UJ5AQ.cjs.map +1 -0
  8. package/dist/{chunk-VK3T6O5Z.cjs → chunk-BUOWM3LC.cjs} +745 -62
  9. package/dist/chunk-BUOWM3LC.cjs.map +1 -0
  10. package/dist/{chunk-L3VJXZFD.cjs → chunk-EKAWJFJQ.cjs} +15 -15
  11. package/dist/{chunk-L3VJXZFD.cjs.map → chunk-EKAWJFJQ.cjs.map} +1 -1
  12. package/dist/{chunk-BODZN3ZI.js → chunk-JCRPLPKV.js} +156 -23
  13. package/dist/chunk-JCRPLPKV.js.map +1 -0
  14. package/dist/{chunk-IEHE6WVN.js → chunk-JQK4IGXJ.js} +489 -51
  15. package/dist/chunk-JQK4IGXJ.js.map +1 -0
  16. package/dist/{chunk-XY2GZUHC.cjs → chunk-KXYSO6GC.cjs} +498 -50
  17. package/dist/chunk-KXYSO6GC.cjs.map +1 -0
  18. package/dist/{chunk-G7NRK5AG.js → chunk-MUKIGLR5.js} +717 -34
  19. package/dist/chunk-MUKIGLR5.js.map +1 -0
  20. package/dist/{chunk-TWDLOXRM.cjs → chunk-OWNVXKXN.cjs} +170 -37
  21. package/dist/chunk-OWNVXKXN.cjs.map +1 -0
  22. package/dist/{chunk-LTGF5OHP.js → chunk-SDMQRSRW.js} +941 -143
  23. package/dist/chunk-SDMQRSRW.js.map +1 -0
  24. package/dist/{chunk-7VW2XKVB.js → chunk-ZNHYW47T.js} +3 -3
  25. package/dist/{chunk-7VW2XKVB.js.map → chunk-ZNHYW47T.js.map} +1 -1
  26. package/dist/index.cjs +57 -29
  27. package/dist/index.d.cts +80 -7
  28. package/dist/index.d.ts +80 -7
  29. package/dist/index.js +5 -5
  30. package/dist/interaction/index.cjs +245 -235
  31. package/dist/interaction/index.cjs.map +1 -1
  32. package/dist/interaction/index.d.cts +3 -2
  33. package/dist/interaction/index.d.ts +3 -2
  34. package/dist/interaction/index.js +17 -7
  35. package/dist/interaction/index.js.map +1 -1
  36. package/dist/{render-CgX_y15a.d.ts → render-BU2uYzjG.d.cts} +40 -16
  37. package/dist/{render-CgX_y15a.d.cts → render-BU2uYzjG.d.ts} +40 -16
  38. package/dist/{runtime-reWgr7MP.d.cts → runtime-B7KiTmn8.d.cts} +2 -2
  39. package/dist/{runtime-DnUxca3Y.d.ts → runtime-BPzyD-Nd.d.ts} +2 -2
  40. package/dist/{runtimeTypes-D60w6nyF.d.cts → runtimeTypes-BIP70z72.d.cts} +3 -2
  41. package/dist/{runtimeTypes-CEBGueYM.d.ts → runtimeTypes-DalvhScn.d.ts} +3 -2
  42. package/dist/stickyflow-diagram.global.js +387 -36
  43. package/dist/stickyflow-diagram.global.js.map +1 -1
  44. package/dist/{types-DYLC_lsk.d.ts → types-DMWs27Hn.d.ts} +1 -1
  45. package/dist/{types-DvhMpqrL.d.cts → types-D_2NZ6lL.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-BODZN3ZI.js.map +0 -1
  56. package/dist/chunk-G7NRK5AG.js.map +0 -1
  57. package/dist/chunk-IEHE6WVN.js.map +0 -1
  58. package/dist/chunk-LTGF5OHP.js.map +0 -1
  59. package/dist/chunk-TWDLOXRM.cjs.map +0 -1
  60. package/dist/chunk-VK3T6O5Z.cjs.map +0 -1
  61. package/dist/chunk-XY2GZUHC.cjs.map +0 -1
  62. package/dist/chunk-ZMLQIMJK.cjs.map +0 -1
@@ -1,6 +1,6 @@
1
- import { render } from './chunk-LTGF5OHP.js';
2
- import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-7VW2XKVB.js';
3
- import { formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE } from './chunk-IEHE6WVN.js';
1
+ import { render } from './chunk-SDMQRSRW.js';
2
+ import { parseContractVersion, isContractCompatible, Emitter, resolveOwner, CHANGE_COLOR, findOwnerNode, isPrimary, linkSelectionOverlay, pathSelectionOverlay, isometricSelectionOverlay, shapeSelectionOverlay, DERIVED_HEIGHT_ROLES, quickDuplicateBubbles, isCameraGesture, linkChangeOverlay, shapeChangeOverlay, startChangeFade, REDUCED_MOTION_DURATION_MS, FLASH_DURATION_MS } from './chunk-ZNHYW47T.js';
3
+ import { getComponentDescriptor, formatRollingNumber, DEFAULT_ROLLING_NUMBER_STYLE } from './chunk-JQK4IGXJ.js';
4
4
 
5
5
  // src/runtime/viewer/components/rollingNumberDom.ts
6
6
  var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
@@ -1927,10 +1927,234 @@ var haloProgram = {
1927
1927
  fragmentSource: fragmentSource9
1928
1928
  };
1929
1929
 
1930
- // src/runtime/viewer/shaders/builtins/lumenPortal.ts
1930
+ // src/runtime/viewer/shaders/builtins/ledMatrix.ts
1931
1931
  var fragmentSource10 = `
1932
1932
  precision highp float;
1933
1933
 
1934
+ uniform vec2 uResolution;
1935
+ uniform float uTime;
1936
+ uniform float uSpeed;
1937
+ uniform float uIntensity;
1938
+ uniform float uColumns;
1939
+ uniform float uCellAspect;
1940
+ uniform float uGap;
1941
+ uniform float uGlow;
1942
+ uniform float uDepth;
1943
+ uniform float uGrain;
1944
+ uniform float uRotation;
1945
+ uniform float uRipple;
1946
+ uniform float uWave;
1947
+ uniform float uVariation;
1948
+ uniform float uFade;
1949
+ uniform float uOriginX;
1950
+ uniform float uOriginY;
1951
+ uniform float uSpread;
1952
+ uniform float uDrift;
1953
+ uniform float uReaction;
1954
+ uniform float uPointerSize;
1955
+ uniform float uHover;
1956
+ uniform vec2 uPointer;
1957
+ uniform vec3 uWake[16];
1958
+ uniform float uCornerRadius;
1959
+ uniform vec3 uBaseColor;
1960
+ uniform vec3 uOffColor;
1961
+ uniform vec3 uColor;
1962
+ uniform vec3 uHotColor;
1963
+ varying vec2 vUv;
1964
+
1965
+ float boxMask(vec2 uv) {
1966
+ vec2 halfBox = uResolution * 0.5;
1967
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
1968
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
1969
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
1970
+ return 1.0 - smoothstep(-1.0, 1.0, d);
1971
+ }
1972
+
1973
+ float roundedBox(vec2 point, vec2 halfSize, float radius) {
1974
+ vec2 q = abs(point) - halfSize + radius;
1975
+ return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
1976
+ }
1977
+
1978
+ float hash(vec2 p) {
1979
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
1980
+ }
1981
+
1982
+ void main() {
1983
+ float shape = boxMask(vUv);
1984
+ if (shape <= 0.0) discard;
1985
+
1986
+ float time = uTime * max(uSpeed, 0.0);
1987
+ float columns = max(uColumns, 2.0);
1988
+ vec2 cellPx = vec2(uResolution.x / columns);
1989
+ cellPx.y *= max(uCellAspect, 0.2);
1990
+ vec2 rows = uResolution / cellPx;
1991
+
1992
+ // The grid can be turned around the middle of the surface.
1993
+ float angle = radians(uRotation);
1994
+ vec2 centered = (vUv - 0.5) * uResolution;
1995
+ vec2 turned = vec2(cos(angle) * centered.x - sin(angle) * centered.y, sin(angle) * centered.x + cos(angle) * centered.y);
1996
+ vec2 turnedUv = turned / uResolution + 0.5;
1997
+ vec2 grid = vec2(turnedUv.x, 1.0 - turnedUv.y) * rows;
1998
+ vec2 cell = floor(grid);
1999
+ vec2 local = (fract(grid) - 0.5) * cellPx;
2000
+ vec2 center = (cell + 0.5) / rows;
2001
+
2002
+ // 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.
2003
+ float spread = max(uSpread, 0.05);
2004
+ float lit = smoothstep(0.0, 0.05, uSpread);
2005
+ vec2 p = vec2(center.x, 1.0 - center.y);
2006
+ vec2 origin = vec2(uOriginX + uDrift * sin(time * 0.7), uOriginY);
2007
+ float aspect = uResolution.x / uResolution.y;
2008
+ float blob = exp(-pow(length((p - origin) * vec2(1.0, 1.55)) / spread, 2.0) * 5.5) * lit;
2009
+ float wave = 0.5 + 0.5 * sin(p.x * 5.0 + time * 1.3 + sin(p.y * 3.0 - time));
2010
+ 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;
2011
+ float glowLevel = blob * 1.15 + rise * 0.5 + 0.03;
2012
+
2013
+ // Rings that run outward from the light, and a different brightness for every light.
2014
+ float rings = 1.0 + uRipple * 0.5 * sin(length((p - origin) * vec2(1.0, 1.55)) * 16.0 - time * 2.5);
2015
+ float jitter = 1.0 - uVariation * 0.55 * hash(cell);
2016
+ float vignette = 1.0 - clamp(uFade, 0.0, 1.0) * smoothstep(0.3, 0.8, length(p - 0.5) * 1.3);
2017
+
2018
+ // 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.
2019
+ float near = exp(-pow(length((p - uPointer) * vec2(aspect, 1.0)) / max(uPointerSize, 0.01), 2.0)) * uHover;
2020
+ float wake = 0.0;
2021
+ for (int i = 0; i < 16; i++) {
2022
+ wake += uWake[i].z * exp(-pow(length((p - uWake[i].xy) * vec2(aspect, 1.0)) / max(uPointerSize * 0.88, 0.01), 2.0));
2023
+ }
2024
+ float touch = min(near + wake, 1.3) * max(uReaction, 0.0);
2025
+ float level = clamp(glowLevel * rings * jitter * vignette * max(uIntensity, 0.0) + touch * 1.1, 0.0, 1.0);
2026
+
2027
+ vec3 tint = mix(uOffColor, uColor, smoothstep(0.0, 0.6, level));
2028
+ tint = mix(tint, uHotColor, smoothstep(0.55, 1.0, level));
2029
+
2030
+ vec2 halfSize = cellPx * 0.5 * (1.0 - clamp(uGap, 0.0, 0.8));
2031
+ float d = roundedBox(local, halfSize, min(halfSize.x, halfSize.y));
2032
+ float body = 1.0 - smoothstep(-0.9, 0.9, d);
2033
+ // Depth shades a light like a small bulb: bright in the upper part, darker at the rim.
2034
+ float sheen = 1.0 - smoothstep(0.0, halfSize.y * 1.2, abs(local.y + halfSize.y * 0.35));
2035
+ float rim = smoothstep(-halfSize.x * 0.7, 0.0, d);
2036
+ float depth = clamp(uDepth, 0.0, 1.0);
2037
+ vec3 cellColor = tint * (1.0 - 0.4 * depth + 0.4 * depth * sheen) * (1.0 - 0.35 * depth * rim);
2038
+
2039
+ vec3 color = uBaseColor + tint * level * max(uGlow, 0.0) * 0.18;
2040
+ color = mix(color, cellColor, body);
2041
+ color += (hash(gl_FragCoord.xy) - 0.5) * max(uGrain, 0.0) * 0.2;
2042
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
2043
+ }
2044
+ `;
2045
+ var ledMatrixProgram = {
2046
+ name: "ledMatrix",
2047
+ fragmentSource: fragmentSource10,
2048
+ defaultParameters: {
2049
+ speed: 0.25,
2050
+ intensity: 1,
2051
+ columns: 44,
2052
+ cellAspect: 1.7,
2053
+ gap: 0.3,
2054
+ originX: 0.42,
2055
+ originY: 0.04,
2056
+ spread: 1,
2057
+ drift: 0.2,
2058
+ depth: 0.5,
2059
+ glow: 1,
2060
+ grain: 0.2,
2061
+ rotation: 0,
2062
+ ripple: 0.3,
2063
+ wave: 1,
2064
+ variation: 0.2,
2065
+ fade: 0.3,
2066
+ reaction: 1,
2067
+ pointerSize: 0.17,
2068
+ trail: 1.4,
2069
+ cornerRadius: 0.025,
2070
+ baseColor: "#050505",
2071
+ offColor: "#262626",
2072
+ color: "#a3a3a3",
2073
+ hotColor: "#ffffff"
2074
+ }
2075
+ };
2076
+
2077
+ // src/runtime/viewer/shaders/builtins/lightBand.ts
2078
+ var fragmentSource11 = `
2079
+ precision highp float;
2080
+
2081
+ uniform vec2 uResolution;
2082
+ uniform float uTime;
2083
+ uniform float uSpeed;
2084
+ uniform float uIntensity;
2085
+ uniform float uThickness;
2086
+ uniform float uBloom;
2087
+ uniform float uWave;
2088
+ uniform float uGrain;
2089
+ uniform float uCornerRadius;
2090
+ uniform vec3 uBaseColor;
2091
+ uniform vec3 uColorA;
2092
+ uniform vec3 uColorB;
2093
+ uniform vec3 uColorC;
2094
+ varying vec2 vUv;
2095
+
2096
+ float boxMask(vec2 uv) {
2097
+ vec2 halfBox = uResolution * 0.5;
2098
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
2099
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
2100
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
2101
+ return 1.0 - smoothstep(-1.0, 1.0, d);
2102
+ }
2103
+
2104
+ float hash(vec2 p) {
2105
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
2106
+ }
2107
+
2108
+ void main() {
2109
+ float shape = boxMask(vUv);
2110
+ if (shape <= 0.0) discard;
2111
+
2112
+ float t = uTime * max(uSpeed, 0.0);
2113
+ float aspect = uResolution.x / uResolution.y;
2114
+ vec2 p = vec2(vUv.x, 1.0 - vUv.y);
2115
+
2116
+ // The middle of the band wanders across the surface, and its width breathes along the way.
2117
+ float middle = 0.5 + uWave * (0.11 * sin(p.x * 3.4 + t) + 0.05 * sin(p.x * 7.1 - t * 1.4));
2118
+ float width = max(uThickness, 0.002) * (0.65 + 0.35 * sin(p.x * 2.4 + t * 0.6));
2119
+ float offset = (p.y - middle) * aspect * 0.6;
2120
+ float core = exp(-pow(offset / width, 2.0));
2121
+ float halo = exp(-pow(offset / (width * (2.5 + uBloom * 5.0)), 2.0));
2122
+
2123
+ // Blue at one end, pink at the other, and the colors drift a little.
2124
+ float along = clamp(p.x + 0.12 * sin(t * 0.8), 0.0, 1.0);
2125
+ vec3 tint = along < 0.5 ? mix(uColorA, uColorB, along * 2.0) : mix(uColorB, uColorC, along * 2.0 - 1.0);
2126
+ float pulse = 0.6 + 0.4 * sin(p.x * 6.0 - t * 2.0);
2127
+
2128
+ vec3 color = uBaseColor;
2129
+ color += tint * halo * 0.55 * pulse * max(uBloom, 0.0);
2130
+ color += mix(tint, vec3(1.0), 0.55) * core * (0.55 + 0.45 * pulse);
2131
+ color *= max(uIntensity, 0.0);
2132
+ color += (hash(gl_FragCoord.xy + t) - 0.5) * max(uGrain, 0.0);
2133
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
2134
+ }
2135
+ `;
2136
+ var lightBandProgram = {
2137
+ name: "lightBand",
2138
+ fragmentSource: fragmentSource11,
2139
+ defaultParameters: {
2140
+ speed: 0.3,
2141
+ intensity: 1,
2142
+ thickness: 0.035,
2143
+ bloom: 1,
2144
+ wave: 1,
2145
+ grain: 0.02,
2146
+ cornerRadius: 0.02,
2147
+ baseColor: "#0f0e14",
2148
+ colorA: "#7ea8ff",
2149
+ colorB: "#c13fd6",
2150
+ colorC: "#ff6fb8"
2151
+ }
2152
+ };
2153
+
2154
+ // src/runtime/viewer/shaders/builtins/lumenPortal.ts
2155
+ var fragmentSource12 = `
2156
+ precision highp float;
2157
+
1934
2158
  uniform float uTime;
1935
2159
  uniform float uSpeed;
1936
2160
  uniform float uIntensity;
@@ -1986,11 +2210,11 @@ void main() {
1986
2210
  `;
1987
2211
  var lumenPortalProgram = {
1988
2212
  name: "lumenPortal",
1989
- fragmentSource: fragmentSource10
2213
+ fragmentSource: fragmentSource12
1990
2214
  };
1991
2215
 
1992
2216
  // src/runtime/viewer/shaders/builtins/lumenPortalLight.ts
1993
- var fragmentSource11 = `
2217
+ var fragmentSource13 = `
1994
2218
  precision highp float;
1995
2219
 
1996
2220
  uniform float uTime;
@@ -2049,11 +2273,11 @@ void main() {
2049
2273
  `;
2050
2274
  var lumenPortalLightProgram = {
2051
2275
  name: "lumenPortalLight",
2052
- fragmentSource: fragmentSource11
2276
+ fragmentSource: fragmentSource13
2053
2277
  };
2054
2278
 
2055
2279
  // src/runtime/viewer/shaders/builtins/orb.ts
2056
- var fragmentSource12 = `
2280
+ var fragmentSource14 = `
2057
2281
  precision highp float;
2058
2282
 
2059
2283
  uniform vec2 uResolution;
@@ -2089,11 +2313,11 @@ void main() {
2089
2313
  `;
2090
2314
  var orbProgram = {
2091
2315
  name: "orb",
2092
- fragmentSource: fragmentSource12
2316
+ fragmentSource: fragmentSource14
2093
2317
  };
2094
2318
 
2095
2319
  // src/runtime/viewer/shaders/builtins/pixelConstellation.ts
2096
- var fragmentSource13 = `
2320
+ var fragmentSource15 = `
2097
2321
  precision highp float;
2098
2322
 
2099
2323
  uniform float uTime;
@@ -2193,11 +2417,11 @@ void main() {
2193
2417
  `;
2194
2418
  var pixelConstellationProgram = {
2195
2419
  name: "pixelConstellation",
2196
- fragmentSource: fragmentSource13
2420
+ fragmentSource: fragmentSource15
2197
2421
  };
2198
2422
 
2199
2423
  // src/runtime/viewer/shaders/builtins/plasmaGauge.ts
2200
- var fragmentSource14 = `
2424
+ var fragmentSource16 = `
2201
2425
  precision highp float;
2202
2426
 
2203
2427
  uniform vec2 uResolution;
@@ -2299,12 +2523,12 @@ void main() {
2299
2523
  `;
2300
2524
  var plasmaGaugeProgram = {
2301
2525
  name: "plasmaGauge",
2302
- fragmentSource: fragmentSource14,
2526
+ fragmentSource: fragmentSource16,
2303
2527
  replacesBaseFill: true
2304
2528
  };
2305
2529
 
2306
2530
  // src/runtime/viewer/shaders/builtins/prismSlats.ts
2307
- var fragmentSource15 = `
2531
+ var fragmentSource17 = `
2308
2532
  precision highp float;
2309
2533
 
2310
2534
  uniform vec2 uResolution;
@@ -2379,11 +2603,136 @@ void main() {
2379
2603
  `;
2380
2604
  var prismSlatsProgram = {
2381
2605
  name: "prismSlats",
2382
- fragmentSource: fragmentSource15
2606
+ fragmentSource: fragmentSource17
2607
+ };
2608
+
2609
+ // src/runtime/viewer/shaders/builtins/reactivePanel.ts
2610
+ var fragmentSource18 = `
2611
+ precision highp float;
2612
+
2613
+ uniform float uTime;
2614
+ uniform float uSpeed;
2615
+ uniform float uIntensity;
2616
+ uniform float uEmission;
2617
+ uniform float uReception;
2618
+ uniform float uEmitterFill;
2619
+ uniform float uGrain;
2620
+ uniform float uGrainScale;
2621
+ uniform float uCornerRadius;
2622
+ uniform float uBorderWidth;
2623
+ uniform float uGlowRadius;
2624
+ uniform float uSurfacePadding;
2625
+ uniform float uLightX;
2626
+ uniform float uLightY;
2627
+ uniform float uLightStrength;
2628
+ uniform float uPixelScale;
2629
+ uniform vec2 uResolution;
2630
+ uniform vec3 uShapeColor;
2631
+ uniform vec3 uBaseColor;
2632
+ uniform vec3 uEdgeColor;
2633
+ uniform vec3 uLightColor;
2634
+ varying vec2 vUv;
2635
+
2636
+ float roundedBoxDistance(vec2 point, vec2 halfSize, float radius) {
2637
+ vec2 offset = abs(point) - halfSize + radius;
2638
+ return min(max(offset.x, offset.y), 0.0) + length(max(offset, 0.0)) - radius;
2639
+ }
2640
+
2641
+ float random(vec2 point) {
2642
+ vec3 value = fract(vec3(point.xyx) * 0.1031);
2643
+ value += dot(value, value.yzx + 33.33);
2644
+ return fract((value.x + value.y) * value.z);
2645
+ }
2646
+
2647
+ void main() {
2648
+ vec2 pixel = vUv * uResolution;
2649
+ float pixelScale = max(uPixelScale, 0.0001);
2650
+ float padding = clamp(uSurfacePadding * pixelScale, 0.0, min(uResolution.x, uResolution.y) * 0.45);
2651
+ vec2 panelHalfSize = max(vec2(1.0), uResolution * 0.5 - padding);
2652
+ vec2 panelPoint = pixel - uResolution * 0.5;
2653
+ float radius = min(max(uCornerRadius * pixelScale, 0.0), min(panelHalfSize.x, panelHalfSize.y));
2654
+ float distance = roundedBoxDistance(panelPoint, panelHalfSize, radius);
2655
+ float body = 1.0 - smoothstep(-1.25, 0.75, distance);
2656
+ float borderWidth = max(uBorderWidth * pixelScale, 0.5);
2657
+ float edge = exp(-pow(distance / borderWidth, 2.0));
2658
+ float innerEdge = exp(-pow((distance + borderWidth * 2.25) / (borderWidth * 2.2), 2.0)) * body;
2659
+
2660
+ vec2 lightPosition = vec2(uLightX, 1.0 - uLightY) * uResolution;
2661
+ float lightDistance = length(pixel - lightPosition);
2662
+ float lightRadius = max(uGlowRadius * pixelScale, 1.0);
2663
+ float receivedLight = exp(-pow(lightDistance / lightRadius, 2.0));
2664
+ receivedLight *= max(uReception, 0.0) * max(uLightStrength, 0.0);
2665
+
2666
+ float speed = max(uSpeed, 0.0);
2667
+ float breath = 0.88 + 0.12 * sin(uTime * speed * 6.2831853);
2668
+ float emittedLight = max(uEmission, 0.0) * breath;
2669
+ float outsideFalloff = exp(-max(distance, 0.0) / max(lightRadius * 0.22, 1.0));
2670
+ float outsideGlow = outsideFalloff * (emittedLight * 1.35 + receivedLight * 0.9);
2671
+ float frameDistance = min(min(pixel.x, uResolution.x - pixel.x), min(pixel.y, uResolution.y - pixel.y));
2672
+ float frameFade = smoothstep(0.0, max(padding * 0.65, 1.0), frameDistance);
2673
+ outsideGlow *= frameFade;
2674
+
2675
+ vec3 baseColor = dot(uBaseColor, uBaseColor) > 0.0 ? uBaseColor : uShapeColor;
2676
+ vec3 edgeColor = dot(uEdgeColor, uEdgeColor) > 0.0 ? uEdgeColor : vec3(0.22, 0.72, 1.0);
2677
+ vec3 lightColor = dot(uLightColor, uLightColor) > 0.0 ? uLightColor : edgeColor;
2678
+ vec3 color = baseColor * (0.82 + receivedLight * 0.42);
2679
+
2680
+ // Emission lights the material itself instead of leaving a dark cutout behind.
2681
+ // A soft centre bias keeps the fill dimensional while the edge remains crisp.
2682
+ vec2 normalizedPoint = panelPoint / max(panelHalfSize, vec2(1.0));
2683
+ float centreLight = 1.0 - smoothstep(0.05, 1.25, length(normalizedPoint));
2684
+ float fillLight = clamp(emittedLight * max(uEmitterFill, 0.0), 0.0, 1.0) * body;
2685
+ vec3 illuminatedFill = mix(edgeColor, lightColor, 0.62 + centreLight * 0.28);
2686
+ color = mix(color, illuminatedFill * (0.72 + centreLight * 0.62), fillLight);
2687
+
2688
+ // Fine object-space luminance grain. It is intentionally emission-gated so
2689
+ // receiver panels stay clean and the texture stays fixed on the active tile.
2690
+ float grainScale = max(uGrainScale * pixelScale, 0.75);
2691
+ vec2 grainCell = floor(pixel / grainScale);
2692
+ float grainValue = random(grainCell);
2693
+ float grainLight = (grainValue - 0.36) * max(uGrain, 0.0) * fillLight;
2694
+ color += lightColor * grainLight * (0.5 + centreLight * 0.75);
2695
+
2696
+ color += edgeColor * edge * (0.42 + emittedLight * 1.7);
2697
+ color += lightColor * edge * receivedLight * 2.5;
2698
+ color += lightColor * innerEdge * receivedLight * 1.25;
2699
+
2700
+ float intensity = max(uIntensity, 0.0);
2701
+ float halo = outsideGlow * (1.0 - body) * 0.9 * intensity;
2702
+ float alpha = body + halo;
2703
+ if (alpha < 0.002) discard;
2704
+
2705
+ vec3 haloColor = mix(edgeColor, lightColor, clamp(receivedLight * 1.5, 0.0, 1.0));
2706
+ vec3 premultiplied = color * body * intensity + haloColor * halo;
2707
+ gl_FragColor = vec4(clamp(premultiplied, 0.0, 1.0), clamp(alpha, 0.0, 1.0));
2708
+ }
2709
+ `;
2710
+ var reactivePanelProgram = {
2711
+ name: "reactivePanel",
2712
+ fragmentSource: fragmentSource18,
2713
+ defaultParameters: {
2714
+ intensity: 0.5,
2715
+ speed: 0.18,
2716
+ emission: 0,
2717
+ reception: 0.85,
2718
+ emitterFill: 0,
2719
+ grain: 0,
2720
+ grainScale: 1.5,
2721
+ cornerRadius: 18,
2722
+ borderWidth: 2,
2723
+ glowRadius: 90,
2724
+ lightX: 0.5,
2725
+ lightY: 0.5,
2726
+ lightStrength: 0,
2727
+ baseColor: "#09101c",
2728
+ edgeColor: "#33b8ff",
2729
+ lightColor: "#59d1ff"
2730
+ },
2731
+ replacesBaseFill: true
2383
2732
  };
2384
2733
 
2385
2734
  // src/runtime/viewer/shaders/builtins/ruler.ts
2386
- var fragmentSource16 = `
2735
+ var fragmentSource19 = `
2387
2736
  precision highp float;
2388
2737
 
2389
2738
  uniform vec2 uResolution;
@@ -2488,12 +2837,120 @@ void main() {
2488
2837
  `;
2489
2838
  var rulerProgram = {
2490
2839
  name: "ruler",
2491
- fragmentSource: fragmentSource16,
2840
+ fragmentSource: fragmentSource19,
2492
2841
  replacesBaseFill: true
2493
2842
  };
2494
2843
 
2844
+ // src/runtime/viewer/shaders/builtins/silkFolds.ts
2845
+ var fragmentSource20 = `
2846
+ precision highp float;
2847
+
2848
+ uniform vec2 uResolution;
2849
+ uniform float uTime;
2850
+ uniform float uSpeed;
2851
+ uniform float uIntensity;
2852
+ uniform float uScale;
2853
+ uniform float uSharpness;
2854
+ uniform float uDepth;
2855
+ uniform float uGlow;
2856
+ uniform float uGrain;
2857
+ uniform float uRotation;
2858
+ uniform float uRipple;
2859
+ uniform float uWave;
2860
+ uniform float uVariation;
2861
+ uniform float uFade;
2862
+ uniform float uReaction;
2863
+ uniform float uHover;
2864
+ uniform vec2 uPointer;
2865
+ uniform float uCornerRadius;
2866
+ uniform vec3 uBaseColor;
2867
+ uniform vec3 uColor;
2868
+ uniform vec3 uHighlightColor;
2869
+ varying vec2 vUv;
2870
+
2871
+ float boxMask(vec2 uv) {
2872
+ vec2 halfBox = uResolution * 0.5;
2873
+ float radius = uCornerRadius * min(uResolution.x, uResolution.y);
2874
+ vec2 q = abs(uv * uResolution - halfBox) - halfBox + radius;
2875
+ float d = length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - radius;
2876
+ return 1.0 - smoothstep(-1.0, 1.0, d);
2877
+ }
2878
+
2879
+ float hash(vec2 p) {
2880
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
2881
+ }
2882
+
2883
+ vec2 turn(vec2 point, float angle) {
2884
+ float c = cos(angle);
2885
+ float s = sin(angle);
2886
+ return vec2(c * point.x - s * point.y, s * point.x + c * point.y);
2887
+ }
2888
+
2889
+ void main() {
2890
+ float shape = boxMask(vUv);
2891
+ if (shape <= 0.0) discard;
2892
+
2893
+ float t = uTime * max(uSpeed, 0.0);
2894
+ float aspect = uResolution.x / uResolution.y;
2895
+ float angle = radians(uRotation);
2896
+ float zoom = max(uScale, 0.2) * 2.0;
2897
+ vec2 p = turn((vUv - 0.5) * vec2(aspect, 1.0), angle) * zoom;
2898
+
2899
+ // An irregular, slow bend of the whole cloth, so no two folds are alike.
2900
+ p += uVariation * 1.3 * vec2(sin(p.y * 0.37 + 3.1), cos(p.x * 0.41 + 1.7));
2901
+
2902
+ // Bend the plane a few times, then lay a wave over it: the crests of the wave are the folds of the cloth.
2903
+ for (int i = 0; i < 3; i++) {
2904
+ float k = float(i);
2905
+ 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));
2906
+ }
2907
+
2908
+ // The cloth lifts where the pointer is over it.
2909
+ vec2 touch = turn((uPointer - 0.5) * vec2(aspect, 1.0), angle) * zoom;
2910
+ float lift = exp(-pow(length(p - touch) * 0.55, 2.0)) * uHover * max(uReaction, 0.0);
2911
+
2912
+ 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;
2913
+ phase += uRipple * 0.35 * sin(p.x * 7.0 + p.y * 5.0 + t * 1.1);
2914
+ float wave = 0.5 + 0.5 * sin(phase);
2915
+
2916
+ float crest = pow(wave, max(uSharpness, 0.5));
2917
+ float body = pow(wave, mix(1.0, 3.2, clamp(uDepth, 0.0, 1.0)));
2918
+ float bloom = pow(wave, 1.3) * max(uGlow, 0.0);
2919
+
2920
+ vec3 color = mix(uBaseColor, uColor, body * 0.9);
2921
+ color += uHighlightColor * (crest * (0.65 + 0.35 * lift) + bloom * 0.28);
2922
+ color *= max(uIntensity, 0.0);
2923
+ color *= 1.0 - clamp(uFade, 0.0, 1.0) * smoothstep(0.3, 0.78, length(vUv - 0.5) * 1.35);
2924
+ color += (hash(gl_FragCoord.xy) - 0.5) * max(uGrain, 0.0);
2925
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), shape);
2926
+ }
2927
+ `;
2928
+ var silkFoldsProgram = {
2929
+ name: "silkFolds",
2930
+ fragmentSource: fragmentSource20,
2931
+ defaultParameters: {
2932
+ speed: 0.2,
2933
+ intensity: 1,
2934
+ scale: 2.2,
2935
+ sharpness: 5,
2936
+ depth: 0.5,
2937
+ glow: 0.3,
2938
+ grain: 0.08,
2939
+ rotation: 0,
2940
+ ripple: 0.3,
2941
+ wave: 1,
2942
+ variation: 0,
2943
+ fade: 0.3,
2944
+ reaction: 1,
2945
+ cornerRadius: 0.02,
2946
+ baseColor: "#030303",
2947
+ color: "#4d4d4d",
2948
+ highlightColor: "#ffffff"
2949
+ }
2950
+ };
2951
+
2495
2952
  // src/runtime/viewer/shaders/builtins/smearOrb.ts
2496
- var fragmentSource17 = `
2953
+ var fragmentSource21 = `
2497
2954
  precision highp float;
2498
2955
 
2499
2956
  uniform vec2 uResolution;
@@ -2569,12 +3026,12 @@ void main() {
2569
3026
  `;
2570
3027
  var smearOrbProgram = {
2571
3028
  name: "smearOrb",
2572
- fragmentSource: fragmentSource17,
3029
+ fragmentSource: fragmentSource21,
2573
3030
  replacesBaseFill: true
2574
3031
  };
2575
3032
 
2576
3033
  // src/runtime/viewer/shaders/builtins/tickScale.ts
2577
- var fragmentSource18 = `
3034
+ var fragmentSource22 = `
2578
3035
  precision highp float;
2579
3036
 
2580
3037
  uniform vec2 uResolution;
@@ -2633,12 +3090,12 @@ void main() {
2633
3090
  `;
2634
3091
  var tickScaleProgram = {
2635
3092
  name: "tickScale",
2636
- fragmentSource: fragmentSource18,
3093
+ fragmentSource: fragmentSource22,
2637
3094
  replacesBaseFill: true
2638
3095
  };
2639
3096
 
2640
3097
  // src/runtime/viewer/shaders/builtins/violetGlass.ts
2641
- var fragmentSource19 = `
3098
+ var fragmentSource23 = `
2642
3099
  precision highp float;
2643
3100
 
2644
3101
  uniform float uTime;
@@ -2718,11 +3175,11 @@ void main() {
2718
3175
  `;
2719
3176
  var violetGlassProgram = {
2720
3177
  name: "violetGlass",
2721
- fragmentSource: fragmentSource19
3178
+ fragmentSource: fragmentSource23
2722
3179
  };
2723
3180
 
2724
3181
  // src/runtime/viewer/shaders/builtins/violetGlassLight.ts
2725
- var fragmentSource20 = `
3182
+ var fragmentSource24 = `
2726
3183
  precision highp float;
2727
3184
 
2728
3185
  uniform float uTime;
@@ -2792,7 +3249,7 @@ void main() {
2792
3249
  `;
2793
3250
  var violetGlassLightProgram = {
2794
3251
  name: "violetGlassLight",
2795
- fragmentSource: fragmentSource20
3252
+ fragmentSource: fragmentSource24
2796
3253
  };
2797
3254
 
2798
3255
  // src/runtime/viewer/shaders/programs.ts
@@ -2816,7 +3273,11 @@ var builtins = [
2816
3273
  violetGlassProgram,
2817
3274
  violetGlassLightProgram,
2818
3275
  lumenPortalProgram,
2819
- lumenPortalLightProgram
3276
+ lumenPortalLightProgram,
3277
+ reactivePanelProgram,
3278
+ ledMatrixProgram,
3279
+ lightBandProgram,
3280
+ silkFoldsProgram
2820
3281
  ];
2821
3282
  var programs = new Map(builtins.map((program) => [program.name, program]));
2822
3283
  function registerShaderProgram(program) {
@@ -2930,8 +3391,8 @@ function uniform2f(surface, name, value) {
2930
3391
  surface.gl.uniform2f(location, ...value);
2931
3392
  }
2932
3393
  }
2933
- function uniformName(parameter) {
2934
- return `u${parameter.charAt(0).toUpperCase()}${parameter.slice(1)}`;
3394
+ function uniformName(parameter2) {
3395
+ return `u${parameter2.charAt(0).toUpperCase()}${parameter2.slice(1)}`;
2935
3396
  }
2936
3397
  function enumParameter(name, value) {
2937
3398
  const values = {
@@ -2997,9 +3458,9 @@ function compile(gl, type, source) {
2997
3458
  }
2998
3459
  return shader;
2999
3460
  }
3000
- function linkProgram(gl, fragmentSource21) {
3461
+ function linkProgram(gl, fragmentSource25) {
3001
3462
  const vertex = compile(gl, gl.VERTEX_SHADER, VERTEX_SOURCE);
3002
- const fragment = compile(gl, gl.FRAGMENT_SHADER, fragmentSource21);
3463
+ const fragment = compile(gl, gl.FRAGMENT_SHADER, fragmentSource25);
3003
3464
  if (!vertex || !fragment) {
3004
3465
  if (vertex) {
3005
3466
  gl.deleteShader(vertex);
@@ -3049,6 +3510,10 @@ function parametersOf(owner) {
3049
3510
  return {};
3050
3511
  }
3051
3512
  }
3513
+ function surfacePaddingOf(owner) {
3514
+ const padding = Number(owner.getAttribute("data-sf-shader-padding"));
3515
+ return Number.isFinite(padding) ? Math.max(0, padding) : 0;
3516
+ }
3052
3517
  function bindFullScreenQuad(gl, program) {
3053
3518
  const buffer = gl.createBuffer();
3054
3519
  if (!buffer) {
@@ -3101,8 +3566,13 @@ function createSurface(canvas) {
3101
3566
  gl,
3102
3567
  program,
3103
3568
  buffer,
3104
- parameters: parametersOf(owner),
3569
+ parameters: { ...definition.defaultParameters, ...parametersOf(owner) },
3570
+ surfacePadding: surfacePaddingOf(owner),
3105
3571
  smoothed: /* @__PURE__ */ new Map(),
3572
+ pointer: { x: 0.5, y: 0.5 },
3573
+ hovering: false,
3574
+ hover: 0,
3575
+ trail: [],
3106
3576
  backdropTexture: usesBackdrop ? transparentTexture(gl) : void 0,
3107
3577
  backdropOrigin: [0, 0],
3108
3578
  backdropScale: [1, 1],
@@ -3128,6 +3598,108 @@ function releaseSurface(surface) {
3128
3598
  }
3129
3599
  }
3130
3600
 
3601
+ // src/runtime/viewer/shaders/reactiveLightField.ts
3602
+ function geometryOf(surface) {
3603
+ const x = Number(surface.owner.getAttribute("x"));
3604
+ const y = Number(surface.owner.getAttribute("y"));
3605
+ const width = Number(surface.owner.getAttribute("width"));
3606
+ const height = Number(surface.owner.getAttribute("height"));
3607
+ if (![x, y, width, height].every(Number.isFinite) || width <= 0 || height <= 0) {
3608
+ return void 0;
3609
+ }
3610
+ const matrix = surface.owner.getCTM?.();
3611
+ const a = matrix?.a ?? 1;
3612
+ const b = matrix?.b ?? 0;
3613
+ const c = matrix?.c ?? 0;
3614
+ const d = matrix?.d ?? 1;
3615
+ const e = matrix?.e ?? 0;
3616
+ const f = matrix?.f ?? 0;
3617
+ const determinant = a * d - b * c;
3618
+ const centerX = a * (x + width / 2) + c * (y + height / 2) + e;
3619
+ const centerY = b * (x + width / 2) + d * (y + height / 2) + f;
3620
+ const localPoint = (worldX, worldY) => {
3621
+ if (Math.abs(determinant) < 1e-6) {
3622
+ return [worldX, worldY];
3623
+ }
3624
+ const translatedX = worldX - e;
3625
+ const translatedY = worldY - f;
3626
+ return [(d * translatedX - c * translatedY) / determinant, (-b * translatedX + a * translatedY) / determinant];
3627
+ };
3628
+ return { width, height, centerX, centerY, localPoint };
3629
+ }
3630
+ function parameter(parameters3, key, fallback) {
3631
+ return number(parameters3[key], fallback);
3632
+ }
3633
+ function normalizedLightPosition(sourceX, sourceY, receiverX, receiverY, receiverWidth, receiverHeight) {
3634
+ return [(sourceX - receiverX) / receiverWidth, (sourceY - receiverY) / receiverHeight];
3635
+ }
3636
+ function updateReactiveLightFields(surfaces) {
3637
+ const reactive = surfaces.filter((surface) => surface.owner.getAttribute("data-sf-shader") === "reactivePanel").flatMap((surface) => {
3638
+ const geometry = geometryOf(surface);
3639
+ return geometry ? [{ surface, geometry }] : [];
3640
+ });
3641
+ for (const receiver of reactive) {
3642
+ const sources = [];
3643
+ for (const candidate of reactive) {
3644
+ if (candidate.surface === receiver.surface) {
3645
+ continue;
3646
+ }
3647
+ const emission = Math.max(
3648
+ 0,
3649
+ candidate.surface.smoothed.get("emission") ?? parameter(candidate.surface.parameters, "emission", 0)
3650
+ );
3651
+ if (emission <= 1e-4) {
3652
+ continue;
3653
+ }
3654
+ const distance = Math.hypot(
3655
+ candidate.geometry.centerX - receiver.geometry.centerX,
3656
+ candidate.geometry.centerY - receiver.geometry.centerY
3657
+ );
3658
+ sources.push({ candidate, emission, weight: emission / Math.max(distance, 1) });
3659
+ }
3660
+ const totalWeight = sources.reduce((sum, source) => sum + source.weight, 0);
3661
+ if (totalWeight <= 0) {
3662
+ receiver.surface.reactiveLight = void 0;
3663
+ continue;
3664
+ }
3665
+ let worldX = 0;
3666
+ let worldY = 0;
3667
+ let sourceEmission = 0;
3668
+ let radius = 0;
3669
+ const lightColor = [0, 0, 0];
3670
+ for (const source of sources) {
3671
+ const influence = source.weight / totalWeight;
3672
+ worldX += source.candidate.geometry.centerX * influence;
3673
+ worldY += source.candidate.geometry.centerY * influence;
3674
+ sourceEmission += source.emission;
3675
+ radius += Math.max(1, parameter(source.candidate.surface.parameters, "glowRadius", 90)) * influence;
3676
+ const sourceColor = color(source.candidate.surface.parameters.lightColor, [0.35, 0.82, 1]);
3677
+ lightColor[0] += sourceColor[0] * influence;
3678
+ lightColor[1] += sourceColor[1] * influence;
3679
+ lightColor[2] += sourceColor[2] * influence;
3680
+ }
3681
+ const receiverStrength = Math.max(0, parameter(receiver.surface.parameters, "lightStrength", 1));
3682
+ const [sourceX, sourceY] = receiver.geometry.localPoint(worldX, worldY);
3683
+ const receiverX = Number(receiver.surface.owner.getAttribute("x"));
3684
+ const receiverY = Number(receiver.surface.owner.getAttribute("y"));
3685
+ const [lightX, lightY] = normalizedLightPosition(
3686
+ sourceX,
3687
+ sourceY,
3688
+ receiverX,
3689
+ receiverY,
3690
+ receiver.geometry.width,
3691
+ receiver.geometry.height
3692
+ );
3693
+ receiver.surface.reactiveLight = {
3694
+ x: lightX,
3695
+ y: lightY,
3696
+ strength: sourceEmission * receiverStrength * 1.8,
3697
+ radius,
3698
+ color: lightColor
3699
+ };
3700
+ }
3701
+ }
3702
+
3131
3703
  // src/runtime/viewer/shaders/renderSurface.ts
3132
3704
  function syncBackdropBounds(surface) {
3133
3705
  const svg = surface.canvas.closest("svg");
@@ -3156,6 +3728,7 @@ function applyBackdrop(surface, backdrop) {
3156
3728
  gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, backdrop.image);
3157
3729
  }
3158
3730
  var MAX_SURFACE_PIXELS = 2560;
3731
+ var TRAIL_LENGTH = 16;
3159
3732
  function renderSurface(surface, seconds) {
3160
3733
  const { canvas, gl, parameters: parameters3 } = surface;
3161
3734
  const shown = canvas.getBoundingClientRect();
@@ -3175,6 +3748,12 @@ function renderSurface(surface, seconds) {
3175
3748
  if (resolution) {
3176
3749
  gl.uniform2f(resolution, width, height);
3177
3750
  }
3751
+ const logicalWidth = Number(surface.owner.getAttribute("width"));
3752
+ uniform1f(
3753
+ surface,
3754
+ "uPixelScale",
3755
+ Number.isFinite(logicalWidth) && logicalWidth > 0 ? width / logicalWidth : density * fit
3756
+ );
3178
3757
  uniform1f(surface, "uTime", seconds);
3179
3758
  if (surface.backdropTexture) {
3180
3759
  syncBackdropBounds(surface);
@@ -3197,6 +3776,28 @@ function renderSurface(surface, seconds) {
3197
3776
  const elapsed = surface.lastSeconds === void 0 ? 0 : Math.max(0, Math.min(seconds - surface.lastSeconds, 0.1));
3198
3777
  surface.lastSeconds = seconds;
3199
3778
  applyParameters(surface, elapsed);
3779
+ surface.hover += ((surface.hovering ? 1 : 0) - surface.hover) * (1 - Math.exp(-elapsed / 0.18));
3780
+ uniform2f(surface, "uPointer", [surface.pointer.x, surface.pointer.y]);
3781
+ uniform1f(surface, "uHover", surface.hover);
3782
+ const fade = number(parameters3.trail, 0);
3783
+ const places = new Float32Array(TRAIL_LENGTH * 3);
3784
+ if (fade > 0) {
3785
+ surface.trail.slice(-TRAIL_LENGTH).forEach((place, index) => {
3786
+ places.set([place.x, place.y, Math.exp(-Math.max(seconds - place.at, 0) / fade)], index * 3);
3787
+ });
3788
+ }
3789
+ const trail = gl.getUniformLocation(surface.program, "uWake[0]");
3790
+ if (trail) {
3791
+ gl.uniform3fv(trail, places);
3792
+ }
3793
+ if (surface.reactiveLight) {
3794
+ uniform1f(surface, "uLightX", surface.reactiveLight.x);
3795
+ uniform1f(surface, "uLightY", surface.reactiveLight.y);
3796
+ uniform1f(surface, "uLightStrength", surface.reactiveLight.strength);
3797
+ uniform1f(surface, "uGlowRadius", surface.reactiveLight.radius);
3798
+ uniform3f(surface, "uLightColor", surface.reactiveLight.color);
3799
+ }
3800
+ uniform1f(surface, "uSurfacePadding", surface.surfacePadding);
3200
3801
  gl.drawArrays(gl.TRIANGLES, 0, 6);
3201
3802
  }
3202
3803
 
@@ -3222,6 +3823,8 @@ function createSurfaceClock(view) {
3222
3823
 
3223
3824
  // src/runtime/viewer/shaders/surface.ts
3224
3825
  var RECAPTURE_DELAY_MS = 120;
3826
+ var TRAIL_SPACING = 0.055;
3827
+ var TRAIL_LENGTH2 = 16;
3225
3828
  function capturePngs(svg, surfaces, seconds) {
3226
3829
  const surfaceByCanvas = new Map(surfaces.map((surface) => [surface.canvas, surface]));
3227
3830
  return [...svg.querySelectorAll("canvas[data-sf-shader-canvas]")].map((canvas) => {
@@ -3245,9 +3848,14 @@ function updateParameters(surfaces, ownerId, parameters3, seconds) {
3245
3848
  }
3246
3849
  Object.assign(surface.parameters, parameters3);
3247
3850
  surface.owner.setAttribute("data-sf-shader-params", JSON.stringify(surface.parameters));
3248
- renderSurface(surface, seconds);
3249
3851
  changed = true;
3250
3852
  }
3853
+ if (changed) {
3854
+ updateReactiveLightFields(surfaces);
3855
+ for (const surface of surfaces) {
3856
+ renderSurface(surface, seconds);
3857
+ }
3858
+ }
3251
3859
  return changed;
3252
3860
  }
3253
3861
  function watchSvgChanges(svg, view, onChange) {
@@ -3272,6 +3880,7 @@ function mountShaderSurfaces(svg) {
3272
3880
  const clock = createSurfaceClock(view);
3273
3881
  const draw = (milliseconds) => {
3274
3882
  if (!clock.paused()) {
3883
+ updateReactiveLightFields(surfaces);
3275
3884
  for (const surface of surfaces) {
3276
3885
  renderSurface(surface, milliseconds / 1e3 - clock.spent());
3277
3886
  }
@@ -3315,12 +3924,41 @@ function mountShaderSurfaces(svg) {
3315
3924
  frame = view.requestAnimationFrame(draw);
3316
3925
  };
3317
3926
  const refresh = () => {
3927
+ const previousState = new Map(
3928
+ surfaces.flatMap((surface) => {
3929
+ const ownerId = surface.owner.getAttribute("data-sf-id");
3930
+ return ownerId ? [
3931
+ [
3932
+ ownerId,
3933
+ {
3934
+ smoothed: new Map(surface.smoothed),
3935
+ reactiveLight: surface.reactiveLight,
3936
+ pointer: surface.pointer,
3937
+ hover: surface.hover,
3938
+ hovering: surface.hovering,
3939
+ trail: surface.trail
3940
+ }
3941
+ ]
3942
+ ] : [];
3943
+ })
3944
+ );
3318
3945
  stop();
3319
3946
  const generation = ++backdropGeneration;
3320
3947
  surfaces = [...svg.querySelectorAll("canvas[data-sf-shader-canvas]")].flatMap((canvas) => {
3321
3948
  const surface = createSurface(canvas);
3949
+ const ownerId = surface?.owner.getAttribute("data-sf-id");
3950
+ const previous = ownerId ? previousState.get(ownerId) : void 0;
3951
+ if (surface && previous) {
3952
+ surface.smoothed = previous.smoothed;
3953
+ surface.reactiveLight = previous.reactiveLight;
3954
+ surface.pointer = previous.pointer;
3955
+ surface.hover = previous.hover;
3956
+ surface.hovering = previous.hovering;
3957
+ surface.trail = previous.trail;
3958
+ }
3322
3959
  return surface ? [surface] : [];
3323
3960
  });
3961
+ updateReactiveLightFields(surfaces);
3324
3962
  captureBackdrops(generation);
3325
3963
  if (surfaces.length > 0) {
3326
3964
  startFrames();
@@ -3336,10 +3974,37 @@ function mountShaderSurfaces(svg) {
3336
3974
  }, RECAPTURE_DELAY_MS);
3337
3975
  };
3338
3976
  const unwatch = watchSvgChanges(svg, view, scheduleRecapture);
3977
+ const track = (event) => {
3978
+ for (const surface of surfaces) {
3979
+ const box = surface.canvas.getBoundingClientRect();
3980
+ const inside = box.width > 0 && box.height > 0 && event.clientX >= box.left && event.clientX <= box.right && event.clientY >= box.top && event.clientY <= box.bottom;
3981
+ surface.hovering = inside;
3982
+ if (inside) {
3983
+ surface.pointer = { x: (event.clientX - box.left) / box.width, y: 1 - (event.clientY - box.top) / box.height };
3984
+ const now = clock.now();
3985
+ const last = surface.trail[surface.trail.length - 1];
3986
+ if (!last || now - last.at >= TRAIL_SPACING) {
3987
+ surface.trail.push({ ...surface.pointer, at: now });
3988
+ if (surface.trail.length > TRAIL_LENGTH2) {
3989
+ surface.trail.shift();
3990
+ }
3991
+ }
3992
+ }
3993
+ }
3994
+ };
3995
+ const leave = () => {
3996
+ for (const surface of surfaces) {
3997
+ surface.hovering = false;
3998
+ }
3999
+ };
4000
+ svg.addEventListener("pointermove", track);
4001
+ svg.addEventListener("pointerleave", leave);
3339
4002
  refresh();
3340
4003
  const destroy = () => {
3341
4004
  backdropGeneration += 1;
3342
4005
  unwatch();
4006
+ svg.removeEventListener("pointermove", track);
4007
+ svg.removeEventListener("pointerleave", leave);
3343
4008
  if (recapture !== void 0) {
3344
4009
  view?.clearTimeout(recapture);
3345
4010
  }
@@ -3602,6 +4267,22 @@ function trackScales(wiring, event) {
3602
4267
  }
3603
4268
  }
3604
4269
  }
4270
+ function driveValue(wiring, id, event) {
4271
+ const { runtime, svg } = wiring;
4272
+ const kind = getComponentDescriptor(runtime.graph.elements.get(id)?.componentType)?.interaction;
4273
+ if (kind !== "slide" && kind !== "pick" && kind !== "turn" && kind !== "range") {
4274
+ return;
4275
+ }
4276
+ const node = svg.querySelector(`[data-sf-primary][data-sf-id="${CSS.escape(id)}"]`);
4277
+ if (!node) {
4278
+ return;
4279
+ }
4280
+ const box = node.getBoundingClientRect();
4281
+ if (box.width > 0 && box.height > 0) {
4282
+ const within = (value) => Math.min(1, Math.max(0, value));
4283
+ runtime.slide(id, within((event.clientX - box.left) / box.width), within((event.clientY - box.top) / box.height));
4284
+ }
4285
+ }
3605
4286
  function updateHover(wiring, event) {
3606
4287
  const { runtime, svg, options, session } = wiring;
3607
4288
  const over = options.enabled?.() === false ? null : hit(svg, runtime.interactive.pressable, event.clientX, event.clientY);
@@ -3633,6 +4314,7 @@ function pressStart(wiring, event) {
3633
4314
  session.active = id;
3634
4315
  trackScales(wiring, event);
3635
4316
  runtime.press(id);
4317
+ driveValue(wiring, id, event);
3636
4318
  runtime.drag(id);
3637
4319
  }
3638
4320
  function pressMove(wiring, event) {
@@ -3642,6 +4324,7 @@ function pressMove(wiring, event) {
3642
4324
  return;
3643
4325
  }
3644
4326
  trackScales(wiring, event);
4327
+ driveValue(wiring, session.active, event);
3645
4328
  runtime.drag(session.active);
3646
4329
  }
3647
4330
  function pressEnd(wiring, event, tapOnElement) {
@@ -3721,5 +4404,5 @@ function createViewer(options) {
3721
4404
  }
3722
4405
 
3723
4406
  export { SHADER_DEFAULTS, connectInteraction, createViewer, registerShaderProgram, shaderProgram };
3724
- //# sourceMappingURL=chunk-G7NRK5AG.js.map
3725
- //# sourceMappingURL=chunk-G7NRK5AG.js.map
4407
+ //# sourceMappingURL=chunk-MUKIGLR5.js.map
4408
+ //# sourceMappingURL=chunk-MUKIGLR5.js.map