I've drawn 300k lines on PixiJs, but the performance is terrible, any good tips to improve the performance?
Here is an example,and codepen Link.
I mainly want to make a previewer that can be zoomed and moved. It would be a lot faster to use a texture, but as the container gets bigger, the lines also get very wide, which is not what I want.
When I he dragged, only by a few frames. I simply output the fps in the console.
function draw(num) {
const graphics = new PIXI.Graphics();
graphics.lineStyle(2, 0xfeeb77, 1, 0.5, true);
graphics.beginFill(0x650a5a);
for (let index = 0; index < num; index++) {
let x1 = Math.random() * 600;
let y1 = Math.random() * 600;
let x2 = Math.random() * 600;
let y2 = Math.random() * 600;
graphics.moveTo(x1, y1);
graphics.lineTo(x2, y2);
}
graphics.endFill();
container.addChild(graphics);
}
draw(300000);
Thank you for your help !