@robosystems/core 0.21.7 → 0.22.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 +1 -0
- package/graph-stage/Dust.d.ts +10 -0
- package/graph-stage/Dust.js +28 -0
- package/graph-stage/GraphGalaxies.d.ts +11 -0
- package/graph-stage/GraphGalaxies.js +47 -0
- package/graph-stage/GraphOrb.d.ts +6 -0
- package/graph-stage/GraphOrb.js +94 -0
- package/graph-stage/GraphStage.d.ts +10 -0
- package/graph-stage/GraphStage.js +24 -0
- package/graph-stage/GridFloor.d.ts +10 -0
- package/graph-stage/GridFloor.js +11 -0
- package/graph-stage/NodeGlow.d.ts +6 -0
- package/graph-stage/NodeGlow.js +22 -0
- package/graph-stage/graphGalaxy.d.ts +24 -0
- package/graph-stage/graphGalaxy.js +87 -0
- package/graph-stage/graphStageGl.d.ts +47 -0
- package/graph-stage/graphStageGl.js +389 -0
- package/graph-stage/index.d.ts +7 -0
- package/graph-stage/index.js +7 -0
- package/graph-stage/palette.d.ts +15 -0
- package/graph-stage/palette.js +40 -0
- package/package.json +1 -1
- package/styles/graph-stage.css +360 -0
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@ Part of RoboSystems, the open-source knowledge graph for finance. Shared React c
|
|
|
12
12
|
- **Task monitoring** — SSE-based operation monitoring with a polling fallback for long-running jobs
|
|
13
13
|
- **UI components** — layout, chat, forms, settings, API keys, and the shared Tailwind theme and the owned UI primitives (`@robosystems/core/ui`)
|
|
14
14
|
- **Docs rendering** — the docs catalog loader (`@robosystems/core/docs/catalog`) and the markdown renderer (`@robosystems/core/docs/DocsMarkdown`), server-side, for each app's `/docs`
|
|
15
|
+
- **Graph stage** — the landing pages' backdrop (`@robosystems/core/graph-stage`): a live clustered graph, dust, sphere orbs, galaxies, a grid floor and the `node-card` / `node-icon` styles, in each app's own colours
|
|
15
16
|
- **Hooks & utilities** — user, limits, toast, and media-query hooks plus cookie persistence helpers
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dust of the brand film's stage as a section backdrop: faint points drifting
|
|
3
|
+
* slowly upward, in two layers at different speeds. It is two repeating tiles moved by CSS,
|
|
4
|
+
* so it costs no script and carries on below the hero's live graph without a second WebGL
|
|
5
|
+
* canvas. Each tile is a mask over the first brand colour (`--graph-1`), so the dust takes
|
|
6
|
+
* the app's colour. Decorative, and still for a visitor who asks for reduced motion.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Dust({ className }: {
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The dust of the brand film's stage as a section backdrop: faint points drifting
|
|
4
|
+
* slowly upward, in two layers at different speeds. It is two repeating tiles moved by CSS,
|
|
5
|
+
* so it costs no script and carries on below the hero's live graph without a second WebGL
|
|
6
|
+
* canvas. Each tile is a mask over the first brand colour (`--graph-1`), so the dust takes
|
|
7
|
+
* the app's colour. Decorative, and still for a visitor who asks for reduced motion.
|
|
8
|
+
*/
|
|
9
|
+
/** One square tile of seeded points, as a CSS mask image. */
|
|
10
|
+
function tile(seed, size, count) {
|
|
11
|
+
let s = seed;
|
|
12
|
+
const rnd = () => ((s = (s * 16807) % 2147483647), s / 2147483647);
|
|
13
|
+
const dots = Array.from({ length: count }, (_, i) => {
|
|
14
|
+
// every eighth point is large and soft, out of the lens's focus
|
|
15
|
+
const soft = i % 8 === 0;
|
|
16
|
+
const r = soft ? 3 + rnd() * 3 : 0.6 + rnd() * 1.3;
|
|
17
|
+
const o = soft ? 0.05 + rnd() * 0.06 : 0.14 + rnd() * 0.34;
|
|
18
|
+
const [x, y] = [rnd() * size, rnd() * size];
|
|
19
|
+
return `<circle cx="${x.toFixed(1)}" cy="${y.toFixed(1)}" r="${r.toFixed(1)}" opacity="${o.toFixed(2)}"/>`;
|
|
20
|
+
});
|
|
21
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="#000">${dots.join('')}</svg>`;
|
|
22
|
+
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
|
23
|
+
}
|
|
24
|
+
const NEAR = tile(11, 900, 46);
|
|
25
|
+
const FAR = tile(29, 620, 40);
|
|
26
|
+
export function Dust({ className = '' }) {
|
|
27
|
+
return (_jsxs("div", { "aria-hidden": "true", className: `pointer-events-none absolute inset-0 overflow-hidden ${className}`, children: [_jsx("div", { className: "graph-dust graph-dust-far absolute inset-x-0 top-0 h-[calc(100%+620px)] opacity-60", style: { maskImage: FAR, WebkitMaskImage: FAR } }), _jsx("div", { className: "graph-dust graph-dust-near absolute inset-x-0 top-0 h-[calc(100%+900px)]", style: { maskImage: NEAR, WebkitMaskImage: NEAR } })] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Knowledge graphs in the distance behind a section: a few galaxies of clustered nodes,
|
|
3
|
+
* different on every visit, each floating and turning slowly. Decorative, drawn only in the
|
|
4
|
+
* browser (the server sends nothing, so nothing random has to match), and still for a
|
|
5
|
+
* visitor who asks for reduced motion.
|
|
6
|
+
*/
|
|
7
|
+
export declare function GraphGalaxies({ count, keepClear, }: {
|
|
8
|
+
count?: number;
|
|
9
|
+
/** A side to leave empty, for a section that has something else there. */
|
|
10
|
+
keepClear?: 'left' | 'right';
|
|
11
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useSyncExternalStore } from 'react';
|
|
4
|
+
import { buildGalaxy, HUB } from './graphGalaxy';
|
|
5
|
+
import { ink } from './palette';
|
|
6
|
+
const subscribeNever = () => () => { };
|
|
7
|
+
const colour = (hue) => (hue === HUB ? '#fff' : ink(hue));
|
|
8
|
+
/** Galaxies scattered toward the edges of a section, smaller ones dimmer, as if further off. */
|
|
9
|
+
function scatter(count, keepClear) {
|
|
10
|
+
const rnd = Math.random;
|
|
11
|
+
const firstLeft = rnd() < 0.5;
|
|
12
|
+
return Array.from({ length: count }, (_, i) => {
|
|
13
|
+
const left = keepClear ? keepClear === 'right' : firstLeft === (i % 2 === 0);
|
|
14
|
+
const size = 260 + rnd() * 400;
|
|
15
|
+
const edge = `${-(size * (0.1 + rnd() * 0.28)).toFixed(0)}px`;
|
|
16
|
+
return {
|
|
17
|
+
galaxy: buildGalaxy(rnd),
|
|
18
|
+
style: {
|
|
19
|
+
width: size,
|
|
20
|
+
height: size,
|
|
21
|
+
top: `${(4 + ((i + rnd()) / count) * 78).toFixed(1)}%`,
|
|
22
|
+
[left ? 'left' : 'right']: edge,
|
|
23
|
+
opacity: 0.42 + ((size - 260) / 400) * 0.45,
|
|
24
|
+
},
|
|
25
|
+
spin: {
|
|
26
|
+
animationDuration: `${(220 + rnd() * 260).toFixed(0)}s`,
|
|
27
|
+
animationDirection: rnd() < 0.5 ? 'normal' : 'reverse',
|
|
28
|
+
},
|
|
29
|
+
float: i % 2 ? 'graph-float-b' : 'graph-float-a',
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Knowledge graphs in the distance behind a section: a few galaxies of clustered nodes,
|
|
35
|
+
* different on every visit, each floating and turning slowly. Decorative, drawn only in the
|
|
36
|
+
* browser (the server sends nothing, so nothing random has to match), and still for a
|
|
37
|
+
* visitor who asks for reduced motion.
|
|
38
|
+
*/
|
|
39
|
+
export function GraphGalaxies({ count = 2, keepClear, }) {
|
|
40
|
+
const inBrowser = useSyncExternalStore(subscribeNever, () => true, () => false);
|
|
41
|
+
const [placed] = useState(() => scatter(count, keepClear));
|
|
42
|
+
if (!inBrowser)
|
|
43
|
+
return null;
|
|
44
|
+
return (_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 overflow-hidden", children: placed.map(({ galaxy, style, spin, float }, i) => (_jsx("div", { className: `absolute ${float}`, style: style, children: _jsxs("svg", { viewBox: "-1.05 -1.05 2.1 2.1", className: "graph-turn h-full w-full", style: spin, children: [galaxy.links.map(({ a, b, lit, hue }) => (_jsx("line", { x1: galaxy.nodes[a].x, y1: galaxy.nodes[a].y, x2: galaxy.nodes[b].x, y2: galaxy.nodes[b].y, style: { stroke: colour(hue) }, strokeWidth: 0.004, opacity: lit * 0.5 }, `${a}-${b}`))), galaxy.nodes.map(({ x, y, r, lit, hue }, n) => (_jsx("circle", { cx: x, cy: y, r: r, style: { fill: colour(hue) }, opacity: lit }, n))), galaxy.nodes
|
|
45
|
+
.filter(({ hue }) => hue === HUB)
|
|
46
|
+
.map(({ x, y, r, lit }, n) => (_jsx("circle", { cx: x, cy: y, r: r * 2.1, fill: "none", stroke: "#ffffff", strokeWidth: 0.004, opacity: lit * 0.45 }, `ring-${n}`)))] }) }, i))) }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function GraphOrb({ side, count, }: {
|
|
2
|
+
/** The edge of the section the balls hang off. */
|
|
3
|
+
side: 'left' | 'right';
|
|
4
|
+
/** How many balls: one large and close, or two or three smaller at different distances. */
|
|
5
|
+
count?: 1 | 2 | 3;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useSyncExternalStore } from 'react';
|
|
4
|
+
import { ink as tint } from './palette';
|
|
5
|
+
/**
|
|
6
|
+
* The brand film's sphere as a section backdrop: balls of linked points, each with a soft
|
|
7
|
+
* glow for its body, hanging off one edge of the section, floating and turning slowly. One
|
|
8
|
+
* alone is large and close; two or three are smaller, and the smaller a ball the dimmer it
|
|
9
|
+
* is, as if further off. Each is a node of the galaxies seen near: a graph inside a node.
|
|
10
|
+
* Sizes, places and angles are drawn at random in the browser, so they differ on every
|
|
11
|
+
* visit. Inline SVG moved by CSS: no canvas. Decorative.
|
|
12
|
+
*/
|
|
13
|
+
const COUNT = 150;
|
|
14
|
+
// The film's sphere: points spread evenly over a ball, each joined to its three nearest.
|
|
15
|
+
const BALL = Array.from({ length: COUNT }, (_, i) => {
|
|
16
|
+
const y = 1 - (i / (COUNT - 1)) * 2;
|
|
17
|
+
const r = Math.sqrt(1 - y * y);
|
|
18
|
+
const a = i * 2.39996;
|
|
19
|
+
return [Math.cos(a) * r, y, Math.sin(a) * r];
|
|
20
|
+
});
|
|
21
|
+
const LINKS = BALL.flatMap((p, i) => BALL.map((q, j) => ({
|
|
22
|
+
j,
|
|
23
|
+
d: Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]),
|
|
24
|
+
}))
|
|
25
|
+
.sort((m, n) => m.d - n.d)
|
|
26
|
+
.slice(1, 4)
|
|
27
|
+
.filter(({ j }) => i < j)
|
|
28
|
+
.map(({ j }) => [i, j]));
|
|
29
|
+
const lit = (z) => 0.14 + 0.86 * Math.max(0, Math.min(1, z + 0.4));
|
|
30
|
+
/** The ball turned to an angle and flattened onto the page; depth decides brightness. */
|
|
31
|
+
function turned(ay, ax) {
|
|
32
|
+
const [cy, sy, cx, sx] = [
|
|
33
|
+
Math.cos(ay),
|
|
34
|
+
Math.sin(ay),
|
|
35
|
+
Math.cos(ax),
|
|
36
|
+
Math.sin(ax),
|
|
37
|
+
];
|
|
38
|
+
return BALL.map(([x, y, z]) => {
|
|
39
|
+
const [x1, z1] = [x * cy + z * sy, z * cy - x * sy];
|
|
40
|
+
return { x: x1, y: y * cx - z1 * sx, z: y * sx + z1 * cx };
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
// each ball's lines in one brand colour's lighter shade, its glow in that colour and the next
|
|
44
|
+
const TINTS = [
|
|
45
|
+
[tint(1), `${tint(0, 0.16)}, ${tint(2, 0.08)}`],
|
|
46
|
+
[tint(3), `${tint(2, 0.18)}, ${tint(4, 0.08)}`],
|
|
47
|
+
[tint(5), `${tint(4, 0.18)}, ${tint(0, 0.07)}`],
|
|
48
|
+
];
|
|
49
|
+
// how large a ball may be, by how many share the section: [smallest, largest] in px
|
|
50
|
+
const SIZES = {
|
|
51
|
+
1: [560, 720],
|
|
52
|
+
2: [300, 580],
|
|
53
|
+
3: [220, 480],
|
|
54
|
+
};
|
|
55
|
+
function scatter(count, side) {
|
|
56
|
+
const rnd = Math.random;
|
|
57
|
+
const [lo, hi] = SIZES[count];
|
|
58
|
+
return Array.from({ length: count }, (_, i) => {
|
|
59
|
+
// 0 = the furthest a ball gets here, 1 = the nearest
|
|
60
|
+
const near = count === 1 ? rnd() : (i + rnd()) / count;
|
|
61
|
+
const size = lo + (hi - lo) * near;
|
|
62
|
+
const [ink, glow] = TINTS[Math.floor(rnd() * TINTS.length)];
|
|
63
|
+
return {
|
|
64
|
+
points: turned(rnd() * Math.PI * 2, (rnd() - 0.5) * 1.2),
|
|
65
|
+
ink,
|
|
66
|
+
glow,
|
|
67
|
+
near,
|
|
68
|
+
// a near ball hangs well off the edge; a far one sits just inside it
|
|
69
|
+
box: {
|
|
70
|
+
width: size,
|
|
71
|
+
height: size,
|
|
72
|
+
[side]: -size * (0.05 + 0.38 * near),
|
|
73
|
+
},
|
|
74
|
+
spin: {
|
|
75
|
+
animationDuration: `${(200 + rnd() * 200).toFixed(0)}s`,
|
|
76
|
+
animationDirection: rnd() < 0.5 ? 'normal' : 'reverse',
|
|
77
|
+
},
|
|
78
|
+
float: i % 2 ? 'graph-float-b' : 'graph-float-a',
|
|
79
|
+
};
|
|
80
|
+
})
|
|
81
|
+
.sort(() => rnd() - 0.5)
|
|
82
|
+
.map((orb, slot) => (Object.assign(Object.assign({}, orb), { box: Object.assign(Object.assign({}, orb.box), { top: `${(6 + ((slot + rnd() * 0.5) / count) * 72).toFixed(1)}%` }) })));
|
|
83
|
+
}
|
|
84
|
+
const subscribeNever = () => () => { };
|
|
85
|
+
const n = (v) => v.toFixed(3);
|
|
86
|
+
export function GraphOrb({ side, count = 1, }) {
|
|
87
|
+
const inBrowser = useSyncExternalStore(subscribeNever, () => true, () => false);
|
|
88
|
+
const [orbs] = useState(() => scatter(count, side));
|
|
89
|
+
if (!inBrowser)
|
|
90
|
+
return null;
|
|
91
|
+
return (_jsx("div", { "aria-hidden": "true", className: "pointer-events-none absolute inset-0 overflow-hidden", children: orbs.map(({ points, ink, glow, box, near, spin, float }, i) => (_jsxs("div", { className: `absolute ${float}`, style: Object.assign(Object.assign({}, box), { opacity: 0.45 + 0.55 * near }), children: [_jsx("div", { className: "absolute inset-0 rounded-full blur-2xl", style: {
|
|
92
|
+
backgroundImage: `radial-gradient(circle at 38% 32%, ${glow} 48%, transparent 70%)`,
|
|
93
|
+
} }), _jsxs("svg", { viewBox: "-1.06 -1.06 2.12 2.12", className: "graph-turn absolute inset-0 h-full w-full opacity-60", style: spin, children: [_jsx("g", { style: { stroke: ink }, strokeWidth: "0.004", children: LINKS.map(([a, b]) => (_jsx("line", { x1: n(points[a].x), y1: n(points[a].y), x2: n(points[b].x), y2: n(points[b].y), opacity: n(lit((points[a].z + points[b].z) / 2) * 0.6) }, `${a}-${b}`))) }), _jsx("g", { fill: "#fff", children: points.map((p, k) => (_jsx("circle", { cx: n(p.x), cy: n(p.y), r: k % 6 === 0 ? 0.02 : 0.012, opacity: n(lit(p.z)) }, k))) })] })] }, i))) }));
|
|
94
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A knowledge graph in the brand film's look, as a live backdrop, in the colours the app
|
|
3
|
+
* sets (see palette.ts). Decorative: it fills its positioned parent, takes no pointer events
|
|
4
|
+
* and is hidden from screen readers.
|
|
5
|
+
*/
|
|
6
|
+
export declare function GraphStage({ besideFrom, className, }: {
|
|
7
|
+
/** The width from which the page sets its words beside the graph (Tailwind's xl). */
|
|
8
|
+
besideFrom?: number;
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { mountGraphStage } from './graphStageGl';
|
|
5
|
+
/**
|
|
6
|
+
* A knowledge graph in the brand film's look, as a live backdrop, in the colours the app
|
|
7
|
+
* sets (see palette.ts). Decorative: it fills its positioned parent, takes no pointer events
|
|
8
|
+
* and is hidden from screen readers.
|
|
9
|
+
*/
|
|
10
|
+
export function GraphStage({ besideFrom = 1280, className = '', }) {
|
|
11
|
+
const canvas = useRef(null);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!canvas.current)
|
|
14
|
+
return;
|
|
15
|
+
try {
|
|
16
|
+
return mountGraphStage(canvas.current, besideFrom);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
// The page stands without the backdrop, but a broken shader should still show up.
|
|
20
|
+
console.error('GraphStage failed to start', err);
|
|
21
|
+
}
|
|
22
|
+
}, [besideFrom]);
|
|
23
|
+
return (_jsx("canvas", { ref: canvas, "aria-hidden": "true", className: `pointer-events-none absolute inset-0 h-full w-full ${className}` }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A grid floor running away to a horizon, for the foot of a section. It is one plane tilted
|
|
3
|
+
* in perspective: the horizon sits perspective / tan(tilt) above the section's foot, about
|
|
4
|
+
* 480px here. The lines that run across are drawn thicker, because the tilt thins them and
|
|
5
|
+
* they would vanish. Drawn in the first brand colour (`--graph-1`). Decorative; it fills
|
|
6
|
+
* the width of its positioned parent, which should hide its overflow.
|
|
7
|
+
*/
|
|
8
|
+
export declare function GridFloor({ className }: {
|
|
9
|
+
className?: string;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A grid floor running away to a horizon, for the foot of a section. It is one plane tilted
|
|
4
|
+
* in perspective: the horizon sits perspective / tan(tilt) above the section's foot, about
|
|
5
|
+
* 480px here. The lines that run across are drawn thicker, because the tilt thins them and
|
|
6
|
+
* they would vanish. Drawn in the first brand colour (`--graph-1`). Decorative; it fills
|
|
7
|
+
* the width of its positioned parent, which should hide its overflow.
|
|
8
|
+
*/
|
|
9
|
+
export function GridFloor({ className = '' }) {
|
|
10
|
+
return (_jsx("div", { "aria-hidden": "true", className: `graph-floor pointer-events-none absolute -inset-x-[150%] bottom-0 h-[600%] origin-bottom ${className}` }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lights the cards marked `node-card` under the pointer. Mounted once on a page, it tells
|
|
3
|
+
* whichever card the pointer is over where the pointer is (`--mx`, `--my`), and the
|
|
4
|
+
* `node-card` styles in styles/graph-stage.css draw the glow and the lit edge from that. Renders nothing.
|
|
5
|
+
*/
|
|
6
|
+
export declare function NodeGlow(): any;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Lights the cards marked `node-card` under the pointer. Mounted once on a page, it tells
|
|
5
|
+
* whichever card the pointer is over where the pointer is (`--mx`, `--my`), and the
|
|
6
|
+
* `node-card` styles in styles/graph-stage.css draw the glow and the lit edge from that. Renders nothing.
|
|
7
|
+
*/
|
|
8
|
+
export function NodeGlow() {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const move = (e) => {
|
|
11
|
+
const card = e.target instanceof Element ? e.target.closest('.node-card') : null;
|
|
12
|
+
if (!(card instanceof HTMLElement))
|
|
13
|
+
return;
|
|
14
|
+
const box = card.getBoundingClientRect();
|
|
15
|
+
card.style.setProperty('--mx', `${e.clientX - box.left}px`);
|
|
16
|
+
card.style.setProperty('--my', `${e.clientY - box.top}px`);
|
|
17
|
+
};
|
|
18
|
+
document.addEventListener('pointermove', move, { passive: true });
|
|
19
|
+
return () => document.removeEventListener('pointermove', move);
|
|
20
|
+
}, []);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One galaxy: a small knowledge graph in clusters, like the hero's, but drawn from whatever
|
|
3
|
+
* random source it is given, so no two are alike. Built in three dimensions, turned to a
|
|
4
|
+
* random angle and flattened onto the page; a node's depth decides how bright it is.
|
|
5
|
+
*/
|
|
6
|
+
export interface Galaxy {
|
|
7
|
+
/** x, y in -1..1, radius, brightness 0..1, and a palette colour (`HUB` for a hub). */
|
|
8
|
+
nodes: Array<{
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
r: number;
|
|
12
|
+
lit: number;
|
|
13
|
+
hue: number;
|
|
14
|
+
}>;
|
|
15
|
+
links: Array<{
|
|
16
|
+
a: number;
|
|
17
|
+
b: number;
|
|
18
|
+
lit: number;
|
|
19
|
+
hue: number;
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** A hub's colour: not one of the palette's, it is drawn white. */
|
|
23
|
+
export declare const HUB = -1;
|
|
24
|
+
export declare function buildGalaxy(rnd: () => number): Galaxy;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One galaxy: a small knowledge graph in clusters, like the hero's, but drawn from whatever
|
|
3
|
+
* random source it is given, so no two are alike. Built in three dimensions, turned to a
|
|
4
|
+
* random angle and flattened onto the page; a node's depth decides how bright it is.
|
|
5
|
+
*/
|
|
6
|
+
/** A hub's colour: not one of the palette's, it is drawn white. */
|
|
7
|
+
export const HUB = -1;
|
|
8
|
+
// the three brand colours, in two shades each
|
|
9
|
+
const HUES = 6;
|
|
10
|
+
export function buildGalaxy(rnd) {
|
|
11
|
+
const between = (lo, hi) => lo + rnd() * (hi - lo);
|
|
12
|
+
const clusters = Math.round(between(3, 8));
|
|
13
|
+
// the shape it is spread over: anything from a ball to a flat, stretched disc
|
|
14
|
+
const shape = [between(0.6, 1), between(0.35, 1), between(0.25, 0.9)];
|
|
15
|
+
const turn = between(0, Math.PI * 2);
|
|
16
|
+
const pts = [];
|
|
17
|
+
const hue = [];
|
|
18
|
+
const hubs = [];
|
|
19
|
+
const links = [];
|
|
20
|
+
const d2 = (i, j) => pts[i].reduce((sum, v, k) => sum + (v - pts[j][k]) ** 2, 0);
|
|
21
|
+
const nearest = (i, among, n) => among
|
|
22
|
+
.filter((j) => j !== i)
|
|
23
|
+
.sort((p, q) => d2(i, p) - d2(i, q))
|
|
24
|
+
.slice(0, n);
|
|
25
|
+
for (let c = 0; c < clusters; c++) {
|
|
26
|
+
const y = 1 - ((c + 0.5) / clusters) * 2;
|
|
27
|
+
const r = Math.sqrt(1 - y * y);
|
|
28
|
+
const a = c * 2.39996 + turn;
|
|
29
|
+
const centre = [
|
|
30
|
+
Math.cos(a) * r * shape[0],
|
|
31
|
+
y * shape[1],
|
|
32
|
+
Math.sin(a) * r * shape[2],
|
|
33
|
+
];
|
|
34
|
+
const count = Math.round(between(8, 30));
|
|
35
|
+
const spread = between(0.1, 0.24);
|
|
36
|
+
const tint = Math.floor(rnd() * HUES);
|
|
37
|
+
const members = [];
|
|
38
|
+
for (let m = 0; m < count; m++) {
|
|
39
|
+
const off = () => (m === 0 ? 0 : (rnd() + rnd() + rnd() - 1.5) * spread);
|
|
40
|
+
pts.push([centre[0] + off(), centre[1] + off(), centre[2] + off()]);
|
|
41
|
+
hue.push(m === 0 ? HUB : tint);
|
|
42
|
+
members.push(pts.length - 1);
|
|
43
|
+
}
|
|
44
|
+
hubs.push(members[0]);
|
|
45
|
+
members.slice(1).forEach((n) => {
|
|
46
|
+
if (rnd() < 0.62 || members.length < 3)
|
|
47
|
+
links.push([members[0], n]);
|
|
48
|
+
else
|
|
49
|
+
links.push([n, nearest(n, members.slice(1), 1)[0]]);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
hubs.forEach((h) => nearest(h, hubs, 2).forEach((o) => {
|
|
53
|
+
if (!links.some(([p, q]) => p === o && q === h))
|
|
54
|
+
links.push([h, o]);
|
|
55
|
+
}));
|
|
56
|
+
// a random turn about two axes, then fitted inside the unit circle
|
|
57
|
+
const [ay, ax] = [between(0, Math.PI * 2), between(-0.9, 0.9)];
|
|
58
|
+
const turned = pts.map(([x, y, z]) => {
|
|
59
|
+
const [x1, z1] = [
|
|
60
|
+
x * Math.cos(ay) + z * Math.sin(ay),
|
|
61
|
+
z * Math.cos(ay) - x * Math.sin(ay),
|
|
62
|
+
];
|
|
63
|
+
return [
|
|
64
|
+
x1,
|
|
65
|
+
y * Math.cos(ax) - z1 * Math.sin(ax),
|
|
66
|
+
y * Math.sin(ax) + z1 * Math.cos(ax),
|
|
67
|
+
];
|
|
68
|
+
});
|
|
69
|
+
const reach = Math.max(...turned.map(([x, y]) => Math.hypot(x, y)));
|
|
70
|
+
const lit = (z) => 0.3 + 0.7 * Math.max(0, Math.min(1, z / 1.6 + 0.5));
|
|
71
|
+
const nodes = turned.map(([x, y, z], i) => ({
|
|
72
|
+
x: (x / reach) * 0.97,
|
|
73
|
+
y: (y / reach) * 0.97,
|
|
74
|
+
r: hubs.includes(i) ? 0.026 : between(0.007, 0.014),
|
|
75
|
+
lit: lit(z),
|
|
76
|
+
hue: hue[i],
|
|
77
|
+
}));
|
|
78
|
+
return {
|
|
79
|
+
nodes,
|
|
80
|
+
links: links.map(([a, b]) => ({
|
|
81
|
+
a,
|
|
82
|
+
b,
|
|
83
|
+
lit: (nodes[a].lit + nodes[b].lit) / 2,
|
|
84
|
+
hue: hue[a] === HUB ? hue[b] : hue[a],
|
|
85
|
+
})),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A knowledge graph drawn live, in the look of the brand film: nodes scattered in space come
|
|
3
|
+
* home to clusters around their hubs, drift a little, and turn slowly over a field of dust,
|
|
4
|
+
* while a pulse of light travels each link between hubs. Decoration: the clusters stand for
|
|
5
|
+
* nothing in particular. Plain WebGL with no library, so the landing page pays for a few
|
|
6
|
+
* hundred lines rather than a 3D engine. The lens and the dust are the film stage's own.
|
|
7
|
+
*/
|
|
8
|
+
import { type Rgb } from './palette';
|
|
9
|
+
export declare const RADIUS = 3.4;
|
|
10
|
+
export interface Graph {
|
|
11
|
+
dust: Float32Array;
|
|
12
|
+
dustSize: Float32Array;
|
|
13
|
+
scatter: Float32Array;
|
|
14
|
+
home: Float32Array;
|
|
15
|
+
size: Float32Array;
|
|
16
|
+
/** One colour per node. */
|
|
17
|
+
color: Float32Array;
|
|
18
|
+
/** How far each node drifts about its place. */
|
|
19
|
+
drift: Float32Array;
|
|
20
|
+
/** Index pairs: the relationships drawn between nodes. */
|
|
21
|
+
pairs: number[];
|
|
22
|
+
/** Index pairs, hub to hub, that a pulse of light travels along. */
|
|
23
|
+
routes: number[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Seeded, so every visitor and every screenshot gets the same picture. The palette colours
|
|
27
|
+
* the nodes and takes no part in where they sit.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildGraph(seed?: number, palette?: Rgb[]): Graph;
|
|
30
|
+
/**
|
|
31
|
+
* Where the graph sits: right of the words when they are set beside it, above them
|
|
32
|
+
* otherwise. Beside them its centre is a fixed distance from the top, level with the words,
|
|
33
|
+
* so a tall window does not drop it toward the section below.
|
|
34
|
+
*/
|
|
35
|
+
export declare function placeGraph(aspect: number, beside: boolean, height: number): {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
scale: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Draws the stage on `canvas` until the returned function is called. It runs only while the
|
|
42
|
+
* canvas is on screen, and holds one settled frame for a visitor who asks for reduced
|
|
43
|
+
* motion. Where WebGL is unavailable it draws nothing: the page stands without it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function mountGraphStage(canvas: HTMLCanvasElement,
|
|
46
|
+
/** The CSS width from which the page sets its words beside the graph. */
|
|
47
|
+
besideFrom: number): () => void;
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A knowledge graph drawn live, in the look of the brand film: nodes scattered in space come
|
|
3
|
+
* home to clusters around their hubs, drift a little, and turn slowly over a field of dust,
|
|
4
|
+
* while a pulse of light travels each link between hubs. Decoration: the clusters stand for
|
|
5
|
+
* nothing in particular. Plain WebGL with no library, so the landing page pays for a few
|
|
6
|
+
* hundred lines rather than a 3D engine. The lens and the dust are the film stage's own.
|
|
7
|
+
*/
|
|
8
|
+
import { DEFAULT_PALETTE, readPalette } from './palette';
|
|
9
|
+
const DUST_COUNT = 900;
|
|
10
|
+
export const RADIUS = 3.4; // the graph fits inside a sphere of this size
|
|
11
|
+
const CAM_Z = 14;
|
|
12
|
+
const FOV = 38;
|
|
13
|
+
const BESIDE_CENTRE = 460; // CSS px from the top, the middle of the hero's words
|
|
14
|
+
const SETTLED = 8; // seconds in, the picture reduced motion holds
|
|
15
|
+
const clamp = (x) => Math.max(0, Math.min(1, x));
|
|
16
|
+
const seg = (t, a, b) => clamp((t - a) / (b - a));
|
|
17
|
+
const easeOut = (x) => 1 - Math.pow(1 - clamp(x), 3);
|
|
18
|
+
const easeInOut = (x) => {
|
|
19
|
+
x = clamp(x);
|
|
20
|
+
return x < 0.5 ? 4 * x * x * x : 1 - Math.pow(-2 * x + 2, 3) / 2;
|
|
21
|
+
};
|
|
22
|
+
// Each cluster's size and which palette colour it wears.
|
|
23
|
+
const CLUSTERS = [
|
|
24
|
+
[46, 1],
|
|
25
|
+
[42, 2],
|
|
26
|
+
[38, 5],
|
|
27
|
+
[34, 0],
|
|
28
|
+
[32, 3],
|
|
29
|
+
[28, 4],
|
|
30
|
+
[24, 1],
|
|
31
|
+
[20, 2],
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Seeded, so every visitor and every screenshot gets the same picture. The palette colours
|
|
35
|
+
* the nodes and takes no part in where they sit.
|
|
36
|
+
*/
|
|
37
|
+
export function buildGraph(seed = 11, palette = DEFAULT_PALETTE) {
|
|
38
|
+
let s = seed;
|
|
39
|
+
const rnd = () => ((s = (s * 16807) % 2147483647), s / 2147483647);
|
|
40
|
+
const dust = new Float32Array(DUST_COUNT * 3);
|
|
41
|
+
const dustSize = new Float32Array(DUST_COUNT);
|
|
42
|
+
for (let i = 0; i < DUST_COUNT; i++) {
|
|
43
|
+
dust.set([(rnd() - 0.5) * 60, (rnd() - 0.5) * 34, -rnd() * 110 + 8], i * 3);
|
|
44
|
+
dustSize[i] = 0.3 + rnd() * 0.8;
|
|
45
|
+
}
|
|
46
|
+
const total = CLUSTERS.reduce((n, [count]) => n + count, 0);
|
|
47
|
+
const scatter = new Float32Array(total * 3);
|
|
48
|
+
const home = new Float32Array(total * 3);
|
|
49
|
+
const size = new Float32Array(total);
|
|
50
|
+
const color = new Float32Array(total * 3);
|
|
51
|
+
const drift = new Float32Array(total);
|
|
52
|
+
const pairs = [];
|
|
53
|
+
const hubs = [];
|
|
54
|
+
const at = (i) => [home[i * 3], home[i * 3 + 1], home[i * 3 + 2]];
|
|
55
|
+
const d2 = (i, j) => at(i).reduce((sum, v, k) => sum + (v - at(j)[k]) ** 2, 0);
|
|
56
|
+
const nearest = (i, among, n) => among
|
|
57
|
+
.filter((j) => j !== i)
|
|
58
|
+
.sort((p, q) => d2(i, p) - d2(i, q))
|
|
59
|
+
.slice(0, n);
|
|
60
|
+
let i = 0;
|
|
61
|
+
CLUSTERS.forEach(([count, tint], c) => {
|
|
62
|
+
const rgb = palette[tint];
|
|
63
|
+
// cluster centres spread evenly over an ellipsoid, members in a soft cloud about each
|
|
64
|
+
const y = 1 - ((c + 0.5) / CLUSTERS.length) * 2;
|
|
65
|
+
const r = Math.sqrt(1 - y * y);
|
|
66
|
+
const a = c * 2.39996 + 0.6;
|
|
67
|
+
const centre = [Math.cos(a) * r * 3.0, y * 2.6, Math.sin(a) * r * 2.6];
|
|
68
|
+
const spread = 0.46 + count * 0.011;
|
|
69
|
+
const members = [];
|
|
70
|
+
for (let m = 0; m < count; m++, i++) {
|
|
71
|
+
const hub = m === 0;
|
|
72
|
+
scatter.set([(rnd() - 0.5) * 44, (rnd() - 0.5) * 24, -rnd() * 46 + 4], i * 3);
|
|
73
|
+
const off = () => (hub ? 0 : (rnd() + rnd() + rnd() - 1.5) * spread);
|
|
74
|
+
home.set([centre[0] + off(), centre[1] + off(), centre[2] + off()], i * 3);
|
|
75
|
+
size[i] = hub ? 4.4 : 1.4 + rnd() * 1.3;
|
|
76
|
+
color.set(hub ? [1, 1, 1] : rgb, i * 3);
|
|
77
|
+
drift[i] = hub ? 0.03 : 0.05 + rnd() * 0.07;
|
|
78
|
+
members.push(i);
|
|
79
|
+
}
|
|
80
|
+
hubs.push(members[0]);
|
|
81
|
+
members.slice(1).forEach((n) => {
|
|
82
|
+
// most members hang off the hub; the rest, and a few besides, off a neighbour
|
|
83
|
+
if (rnd() < 0.62)
|
|
84
|
+
pairs.push(members[0], n);
|
|
85
|
+
else
|
|
86
|
+
pairs.push(n, nearest(n, members.slice(1), 1)[0]);
|
|
87
|
+
if (rnd() < 0.3)
|
|
88
|
+
pairs.push(n, nearest(n, members.slice(1), 2)[1]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
// pull the whole graph inside its sphere, so no outlying node strays off the stage
|
|
92
|
+
const reach = Math.max(...Array.from({ length: total }, (_, n) => Math.hypot(...at(n))));
|
|
93
|
+
const fit = Math.min(1, (RADIUS - 0.15) / reach);
|
|
94
|
+
for (let k = 0; k < home.length; k++)
|
|
95
|
+
home[k] *= fit;
|
|
96
|
+
const routes = [];
|
|
97
|
+
hubs.forEach((h) => nearest(h, hubs, 2).forEach((o) => {
|
|
98
|
+
const seen = routes.some((_, k) => k % 2 === 0 && routes[k] === o && routes[k + 1] === h);
|
|
99
|
+
if (!seen)
|
|
100
|
+
routes.push(h, o);
|
|
101
|
+
}));
|
|
102
|
+
pairs.push(...routes);
|
|
103
|
+
return { dust, dustSize, scatter, home, size, color, drift, pairs, routes };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Where the graph sits: right of the words when they are set beside it, above them
|
|
107
|
+
* otherwise. Beside them its centre is a fixed distance from the top, level with the words,
|
|
108
|
+
* so a tall window does not drop it toward the section below.
|
|
109
|
+
*/
|
|
110
|
+
export function placeGraph(aspect, beside, height) {
|
|
111
|
+
const halfH = CAM_Z * Math.tan((FOV * Math.PI) / 360);
|
|
112
|
+
const halfW = halfH * aspect;
|
|
113
|
+
if (beside) {
|
|
114
|
+
const scale = Math.min(1, (halfW * 0.36) / RADIUS, (halfH * 0.8) / RADIUS);
|
|
115
|
+
const centre = Math.min(BESIDE_CENTRE, height / 2) / height;
|
|
116
|
+
return { x: halfW * 0.48, y: halfH * (1 - 2 * centre), scale };
|
|
117
|
+
}
|
|
118
|
+
const scale = Math.min(1, (halfW * 0.8) / RADIUS, (halfH * 0.29) / RADIUS);
|
|
119
|
+
return { x: 0, y: halfH * 0.47, scale };
|
|
120
|
+
}
|
|
121
|
+
const POINT_VERT = `
|
|
122
|
+
precision mediump float;
|
|
123
|
+
attribute vec3 position; attribute vec3 color; attribute float size; attribute float front;
|
|
124
|
+
uniform mat4 uProj; uniform float uRot, uFocus, uAperture, uPx, uHalo;
|
|
125
|
+
varying float vA; varying vec3 vC;
|
|
126
|
+
void main() {
|
|
127
|
+
vC = color;
|
|
128
|
+
float c = cos(uRot), s = sin(uRot);
|
|
129
|
+
vec3 p = vec3(c * position.x + s * position.z, position.y, c * position.z - s * position.x);
|
|
130
|
+
float d = ${CAM_Z.toFixed(1)} - p.z;
|
|
131
|
+
float coc = abs(d - uFocus) * uAperture;
|
|
132
|
+
gl_PointSize = (size + coc * 5.) * 60. / d * uPx * uHalo;
|
|
133
|
+
gl_Position = uProj * vec4(p.xy, -d, 1.);
|
|
134
|
+
vec2 n = abs(gl_Position.xy / gl_Position.w);
|
|
135
|
+
vA = smoothstep(1.5, 5., d) * smoothstep(1.02, .84, max(n.x, n.y)) / (1. + coc * coc * 1.6) * front;
|
|
136
|
+
}`;
|
|
137
|
+
// The film blooms its highlights in a second pass; here each point carries its own soft halo.
|
|
138
|
+
const POINT_FRAG = `
|
|
139
|
+
precision mediump float;
|
|
140
|
+
uniform float uAlpha, uHalo, uGlow; varying float vA; varying vec3 vC;
|
|
141
|
+
void main() {
|
|
142
|
+
float r = length(gl_PointCoord - .5) * uHalo;
|
|
143
|
+
float a = smoothstep(.5, .32, r) + uGlow * exp(-r * r * 5.);
|
|
144
|
+
gl_FragColor = vec4(vC, a * vA * uAlpha);
|
|
145
|
+
}`;
|
|
146
|
+
const LINE_VERT = `
|
|
147
|
+
precision mediump float;
|
|
148
|
+
attribute vec3 position; attribute vec3 color; attribute float front; uniform mat4 uProj;
|
|
149
|
+
varying float vF; varying vec3 vC;
|
|
150
|
+
void main() { vF = front; vC = color; gl_Position = uProj * vec4(position.xy, position.z - ${CAM_Z.toFixed(1)}, 1.); }`;
|
|
151
|
+
const LINE_FRAG = `
|
|
152
|
+
precision mediump float; uniform float uAlpha; varying float vF; varying vec3 vC;
|
|
153
|
+
void main() { gl_FragColor = vec4(vC, uAlpha * vF); }`;
|
|
154
|
+
function program(gl, vert, frag) {
|
|
155
|
+
var _a;
|
|
156
|
+
const p = gl.createProgram();
|
|
157
|
+
for (const [type, src] of [
|
|
158
|
+
[gl.VERTEX_SHADER, vert],
|
|
159
|
+
[gl.FRAGMENT_SHADER, frag],
|
|
160
|
+
]) {
|
|
161
|
+
const sh = gl.createShader(type);
|
|
162
|
+
gl.shaderSource(sh, src);
|
|
163
|
+
gl.compileShader(sh);
|
|
164
|
+
gl.attachShader(p, sh);
|
|
165
|
+
}
|
|
166
|
+
gl.linkProgram(p);
|
|
167
|
+
if (!gl.getProgramParameter(p, gl.LINK_STATUS)) {
|
|
168
|
+
throw new Error((_a = gl.getProgramInfoLog(p)) !== null && _a !== void 0 ? _a : 'shader link failed');
|
|
169
|
+
}
|
|
170
|
+
const u = (name) => gl.getUniformLocation(p, name);
|
|
171
|
+
const a = (name) => gl.getAttribLocation(p, name);
|
|
172
|
+
return { p, u, a };
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Draws the stage on `canvas` until the returned function is called. It runs only while the
|
|
176
|
+
* canvas is on screen, and holds one settled frame for a visitor who asks for reduced
|
|
177
|
+
* motion. Where WebGL is unavailable it draws nothing: the page stands without it.
|
|
178
|
+
*/
|
|
179
|
+
export function mountGraphStage(canvas,
|
|
180
|
+
/** The CSS width from which the page sets its words beside the graph. */
|
|
181
|
+
besideFrom) {
|
|
182
|
+
const gl = canvas.getContext('webgl', { alpha: true, antialias: true });
|
|
183
|
+
if (!gl)
|
|
184
|
+
return () => { };
|
|
185
|
+
const palette = readPalette(canvas);
|
|
186
|
+
const g = buildGraph(11, palette);
|
|
187
|
+
const count = g.size.length;
|
|
188
|
+
const points = program(gl, POINT_VERT, POINT_FRAG);
|
|
189
|
+
const lines = program(gl, LINE_VERT, LINE_FRAG);
|
|
190
|
+
const buffer = (data, usage = gl.STATIC_DRAW) => {
|
|
191
|
+
const b = gl.createBuffer();
|
|
192
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, b);
|
|
193
|
+
gl.bufferData(gl.ARRAY_BUFFER, data, usage);
|
|
194
|
+
return b;
|
|
195
|
+
};
|
|
196
|
+
const bind = (prog, name, b, n) => {
|
|
197
|
+
const loc = prog.a(name);
|
|
198
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, b);
|
|
199
|
+
gl.enableVertexAttribArray(loc);
|
|
200
|
+
gl.vertexAttribPointer(loc, n, gl.FLOAT, false, 0, 0);
|
|
201
|
+
};
|
|
202
|
+
const dustPos = buffer(g.dust);
|
|
203
|
+
const dustSize = buffer(g.dustSize);
|
|
204
|
+
const nodeSize = buffer(g.size);
|
|
205
|
+
const nodeColor = buffer(g.color);
|
|
206
|
+
const pos = new Float32Array(count * 3);
|
|
207
|
+
const front = new Float32Array(count);
|
|
208
|
+
const edgePos = new Float32Array(g.pairs.length * 3);
|
|
209
|
+
const edgeFront = new Float32Array(g.pairs.length);
|
|
210
|
+
const edgeColor = new Float32Array(g.pairs.length * 3);
|
|
211
|
+
g.pairs.forEach((n, k) => edgeColor.set(g.color.subarray(n * 3, n * 3 + 3), k * 3));
|
|
212
|
+
const edgeColorBuf = buffer(edgeColor);
|
|
213
|
+
// a pulse of light along each route between hubs
|
|
214
|
+
const pulses = g.routes.length / 2;
|
|
215
|
+
const pulsePos = new Float32Array(pulses * 3);
|
|
216
|
+
const pulseFront = new Float32Array(pulses);
|
|
217
|
+
const pulsePosBuf = buffer(pulsePos, gl.DYNAMIC_DRAW);
|
|
218
|
+
const pulseFrontBuf = buffer(pulseFront, gl.DYNAMIC_DRAW);
|
|
219
|
+
const pulseSize = buffer(new Float32Array(pulses).fill(2.4));
|
|
220
|
+
const nodePos = buffer(pos, gl.DYNAMIC_DRAW);
|
|
221
|
+
const nodeFront = buffer(front, gl.DYNAMIC_DRAW);
|
|
222
|
+
const edgePosBuf = buffer(edgePos, gl.DYNAMIC_DRAW);
|
|
223
|
+
const edgeFrontBuf = buffer(edgeFront, gl.DYNAMIC_DRAW);
|
|
224
|
+
gl.enable(gl.BLEND);
|
|
225
|
+
// Light is added, and alpha is kept in step with it: a GPU compositor drops colour that
|
|
226
|
+
// has no alpha behind it, though a software one shows it.
|
|
227
|
+
gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE, gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
228
|
+
gl.clearColor(0, 0, 0, 0);
|
|
229
|
+
const proj = new Float32Array(16);
|
|
230
|
+
let place = placeGraph(1, false, 1);
|
|
231
|
+
const resize = () => {
|
|
232
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
233
|
+
const w = Math.max(1, Math.round(canvas.clientWidth * dpr));
|
|
234
|
+
const h = Math.max(1, Math.round(canvas.clientHeight * dpr));
|
|
235
|
+
if (canvas.width !== w || canvas.height !== h) {
|
|
236
|
+
canvas.width = w;
|
|
237
|
+
canvas.height = h;
|
|
238
|
+
}
|
|
239
|
+
gl.viewport(0, 0, w, h);
|
|
240
|
+
const f = 1 / Math.tan((FOV * Math.PI) / 360);
|
|
241
|
+
const near = 0.1;
|
|
242
|
+
const far = 400;
|
|
243
|
+
proj.fill(0);
|
|
244
|
+
proj[0] = f / (w / h);
|
|
245
|
+
proj[5] = f;
|
|
246
|
+
proj[10] = (far + near) / (near - far);
|
|
247
|
+
proj[11] = -1;
|
|
248
|
+
proj[14] = (2 * far * near) / (near - far);
|
|
249
|
+
place = placeGraph(w / h, canvas.clientWidth >= besideFrom, canvas.clientHeight);
|
|
250
|
+
};
|
|
251
|
+
const draw = (t) => {
|
|
252
|
+
const home = easeInOut(seg(t, 0.3, 3.2));
|
|
253
|
+
// The turn: a slow spin about the upright axis, then a slight tilt toward the viewer.
|
|
254
|
+
const [tilt, spin] = [0.22, t * 0.07];
|
|
255
|
+
const [cx, sx, cy, sy] = [
|
|
256
|
+
Math.cos(tilt),
|
|
257
|
+
Math.sin(tilt),
|
|
258
|
+
Math.cos(spin),
|
|
259
|
+
Math.sin(spin),
|
|
260
|
+
];
|
|
261
|
+
for (let i = 0; i < count; i++) {
|
|
262
|
+
const w = g.drift[i];
|
|
263
|
+
const hx = g.home[i * 3] + w * Math.sin(t * 0.6 + i);
|
|
264
|
+
const hy = g.home[i * 3 + 1] + w * Math.cos(t * 0.5 + i * 1.3);
|
|
265
|
+
const hz = g.home[i * 3 + 2] + w * Math.sin(t * 0.4 + i * 0.7);
|
|
266
|
+
const x2 = cy * hx + sy * hz;
|
|
267
|
+
const z2 = cy * hz - sy * hx;
|
|
268
|
+
const y3 = cx * hy - sx * z2;
|
|
269
|
+
const z3 = sx * hy + cx * z2;
|
|
270
|
+
const target = [
|
|
271
|
+
place.x + x2 * place.scale,
|
|
272
|
+
place.y + y3 * place.scale,
|
|
273
|
+
z3 * place.scale,
|
|
274
|
+
];
|
|
275
|
+
for (let k = 0; k < 3; k++) {
|
|
276
|
+
const from = g.scatter[i * 3 + k];
|
|
277
|
+
pos[i * 3 + k] = from + (target[k] - from) * home;
|
|
278
|
+
}
|
|
279
|
+
// nodes on the far side are dimmed, which is what gives the graph its depth
|
|
280
|
+
const facing = 0.4 + 0.6 * easeInOut(seg(z3 / RADIUS, -1, 0.5));
|
|
281
|
+
front[i] = 1 + (facing - 1) * home;
|
|
282
|
+
}
|
|
283
|
+
g.pairs.forEach((n, k) => {
|
|
284
|
+
edgePos.set(pos.subarray(n * 3, n * 3 + 3), k * 3);
|
|
285
|
+
edgeFront[k] = front[n];
|
|
286
|
+
});
|
|
287
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
288
|
+
const px = canvas.height / 1080;
|
|
289
|
+
gl.useProgram(lines.p);
|
|
290
|
+
gl.uniformMatrix4fv(lines.u('uProj'), false, proj);
|
|
291
|
+
gl.uniform1f(lines.u('uAlpha'), 0.42 * easeOut(seg(t, 2.4, 4)));
|
|
292
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, edgePosBuf);
|
|
293
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, edgePos);
|
|
294
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, edgeFrontBuf);
|
|
295
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, edgeFront);
|
|
296
|
+
bind(lines, 'position', edgePosBuf, 3);
|
|
297
|
+
bind(lines, 'front', edgeFrontBuf, 1);
|
|
298
|
+
bind(lines, 'color', edgeColorBuf, 3);
|
|
299
|
+
gl.drawArrays(gl.LINES, 0, g.pairs.length);
|
|
300
|
+
gl.useProgram(points.p);
|
|
301
|
+
gl.uniformMatrix4fv(points.u('uProj'), false, proj);
|
|
302
|
+
gl.uniform1f(points.u('uFocus'), CAM_Z);
|
|
303
|
+
// dust: the first brand colour, small, drifting almost imperceptibly
|
|
304
|
+
gl.uniform1f(points.u('uRot'), t * 0.004);
|
|
305
|
+
gl.uniform1f(points.u('uAperture'), 0.05);
|
|
306
|
+
gl.uniform1f(points.u('uPx'), px);
|
|
307
|
+
gl.uniform1f(points.u('uHalo'), 1);
|
|
308
|
+
gl.uniform1f(points.u('uGlow'), 0);
|
|
309
|
+
gl.uniform1f(points.u('uAlpha'), 0.5);
|
|
310
|
+
bind(points, 'position', dustPos, 3);
|
|
311
|
+
bind(points, 'size', dustSize, 1);
|
|
312
|
+
gl.disableVertexAttribArray(points.a('front'));
|
|
313
|
+
gl.vertexAttrib1f(points.a('front'), 1);
|
|
314
|
+
gl.disableVertexAttribArray(points.a('color'));
|
|
315
|
+
gl.vertexAttrib3f(points.a('color'), ...palette[0]);
|
|
316
|
+
gl.drawArrays(gl.POINTS, 0, DUST_COUNT);
|
|
317
|
+
// the nodes: haloed, white hubs and coloured members
|
|
318
|
+
gl.uniform1f(points.u('uRot'), 0);
|
|
319
|
+
gl.uniform1f(points.u('uAperture'), 0.06);
|
|
320
|
+
gl.uniform1f(points.u('uPx'), px * (1 + (place.scale - 1) * home));
|
|
321
|
+
gl.uniform1f(points.u('uHalo'), 3);
|
|
322
|
+
gl.uniform1f(points.u('uGlow'), 0.22);
|
|
323
|
+
gl.uniform1f(points.u('uAlpha'), 1);
|
|
324
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, nodePos);
|
|
325
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, pos);
|
|
326
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, nodeFront);
|
|
327
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, front);
|
|
328
|
+
bind(points, 'position', nodePos, 3);
|
|
329
|
+
bind(points, 'size', nodeSize, 1);
|
|
330
|
+
bind(points, 'front', nodeFront, 1);
|
|
331
|
+
bind(points, 'color', nodeColor, 3);
|
|
332
|
+
gl.drawArrays(gl.POINTS, 0, count);
|
|
333
|
+
{
|
|
334
|
+
const lit = easeOut(seg(t, 3.6, 5));
|
|
335
|
+
for (let k = 0; k < pulses; k++) {
|
|
336
|
+
const [a, b] = [g.routes[k * 2], g.routes[k * 2 + 1]];
|
|
337
|
+
const along = (t * 0.16 + k * 0.37) % 1;
|
|
338
|
+
for (let c = 0; c < 3; c++) {
|
|
339
|
+
pulsePos[k * 3 + c] =
|
|
340
|
+
pos[a * 3 + c] + (pos[b * 3 + c] - pos[a * 3 + c]) * along;
|
|
341
|
+
}
|
|
342
|
+
pulseFront[k] = Math.sin(Math.PI * along) * lit;
|
|
343
|
+
}
|
|
344
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, pulsePosBuf);
|
|
345
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, pulsePos);
|
|
346
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, pulseFrontBuf);
|
|
347
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, pulseFront);
|
|
348
|
+
bind(points, 'position', pulsePosBuf, 3);
|
|
349
|
+
bind(points, 'size', pulseSize, 1);
|
|
350
|
+
bind(points, 'front', pulseFrontBuf, 1);
|
|
351
|
+
gl.disableVertexAttribArray(points.a('color'));
|
|
352
|
+
gl.vertexAttrib3f(points.a('color'), 1, 1, 1);
|
|
353
|
+
gl.drawArrays(gl.POINTS, 0, pulses);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
const still = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
357
|
+
let raf = 0;
|
|
358
|
+
let start = 0;
|
|
359
|
+
let onScreen = false;
|
|
360
|
+
const loop = (now) => {
|
|
361
|
+
start || (start = now);
|
|
362
|
+
draw((now - start) / 1000);
|
|
363
|
+
raf = requestAnimationFrame(loop);
|
|
364
|
+
};
|
|
365
|
+
const run = () => {
|
|
366
|
+
cancelAnimationFrame(raf);
|
|
367
|
+
if (still)
|
|
368
|
+
draw(SETTLED);
|
|
369
|
+
else if (onScreen)
|
|
370
|
+
raf = requestAnimationFrame(loop);
|
|
371
|
+
};
|
|
372
|
+
const sized = new ResizeObserver(() => {
|
|
373
|
+
resize();
|
|
374
|
+
if (still)
|
|
375
|
+
draw(SETTLED);
|
|
376
|
+
});
|
|
377
|
+
const seen = new IntersectionObserver(([entry]) => {
|
|
378
|
+
onScreen = entry.isIntersecting;
|
|
379
|
+
run();
|
|
380
|
+
});
|
|
381
|
+
resize();
|
|
382
|
+
sized.observe(canvas);
|
|
383
|
+
seen.observe(canvas);
|
|
384
|
+
return () => {
|
|
385
|
+
cancelAnimationFrame(raf);
|
|
386
|
+
sized.disconnect();
|
|
387
|
+
seen.disconnect();
|
|
388
|
+
};
|
|
389
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Dust } from './Dust';
|
|
2
|
+
export { GraphGalaxies } from './GraphGalaxies';
|
|
3
|
+
export { GraphOrb } from './GraphOrb';
|
|
4
|
+
export { GraphStage } from './GraphStage';
|
|
5
|
+
export { GridFloor } from './GridFloor';
|
|
6
|
+
export { NodeGlow } from './NodeGlow';
|
|
7
|
+
export { DEFAULT_PALETTE, PALETTE_VARS, type Rgb } from './palette';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Dust } from './Dust';
|
|
2
|
+
export { GraphGalaxies } from './GraphGalaxies';
|
|
3
|
+
export { GraphOrb } from './GraphOrb';
|
|
4
|
+
export { GraphStage } from './GraphStage';
|
|
5
|
+
export { GridFloor } from './GridFloor';
|
|
6
|
+
export { NodeGlow } from './NodeGlow';
|
|
7
|
+
export { DEFAULT_PALETTE, PALETTE_VARS } from './palette';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colours of the graph stage. An app names its three brand colours, each with a lighter
|
|
3
|
+
* shade, as CSS variables holding space-separated RGB (`--graph-1: 34 211 238`); the defaults
|
|
4
|
+
* are in styles/graph-stage.css. The SVG and CSS pieces use the variables directly, and the
|
|
5
|
+
* live canvas reads them once when it starts.
|
|
6
|
+
*/
|
|
7
|
+
export type Rgb = [number, number, number];
|
|
8
|
+
/** In palette order: each colour, then its lighter shade. */
|
|
9
|
+
export declare const PALETTE_VARS: readonly ["--graph-1", "--graph-1-light", "--graph-2", "--graph-2-light", "--graph-3", "--graph-3-light"];
|
|
10
|
+
/** The RoboSystems colours (cyan, blue, indigo), for where no variables are set. */
|
|
11
|
+
export declare const DEFAULT_PALETTE: Rgb[];
|
|
12
|
+
/** A palette colour as CSS, with an optional opacity. */
|
|
13
|
+
export declare const ink: (index: number, alpha?: number) => string;
|
|
14
|
+
/** The palette an element inherits, as 0..1 channels; the default where a variable is unset. */
|
|
15
|
+
export declare function readPalette(el: Element): Rgb[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The colours of the graph stage. An app names its three brand colours, each with a lighter
|
|
3
|
+
* shade, as CSS variables holding space-separated RGB (`--graph-1: 34 211 238`); the defaults
|
|
4
|
+
* are in styles/graph-stage.css. The SVG and CSS pieces use the variables directly, and the
|
|
5
|
+
* live canvas reads them once when it starts.
|
|
6
|
+
*/
|
|
7
|
+
/** In palette order: each colour, then its lighter shade. */
|
|
8
|
+
export const PALETTE_VARS = [
|
|
9
|
+
'--graph-1',
|
|
10
|
+
'--graph-1-light',
|
|
11
|
+
'--graph-2',
|
|
12
|
+
'--graph-2-light',
|
|
13
|
+
'--graph-3',
|
|
14
|
+
'--graph-3-light',
|
|
15
|
+
];
|
|
16
|
+
/** The RoboSystems colours (cyan, blue, indigo), for where no variables are set. */
|
|
17
|
+
export const DEFAULT_PALETTE = [
|
|
18
|
+
[0.13, 0.83, 0.93],
|
|
19
|
+
[0.4, 0.91, 0.98],
|
|
20
|
+
[0.23, 0.48, 0.96],
|
|
21
|
+
[0.38, 0.65, 0.98],
|
|
22
|
+
[0.39, 0.4, 0.95],
|
|
23
|
+
[0.51, 0.55, 0.97],
|
|
24
|
+
];
|
|
25
|
+
/** A palette colour as CSS, with an optional opacity. */
|
|
26
|
+
export const ink = (index, alpha) => `rgb(var(${PALETTE_VARS[index]})${alpha === undefined ? '' : ` / ${alpha}`})`;
|
|
27
|
+
/** The palette an element inherits, as 0..1 channels; the default where a variable is unset. */
|
|
28
|
+
export function readPalette(el) {
|
|
29
|
+
const style = getComputedStyle(el);
|
|
30
|
+
return PALETTE_VARS.map((name, i) => {
|
|
31
|
+
const parts = style
|
|
32
|
+
.getPropertyValue(name)
|
|
33
|
+
.trim()
|
|
34
|
+
.split(/[\s,]+/)
|
|
35
|
+
.map(Number);
|
|
36
|
+
return parts.length === 3 && parts.every(Number.isFinite)
|
|
37
|
+
? parts.map((v) => v / 255)
|
|
38
|
+
: DEFAULT_PALETTE[i];
|
|
39
|
+
});
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The graph stage: the styles behind the pieces in graph-stage/ (the live graph, dust, orbs,
|
|
3
|
+
* galaxies, grid floor) and the node classes an app puts on its own cards and icons
|
|
4
|
+
* (`node-card`, `node-link`, `node-icon`). An app imports this once.
|
|
5
|
+
*
|
|
6
|
+
* Colour: three brand colours, each with a lighter shade, as space-separated RGB so they
|
|
7
|
+
* take an opacity (`rgb(var(--graph-1) / 0.4)`). These defaults are RoboSystems' cyan, blue
|
|
8
|
+
* and indigo; an app sets its own on :root after the import. --graph-1 is the lead colour:
|
|
9
|
+
* the dust, the floor, and the light on cards and icons.
|
|
10
|
+
*/
|
|
11
|
+
:root {
|
|
12
|
+
--graph-1: 34 211 238;
|
|
13
|
+
--graph-1-light: 103 232 249;
|
|
14
|
+
--graph-2: 59 122 245;
|
|
15
|
+
--graph-2-light: 97 166 250;
|
|
16
|
+
--graph-3: 99 102 241;
|
|
17
|
+
--graph-3-light: 129 140 248;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/* Orbs and galaxies: each floats on one of two slow paths and turns at its own pace (the
|
|
21
|
+
component sets the duration and direction). */
|
|
22
|
+
@keyframes graph-float-a {
|
|
23
|
+
50% {
|
|
24
|
+
transform: translate(20px, -40px);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@keyframes graph-float-b {
|
|
29
|
+
50% {
|
|
30
|
+
transform: translate(-15px, 30px);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@keyframes graph-turn {
|
|
35
|
+
to {
|
|
36
|
+
transform: rotate(360deg);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.graph-float-a {
|
|
41
|
+
animation: graph-float-a 8s ease-in-out infinite;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.graph-float-b {
|
|
45
|
+
animation: graph-float-b 10s ease-in-out infinite;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.graph-turn {
|
|
49
|
+
animation: graph-turn 300s linear infinite;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* The dust backdrop (Dust.tsx): each layer is a tile of points masking the lead colour, and
|
|
53
|
+
rises by exactly one tile, so the loop has no seam. */
|
|
54
|
+
.graph-dust {
|
|
55
|
+
background-color: rgb(var(--graph-1));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@keyframes graph-dust-near {
|
|
59
|
+
to {
|
|
60
|
+
transform: translateY(-900px);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@keyframes graph-dust-far {
|
|
65
|
+
to {
|
|
66
|
+
transform: translateY(-620px);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.graph-dust-near {
|
|
71
|
+
animation: graph-dust-near 150s linear infinite;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.graph-dust-far {
|
|
75
|
+
animation: graph-dust-far 260s linear infinite;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* The grid floor (GridFloor.tsx). */
|
|
79
|
+
.graph-floor {
|
|
80
|
+
transform: perspective(900px) rotateX(62deg);
|
|
81
|
+
background-image:
|
|
82
|
+
linear-gradient(rgb(var(--graph-1) / 0.6) 2.5px, transparent 2.5px),
|
|
83
|
+
linear-gradient(90deg, rgb(var(--graph-1) / 0.55) 1px, transparent 1px);
|
|
84
|
+
background-size: 80px 80px;
|
|
85
|
+
-webkit-mask-image: linear-gradient(to top, black, transparent 96%);
|
|
86
|
+
mask-image: linear-gradient(to top, black, transparent 96%);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* A card as a node (NodeGlow.tsx tells it where the pointer is). Every node card wears the
|
|
90
|
+
mark the hubs wear in the galaxies, a white point in a thin ring, in its top right corner.
|
|
91
|
+
Under the pointer a soft light spreads inside the card, its edge lights up nearest the
|
|
92
|
+
pointer and the mark brightens, as a node does when it is picked out of a graph.
|
|
93
|
+
--lit runs 0 to 1 with the hover; registering it lets it be eased. */
|
|
94
|
+
@property --lit {
|
|
95
|
+
syntax: '<number>';
|
|
96
|
+
inherits: true;
|
|
97
|
+
initial-value: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.node-card {
|
|
101
|
+
--lit: 0;
|
|
102
|
+
--mark: calc(100% - 18px) 18px;
|
|
103
|
+
position: relative;
|
|
104
|
+
isolation: isolate;
|
|
105
|
+
transition: --lit 0.35s ease;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.node-card:hover {
|
|
109
|
+
--lit: 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.node-card::before,
|
|
113
|
+
.node-card::after {
|
|
114
|
+
content: '';
|
|
115
|
+
position: absolute;
|
|
116
|
+
inset: 0;
|
|
117
|
+
border-radius: inherit;
|
|
118
|
+
pointer-events: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.node-card::before {
|
|
122
|
+
z-index: -1;
|
|
123
|
+
background:
|
|
124
|
+
radial-gradient(
|
|
125
|
+
circle at var(--mark),
|
|
126
|
+
rgb(255 255 255 / calc(0.5 + 0.5 * var(--lit))) 0 2.4px,
|
|
127
|
+
transparent 3.2px
|
|
128
|
+
),
|
|
129
|
+
radial-gradient(
|
|
130
|
+
circle at var(--mark),
|
|
131
|
+
transparent 0 5.6px,
|
|
132
|
+
rgb(var(--graph-1-light) / calc(0.28 + 0.6 * var(--lit))) 5.6px 6.5px,
|
|
133
|
+
transparent 7.3px
|
|
134
|
+
),
|
|
135
|
+
radial-gradient(
|
|
136
|
+
circle at var(--mark),
|
|
137
|
+
rgb(var(--graph-1) / calc(0.4 * var(--lit))),
|
|
138
|
+
transparent 26px
|
|
139
|
+
),
|
|
140
|
+
radial-gradient(
|
|
141
|
+
460px circle at var(--mx, 50%) var(--my, 0%),
|
|
142
|
+
rgb(var(--graph-1) / calc(0.15 * var(--lit))),
|
|
143
|
+
rgb(var(--graph-2) / calc(0.06 * var(--lit))) 45%,
|
|
144
|
+
transparent 68%
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.node-card::after {
|
|
149
|
+
padding: 1px;
|
|
150
|
+
background: radial-gradient(
|
|
151
|
+
320px circle at var(--mx, 50%) var(--my, 0%),
|
|
152
|
+
rgb(var(--graph-1-light) / calc(0.95 * var(--lit))),
|
|
153
|
+
rgb(var(--graph-1) / calc(0.35 * var(--lit))) 45%,
|
|
154
|
+
transparent 72%
|
|
155
|
+
);
|
|
156
|
+
-webkit-mask:
|
|
157
|
+
linear-gradient(#000 0 0) content-box,
|
|
158
|
+
linear-gradient(#000 0 0);
|
|
159
|
+
-webkit-mask-composite: xor;
|
|
160
|
+
mask:
|
|
161
|
+
linear-gradient(#000 0 0) content-box exclude,
|
|
162
|
+
linear-gradient(#000 0 0);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* An icon inside a node: the glyph sits in a small ball of linked points, the same sphere
|
|
166
|
+
the sections hang at their edges, so a card is a node and its icon is the graph inside
|
|
167
|
+
it. The ball is two images, its links (a mask over the lead colour) and its points
|
|
168
|
+
(white), both shown only near the rim so the glyph stays clear, turning slowly together.
|
|
169
|
+
Inside a node card it brightens with the card. */
|
|
170
|
+
.node-icon {
|
|
171
|
+
--node-links: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%22-1.08 -1.08 2.16 2.16%22%3E%3Cg stroke=%22%23000%22 stroke-width=%22.022%22%3E%3Cpath d=%22M0.00 0.96L-0.10 0.83%22 opacity=%220.62%22/%3E%3Cpath d=%22M0.00 0.96L-0.17 0.97%22 opacity=%220.43%22/%3E%3Cpath d=%22M0.00 0.96L0.48 0.75%22 opacity=%220.59%22/%3E%3Cpath d=%22M-0.10 0.83L-0.58 0.71%22 opacity=%220.66%22/%3E%3Cpath d=%22M-0.10 0.83L0.16 0.47%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.17 0.97L0.33 0.88%22 opacity=%220.24%22/%3E%3Cpath d=%22M-0.17 0.97L-0.63 0.74%22 opacity=%220.28%22/%3E%3Cpath d=%22M0.48 0.75L0.16 0.47%22 opacity=%220.70%22/%3E%3Cpath d=%22M0.48 0.75L0.80 0.60%22 opacity=%220.53%22/%3E%3Cpath d=%22M-0.58 0.71L-0.53 0.34%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.58 0.71L-0.92 0.38%22 opacity=%220.52%22/%3E%3Cpath d=%22M0.33 0.88L-0.05 0.71%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.33 0.88L0.72 0.49%22 opacity=%220.14%22/%3E%3Cpath d=%22M0.16 0.47L0.64 0.24%22 opacity=%220.70%22/%3E%3Cpath d=%22M0.16 0.47L-0.12 0.00%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.63 0.74L-0.92 0.38%22 opacity=%220.34%22/%3E%3Cpath d=%22M-0.63 0.74L-0.56 0.44%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.80 0.60L0.72 0.49%22 opacity=%220.26%22/%3E%3Cpath d=%22M0.80 0.60L0.96 0.12%22 opacity=%220.47%22/%3E%3Cpath d=%22M-0.53 0.34L-0.12 0.00%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.53 0.34L-0.85 -0.02%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.05 0.71L-0.56 0.44%22 opacity=%220.13%22/%3E%3Cpath d=%22M-0.05 0.71L0.29 0.34%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.64 0.24L0.96 0.12%22 opacity=%220.66%22/%3E%3Cpath d=%22M0.64 0.24L0.43 -0.23%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.92 0.38L-0.85 -0.02%22 opacity=%220.55%22/%3E%3Cpath d=%22M-0.92 0.38L-0.92 0.08%22 opacity=%220.30%22/%3E%3Cpath d=%22M0.72 0.49L0.29 0.34%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.72 0.49L0.93 0.02%22 opacity=%220.14%22/%3E%3Cpath d=%22M-0.12 0.00L0.43 -0.23%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.12 0.00L-0.45 -0.37%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.56 0.44L-0.26 0.09%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.96 0.12L0.82 -0.37%22 opacity=%220.58%22/%3E%3Cpath d=%22M-0.85 -0.02L-0.94 -0.32%22 opacity=%220.56%22/%3E%3Cpath d=%22M0.29 0.34L0.57 -0.11%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.43 -0.23L0.09 -0.63%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.92 0.08L-0.94 -0.32%22 opacity=%220.30%22/%3E%3Cpath d=%22M-0.92 0.08L-0.67 -0.25%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.93 0.02L0.57 -0.11%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.93 0.02L0.87 -0.47%22 opacity=%220.24%22/%3E%3Cpath d=%22M-0.45 -0.37L0.09 -0.63%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.45 -0.37L-0.62 -0.68%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.26 0.09L-0.67 -0.25%22 opacity=%220.13%22/%3E%3Cpath d=%22M-0.26 0.09L0.07 -0.34%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.82 -0.37L0.87 -0.47%22 opacity=%220.47%22/%3E%3Cpath d=%22M0.82 -0.37L0.47 -0.78%22 opacity=%220.62%22/%3E%3Cpath d=%22M-0.94 -0.32L-0.62 -0.68%22 opacity=%220.52%22/%3E%3Cpath d=%22M-0.94 -0.32L-0.71 -0.63%22 opacity=%220.32%22/%3E%3Cpath d=%22M0.57 -0.11L0.07 -0.34%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.57 -0.11L0.56 -0.61%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.09 -0.63L0.47 -0.78%22 opacity=%220.70%22/%3E%3Cpath d=%22M0.09 -0.63L-0.15 -0.93%22 opacity=%220.70%22/%3E%3Cpath d=%22M-0.67 -0.25L-0.71 -0.63%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.87 -0.47L0.56 -0.61%22 opacity=%220.18%22/%3E%3Cpath d=%22M-0.62 -0.68L-0.15 -0.93%22 opacity=%220.59%22/%3E%3Cpath d=%22M0.07 -0.34L-0.25 -0.68%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.47 -0.78L0.41 -0.90%22 opacity=%220.47%22/%3E%3Cpath d=%22M-0.71 -0.63L-0.25 -0.68%22 opacity=%220.13%22/%3E%3Cpath d=%22M-0.71 -0.63L-0.29 -0.95%22 opacity=%220.25%22/%3E%3Cpath d=%22M0.56 -0.61L0.41 -0.90%22 opacity=%220.20%22/%3E%3Cpath d=%22M-0.15 -0.93L-0.29 -0.95%22 opacity=%220.44%22/%3E%3Cpath d=%22M-0.25 -0.68L0.00 -0.96%22 opacity=%220.13%22/%3E%3Cpath d=%22M0.41 -0.90L0.00 -0.96%22 opacity=%220.27%22/%3E%3Cpath d=%22M-0.29 -0.95L0.00 -0.96%22 opacity=%220.26%22/%3E%3C/g%3E%3C/svg%3E');
|
|
172
|
+
--node-points: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%22-1.08 -1.08 2.16 2.16%22%3E%3Cg fill=%22%23fff%22%3E%3Ccircle cx=%220.00%22 cy=%220.96%22 r=%22.04%22 opacity=%220.78%22/%3E%3Ccircle cx=%22-0.10%22 cy=%220.83%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.17%22 cy=%220.97%22 r=%22.04%22 opacity=%220.44%22/%3E%3Ccircle cx=%220.48%22 cy=%220.75%22 r=%22.04%22 opacity=%220.92%22/%3E%3Ccircle cx=%22-0.58%22 cy=%220.71%22 r=%22.04%22 opacity=%220.88%22/%3E%3Ccircle cx=%220.33%22 cy=%220.88%22 r=%22.04%22 opacity=%220.26%22/%3E%3Ccircle cx=%220.16%22 cy=%220.47%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.63%22 cy=%220.74%22 r=%22.04%22 opacity=%220.36%22/%3E%3Ccircle cx=%220.80%22 cy=%220.60%22 r=%22.04%22 opacity=%220.60%22/%3E%3Ccircle cx=%22-0.53%22 cy=%220.34%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.05%22 cy=%220.71%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.64%22 cy=%220.24%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.92%22 cy=%220.38%22 r=%22.04%22 opacity=%220.61%22/%3E%3Ccircle cx=%220.72%22 cy=%220.49%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%22-0.12%22 cy=%220.00%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.56%22 cy=%220.44%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.96%22 cy=%220.12%22 r=%22.04%22 opacity=%220.75%22/%3E%3Ccircle cx=%22-0.85%22 cy=%22-0.02%22 r=%22.04%22 opacity=%220.97%22/%3E%3Ccircle cx=%220.29%22 cy=%220.34%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.43%22 cy=%22-0.23%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.92%22 cy=%220.08%22 r=%22.04%22 opacity=%220.25%22/%3E%3Ccircle cx=%220.93%22 cy=%220.02%22 r=%22.04%22 opacity=%220.26%22/%3E%3Ccircle cx=%22-0.45%22 cy=%22-0.37%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.26%22 cy=%220.09%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.82%22 cy=%22-0.37%22 r=%22.04%22 opacity=%220.90%22/%3E%3Ccircle cx=%22-0.94%22 cy=%22-0.32%22 r=%22.04%22 opacity=%220.62%22/%3E%3Ccircle cx=%220.57%22 cy=%22-0.11%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.09%22 cy=%22-0.63%22 r=%22.04%22 opacity=%221.00%22/%3E%3Ccircle cx=%22-0.67%22 cy=%22-0.25%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.87%22 cy=%22-0.47%22 r=%22.04%22 opacity=%220.43%22/%3E%3Ccircle cx=%22-0.62%22 cy=%22-0.68%22 r=%22.04%22 opacity=%220.88%22/%3E%3Ccircle cx=%220.07%22 cy=%22-0.34%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.47%22 cy=%22-0.78%22 r=%22.04%22 opacity=%220.88%22/%3E%3Ccircle cx=%22-0.71%22 cy=%22-0.63%22 r=%22.04%22 opacity=%220.30%22/%3E%3Ccircle cx=%220.56%22 cy=%22-0.61%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%22-0.15%22 cy=%22-0.93%22 r=%22.04%22 opacity=%220.83%22/%3E%3Ccircle cx=%22-0.25%22 cy=%22-0.68%22 r=%22.04%22 opacity=%220.18%22/%3E%3Ccircle cx=%220.41%22 cy=%22-0.90%22 r=%22.04%22 opacity=%220.46%22/%3E%3Ccircle cx=%22-0.29%22 cy=%22-0.95%22 r=%22.04%22 opacity=%220.43%22/%3E%3Ccircle cx=%220.00%22 cy=%22-0.96%22 r=%22.04%22 opacity=%220.32%22/%3E%3C/g%3E%3C/svg%3E');
|
|
173
|
+
--node-rim: radial-gradient(circle, transparent 42%, #000 74%);
|
|
174
|
+
position: relative;
|
|
175
|
+
isolation: isolate;
|
|
176
|
+
border-radius: 9999px;
|
|
177
|
+
color: color-mix(in srgb, rgb(var(--graph-1-light)) 35%, white);
|
|
178
|
+
background: radial-gradient(
|
|
179
|
+
circle at 36% 30%,
|
|
180
|
+
rgb(var(--graph-1) / 0.24),
|
|
181
|
+
rgb(var(--graph-2) / 0.12) 55%,
|
|
182
|
+
rgb(4 7 12 / 0.5)
|
|
183
|
+
);
|
|
184
|
+
box-shadow:
|
|
185
|
+
inset 0 0 0 1px rgb(var(--graph-1-light) / calc(0.3 + 0.5 * var(--lit, 0))),
|
|
186
|
+
0 0 calc(4px + 16px * var(--lit, 0))
|
|
187
|
+
rgb(var(--graph-1) / calc(0.1 + 0.45 * var(--lit, 0)));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.node-icon svg {
|
|
191
|
+
color: color-mix(in srgb, rgb(var(--graph-1-light)) 35%, white);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.node-icon::before,
|
|
195
|
+
.node-icon::after {
|
|
196
|
+
content: '';
|
|
197
|
+
position: absolute;
|
|
198
|
+
inset: -2px;
|
|
199
|
+
z-index: -1;
|
|
200
|
+
border-radius: inherit;
|
|
201
|
+
opacity: calc(0.55 + 0.45 * var(--lit, 0));
|
|
202
|
+
animation: graph-turn 70s linear infinite;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.node-icon::before {
|
|
206
|
+
background: rgb(var(--graph-1-light));
|
|
207
|
+
-webkit-mask:
|
|
208
|
+
var(--node-links) center / 100% no-repeat,
|
|
209
|
+
var(--node-rim);
|
|
210
|
+
-webkit-mask-composite: source-in;
|
|
211
|
+
mask:
|
|
212
|
+
var(--node-links) center / 100% no-repeat intersect,
|
|
213
|
+
var(--node-rim);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.node-icon::after {
|
|
217
|
+
background: var(--node-points) center / 100% no-repeat;
|
|
218
|
+
-webkit-mask: var(--node-rim);
|
|
219
|
+
mask: var(--node-rim);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* A link between two node cards (a span inside the first): a thin line across the gap to
|
|
223
|
+
the next card, with a port at each end. It runs sideways where the cards sit in a row
|
|
224
|
+
(from md, or from lg with `node-link-lg` beside it) and downward where they stack. When
|
|
225
|
+
either card it joins is under the pointer, the line lights and a pulse travels along it. */
|
|
226
|
+
@property --on {
|
|
227
|
+
syntax: '<number>';
|
|
228
|
+
inherits: true;
|
|
229
|
+
initial-value: 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.node-link {
|
|
233
|
+
--on: 0;
|
|
234
|
+
position: absolute;
|
|
235
|
+
top: 100%;
|
|
236
|
+
left: 50%;
|
|
237
|
+
width: 1px;
|
|
238
|
+
height: var(--gap, 1.5rem);
|
|
239
|
+
pointer-events: none;
|
|
240
|
+
background: rgb(var(--graph-1-light) / calc(0.3 + 0.6 * var(--on)));
|
|
241
|
+
transition: --on 0.35s ease;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.node-link::before,
|
|
245
|
+
.node-link::after {
|
|
246
|
+
content: '';
|
|
247
|
+
position: absolute;
|
|
248
|
+
left: -2px;
|
|
249
|
+
width: 5px;
|
|
250
|
+
height: 5px;
|
|
251
|
+
border-radius: 9999px;
|
|
252
|
+
background: rgb(255 255 255 / calc(0.55 + 0.45 * var(--on)));
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.node-link::before {
|
|
256
|
+
top: -3px;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.node-link::after {
|
|
260
|
+
top: calc(100% - 2px);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.node-card:hover > .node-link,
|
|
264
|
+
.node-card:has(+ .node-card:hover) > .node-link {
|
|
265
|
+
--on: 1;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.node-link > i {
|
|
269
|
+
position: absolute;
|
|
270
|
+
left: -2px;
|
|
271
|
+
top: 0;
|
|
272
|
+
width: 5px;
|
|
273
|
+
height: 5px;
|
|
274
|
+
border-radius: 9999px;
|
|
275
|
+
background: #fff;
|
|
276
|
+
box-shadow: 0 0 8px 2px rgb(var(--graph-1) / 0.9);
|
|
277
|
+
opacity: var(--on);
|
|
278
|
+
animation: node-pulse-down 1.4s linear infinite;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
@keyframes node-pulse-down {
|
|
282
|
+
to {
|
|
283
|
+
transform: translateY(var(--gap, 1.5rem));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
@keyframes node-pulse-across {
|
|
288
|
+
to {
|
|
289
|
+
transform: translateX(var(--gap, 1.5rem));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@media (min-width: 768px) {
|
|
294
|
+
.node-link:not(.node-link-lg) {
|
|
295
|
+
top: 50%;
|
|
296
|
+
left: 100%;
|
|
297
|
+
width: var(--gap, 1.5rem);
|
|
298
|
+
height: 1px;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.node-link:not(.node-link-lg)::before,
|
|
302
|
+
.node-link:not(.node-link-lg)::after {
|
|
303
|
+
top: -2px;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.node-link:not(.node-link-lg)::before {
|
|
307
|
+
left: -3px;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.node-link:not(.node-link-lg)::after {
|
|
311
|
+
left: calc(100% - 2px);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.node-link:not(.node-link-lg) > i {
|
|
315
|
+
left: 0;
|
|
316
|
+
top: -2px;
|
|
317
|
+
animation-name: node-pulse-across;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@media (min-width: 1024px) {
|
|
322
|
+
.node-link-lg {
|
|
323
|
+
top: 50%;
|
|
324
|
+
left: 100%;
|
|
325
|
+
width: var(--gap, 1.5rem);
|
|
326
|
+
height: 1px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.node-link-lg::before,
|
|
330
|
+
.node-link-lg::after {
|
|
331
|
+
top: -2px;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.node-link-lg::before {
|
|
335
|
+
left: -3px;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.node-link-lg::after {
|
|
339
|
+
left: calc(100% - 2px);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.node-link-lg > i {
|
|
343
|
+
left: 0;
|
|
344
|
+
top: -2px;
|
|
345
|
+
animation-name: node-pulse-across;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
@media (prefers-reduced-motion: reduce) {
|
|
350
|
+
.graph-float-a,
|
|
351
|
+
.graph-float-b,
|
|
352
|
+
.graph-turn,
|
|
353
|
+
.graph-dust-near,
|
|
354
|
+
.graph-dust-far,
|
|
355
|
+
.node-icon::before,
|
|
356
|
+
.node-icon::after,
|
|
357
|
+
.node-link > i {
|
|
358
|
+
animation: none;
|
|
359
|
+
}
|
|
360
|
+
}
|