hack(viewer): allow for loading assets load with data urls (data:img/png...)

This commit is contained in:
Dimitrie Stefanescu
2022-08-15 08:56:44 +03:00
parent a300ac4385
commit e15d53a7c4
+10
View File
@@ -80,10 +80,20 @@ export class Assets {
} else {
srcUrl = asset as string
}
if (this._cache[srcUrl]) {
return Promise.resolve(this._cache[srcUrl])
}
// Hack to load 'data:image's - for some reason, the frontend receives the default
// gradient map as a data image url, rather than a file (?).
if (srcUrl.includes('data:image')) {
const texture = new Texture(srcUrl as unknown as HTMLImageElement)
texture.needsUpdate = true
this._cache[srcUrl] = texture
return Promise.resolve(texture)
}
return new Promise<Texture>((resolve, reject) => {
const loader = Assets.getLoader(srcUrl, assetType)
if (loader) {