Merge pull request #507 from mzgoddard/sync-svg-renderer-skin-props
synchronously store SVGRenderer props used in SVGSkin
This commit is contained in:
@@ -116,15 +116,13 @@ class SVGSkin extends Skin {
|
|||||||
setSVG (svgData, rotationCenter) {
|
setSVG (svgData, rotationCenter) {
|
||||||
this._svgRenderer.loadString(svgData);
|
this._svgRenderer.loadString(svgData);
|
||||||
|
|
||||||
// Size must be updated synchronously because the VM sets the costume's `size` immediately after calling this.
|
// Size must be updated synchronously because the VM sets the costume's
|
||||||
// TODO: add either a callback to this function so the costume size can be set after this is done,
|
// `size` immediately after calling this.
|
||||||
// or something in the VM to handle setting the costume size when Skin.Events.WasAltered is emitted.
|
|
||||||
this.size = this._svgRenderer.size;
|
this.size = this._svgRenderer.size;
|
||||||
if (typeof rotationCenter === 'undefined') rotationCenter = this.calculateRotationCenter();
|
|
||||||
this._viewOffset = this._svgRenderer.viewOffset;
|
this._viewOffset = this._svgRenderer.viewOffset;
|
||||||
// Reset rawRotationCenter when we update viewOffset.
|
// Reset rawRotationCenter when we update viewOffset. The rotation
|
||||||
|
// center used to render will be updated later.
|
||||||
this._rawRotationCenter = [NaN, NaN];
|
this._rawRotationCenter = [NaN, NaN];
|
||||||
this.setRotationCenter(rotationCenter[0], rotationCenter[1]);
|
|
||||||
|
|
||||||
this._svgRenderer._draw(1, () => {
|
this._svgRenderer._draw(1, () => {
|
||||||
const gl = this._renderer.gl;
|
const gl = this._renderer.gl;
|
||||||
@@ -159,6 +157,9 @@ class SVGSkin extends Skin {
|
|||||||
this._maxTextureScale = testScale;
|
this._maxTextureScale = testScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof rotationCenter === 'undefined') rotationCenter = this.calculateRotationCenter();
|
||||||
|
this.setRotationCenter(rotationCenter[0], rotationCenter[1]);
|
||||||
|
|
||||||
this.emit(Skin.Events.WasAltered);
|
this.emit(Skin.Events.WasAltered);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user