@fusefactory/fuse-three-forcegraph 1.0.3 → 1.0.4

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/index.d.mts CHANGED
@@ -803,6 +803,10 @@ declare class LinksRenderer {
803
803
  * Highlight links connected to a specific node
804
804
  */
805
805
  highlightConnectedLinks(nodeId: string, step?: number): void;
806
+ /**
807
+ * Highlight links connected to any of the given nodes
808
+ */
809
+ highlightConnectedToNodes(nodeIds: Set<string>, step?: number): void;
806
810
  /**
807
811
  * Clear all highlights (return to defaultAlpha)
808
812
  */
package/dist/index.mjs CHANGED
@@ -686,7 +686,7 @@ var InteractionManager = class {
686
686
  const linkRenderer = this.graphScene.getLinkRenderer();
687
687
  const nodeRenderer = this.graphScene.getNodeRenderer();
688
688
  if (this.searchHighlightIds.length > 0) {
689
- linkRenderer?.clearHighlights(.05);
689
+ linkRenderer?.highlightConnectedToNodes(new Set(this.searchHighlightIds), .05);
690
690
  nodeRenderer?.highlight(this.searchHighlightIds);
691
691
  } else {
692
692
  linkRenderer?.clearHighlights(.05);
@@ -728,7 +728,7 @@ var InteractionManager = class {
728
728
  const linkRenderer = this.graphScene.getLinkRenderer();
729
729
  const nodeRenderer = this.graphScene.getNodeRenderer();
730
730
  if (this.searchHighlightIds.length > 0) {
731
- linkRenderer?.clearHighlights(.05);
731
+ linkRenderer?.highlightConnectedToNodes(new Set(this.searchHighlightIds), .05);
732
732
  nodeRenderer?.highlight(this.searchHighlightIds);
733
733
  } else {
734
734
  linkRenderer?.clearHighlights(.05);
@@ -776,7 +776,7 @@ var InteractionManager = class {
776
776
  nodeRenderer?.highlight(connectedIds);
777
777
  }
778
778
  } else if (this.searchHighlightIds.length > 0) {
779
- linkRenderer?.clearHighlights(.05);
779
+ linkRenderer?.highlightConnectedToNodes(new Set(this.searchHighlightIds), .05);
780
780
  nodeRenderer?.highlight(this.searchHighlightIds);
781
781
  } else {
782
782
  linkRenderer?.clearHighlights(.05);
@@ -1532,6 +1532,26 @@ var LinksRenderer = class {
1532
1532
  this.linkOpacity.setTargets(targets);
1533
1533
  }
1534
1534
  /**
1535
+ * Highlight links connected to any of the given nodes
1536
+ */
1537
+ highlightConnectedToNodes(nodeIds, step = .01) {
1538
+ if (!this.lines || !this.linkOpacity) return;
1539
+ const linkCount = this.lines.geometry instanceof THREE.InstancedBufferGeometry ? this.lines.geometry.instanceCount : 0;
1540
+ if (linkCount === 0 || linkCount === void 0) return;
1541
+ const targets = new Array(linkCount).fill(this.params.dimmedAlpha);
1542
+ let hasConnections = false;
1543
+ for (const [linkId, instanceIndex] of this.linkIndexMap.entries()) {
1544
+ const [sourceId, targetId] = linkId.split("-");
1545
+ if (nodeIds.has(sourceId) || nodeIds.has(targetId)) {
1546
+ targets[instanceIndex] = this.params.defaultAlpha;
1547
+ hasConnections = true;
1548
+ }
1549
+ }
1550
+ if (!hasConnections) return;
1551
+ this.linkOpacity.setStep(step);
1552
+ this.linkOpacity.setTargets(targets);
1553
+ }
1554
+ /**
1535
1555
  * Clear all highlights (return to defaultAlpha)
1536
1556
  */
1537
1557
  clearHighlights(step = .1) {
@@ -4077,6 +4097,7 @@ var Engine = class {
4077
4097
  highlightNodes(nodeIds) {
4078
4098
  this.interactionManager.searchHighlightIds = nodeIds;
4079
4099
  this.graphScene.getNodeRenderer()?.highlight(nodeIds);
4100
+ this.graphScene.getLinkRenderer()?.highlightConnectedToNodes(new Set(nodeIds));
4080
4101
  }
4081
4102
  /**
4082
4103
  * Clear highlights
@@ -4084,6 +4105,7 @@ var Engine = class {
4084
4105
  clearHighlights() {
4085
4106
  this.interactionManager.searchHighlightIds = [];
4086
4107
  this.graphScene.getNodeRenderer()?.clearHighlights();
4108
+ this.graphScene.getLinkRenderer()?.clearHighlights();
4087
4109
  }
4088
4110
  /**
4089
4111
  * Get node position in 3D space
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusefactory/fuse-three-forcegraph",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "packageManager": "pnpm@10.6.4",
5
5
  "description": "A high-performance GPU-accelerated force-directed graph visualization library built with Three.js. Features a modular pass-based architecture for flexible and extensible force simulations.",
6
6
  "author": "Matteo Amerena",