Update handleLoadCostumeError to properly handle bitmap costumes

This commit is contained in:
Karishma Chadha 2022-05-16 16:24:10 -04:00
parent 1dfaa02c97
commit 05fa6cad3e

View file

@ -257,13 +257,17 @@ const handleCostumeLoadError = function (costume, runtime) {
const oldRotationX = costume.rotationCenterX; const oldRotationX = costume.rotationCenterX;
const oldRotationY = costume.rotationCenterY; const oldRotationY = costume.rotationCenterY;
const AssetType = runtime.storage.AssetType;
const isVector = costume.dataFormat === AssetType.ImageVector.runtimeFormat;
// Use default asset if original fails to load // Use default asset if original fails to load
costume.assetId = runtime.storage.defaultAssetId.ImageVector; costume.assetId = isVector ?
runtime.storage.defaultAssetId.ImageVector :
runtime.storage.defaultAssetId.ImageBitmap;
costume.asset = runtime.storage.get(costume.assetId); costume.asset = runtime.storage.get(costume.assetId);
costume.md5 = `${costume.assetId}.${costume.dataFormat}`; costume.md5 = `${costume.assetId}.${costume.dataFormat}`;
const AssetType = runtime.storage.AssetType; const defaultCostumePromise = (isVector) ?
const defaultCostumePromise = (costume.dataFormat === AssetType.ImageVector.runtimeFormat) ?
loadVector_(costume, runtime) : loadBitmap_(costume, runtime); loadVector_(costume, runtime) : loadBitmap_(costume, runtime);
return defaultCostumePromise.then(loadedCostume => { return defaultCostumePromise.then(loadedCostume => {