From 5072d48d8bf48b312b16c19a20e366fd9b291740 Mon Sep 17 00:00:00 2001 From: tengge1 <930372551@qq.com> Date: Sat, 3 Aug 2019 16:29:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCubeTexture=E4=BB=A5data?= =?UTF-8?q?=E5=BC=80=E5=A4=B4=E7=9A=84src=E4=BF=9D=E5=AD=98bug=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../texture/CubeTextureSerializer.js | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/ShadowEditor.Web/src/serialization/texture/CubeTextureSerializer.js b/ShadowEditor.Web/src/serialization/texture/CubeTextureSerializer.js index af656896..e859bbe8 100644 --- a/ShadowEditor.Web/src/serialization/texture/CubeTextureSerializer.js +++ b/ShadowEditor.Web/src/serialization/texture/CubeTextureSerializer.js @@ -19,13 +19,22 @@ CubeTextureSerializer.prototype.toJSON = function (obj) { json.image = []; obj.image.forEach(n => { - var url = new URL(n.src); // 修复贴图路径自带服务端路径bug - json.image.push({ - tagName: 'img', - src: url.pathname, - width: n.width, - height: n.height - }); + if (n.src.startsWith('data')) { // base64 + json.image.push({ + tagName: 'img', + src: n.src, + width: n.width, + height: n.height + }); + } else { // url + var url = new URL(n.src); // 修复贴图路径自带服务端路径bug + json.image.push({ + tagName: 'img', + src: url.pathname, + width: n.width, + height: n.height + }); + } }); return json;