Skip to content

Commit 4fc9ce7

Browse files
aardgooseaardgoose
and
aardgoose
authored
remove image -> canvas conversion (mrdoob#27021)
Co-authored-by: aardgoose <angus.sawyer@email.com>
1 parent 25ce027 commit 4fc9ce7

File tree

2 files changed

+3
-35
lines changed

2 files changed

+3
-35
lines changed

examples/jsm/renderers/common/Textures.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ class Textures extends DataMap {
191191

192192
for ( const image of texture.images ) {
193193

194-
images.push( this._getUploadImage( image ) );
194+
images.push( image );
195195

196196
}
197197

198198
options.images = images;
199199

200200
} else {
201201

202-
options.image = this._getUploadImage( image );
202+
options.image = image;
203203

204204
}
205205

@@ -317,38 +317,6 @@ class Textures extends DataMap {
317317

318318
}
319319

320-
_getUploadImage( image ) {
321-
322-
if ( this._isHTMLImage( image ) ) {
323-
324-
return this._imageToCanvas( image );
325-
326-
}
327-
328-
return image;
329-
330-
}
331-
332-
_imageToCanvas( image ) {
333-
334-
const { width, height } = image;
335-
336-
// eslint-disable-next-line compat/compat
337-
const canvas = new OffscreenCanvas( width, height );
338-
339-
const context = canvas.getContext( '2d' );
340-
context.drawImage( image, 0, 0, width, height );
341-
342-
return canvas;
343-
344-
}
345-
346-
_isHTMLImage( image ) {
347-
348-
return ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) || ( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement );
349-
350-
}
351-
352320
_destroyTexture( texture ) {
353321

354322
this.backend.destroySampler( texture );

examples/jsm/renderers/webgl/WebGLBackend.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class WebGLBackend extends Backend {
522522

523523
return source.image.data;
524524

525-
} else if ( source instanceof ImageBitmap || source instanceof OffscreenCanvas ) {
525+
} else if ( source instanceof ImageBitmap || source instanceof OffscreenCanvas || source instanceof HTMLImageElement || source instanceof HTMLCanvasElement ) {
526526

527527
return source;
528528

0 commit comments

Comments
 (0)