vireglass 2.0.0 → 2.1.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.
- package/dist/{chunk-JF3FK254.js → chunk-BZC2WHCK.js} +3 -3
- package/dist/{chunk-JF3FK254.js.map → chunk-BZC2WHCK.js.map} +1 -1
- package/dist/{chunk-IQOBZGCF.js → chunk-FL5UZPY5.js} +28 -30
- package/dist/chunk-FL5UZPY5.js.map +1 -0
- package/dist/dom.cjs +31 -32
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +12 -1
- package/dist/dom.d.ts +12 -1
- package/dist/dom.js +5 -4
- package/dist/dom.js.map +1 -1
- package/dist/{group-model-8u4GKrUu.d.cts → group-model-DwtixGhG.d.cts} +15 -6
- package/dist/{group-model-vYSmEVia.d.ts → group-model-z4N27qsC.d.ts} +15 -6
- package/dist/index.cjs +27 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.js +2 -2
- package/package.json +1 -1
- package/src/dom/displacement.ts +7 -2
- package/src/dom/index.ts +9 -1
- package/src/sdf.ts +44 -36
- package/dist/chunk-IQOBZGCF.js.map +0 -1
|
@@ -64,12 +64,21 @@ type MorphShape = {
|
|
|
64
64
|
height: number;
|
|
65
65
|
cornerRadius: number;
|
|
66
66
|
};
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
|
|
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
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
*
|
|
72
|
-
|
|
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
|
@@ -971,36 +971,34 @@ function smin(a, b, k) {
|
|
|
971
971
|
function neckToBridge(gap) {
|
|
972
972
|
return gap > 0 ? gap * 2 : 0;
|
|
973
973
|
}
|
|
974
|
-
function sceneDistance(x, y, w, h, r, smoothing = 0,
|
|
975
|
-
|
|
976
|
-
if (smoothing <= 0
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
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;
|
|
974
|
+
function sceneDistance(x, y, w, h, r, smoothing = 0, ...shapes2) {
|
|
975
|
+
let d = sdfRoundedRect(x, y, w, h, r);
|
|
976
|
+
if (smoothing <= 0) return d;
|
|
977
|
+
for (const s of shapes2) {
|
|
978
|
+
if (!s || s.width <= 0) continue;
|
|
979
|
+
d = smin(d, sdfRoundedRect(x - s.offsetX, y - s.offsetY, s.width, s.height, s.cornerRadius), smoothing);
|
|
1003
980
|
}
|
|
981
|
+
return d;
|
|
982
|
+
}
|
|
983
|
+
function sceneGradient(x, y, w, h, r, smoothing = 0, ...shapes2) {
|
|
984
|
+
let d = sdfRoundedRect(x, y, w, h, r);
|
|
985
|
+
let [gx, gy] = sdfRoundedRectGradient(x, y, w, h, r);
|
|
986
|
+
let blended = false;
|
|
987
|
+
if (smoothing > 0) {
|
|
988
|
+
for (const s of shapes2) {
|
|
989
|
+
if (!s || s.width <= 0) continue;
|
|
990
|
+
const sx = x - s.offsetX;
|
|
991
|
+
const sy = y - s.offsetY;
|
|
992
|
+
const ds = sdfRoundedRect(sx, sy, s.width, s.height, s.cornerRadius);
|
|
993
|
+
const weight = Math.min(Math.max(0.5 + 0.5 * (ds - d) / smoothing, 0), 1);
|
|
994
|
+
const [nx, ny] = sdfRoundedRectGradient(sx, sy, s.width, s.height, s.cornerRadius);
|
|
995
|
+
gx = nx + (gx - nx) * weight;
|
|
996
|
+
gy = ny + (gy - ny) * weight;
|
|
997
|
+
d = smin(d, ds, smoothing);
|
|
998
|
+
blended = true;
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (!blended) return [gx, gy];
|
|
1004
1002
|
gx += EPSILON;
|
|
1005
1003
|
gy += EPSILON;
|
|
1006
1004
|
const len = Math.hypot(gx, gy) || 1;
|