Fix slowdown in progressive render
this is a partial fix for #124
A new method was added: renderIncremental. This will start rendering from the last layer and go from there. It will re-render the last layer bc it probably wasn't complete. So it resets the gcode processing state to just before the last layer, removes the last layer from the scene and continues from there.
This works well with volumetric rendering because of the added load. But it doesn't work well with the gradient in the line rendering. This is bc for the gradient to work, the total number of layers must be known so it can calc a percentage.. With true incremental rendering you never know how many layers or gcode lines there will be. This can only worked around.
To fix the quadratic load in line rendering the gradient will have to be removed.
- [x] DEMO: use renderIncremental when loading benchy
- [x] DEMO: use renderIncremental when dropping a new file
- [ ] DEMO: and when changing one of the options that requires re-rendering
Run & review this pull request in StackBlitz Codeflow.
Visit the preview URL for this PR (updated for commit e969dda):
https://gcode-preview--pr136-feature-progressive-wnduje5t.web.app
(expires Sun, 28 Jul 2024 15:46:13 GMT)
🔥 via Firebase Hosting GitHub Action 🌎
Sign: 59bd114ae4847b32c2bba0b68620b9069a3e3531
I just tested it. Wow. It's so smooth now! I am impressed!
I finally figured out we could parse it all, know the number of layers and then render incrementally. This has the added effect that the color gradient can be accurately computed even when rendering the start. That's why it is stable now. Previously the gradient stretched out during rendering.
I'm not sure about the api change I did. I'm need of critical opinions
Are you sure we need to extract the animation in a new class right now? How would that look like?