Skip to content

Commit 370504b

Browse files
authored
GLTFLoader: Set RGBFormat for jpg with no mimeType. (#21892)
* GLTFLoader: Set RGBFormat for jpg with no mimeType. * GLTFLoader: Handle data:image/jpeg uris.
1 parent 2b34172 commit 370504b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

examples/js/loaders/GLTFLoader.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,10 +2291,11 @@
22912291
}
22922292

22932293
const URL = self.URL || self.webkitURL;
2294-
let sourceURI = source.uri;
2294+
let sourceURI = source.uri || '';
22952295
let isObjectURL = false;
22962296
let hasAlpha = true;
2297-
if ( source.mimeType === 'image/jpeg' ) hasAlpha = false;
2297+
const isJPEG = sourceURI.search( /\.jpe?g($|\?)/i ) > 0 || sourceURI.search( /^data\:image\/jpeg/ ) === 0;
2298+
if ( source.mimeType === 'image/jpeg' || isJPEG ) hasAlpha = false;
22982299

22992300
if ( source.bufferView !== undefined ) {
23002301

examples/jsm/loaders/GLTFLoader.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,11 +2548,13 @@ class GLTFParser {
25482548

25492549
const URL = self.URL || self.webkitURL;
25502550

2551-
let sourceURI = source.uri;
2551+
let sourceURI = source.uri || '';
25522552
let isObjectURL = false;
25532553
let hasAlpha = true;
25542554

2555-
if ( source.mimeType === 'image/jpeg' ) hasAlpha = false;
2555+
const isJPEG = sourceURI.search( /\.jpe?g($|\?)/i ) > 0 || sourceURI.search( /^data\:image\/jpeg/ ) === 0;
2556+
2557+
if ( source.mimeType === 'image/jpeg' || isJPEG ) hasAlpha = false;
25562558

25572559
if ( source.bufferView !== undefined ) {
25582560

0 commit comments

Comments
 (0)