From a56346d0a97383b05b2b3d5042715076aac3ab3b Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Fri, 13 Jan 2017 12:55:21 -0500 Subject: [PATCH] Only update costume rotationCenter if it exists This prevents sending `NaN`s to the renderer as the rotation center, which prevents the initial render of the costume/backdrop. Towards LLK/scratch-gui#18 --- src/sprites/rendered-target.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 69177b9ac..dc7c25d2f 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -329,18 +329,21 @@ RenderedTarget.prototype.setCostume = function (index) { ); if (this.renderer) { var costume = this.sprite.costumes[this.currentCostume]; - var rotationCenter = costume.bitmapResolution ? [ - costume.rotationCenterX / costume.bitmapResolution, - costume.rotationCenterY / costume.bitmapResolution - ] : [ - costume.rotationCenterX, - costume.rotationCenterY - ]; - this.renderer.updateDrawableProperties(this.drawableID, { + var drawableProperties = { skin: costume.skin, - costumeResolution: costume.bitmapResolution, - rotationCenter: rotationCenter - }); + costumeResolution: costume.bitmapResolution + }; + if ( + typeof costume.rotationCenterX !== 'undefined' && + typeof costume.rotationCenterY !== 'undefined' + ) { + var scale = costume.bitmapResolution || 1; + drawableProperties.rotationCenter = [ + costume.rotationCenterX / scale, + costume.rotationCenterY / scale + ]; + } + this.renderer.updateDrawableProperties(this.drawableID, drawableProperties); if (this.visible) { this.runtime.requestRedraw(); }