Clarify loadBitmap_ comments

This commit is contained in:
adroitwhiz 2020-03-26 23:12:10 -04:00
parent a434bc5a34
commit 5387f3a729

View file

@ -212,16 +212,20 @@ const loadBitmap_ = function (costume, runtime, _rotationCenter) {
return fetched; return fetched;
}) })
.then(({canvas, mergeCanvas, rotationCenter}) => { .then(({canvas, mergeCanvas, rotationCenter}) => {
// createBitmapSkin does the right thing if costume.bitmapResolution is undefined... // createBitmapSkin does the right thing if costume.rotationCenter are undefined.
// TODO: is rotationCenter ever undefined? // That will be the case if you upload a bitmap asset or create one by taking a photo.
let center; let center;
if (rotationCenter) { if (rotationCenter) {
// fetchBitmapCanvas will ensure that the costume's bitmap resolution is 2 and its rotation center is
// scaled to match, so it's okay to always divide by 2.
center = [ center = [
rotationCenter[0] / 2, rotationCenter[0] / 2,
rotationCenter[1] / 2 rotationCenter[1] / 2
]; ];
} }
// TODO: costume.bitmapResolution will always be 2 at this point because of fetchBitmapCanvas_, so we don't
// need to pass it in here.
costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, center); costume.skinId = runtime.renderer.createBitmapSkin(canvas, costume.bitmapResolution, center);
canvasPool.release(mergeCanvas); canvasPool.release(mergeCanvas);
const renderSize = runtime.renderer.getSkinSize(costume.skinId); const renderSize = runtime.renderer.getSkinSize(costume.skinId);