diff --git a/src/core/lib/utils.ts b/src/core/lib/utils.ts index 7c526950..41ffaa68 100644 --- a/src/core/lib/utils.ts +++ b/src/core/lib/utils.ts @@ -304,3 +304,7 @@ export function convertUrlToAbsolute(url: string): string { const absoluteUrl = new URL(url, self.location.href); return absoluteUrl.href; } + +export function isBase64Image(src: string) { + return src.startsWith('data:') === true; +} diff --git a/src/core/textures/ImageTexture.ts b/src/core/textures/ImageTexture.ts index 9f6a2915..7f62adc5 100644 --- a/src/core/textures/ImageTexture.ts +++ b/src/core/textures/ImageTexture.ts @@ -23,7 +23,7 @@ import { isCompressedTextureContainer, loadCompressedTexture, } from '../lib/textureCompression.js'; -import { convertUrlToAbsolute } from '../lib/utils.js'; +import { convertUrlToAbsolute, isBase64Image } from '../lib/utils.js'; import { isSvgImage, loadSvg } from '../lib/textureSvg.js'; /** @@ -135,7 +135,7 @@ export class ImageTexture extends Texture { async loadImageFallback(src: string, hasAlpha: boolean) { const img = new Image(); - if (!src.startsWith('data:')) { + if (isBase64Image(src) === false) { img.crossOrigin = 'anonymous'; } @@ -206,6 +206,7 @@ export class ImageTexture extends Texture { if (this.txManager.hasCreateImageBitmap === true) { if ( + isBase64Image(src) === false && this.txManager.hasWorker === true && this.txManager.imageWorkerManager !== null ) {