Component now reuses its canvas. regl implementation reuses its regl instance, and caches resources that already loaded.

This commit is contained in:
Rezmason
2025-05-05 18:59:18 -07:00
parent 237990b44c
commit 664f484723
6 changed files with 115 additions and 87 deletions

View File

@@ -37,7 +37,7 @@ const blVert = [1, 0];
const brVert = [1, 1];
const quadVertices = [tlVert, trVert, brVert, tlVert, brVert, blVert];
export default ({ regl, config, lkg }) => {
export default ({ regl, cache, config, lkg }) => {
// The volumetric mode multiplies the number of columns
// to reach the desired density, and then overlaps them
const volumetric = config.volumetric;
@@ -157,10 +157,10 @@ export default ({ regl, config, lkg }) => {
);
// We render the code into an FBO using MSDFs: https://github.com/Chlumsky/msdfgen
const glyphMSDF = loadImage(regl, config.glyphMSDFURL);
const glintMSDF = loadImage(regl, config.glintMSDFURL);
const baseTexture = loadImage(regl, config.baseTextureURL, true);
const glintTexture = loadImage(regl, config.glintTextureURL, true);
const glyphMSDF = loadImage(cache, regl, config.glyphMSDFURL);
const glintMSDF = loadImage(cache, regl, config.glintMSDFURL);
const baseTexture = loadImage(cache, regl, config.baseTextureURL, true);
const glintTexture = loadImage(cache, regl, config.glintTextureURL, true);
const output = makePassFBO(regl, config.useHalfFloat);
const renderUniforms = {
...commonUniforms,