Skip to content

Commit e6343e8

Browse files
authored
ImageUtils: Add optional type paramter to getDataURL(). (#30751)
1 parent 17d0b43 commit e6343e8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

examples/jsm/exporters/GLTFExporter.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import {
2424
CompressedTexture,
2525
Vector3,
2626
Quaternion,
27-
REVISION
27+
REVISION,
28+
ImageUtils
2829
} from 'three';
2930

3031
/**
@@ -1465,7 +1466,7 @@ class GLTFWriter {
14651466

14661467
} else {
14671468

1468-
imageDef.uri = canvas.toDataURL( mimeType );
1469+
imageDef.uri = ImageUtils.getDataURL( canvas, mimeType );
14691470

14701471
}
14711472

src/extras/ImageUtils.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ class ImageUtils {
1414
* Returns a data URI containing a representation of the given image.
1515
*
1616
* @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.
17+
* @param {string} [type='image/png'] - Indicates the image format.
1718
* @return {string} The data URI.
1819
*/
19-
static getDataURL( image ) {
20+
static getDataURL( image, type = 'image/png' ) {
2021

2122
if ( /^data:/i.test( image.src ) ) {
2223

@@ -59,7 +60,7 @@ class ImageUtils {
5960

6061
}
6162

62-
return canvas.toDataURL( 'image/png' );
63+
return canvas.toDataURL( type );
6364

6465
}
6566

0 commit comments

Comments
 (0)