UNPKG

@jonobr1/force-directed-graph

Version:

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

21 lines (16 loc) 504 B
/** * Calculate the next frame's position for all nodes. */ export const positions = ` uniform float is2D; uniform float timeStep; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec4 texel = texture2D( texturePositions, uv ); vec3 position = texel.xyz; vec3 velocity = texture2D( textureVelocities, uv ).xyz; float isStatic = texel.w; vec3 result = position + velocity * timeStep * ( 1.0 - isStatic ); gl_FragColor = vec4( result.xyz, isStatic ); } `;