mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 05:49:30 -07:00
Came up with some performance improvements. Hopefully this will help it run better on more machines leading up to the sequel coming out.
This commit is contained in:
17
js/main.js
17
js/main.js
@@ -43,6 +43,8 @@ const resize = () => {
|
||||
window.onresize = resize;
|
||||
resize();
|
||||
|
||||
const dimensions = { width: 1, height: 1 };
|
||||
|
||||
document.body.onload = async () => {
|
||||
// All this takes place in a full screen quad.
|
||||
const fullScreenQuad = makeFullScreenQuad(regl);
|
||||
@@ -64,9 +66,20 @@ document.body.onload = async () => {
|
||||
await Promise.all(pipeline.map(({ ready }) => ready));
|
||||
const tick = regl.frame(({ viewportWidth, viewportHeight }) => {
|
||||
// tick.cancel();
|
||||
pipeline.forEach(({ resize }) => resize(viewportWidth, viewportHeight));
|
||||
if (
|
||||
dimensions.width !== viewportWidth ||
|
||||
dimensions.height !== viewportHeight
|
||||
) {
|
||||
dimensions.width = viewportWidth;
|
||||
dimensions.height = viewportHeight;
|
||||
for (const pass of pipeline) {
|
||||
pass.resize(viewportWidth, viewportHeight);
|
||||
}
|
||||
}
|
||||
fullScreenQuad(() => {
|
||||
pipeline.forEach(({ render }) => render());
|
||||
for (const pass of pipeline) {
|
||||
pass.render();
|
||||
}
|
||||
drawToScreen();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user