Skip to content

Commit

Permalink
GLTFLoader: Set RGBFormat for jpg with no mimeType. (#21892)
Browse files Browse the repository at this point in the history
* GLTFLoader: Set RGBFormat for jpg with no mimeType.

* GLTFLoader: Handle data:image/jpeg uris.
  • Loading branch information
mrdoob authored May 27, 2021
1 parent 2b34172 commit 370504b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions examples/js/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2291,10 +2291,11 @@
}

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

if ( source.bufferView !== undefined ) {

Expand Down
6 changes: 4 additions & 2 deletions examples/jsm/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2548,11 +2548,13 @@ class GLTFParser {

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

let sourceURI = source.uri;
let sourceURI = source.uri || '';
let isObjectURL = false;
let hasAlpha = true;

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

if ( source.mimeType === 'image/jpeg' || isJPEG ) hasAlpha = false;

if ( source.bufferView !== undefined ) {

Expand Down

0 comments on commit 370504b

Please sign in to comment.