修复CubeTexture以data开头的src保存bug。

This commit is contained in:
tengge1 2019-08-03 16:29:31 +08:00
parent a459fd3039
commit 5072d48d8b

View File

@ -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;