Don't change the skin ID when making a new one

This commit is contained in:
DD 2017-08-31 11:38:44 -04:00
parent 29366df1d0
commit fa12b523c9

View File

@ -228,22 +228,18 @@ class RenderWebGL extends EventEmitter {
* @param {!string} svgData - new SVG to use.
* @param {?Array<number>} rotationCenter Optional: rotation center of the skin. If not supplied, the center of the
* skin will be used
* @returns {!int} the ID for the skin. This will be different from skinId if the old skin was not SVG.
*/
updateSVGSkin (skinId, svgData, rotationCenter) {
if (this._allSkins[skinId] instanceof SVGSkin) {
this._allSkins[skinId].setSVG(svgData, rotationCenter);
return skinId;
return;
}
const newSkinId = this.createSVGSkin(svgData, rotationCenter);
for (const drawable of this._allDrawables) {
if (drawable && drawable.skin.id === skinId) {
drawable.skin = this._allSkins[newSkinId];
}
}
this.destroySkin(skinId);
return newSkinId;
const newSkin = new SVGSkin(skinId, this);
newSkin.setSVG(svgData, rotationCenter);
const oldSkin = this._allSkins[skinId];
this._allSkins[skinId] = newSkin;
oldSkin.dispose();
}
/**