@@ -3,7 +3,7 @@ const twgl = require('twgl.js');
3
3
const Skin = require ( './Skin' ) ;
4
4
const SvgRenderer = require ( 'scratch-svg-renderer' ) . SVGRenderer ;
5
5
6
- const MAX_TEXTURE_DIMENSION = 10240 ;
6
+ const MAX_TEXTURE_DIMENSION = 2048 ;
7
7
8
8
class SVGSkin extends Skin {
9
9
/**
@@ -68,30 +68,20 @@ class SVGSkin extends Skin {
68
68
getTexture ( scale ) {
69
69
// The texture only ever gets uniform scale. Take the larger of the two axes.
70
70
const scaleMax = scale ? Math . max ( Math . abs ( scale [ 0 ] ) , Math . abs ( scale [ 1 ] ) ) : 100 ;
71
- const requestedScale = scaleMax / 100 ;
71
+ const requestedScale = Math . min ( scaleMax / 100 , this . _maxTextureScale ) ;
72
72
let newScale = this . _textureScale ;
73
73
while ( ( newScale < this . _maxTextureScale ) && ( requestedScale >= 1.5 * newScale ) ) {
74
74
newScale *= 2 ;
75
75
}
76
-
77
- let error ;
78
- const callback = ( ) => {
79
- if ( this . _textureScale === newScale ) {
80
- const gl = this . _renderer . gl ;
81
- gl . bindTexture ( gl . TEXTURE_2D , this . _texture ) ;
82
- gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , gl . RGBA , gl . UNSIGNED_BYTE , this . _svgRenderer . canvas ) ;
83
- error = gl . getError ( ) ;
84
- if ( error && newScale > 1 ) {
85
- newScale /= 2 ;
86
- this . _textureScale = newScale ;
87
- this . _maxTextureScale = newScale ;
88
- this . _svgRenderer . _draw ( this . _textureScale , callback ) ;
89
- }
90
- }
91
- } ;
92
76
if ( this . _textureScale !== newScale ) {
93
77
this . _textureScale = newScale ;
94
- this . _svgRenderer . _draw ( this . _textureScale , callback ) ;
78
+ this . _svgRenderer . _draw ( this . _textureScale , ( ) => {
79
+ if ( this . _textureScale === newScale ) {
80
+ const gl = this . _renderer . gl ;
81
+ gl . bindTexture ( gl . TEXTURE_2D , this . _texture ) ;
82
+ gl . texImage2D ( gl . TEXTURE_2D , 0 , gl . RGBA , gl . RGBA , gl . UNSIGNED_BYTE , this . _svgRenderer . canvas ) ;
83
+ }
84
+ } ) ;
95
85
}
96
86
97
87
return this . _texture ;
0 commit comments