GPU supercharged attraction-graph visualizations built on top of Three.js

Overview

Force Directed Graph

GPU supercharged attraction-graph visualizations for the web built on top of Three.js. Importable as an ES6 module.

  1. Simulation computed on GPU via render targets
  2. Accepts thousands of nodes and links
  3. Configurable point and link colors
  4. Single library dependent (Three.js)
  5. Three.js scene compatible object
  6. Simple data schema to populate compatible with d3.js JSON samples
  7. 2d & 3d simulation modes

Visit the hosted project page for a running demo.

Usage

npm install --save three @jonobr1/force-directed-graph

Import in ES6 environment

import { ForceDirectedGraph } from '@jonobr1/force-directed-graph';

Load Script in HTML file:

This example creates 512 nodes and links them randomly like big snakes.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script>
    <script type="importmap">
      {
        "imports": {
          "three": "https://cdn.jsdelivr.net/npm/three/build/three.module.js",
          "three/examples/jsm/misc/GPUComputationRenderer.js": "https://cdn.jsdelivr.net/npm/three/examples/jsm/misc/GPUComputationRenderer.js",
          "@jonobr1/force-directed-graph": "https://cdn.jsdelivr.net/npm/@jonobr1/force-directed-graph/build/fdg.module.js"
        }
      }
    </script>
    <script>

      import * as THREE from 'three';
      import { ForceDirectedGraph } from '@jonobr1/force-directed-graph';

      const renderer = new THREE.WebGLRenderer({ antialias: true });
      const scene = new THREE.Scene();
      const camera = new THREE.PerspectiveCamera();

      camera.position.z = 250;

      // Generate some fake data
      const amount = 512;
      const data = {
      nodes: [],  // Required, each element should be an object
      links: []   // Required, each element should be an object
                  // with source and target properties that are
                  // indices of their connecting nodes
      };

      for (let i = 0; i < amount; i++) {

        data.nodes.push({ id: i });
        if (i > 0) {
          data.links.push({ target: Math.floor(Math.random() * i), source: i });
        }

      }

      const fdg = new ForceDirectedGraph(renderer, data);
      scene.add(fdg);

      setup();

      function setup() {
        renderer.setClearColor('#fff');
        document.body.appendChild(renderer.domElement);
        window.addEventListener('resize', resize, false);
        resize();
        renderer.setAnimationLoop(render);
      }

      function resize() {

        const width = window.innerWidth;
        const height = window.innerHeight;

        renderer.setSize(width, height);
        camera.aspect = width / height;
        camera.updateProjectionMatrix();

      }

      function render(elapsed) {
        fdg.update(elapsed);
        renderer.render(scene, camera);
      }

    </script>
  </body>
</html>

⚠️ Due to the reliance on the GPU compute rendering, this project is not built for node.js use.

A free and open source tool by Jono Brandel

You might also like...

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

 `raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages

`raaghu-mfe` is an opensource micro front end framework built on top of `raaghu-elements`, Bootstrap 5 and Storybook offering highly customizable UI components and built-in pages. Raaghu mfe can be used as a base to build complex components and UI layouts whilst maintaining a high level of reusability,flexibility with ease of maintenance.

Dec 30, 2022

Adding volumetric effects to a built-in Three.js shader.

Adding volumetric effects to a built-in Three.js shader.

Magical Marbles in Three.js Adding volumetric effects to a built-in Three.js shader. Article on Codrops Demo Installation Install dependencies: yarn

Dec 9, 2022

The Web 3.0 social layer built on top of Twitter

The Web 3.0 social layer built on top of Twitter

Niftycase – The Web 3.0 Chrome extension for Twitter Niftycase is a open-source Chrome extension that allows you to view anybody's NFTs directly on Tw

Jul 14, 2022

A JavaScript library built on top of the Faker.JS library. It generates massive amounts of fake data in the browser and node.js.

Blaver - generate massive amounts of fake data in the browser and node.js Blaver is a JavaScript library built on top of the Faker.JS library. It gene

Dec 30, 2022

A messaging app built on top of Solana blockchain where you can store and view your messages.

Message App on Solana 💬 This Message application written Rust using Anchor ⚓ Setting up the Environment: Rust Installation curl --proto '=https' --tl

Oct 2, 2022

A fast and optimized middleware server with an absurdly small amount of code (300 lines) built on top of Deno's native HTTP APIs

A fast and optimized middleware server with an absurdly small amount of code (300 lines) built on top of Deno's native HTTP APIs with no dependencies. It also has a collection of useful middlewares: log file, serve static, CORS, session, rate limit, token, body parsers, redirect, proxy and handle upload. In "README" there are examples of all the resources. Faster's ideology is: all you need is an optimized middleware manager, all other functionality is middleware.

Dec 28, 2022

📬 Lightweight Typescript-first framework built on top of Express

🔖 abstain Lightweight Typescript-first framework built on top of Express [WIP] 📚 api // index.ts import { Application } from '@pinkcig/abstain'; imp

May 26, 2022

Assertions package for Japa. Built on top of Chai.Assert

@japa/assert Assertion library built on top of Chai.assert An assertion library built on top of Chai.assert with small tweaks and additional features

May 4, 2022
Comments
  • Rewrite links to be serialized in uploaded textures

    Rewrite links to be serialized in uploaded textures

    Right now the texture for all links is a flat list showing all nodes connected to all other nodes. The problem is that for any given node there needs to be traversal of the entire texture to look up its links.

    This would be much more efficient if an index and length attribute were added to each node and that were applied to the uploaded texture. Then, a small portion of the links texture would need to be read on the GPU every frame greatly reducing the load (unless of course everything was connected to everything else; though in this scenario the current model would be just as slow).

    enhancement 
    opened by jonobr1 0
Owner
Jono Brandel
I mix two fundamental disciplines, Graphic Design and Computer Programming, to explore the expressive qualities of technology.
Jono Brandel
Text Engraving & Extrusion demo based on Three.js is implemented with Typescript and webpack5. Used THREE-CSGMesh as the core tech to achieve engraving and extrusion results

Text Engraving & Extrusion Text Engraving & Extrusion demo is implemented using Three.js, with Typescript and webpack5. Used THREE-CSGMesh as the core

Jiahong Li 3 Oct 12, 2022
A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh

three-bvh-csg An experimental, in progress, flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh. More than 100 time

Garrett Johnson 208 Jan 5, 2023
A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

A lightweight, performant, and simple-to-use wrapper component to stick section headers to the top when scrolling brings them to top

Mayank 7 Jun 27, 2022
Beautiful Visualizations For Your App's Dependencies 🧭

Beautiful Visualizations For Your App's Dependencies ?? Outputs SVGs Powered by D3 Overlays security vulnerabilities Works with npm & yarn Made by the

Sandworm 8 Dec 15, 2022
playful fractal flames, GPU accelerated

JWildfire Swan - playful fractal flames, GPU accelerated This is an experimental project and work in progress. Project goals The basic idea is to use

Andreas Maschke 7 Oct 20, 2022
Drawing Newton's fractal using pure js, rust-wasm, SIMDs, threads and GPU

Newton's fractal Runtime Newton's fractal renderer. >>Click<< to open in your browser Inspired by 3blue1brown's video about Newton's fractal. Drawing

Aleksei 86 Nov 17, 2022
GPU-accelerated Augmented Reality for the web.

MARTINS.js WebAR engine Create amazing Augmented Reality experiences with MARTINS.js, a GPU-accelerated Augmented Reality engine for the web. Get star

Alexandre Martins 19 Dec 16, 2022
🐜 GPU-accelerated ant colony simulation

Ants simulation A simple ant colony GPU-accelerated simulation made with Three.js. Live demo Rules Ants can emit two types of pheromones: to-home pher

null 10 Nov 28, 2022
A flexible gateway for running ML inference jobs through cloud providers or your own GPU. Powered by Replicate and Cloudflare Workers.

Cogflare (Working title) Cogflare is a Cloudflare Workers application that aims to simplify running distributed ML inference jobs through a central AP

NightmareBot 14 Dec 12, 2022
GPU Drops' captcha solving extension without affiliate tracking code injection

Noptcha, without affiliate link injection Noptcha is a reCaptcha and hCaptcha solving extension created by GPU Drops. This fork was made because I hat

Sqaaakoi 201 Dec 26, 2022