Fixed SDF math; texture dimensions were accessed before they loaded in the REGL-based renderer

This commit is contained in:
Rezmason
2022-10-04 21:46:26 -07:00
parent b86b97fde9
commit 4f257b87f7
4 changed files with 19 additions and 10 deletions

View File

@@ -190,8 +190,8 @@ export default ({ regl, config, lkg }) => {
glintTexture: glintTexture.texture,
msdfPxRange: 4.0,
glyphMSDFSize: [glyphMSDF.width(), glyphMSDF.height()],
glintMSDFSize: [glintMSDF.width(), glintMSDF.height()],
glyphMSDFSize: () => [glyphMSDF.width(), glyphMSDF.height()],
glintMSDFSize: () => [glintMSDF.width(), glintMSDF.height()],
camera: regl.prop("camera"),
transform: regl.prop("transform"),

View File

@@ -36,8 +36,18 @@ const loadImage = (regl, url) => {
}
return texture;
},
width: () => (loaded ? texture.width : 1),
height: () => (loaded ? texture.height : 1),
width: () => {
if (!loaded && url != null) {
console.warn(`texture still loading: ${url}`);
}
return loaded ? texture.width : 1;
},
height: () => {
if (!loaded && url != null) {
console.warn(`texture still loading: ${url}`);
}
return loaded ? texture.height : 1;
},
loaded: (async () => {
if (url != null) {
const data = new Image();