mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Correct what is being passed into scratch-render if some metadata (rotationCenter, bitmapResolution) is missing.
This commit is contained in:
parent
47a2d76a14
commit
d6f28f2266
1 changed files with 10 additions and 4 deletions
|
@ -20,11 +20,16 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
|
||||||
return costume;
|
return costume;
|
||||||
}
|
}
|
||||||
const AssetType = runtime.storage.AssetType;
|
const AssetType = runtime.storage.AssetType;
|
||||||
const rotationCenter = [
|
let rotationCenter;
|
||||||
|
if (costume.rotationCenterX && costume.rotationCenterY && costume.bitmapResolution) {
|
||||||
|
rotationCenter = [
|
||||||
costume.rotationCenterX / costume.bitmapResolution,
|
costume.rotationCenterX / costume.bitmapResolution,
|
||||||
costume.rotationCenterY / costume.bitmapResolution
|
costume.rotationCenterY / costume.bitmapResolution
|
||||||
];
|
];
|
||||||
|
}
|
||||||
if (costumeAsset.assetType === AssetType.ImageVector) {
|
if (costumeAsset.assetType === AssetType.ImageVector) {
|
||||||
|
// createSVGSkin does the right thing if rotationCenter isn't provided, so it's okay if it's
|
||||||
|
// undefined here
|
||||||
costume.skinId = runtime.renderer.createSVGSkin(costumeAsset.decodeText(), rotationCenter);
|
costume.skinId = runtime.renderer.createSVGSkin(costumeAsset.decodeText(), rotationCenter);
|
||||||
costume.size = runtime.renderer.getSkinSize(costume.skinId);
|
costume.size = runtime.renderer.getSkinSize(costume.skinId);
|
||||||
return costume;
|
return costume;
|
||||||
|
@ -50,6 +55,7 @@ const loadCostumeFromAsset = function (costume, costumeAsset, runtime) {
|
||||||
imageElement.addEventListener('load', onLoad);
|
imageElement.addEventListener('load', onLoad);
|
||||||
imageElement.src = costumeAsset.encodeDataURI();
|
imageElement.src = costumeAsset.encodeDataURI();
|
||||||
}).then(imageElement => {
|
}).then(imageElement => {
|
||||||
|
// createBitmapSkin does the right thing if costume.bitmapResolution or rotationCenter are undefined...
|
||||||
costume.skinId = runtime.renderer.createBitmapSkin(imageElement, costume.bitmapResolution, rotationCenter);
|
costume.skinId = runtime.renderer.createBitmapSkin(imageElement, costume.bitmapResolution, rotationCenter);
|
||||||
costume.size = runtime.renderer.getSkinSize(costume.skinId);
|
costume.size = runtime.renderer.getSkinSize(costume.skinId);
|
||||||
return costume;
|
return costume;
|
||||||
|
|
Loading…
Reference in a new issue