Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function layoutClusters(layerClusters, centroid) {
// Create world with zero gravity.
let world = planck.World({
gravity: planck.Vec2(0,0)
});
// Create bodies for groups.
let layerClusterBodies = [];
layerClusters.forEach(function(layerCluster) {
layerClusterBodies.push(createClusterBody(layerCluster, world));
});
// Create attractor.
let attractorBody = world.createBody(planck.Vec2(centroid.x, centroid.y));
// Create joints between layerClusterBodies and attractor.
layerClusterBodies.forEach(function(layerClusterBody) {
let distanceJoint = planck.DistanceJoint( {
frequencyHz : 0.9, // TODO: Try to avoid overlapping in large datasets!