@fusion.dev/helix-graph 0.248.3 → 0.249.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/dist/connect-graph/looks.d.ts +19 -0
- package/dist/connect-graph/looks.js +9 -2
- package/dist/connect-graph/sizes.d.ts +1 -1
- package/dist/connect-graph/sizes.js +1 -1
- package/dist/snapshot/snapshot.d.ts +1 -1
- package/dist/snapshot/snapshot.js +5 -1
- package/dist/three/three-driver.d.ts +7 -0
- package/dist/three/three-driver.js +22 -16
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -358,6 +358,7 @@ connectGraph(frame, threeDriver(box), {
|
|
|
358
358
|
| `shape` | `circle` | `square` or `diamond`, for every note that does not say; a `ring` is drawn as a circle |
|
|
359
359
|
| `groupLabels` | `true` | `false` leaves each group unnamed |
|
|
360
360
|
| `layoutLimit` | `10000` | The longest a layout runs, in milliseconds |
|
|
361
|
+
| `surfaceShade` | `1` | From 0 to 1, how much of a shape's surface is shaded; less leaves a faint outline that still hides the far side |
|
|
361
362
|
|
|
362
363
|
## An isometric diagram
|
|
363
364
|
|
|
@@ -85,6 +85,11 @@ export interface NodeLook {
|
|
|
85
85
|
selected: boolean;
|
|
86
86
|
/** Its shape, where the note says. */
|
|
87
87
|
shape?: 'circle' | 'diamond' | 'ring' | 'square' | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Its color is a tone's, such as `danger`, which says something about the
|
|
90
|
+
* note, where a group's color only says which group it is in.
|
|
91
|
+
*/
|
|
92
|
+
toned?: boolean | undefined;
|
|
88
93
|
}
|
|
89
94
|
/** A tone from the `tone` axis. */
|
|
90
95
|
export type GraphTone = 'accent' | 'danger' | 'info' | 'neutral' | 'primary' | 'success' | 'warning';
|
|
@@ -128,6 +133,20 @@ export interface GraphLooks {
|
|
|
128
133
|
/** How the note `id` is drawn. */
|
|
129
134
|
node(id: string): NodeLook;
|
|
130
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* How far a group's series color is moved toward the muted ink before a note
|
|
138
|
+
* is drawn in it. The series are chosen to be told apart in a bar chart, at
|
|
139
|
+
* full chroma, and a thousand notes in them at once read as confetti. At 0.3
|
|
140
|
+
* the groups stay apart, which is what they are for, and no group is a
|
|
141
|
+
* primary.
|
|
142
|
+
*/
|
|
143
|
+
export declare const TEMPER = 0.3;
|
|
144
|
+
/**
|
|
145
|
+
* How far a group's color is then moved toward the brand, so every group
|
|
146
|
+
* sits in one family and the graph takes the page's temperature: cool under
|
|
147
|
+
* the default brand, warm under a warm one. Small, so the groups stay apart.
|
|
148
|
+
*/
|
|
149
|
+
export declare const COOL = 0.14;
|
|
131
150
|
/**
|
|
132
151
|
* How the graph is drawn for one selection.
|
|
133
152
|
*
|
|
@@ -72,6 +72,8 @@ export const toneColor = (colors, tone) => tone === undefined || tone === 'prima
|
|
|
72
72
|
? colors.muted
|
|
73
73
|
: colors[tone];
|
|
74
74
|
const FADED = 0.6;
|
|
75
|
+
export const TEMPER = 0.3;
|
|
76
|
+
export const COOL = 0.14;
|
|
75
77
|
export const looksOf = (options) => {
|
|
76
78
|
const { colors, keyed, near, noteOf, selected, shown } = options;
|
|
77
79
|
const order = new Map([...new Set(options.groups)].sort().map((group, at) => [group, at]));
|
|
@@ -84,7 +86,7 @@ export const looksOf = (options) => {
|
|
|
84
86
|
const at = group === undefined ? undefined : order.get(group);
|
|
85
87
|
return at === undefined || colors.series.length === 0
|
|
86
88
|
? colors.muted
|
|
87
|
-
: colors.series[at % colors.series.length];
|
|
89
|
+
: mixRgb(mixRgb(colors.series[at % colors.series.length], colors.muted, TEMPER), colors.primary, COOL);
|
|
88
90
|
};
|
|
89
91
|
const focused = selected !== undefined;
|
|
90
92
|
const hidden = (id) => shown !== undefined && !shown.has(id);
|
|
@@ -112,7 +114,12 @@ export const looksOf = (options) => {
|
|
|
112
114
|
},
|
|
113
115
|
node: (id) => {
|
|
114
116
|
const note = noteOf(id);
|
|
115
|
-
const facts = {
|
|
117
|
+
const facts = {
|
|
118
|
+
emphasis: note?.emphasis,
|
|
119
|
+
material: note?.material,
|
|
120
|
+
shape: note?.shape,
|
|
121
|
+
toned: note?.tone ? true : undefined,
|
|
122
|
+
};
|
|
116
123
|
if (id === selected) {
|
|
117
124
|
return {
|
|
118
125
|
...facts,
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
* is still a note, and the reader came to the graph to find it.
|
|
16
16
|
*/
|
|
17
17
|
export declare const sizeOf: (size: number | undefined, links: number) => number;
|
|
18
|
-
/** A note's drawn radius in pixels, from its relative size: a leaf about
|
|
18
|
+
/** A note's drawn radius in pixels, from its relative size: a leaf about three and a half, a busy hub about eight. */
|
|
19
19
|
export declare const pixelsOf: (size: number) => number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const sizeOf = (size, links) => Number.isFinite(size) ? size : 1 + Math.min(Math.sqrt(Math.max(links, 1)), 6);
|
|
2
|
-
export const pixelsOf = (size) => 1.
|
|
2
|
+
export const pixelsOf = (size) => 1.4 + 1.1 * Math.max(size, 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type NodeLook, type NoteFacts } from '../connect-graph/looks.js';
|
|
2
2
|
import { type GraphReach } from '../connect-graph/reach.js';
|
|
3
3
|
/** A note, as a snapshot draws it: the frame's own, with its place given. */
|
|
4
4
|
export interface SnapshotNode extends NoteFacts {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { COOL, TEMPER, } from '../connect-graph/looks.js';
|
|
1
2
|
import { reachOf } from '../connect-graph/reach.js';
|
|
2
3
|
import { pixelsOf, sizeOf } from '../connect-graph/sizes.js';
|
|
3
4
|
import { clearOf } from '../overlay/overlay.js';
|
|
@@ -61,7 +62,10 @@ export const graphSnapshot = (nodes, links, options = {}) => {
|
|
|
61
62
|
const reached = selected === undefined ? undefined : reachOf(selected, drawn, options.reach ?? 'links');
|
|
62
63
|
const near = reached?.near ?? new Set();
|
|
63
64
|
const groups = [...new Set(nodes.flatMap((node) => (node.group ? [node.group] : [])))].sort();
|
|
64
|
-
const series = new Map(groups.map((group, index) => [
|
|
65
|
+
const series = new Map(groups.map((group, index) => [
|
|
66
|
+
group,
|
|
67
|
+
mix(mix(token(`series-${(index % SERIES) + 1}`), token('foreground-muted'), TEMPER * 100), token('primary'), COOL * 100),
|
|
68
|
+
]));
|
|
65
69
|
const own = (node) => node.tone
|
|
66
70
|
? toneOf(node.tone)
|
|
67
71
|
: ((node.group && series.get(node.group)) ?? token('foreground-muted'));
|
|
@@ -23,6 +23,13 @@ export interface ThreeDriverOptions {
|
|
|
23
23
|
layoutLimit?: number | undefined;
|
|
24
24
|
/** A note's shape where it does not say: `circle` by default, `square` or `diamond`. A `ring` is drawn as a circle. */
|
|
25
25
|
shape?: NodeLook['shape'];
|
|
26
|
+
/**
|
|
27
|
+
* How much of a shape's surface is shaded, from 0 to 1, where the notes
|
|
28
|
+
* are on one: its notes' colors washed over it and the light on it. 1 by
|
|
29
|
+
* default. Less leaves a faint outline that still hides the far side's
|
|
30
|
+
* notes.
|
|
31
|
+
*/
|
|
32
|
+
surfaceShade?: number | undefined;
|
|
26
33
|
}
|
|
27
34
|
/**
|
|
28
35
|
* Drives three.js for a Graph frame: the graph drawn in three dimensions, to
|
|
@@ -17,10 +17,10 @@ const ZOOM = 1.5;
|
|
|
17
17
|
const SAMPLE = 96;
|
|
18
18
|
const LINKS = { dark: { close: 0.16, far: 0.025 }, light: { close: 0.36, far: 0.07 } };
|
|
19
19
|
const TURNING = 5000;
|
|
20
|
-
const WASH = { dark: 0.
|
|
21
|
-
const BLOOM = { dark: 0.
|
|
20
|
+
const WASH = { dark: 0.09, full: 1.5, light: 0.11, notes: 6, reach: 3.5 };
|
|
21
|
+
const BLOOM = { dark: 0.07, light: 0 };
|
|
22
22
|
const LIGHT = new Vector3(-0.4, 0.8, 0.45).normalize();
|
|
23
|
-
const WIDTH = { lit: 1.
|
|
23
|
+
const WIDTH = { lit: 1.5, quiet: 0.6 };
|
|
24
24
|
const FOV = 40;
|
|
25
25
|
const FADE = `
|
|
26
26
|
uniform float middle;
|
|
@@ -151,7 +151,6 @@ const SHAPE_VERTEX = `
|
|
|
151
151
|
${FADE}
|
|
152
152
|
attribute vec4 tone;
|
|
153
153
|
attribute vec4 frame;
|
|
154
|
-
varying vec3 vNormal;
|
|
155
154
|
varying vec4 vTone;
|
|
156
155
|
varying vec4 vFrame;
|
|
157
156
|
varying float vFade;
|
|
@@ -159,7 +158,6 @@ varying float vFade;
|
|
|
159
158
|
void main() {
|
|
160
159
|
vec4 view = viewMatrix * modelMatrix * instanceMatrix * vec4(position, 1.0);
|
|
161
160
|
gl_Position = projectionMatrix * view;
|
|
162
|
-
vNormal = normalize(normalMatrix * mat3(instanceMatrix) * normal);
|
|
163
161
|
vTone = tone;
|
|
164
162
|
vFrame = frame;
|
|
165
163
|
vFade = fade(max(-view.z, 0.001));
|
|
@@ -167,7 +165,6 @@ void main() {
|
|
|
167
165
|
`;
|
|
168
166
|
const SHAPE_FRAGMENT = `
|
|
169
167
|
uniform float dark;
|
|
170
|
-
varying vec3 vNormal;
|
|
171
168
|
varying vec4 vTone;
|
|
172
169
|
varying vec4 vFrame;
|
|
173
170
|
varying float vFade;
|
|
@@ -177,14 +174,13 @@ void main() {
|
|
|
177
174
|
float w = fwidth(e);
|
|
178
175
|
/* The edge as a line about a pixel and a half wide, whatever the size. */
|
|
179
176
|
float line = 1.0 - smoothstep(w * 0.6, w * 2.2, e);
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
vec3 edge = dark > 0.5 ? mix(
|
|
183
|
-
|
|
184
|
-
float faceAlpha = (dark > 0.5 ? 0.1 : 0.16) + 0.3 * inner + 0.12 * (1.0 - facing);
|
|
177
|
+
/* A steady face and a fine edge, with no glow inside the face. */
|
|
178
|
+
vec3 base = vTone.rgb;
|
|
179
|
+
vec3 edge = dark > 0.5 ? mix(base, vec3(1.0), 0.35) : base * 0.8;
|
|
180
|
+
float faceAlpha = dark > 0.5 ? 0.09 : 0.12;
|
|
185
181
|
float alpha = mix(faceAlpha, 1.0, line) * vTone.a * vFade;
|
|
186
182
|
if (alpha < 0.01) discard;
|
|
187
|
-
gl_FragColor = vec4(mix(
|
|
183
|
+
gl_FragColor = vec4(mix(base, edge, line), alpha);
|
|
188
184
|
}
|
|
189
185
|
`;
|
|
190
186
|
const SOLID_VERTEX = `
|
|
@@ -205,6 +201,7 @@ const SOLID_FRAGMENT = `
|
|
|
205
201
|
uniform vec3 ground;
|
|
206
202
|
uniform vec3 ink;
|
|
207
203
|
uniform float strength;
|
|
204
|
+
uniform float shade;
|
|
208
205
|
varying vec3 vNormal;
|
|
209
206
|
varying vec3 vView;
|
|
210
207
|
varying vec4 vWash;
|
|
@@ -219,9 +216,9 @@ void main() {
|
|
|
219
216
|
if (dot(normal, view) < 0.0) normal = -normal;
|
|
220
217
|
float edge = 1.0 - dot(normal, view);
|
|
221
218
|
float lit = max(dot(normal, normalize(vec3(-0.4, 0.8, 0.45))), 0.0);
|
|
222
|
-
float washed = strength * vWash.a;
|
|
219
|
+
float washed = strength * vWash.a * shade;
|
|
223
220
|
vec3 base = mix(ground, vWash.rgb, washed);
|
|
224
|
-
vec3 shaded = mix(base, ink, 0.1 * pow(edge, 2.0) + 0.17 * lit * lit);
|
|
221
|
+
vec3 shaded = mix(base, ink, (0.1 * pow(edge, 2.0) + 0.17 * lit * lit) * shade);
|
|
225
222
|
vec3 rim = mix(shaded, vWash.rgb, washed * 1.6 * pow(edge, 3.0));
|
|
226
223
|
gl_FragColor = vec4(rim, 1.0);
|
|
227
224
|
}
|
|
@@ -413,6 +410,7 @@ export const threeDriver = (container, options = {}) => {
|
|
|
413
410
|
uniforms: {
|
|
414
411
|
ground: { value: [0, 0, 0] },
|
|
415
412
|
ink: { value: [1, 1, 1] },
|
|
413
|
+
shade: { value: Math.min(Math.max(options.surfaceShade ?? 1, 0), 1) },
|
|
416
414
|
strength: { value: WASH.dark },
|
|
417
415
|
},
|
|
418
416
|
vertexShader: SOLID_VERTEX,
|
|
@@ -687,6 +685,7 @@ export const threeDriver = (container, options = {}) => {
|
|
|
687
685
|
let dark = true;
|
|
688
686
|
const sizeOf = (size) => 1.6 + 1.35 * Math.max(size, 0);
|
|
689
687
|
let tints = new Float32Array();
|
|
688
|
+
let toned = new Uint8Array();
|
|
690
689
|
let shapes = new Float32Array();
|
|
691
690
|
let glows = new Float32Array();
|
|
692
691
|
let grownBy = new Float32Array();
|
|
@@ -719,6 +718,7 @@ export const threeDriver = (container, options = {}) => {
|
|
|
719
718
|
}
|
|
720
719
|
if (tints.length !== ids.length * 4) {
|
|
721
720
|
tints = new Float32Array(ids.length * 4);
|
|
721
|
+
toned = new Uint8Array(ids.length);
|
|
722
722
|
drawnSizes = new Float32Array(ids.length);
|
|
723
723
|
shapes = new Float32Array(ids.length);
|
|
724
724
|
glows = new Float32Array(ids.length);
|
|
@@ -731,6 +731,7 @@ export const threeDriver = (container, options = {}) => {
|
|
|
731
731
|
const look = looks.node(id);
|
|
732
732
|
const [red, green, blue] = channels(look.color);
|
|
733
733
|
const alpha = look.hidden ? 0 : 1;
|
|
734
|
+
toned[spot] = look.toned ? 1 : 0;
|
|
734
735
|
if (tints[spot * 4] !== red ||
|
|
735
736
|
tints[spot * 4 + 1] !== green ||
|
|
736
737
|
tints[spot * 4 + 2] !== blue ||
|
|
@@ -830,7 +831,12 @@ export const threeDriver = (container, options = {}) => {
|
|
|
830
831
|
if (mesh) {
|
|
831
832
|
const tone = new Float32Array(spots.length * 4);
|
|
832
833
|
spots.forEach((spot, at) => {
|
|
833
|
-
|
|
834
|
+
const own = tints.subarray(spot * 4, spot * 4 + 4);
|
|
835
|
+
tone.set(own, at * 4);
|
|
836
|
+
if (!toned[spot]) {
|
|
837
|
+
const gray = 0.299 * own[0] + 0.587 * own[1] + 0.114 * own[2];
|
|
838
|
+
tone.fill(gray, at * 4, at * 4 + 3);
|
|
839
|
+
}
|
|
834
840
|
});
|
|
835
841
|
mesh.geometry = solidShape.geometry;
|
|
836
842
|
mesh.geometry.setAttribute('tone', new InstancedBufferAttribute(tone, 4));
|
|
@@ -855,7 +861,7 @@ export const threeDriver = (container, options = {}) => {
|
|
|
855
861
|
continue;
|
|
856
862
|
}
|
|
857
863
|
solidShape.spots.forEach((spot, at) => {
|
|
858
|
-
const size = (drawnSizes[spot] ?? 1) * uniforms.unit.value * 0.
|
|
864
|
+
const size = (drawnSizes[spot] ?? 1) * uniforms.unit.value * 0.38;
|
|
859
865
|
const turned = solidShape.turns[at];
|
|
860
866
|
where.set(positions[spot * 3], positions[spot * 3 + 1], positions[spot * 3 + 2]);
|
|
861
867
|
scaled.setScalar(size);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fusion.dev/helix-graph",
|
|
3
3
|
"description": "Connects the Helix Graph frame to a graph renderer: Sigma.js, cosmos.gl, three.js, or a driver of your own.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.249.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Fusion Development Group",
|
|
7
7
|
"repository": {
|
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
},
|
|
61
61
|
"bugs": "https://github.com/project-fusion/fusion/issues",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@fusion.dev/helix-core": "0.
|
|
63
|
+
"@fusion.dev/helix-core": "0.249.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@cosmos.gl/graph": "^3.6.0",
|
|
67
|
-
"@fusion.dev/helix-headless": "0.
|
|
68
|
-
"@fusion.dev/helix-testing": "0.
|
|
67
|
+
"@fusion.dev/helix-headless": "0.249.0",
|
|
68
|
+
"@fusion.dev/helix-testing": "0.249.0",
|
|
69
69
|
"@luma.gl/core": "~9.3.6",
|
|
70
70
|
"@luma.gl/engine": "~9.3.6",
|
|
71
71
|
"@luma.gl/shadertools": "~9.3.6",
|