vireglass 2.0.0 → 2.2.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 (43) hide show
  1. package/README.md +2 -1
  2. package/dist/{chunk-JF3FK254.js → chunk-2XJJO7SC.js} +4 -4
  3. package/dist/{chunk-JF3FK254.js.map → chunk-2XJJO7SC.js.map} +1 -1
  4. package/dist/{chunk-3PGYF2NK.js → chunk-CTTZNZFV.js} +3 -3
  5. package/dist/{chunk-3PGYF2NK.js.map → chunk-CTTZNZFV.js.map} +1 -1
  6. package/dist/{chunk-IQOBZGCF.js → chunk-H5QTBF67.js} +30 -32
  7. package/dist/chunk-H5QTBF67.js.map +1 -0
  8. package/dist/{chunk-TTOKBARR.js → chunk-MMPK6DCK.js} +10 -3
  9. package/dist/chunk-MMPK6DCK.js.map +1 -0
  10. package/dist/{chunk-P2ZOODXD.js → chunk-SLRPHDV7.js} +3 -3
  11. package/dist/{chunk-P2ZOODXD.js.map → chunk-SLRPHDV7.js.map} +1 -1
  12. package/dist/dom.cjs +79 -52
  13. package/dist/dom.cjs.map +1 -1
  14. package/dist/dom.d.cts +27 -4
  15. package/dist/dom.d.ts +27 -4
  16. package/dist/dom.js +48 -26
  17. package/dist/dom.js.map +1 -1
  18. package/dist/{group-model-8u4GKrUu.d.cts → group-model-DwtixGhG.d.cts} +15 -6
  19. package/dist/{group-model-vYSmEVia.d.ts → group-model-z4N27qsC.d.ts} +15 -6
  20. package/dist/index.cjs +28 -31
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +5 -5
  25. package/dist/law.cjs +8 -1
  26. package/dist/law.cjs.map +1 -1
  27. package/dist/law.d.cts +7 -0
  28. package/dist/law.d.ts +7 -0
  29. package/dist/law.js +1 -1
  30. package/dist/reference.js +2 -2
  31. package/dist/web/index.cjs +1 -2
  32. package/dist/web/index.cjs.map +1 -1
  33. package/dist/web/index.js +4 -4
  34. package/docs/law.md +2 -2
  35. package/package.json +11 -9
  36. package/src/dom/body.ts +24 -9
  37. package/src/dom/displacement.ts +7 -2
  38. package/src/dom/index.ts +52 -11
  39. package/src/dom/probe.ts +27 -3
  40. package/src/law.ts +7 -0
  41. package/src/sdf.ts +44 -36
  42. package/dist/chunk-IQOBZGCF.js.map +0 -1
  43. package/dist/chunk-TTOKBARR.js.map +0 -1
@@ -64,12 +64,21 @@ type MorphShape = {
64
64
  height: number;
65
65
  cornerRadius: number;
66
66
  };
67
- /** Mirrors the scene distance: one shape, smoothly unioned with up to two neighbours when
68
- * `smoothing` is positive. §5's merging and splitting are this union opening and closing. */
69
- declare function sceneDistance(x: number, y: number, w: number, h: number, r: number, smoothing?: number, b?: MorphShape, c?: MorphShape): number;
70
- /** Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which
71
- * the shader derives rather than approximates. */
72
- declare function sceneGradient(x: number, y: number, w: number, h: number, r: number, smoothing?: number, b?: MorphShape, c?: MorphShape): [number, number];
67
+ /**
68
+ * Mirrors the scene distance: one shape, smoothly unioned with any number of neighbours when
69
+ * `smoothing` is positive. §5's merging and splitting are this union opening and closing.
70
+ *
71
+ * A fold, not a pair. The count used to be in the ARGUMENT NAMES — `b` and `c`, and a fourth
72
+ * shape would have been `d` — which is not a limit the material has. Several independent elements
73
+ * flowing into one whole is the behaviour; how many of them there happen to be is the host's.
74
+ */
75
+ declare function sceneDistance(x: number, y: number, w: number, h: number, r: number, smoothing?: number, ...shapes: (MorphShape | undefined)[]): number;
76
+ /**
77
+ * Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which the
78
+ * shader derives rather than approximates. The same fold as `sceneDistance`, carrying the running
79
+ * distance alongside the running normal because each step's weight is measured against it.
80
+ */
81
+ declare function sceneGradient(x: number, y: number, w: number, h: number, r: number, smoothing?: number, ...shapes: (MorphShape | undefined)[]): [number, number];
73
82
  type TouchWarp = {
74
83
  x: number;
75
84
  y: number;
@@ -64,12 +64,21 @@ type MorphShape = {
64
64
  height: number;
65
65
  cornerRadius: number;
66
66
  };
67
- /** Mirrors the scene distance: one shape, smoothly unioned with up to two neighbours when
68
- * `smoothing` is positive. §5's merging and splitting are this union opening and closing. */
69
- declare function sceneDistance(x: number, y: number, w: number, h: number, r: number, smoothing?: number, b?: MorphShape, c?: MorphShape): number;
70
- /** Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which
71
- * the shader derives rather than approximates. */
72
- declare function sceneGradient(x: number, y: number, w: number, h: number, r: number, smoothing?: number, b?: MorphShape, c?: MorphShape): [number, number];
67
+ /**
68
+ * Mirrors the scene distance: one shape, smoothly unioned with any number of neighbours when
69
+ * `smoothing` is positive. §5's merging and splitting are this union opening and closing.
70
+ *
71
+ * A fold, not a pair. The count used to be in the ARGUMENT NAMES — `b` and `c`, and a fourth
72
+ * shape would have been `d` — which is not a limit the material has. Several independent elements
73
+ * flowing into one whole is the behaviour; how many of them there happen to be is the host's.
74
+ */
75
+ declare function sceneDistance(x: number, y: number, w: number, h: number, r: number, smoothing?: number, ...shapes: (MorphShape | undefined)[]): number;
76
+ /**
77
+ * Mirrors `vgSceneNormal`: normals blend with the same weight that blends the distances, which the
78
+ * shader derives rather than approximates. The same fold as `sceneDistance`, carrying the running
79
+ * distance alongside the running normal because each step's weight is measured against it.
80
+ */
81
+ declare function sceneGradient(x: number, y: number, w: number, h: number, r: number, smoothing?: number, ...shapes: (MorphShape | undefined)[]): [number, number];
73
82
  type TouchWarp = {
74
83
  x: number;
75
84
  y: number;
package/dist/index.cjs CHANGED
@@ -41,8 +41,7 @@ var BODY = {
41
41
  darkSideFrom: 0.42,
42
42
  darkSideTo: 0.58,
43
43
  /** Ceiling on any single demand, so one requirement cannot make the glass opaque on its own. */
44
- maxDemand: 0.92
45
- };
44
+ maxDemand: 0.92};
46
45
  var DISPERSION = {
47
46
  /** Red bends less than the base index, blue more — and not symmetrically. */
48
47
  redShift: -0.4,
@@ -971,36 +970,34 @@ function smin(a, b, k) {
971
970
  function neckToBridge(gap) {
972
971
  return gap > 0 ? gap * 2 : 0;
973
972
  }
974
- function sceneDistance(x, y, w, h, r, smoothing = 0, b, c) {
975
- const a = sdfRoundedRect(x, y, w, h, r);
976
- if (smoothing <= 0 || !b || b.width <= 0) return a;
977
- const db = sdfRoundedRect(x - b.offsetX, y - b.offsetY, b.width, b.height, b.cornerRadius);
978
- const ab = smin(a, db, smoothing);
979
- if (!c || c.width <= 0) return ab;
980
- const dc = sdfRoundedRect(x - c.offsetX, y - c.offsetY, c.width, c.height, c.cornerRadius);
981
- return smin(ab, dc, smoothing);
982
- }
983
- function sceneGradient(x, y, w, h, r, smoothing = 0, b, c) {
984
- const na = sdfRoundedRectGradient(x, y, w, h, r);
985
- if (smoothing <= 0 || !b || b.width <= 0) return na;
986
- const bx = x - b.offsetX;
987
- const by = y - b.offsetY;
988
- const da = sdfRoundedRect(x, y, w, h, r);
989
- const db = sdfRoundedRect(bx, by, b.width, b.height, b.cornerRadius);
990
- const hb = Math.min(Math.max(0.5 + 0.5 * (db - da) / smoothing, 0), 1);
991
- const nb = sdfRoundedRectGradient(bx, by, b.width, b.height, b.cornerRadius);
992
- let gx = nb[0] + (na[0] - nb[0]) * hb;
993
- let gy = nb[1] + (na[1] - nb[1]) * hb;
994
- if (c && c.width > 0) {
995
- const cx = x - c.offsetX;
996
- const cy = y - c.offsetY;
997
- const dab = smin(da, db, smoothing);
998
- const dc = sdfRoundedRect(cx, cy, c.width, c.height, c.cornerRadius);
999
- const hc = Math.min(Math.max(0.5 + 0.5 * (dc - dab) / smoothing, 0), 1);
1000
- const nc = sdfRoundedRectGradient(cx, cy, c.width, c.height, c.cornerRadius);
1001
- gx = nc[0] + (gx - nc[0]) * hc;
1002
- gy = nc[1] + (gy - nc[1]) * hc;
973
+ function sceneDistance(x, y, w, h, r, smoothing = 0, ...shapes2) {
974
+ let d = sdfRoundedRect(x, y, w, h, r);
975
+ if (smoothing <= 0) return d;
976
+ for (const s of shapes2) {
977
+ if (!s || s.width <= 0) continue;
978
+ d = smin(d, sdfRoundedRect(x - s.offsetX, y - s.offsetY, s.width, s.height, s.cornerRadius), smoothing);
979
+ }
980
+ return d;
981
+ }
982
+ function sceneGradient(x, y, w, h, r, smoothing = 0, ...shapes2) {
983
+ let d = sdfRoundedRect(x, y, w, h, r);
984
+ let [gx, gy] = sdfRoundedRectGradient(x, y, w, h, r);
985
+ let blended = false;
986
+ if (smoothing > 0) {
987
+ for (const s of shapes2) {
988
+ if (!s || s.width <= 0) continue;
989
+ const sx = x - s.offsetX;
990
+ const sy = y - s.offsetY;
991
+ const ds = sdfRoundedRect(sx, sy, s.width, s.height, s.cornerRadius);
992
+ const weight = Math.min(Math.max(0.5 + 0.5 * (ds - d) / smoothing, 0), 1);
993
+ const [nx, ny] = sdfRoundedRectGradient(sx, sy, s.width, s.height, s.cornerRadius);
994
+ gx = nx + (gx - nx) * weight;
995
+ gy = ny + (gy - ny) * weight;
996
+ d = smin(d, ds, smoothing);
997
+ blended = true;
998
+ }
1003
999
  }
1000
+ if (!blended) return [gx, gy];
1004
1001
  gx += EPSILON;
1005
1002
  gy += EPSILON;
1006
1003
  const len = Math.hypot(gx, gy) || 1;