cope with async renderer.createSVGSkin

This commit is contained in:
Christopher Willis-Ford 2020-10-13 17:58:36 -07:00
parent 2d721c4c74
commit b8b3de967d

View file

@ -21,21 +21,22 @@ const loadVector_ = function (costume, runtime, rotationCenter, optVersion) {
log.error('No V2 SVG adapter present; SVGs may not render correctly.');
}
resolve(svgString); // unmodified
}).then(svgString => {
}).then(svgString => new Promise(resolve => {
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
// undefined here
costume.skinId = runtime.renderer.createSVGSkin(svgString, rotationCenter);
costume.size = runtime.renderer.getSkinSize(costume.skinId);
// Now we should have a rotationCenter even if we didn't before
if (!rotationCenter) {
rotationCenter = runtime.renderer.getSkinRotationCenter(costume.skinId);
costume.rotationCenterX = rotationCenter[0];
costume.rotationCenterY = rotationCenter[1];
costume.bitmapResolution = 1;
}
costume.skinId = runtime.renderer.createSVGSkin(svgString, rotationCenter, () => {
costume.size = runtime.renderer.getSkinSize(costume.skinId);
// Now we should have a rotationCenter even if we didn't before
if (!rotationCenter) {
rotationCenter = runtime.renderer.getSkinRotationCenter(costume.skinId);
costume.rotationCenterX = rotationCenter[0];
costume.rotationCenterY = rotationCenter[1];
costume.bitmapResolution = 1;
}
return costume;
});
resolve(costume);
});
}));
};
const canvasPool = (function () {