mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fix review comments
This commit is contained in:
parent
928245d5c9
commit
b9ce26918d
1 changed files with 8 additions and 3 deletions
|
@ -31,11 +31,10 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
|
|||
];
|
||||
}
|
||||
if (costumeAsset.assetType === AssetType.ImageVector) {
|
||||
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
||||
// undefined here
|
||||
let svgString = costumeAsset.decodeText();
|
||||
// SVG Renderer load fixes "quirks" associated with Scratch 2 projects
|
||||
// Currently costume.version only exists for scratch 2 costumes
|
||||
if (costume.version && costume.version === 2) {
|
||||
// SVG Renderer load fixes "quirks" associated with Scratch 2 projects
|
||||
const svgRenderer = new SvgRenderer();
|
||||
svgRenderer.loadString(svgString);
|
||||
svgString = svgRenderer.toString();
|
||||
|
@ -49,7 +48,11 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
|
|||
(new TextEncoder()).encode(svgString)
|
||||
);
|
||||
costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
|
||||
} else {
|
||||
delete costume.version;
|
||||
}
|
||||
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
||||
// undefined here
|
||||
costume.skinId = renderer.createSVGSkin(svgString, rotationCenter);
|
||||
costume.size = renderer.getSkinSize(costume.skinId);
|
||||
// Now we should have a rotationCenter even if we didn't before
|
||||
|
@ -61,6 +64,8 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
|
|||
|
||||
return costume;
|
||||
}
|
||||
// Other image types do not need a compatibility step
|
||||
delete costume.version;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
const imageElement = new Image();
|
||||
|
|
Loading…
Reference in a new issue