Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
D3.js and WebGL intersection in Stardust.js

I am learning stardust.js and was trying to understand force-directed graphs in stardust.js. I know stardust uses d3.js and WebGL but when I am looking at code I am having a hard time finding bridges between them.

In a directed graph, d3.js is used to render create a forceSimulation.

 var force = d3.forceSimulation()
        .force("link", d3.forceLink().id(function (d) {return d.index }))
        .force("charge", d3.forceManyBody())
        .force("forceX", d3.forceX(width / 2))  //for attracting element to a given point
        .force("forceY", d3.forceY(height / 2))


 force.nodes(nodes);
 force.force("link").links(edges);
 force.force("forceX").strength(0.5); //strength of aatraction
 force.force("forceY").strength(0.5);
 force.force("link").distance(50);
 force.force("link").strength(0.05);
 force.force("charge").strength(-40);

and it is giving data to stardust as

var positions = Stardust.array("Vector2")
        .value(d => [d.x, d.y])
        .data(nodes);

where this position is used for update

  force.on("tick", () => {
        if (isDragging && selectedNode && draggingLocation) {
            selectedNode.x = draggingLocation[0];
            selectedNode.y = draggingLocation[1];
        }
        positions.data(nodes);
        requestRender();
    });

I don't understand what is the use of force is here because it is not used anywhere, just created.

I am curious to know if this is only called so that we could use "tick" event listener just to create animation or motion or moving effect because it will update the position sent to the browser?

Any kind of help is appreciated !! Thanks in advance

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!