Extract textures via Canvas Base64 fallback to prevent revoked blob URL errors

This commit is contained in:
AI Bot
2026-07-30 16:51:59 +05:30
parent 55465099b2
commit 1339fc36de
+18 -2
View File
@@ -1373,8 +1373,24 @@ export default function Editor() {
const extractTextureUrl = (texture: any) => { const extractTextureUrl = (texture: any) => {
if (!texture) return undefined; if (!texture) return undefined;
if (texture.image && typeof texture.image.src === 'string') return texture.image.src; const img = texture.image || (texture.source && texture.source.data);
if (texture.source && texture.source.data && typeof texture.source.data.src === 'string') return texture.source.data.src; if (!img) return undefined;
if (typeof img.src === 'string' && img.src.length > 0) return img.src;
if (typeof img.currentSrc === 'string' && img.currentSrc.length > 0) return img.currentSrc;
// Fallback: draw ImageBitmap or HTMLImageElement to canvas to extract data URL
try {
const canvas = document.createElement('canvas');
canvas.width = img.width || 1024;
canvas.height = img.height || 1024;
const ctx = canvas.getContext('2d');
if (ctx) {
ctx.drawImage(img, 0, 0);
return canvas.toDataURL('image/png');
}
} catch (e) {
console.error('Error extracting texture URL:', e);
}
return undefined; return undefined;
}; };