@@ -114,7 +114,19 @@ class SVGSkin extends Skin {
114114 * @fires Skin.event:WasAltered
115115 */
116116 setSVG ( svgData , rotationCenter ) {
117- this . _svgRenderer . fromString ( svgData , 1 , ( ) => {
117+ this . _svgRenderer . loadString ( svgData ) ;
118+
119+ // Size must be updated synchronously because the VM sets the costume's `size` immediately after calling this.
120+ // TODO: add either a callback to this function so the costume size can be set after this is done,
121+ // or something in the VM to handle setting the costume size when Skin.Events.WasAltered is emitted.
122+ this . size = this . _svgRenderer . size ;
123+ if ( typeof rotationCenter === 'undefined' ) rotationCenter = this . calculateRotationCenter ( ) ;
124+ this . _viewOffset = this . _svgRenderer . viewOffset ;
125+ // Reset rawRotationCenter when we update viewOffset.
126+ this . _rawRotationCenter = [ NaN , NaN ] ;
127+ this . setRotationCenter ( rotationCenter [ 0 ] , rotationCenter [ 1 ] ) ;
128+
129+ this . _svgRenderer . _draw ( 1 , ( ) => {
118130 const gl = this . _renderer . gl ;
119131 this . _textureScale = this . _maxTextureScale = 1 ;
120132
@@ -147,13 +159,6 @@ class SVGSkin extends Skin {
147159 this . _maxTextureScale = testScale ;
148160 }
149161
150- this . size = this . _svgRenderer . size ;
151- if ( typeof rotationCenter === 'undefined' ) rotationCenter = this . calculateRotationCenter ( ) ;
152-
153- this . _viewOffset = this . _svgRenderer . viewOffset ;
154- // Reset rawRotationCenter when we update viewOffset.
155- this . _rawRotationCenter = [ NaN , NaN ] ;
156- this . setRotationCenter ( rotationCenter [ 0 ] , rotationCenter [ 1 ] ) ;
157162 this . emit ( Skin . Events . WasAltered ) ;
158163 } ) ;
159164 }
0 commit comments