-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
Description of the problem
three.js/src/extras/ImageUtils.js
Lines 13 to 53 in b4908d2
| if ( image instanceof HTMLCanvasElement ) { | |
| canvas = image; | |
| } else { | |
| if ( typeof OffscreenCanvas !== 'undefined' ) { | |
| canvas = new OffscreenCanvas( image.width, image.height ); | |
| } else { | |
| canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); | |
| canvas.width = image.width; | |
| canvas.height = image.height; | |
| } | |
| var context = canvas.getContext( '2d' ); | |
| if ( image instanceof ImageData ) { | |
| context.putImageData( image, 0, 0 ); | |
| } else { | |
| context.drawImage( image, 0, 0, image.width, image.height ); | |
| } | |
| } | |
| if ( canvas.width > 2048 || canvas.height > 2048 ) { | |
| return canvas.toDataURL( 'image/jpeg', 0.6 ); | |
| } else { | |
| return canvas.toDataURL( 'image/png' ); | |
| } |
if canvas is an instance of OffscreenCanvas , the call canvas.toDataURL will throw an error, should avoid it,
Three.js version
- Dev
- r95
- ...
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS