@@ -140,7 +140,7 @@ class Skin extends EventEmitter {
140140 */
141141 // eslint-disable-next-line no-unused-vars
142142 getTexture ( scale ) {
143- return null ;
143+ return this . _emptyImageTexture ;
144144 }
145145
146146 /**
@@ -171,6 +171,38 @@ class Skin extends EventEmitter {
171171 */
172172 updateSilhouette ( ) { }
173173
174+ /**
175+ * Set the contents of this skin to an empty skin.
176+ * @fires Skin.event:WasAltered
177+ */
178+ setEmptyImageData ( ) {
179+ // Free up the current reference to the _texture
180+ this . _texture = null ;
181+
182+ if ( ! this . _emptyImageData ) {
183+ // Create a transparent pixel
184+ this . _emptyImageData = new ImageData ( 1 , 1 ) ;
185+
186+ // Create a new texture and update the silhouette
187+ const gl = this . _renderer . gl ;
188+
189+ const textureOptions = {
190+ auto : true ,
191+ wrap : gl . CLAMP_TO_EDGE ,
192+ src : this . _emptyImageData
193+ } ;
194+
195+ // Note: we're using _emptyImageTexture here instead of _texture
196+ // so that we can cache this empty texture for later use as needed.
197+ // this._texture can get modified by other skins (e.g. BitmapSkin
198+ // and SVGSkin, so we can't use that same field for caching)
199+ this . _emptyImageTexture = twgl . createTexture ( gl , textureOptions ) ;
200+ }
201+
202+ this . _silhouette . update ( this . _emptyImageData ) ;
203+ this . emit ( Skin . Events . WasAltered ) ;
204+ }
205+
174206 /**
175207 * Does this point touch an opaque or translucent point on this skin?
176208 * Nearest Neighbor version
0 commit comments