You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently learning PixiJS to replace my SVG-based visualizer with WebGL for performance reasons. My current prototype can be found at https://stackblitz.com/edit/pixi-panzoom. The objective is to display a static polyline with a chain of arrows while allowing the user to pan and zoom to the figure without affecting the width of the stroke of the lines or the size of the arrow head so manipulating the transform matrix of the parent container is not an option. The number of arrows that has to be displayed can reach up to 10,000 to 20,000 so using a Graphics instance to draw the shape primitives can get expensive. In addition, I have to render the lines (the body of the arrows) with a round cap.
Currently, my approach is to render the primitives (parts of the arrow) into a Texture first. The tail of the arrow is a circle to give the impression that the line has a round cap. The body of the arrow simply uses the out of the box WHITE texture. The head of the arrow is ... well a polygon forming an arrow head.
To make the figure responsive with panning and zooming, the transform matrix of each sprite is modified with the scale and translate for every frame. panzoomView is a simple custom class I wrote to deal with panning and zooming in PixiJS
At 1000 arrows, panning and zooming is consistently at 60FPS. At 10,000 arrows however, lag is noticeable but panning and zooming is still useable. Are there any other rendering techniques or optimizations I can use to maintain a consistent 60FPS when dealing with atleast 10,000 arrows?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently learning PixiJS to replace my SVG-based visualizer with WebGL for performance reasons. My current prototype can be found at https://stackblitz.com/edit/pixi-panzoom. The objective is to display a static polyline with a chain of arrows while allowing the user to pan and zoom to the figure without affecting the width of the stroke of the lines or the size of the arrow head so manipulating the transform matrix of the parent container is not an option. The number of arrows that has to be displayed can reach up to 10,000 to 20,000 so using a
Graphics
instance to draw the shape primitives can get expensive. In addition, I have to render the lines (the body of the arrows) with a round cap.Currently, my approach is to render the primitives (parts of the arrow) into a
Texture
first. The tail of the arrow is a circle to give the impression that the line has a round cap. The body of the arrow simply uses the out of the boxWHITE
texture. The head of the arrow is ... well a polygon forming an arrow head.Afterwards, sprites are created from each texture then added into a
ParticleContainer
for the corresponding texture.To make the figure responsive with panning and zooming, the transform matrix of each sprite is modified with the scale and translate for every frame.
panzoomView
is a simple custom class I wrote to deal with panning and zooming in PixiJSAt 1000 arrows, panning and zooming is consistently at 60FPS. At 10,000 arrows however, lag is noticeable but panning and zooming is still useable. Are there any other rendering techniques or optimizations I can use to maintain a consistent 60FPS when dealing with atleast 10,000 arrows?
Beta Was this translation helpful? Give feedback.
All reactions