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.
- package/README.md +2 -1
- package/dist/{chunk-JF3FK254.js → chunk-2XJJO7SC.js} +4 -4
- package/dist/{chunk-JF3FK254.js.map → chunk-2XJJO7SC.js.map} +1 -1
- package/dist/{chunk-3PGYF2NK.js → chunk-CTTZNZFV.js} +3 -3
- package/dist/{chunk-3PGYF2NK.js.map → chunk-CTTZNZFV.js.map} +1 -1
- package/dist/{chunk-IQOBZGCF.js → chunk-H5QTBF67.js} +30 -32
- package/dist/chunk-H5QTBF67.js.map +1 -0
- package/dist/{chunk-TTOKBARR.js → chunk-MMPK6DCK.js} +10 -3
- package/dist/chunk-MMPK6DCK.js.map +1 -0
- package/dist/{chunk-P2ZOODXD.js → chunk-SLRPHDV7.js} +3 -3
- package/dist/{chunk-P2ZOODXD.js.map → chunk-SLRPHDV7.js.map} +1 -1
- package/dist/dom.cjs +79 -52
- package/dist/dom.cjs.map +1 -1
- package/dist/dom.d.cts +27 -4
- package/dist/dom.d.ts +27 -4
- package/dist/dom.js +48 -26
- 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 +28 -31
- 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 +5 -5
- package/dist/law.cjs +8 -1
- package/dist/law.cjs.map +1 -1
- package/dist/law.d.cts +7 -0
- package/dist/law.d.ts +7 -0
- package/dist/law.js +1 -1
- package/dist/reference.js +2 -2
- package/dist/web/index.cjs +1 -2
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.js +4 -4
- package/docs/law.md +2 -2
- package/package.json +11 -9
- package/src/dom/body.ts +24 -9
- package/src/dom/displacement.ts +7 -2
- package/src/dom/index.ts +52 -11
- package/src/dom/probe.ts +27 -3
- package/src/law.ts +7 -0
- package/src/sdf.ts +44 -36
- package/dist/chunk-IQOBZGCF.js.map +0 -1
- 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
|
-
/**
|
|
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
|
@@ -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,
|
|
975
|
-
|
|
976
|
-
if (smoothing <= 0
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
return
|
|
982
|
-
}
|
|
983
|
-
function sceneGradient(x, y, w, h, r, smoothing = 0,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
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;
|