regl-ladder-2
A cluster of 100,000 colored points animates across the screen, moving in a repeating wave pattern with a sinusoidal x-shift and vertical bobbing. The visualization demonstrates a performance optimization in regl, a WebGL library: passing all point attributes (position, color, speed) as a single packed array per frame outperforms passing separate attribute arrays, enabling 60 fps versus the slower alternative. Using regl’s shader system and GPU buffers, the code animates points via a cubic easing function, with colors alternating between blue and orange based on parity. The data is generated procedurally, with random x, y, and speed values for each point.
AI-generated descriptionPassing arrays of attributes:
attributes: {
p: () => data.map(({x, y1, dy, isB, speed}) =>
[x, y1, dy + isB, speed]
),
},
is way faster than passing in seperate properties - 100,000 points at 60 fps instead of 14,000.
attributes: {
speed: () => data.map(d => d.speed),
x: () => data.map(d => d.x),
y0: () => data.map(d => d.y0),
y1: () => data.map(d => d.y1),
dy: () => data.map(d => d.dy),
isB: data.map(d => d.isB)
},