增加对3.7 3.8的二进制读取
This commit is contained in:
1 parent
1b67933cac
commit
4c5033d2f9
10 files changed
+526
-52
No files matched your search
+2
-6
@@ -53,7 +53,7 @@ function loadRuntime(dir) {
|
||||
sandbox.globalThis = sandbox;
|
||||
vm.createContext(sandbox);
|
||||
vm.runInContext(code, sandbox, { filename: 'lib/' + dir + '/spine-canvas.js' });
|
||||
return sandbox.spine;
|
||||
return require('./spine-legacy-binary.js').install(sandbox.spine, dir);
|
||||
}
|
||||
|
||||
/** 构造 TextureAtlas 并挂载贴图(跨版本兼容)。
|
||||
@@ -157,13 +157,9 @@ async function renderThumbnail({ skeletonPath, atlasPath, texturePaths, version,
|
||||
const atlas = await buildTextureAtlas(spine, atlasText, dir, texturePaths);
|
||||
const skeletonData = readSkeletonData(spine, skeletonPath, atlas, isBinary);
|
||||
|
||||
// 3.6/3.7 的二进制骨骼与 3.8 运行时二进制格式不兼容,
|
||||
// 且 3.6/3.7 的 JS 运行时本身不含二进制解析器,因此这类文件无法加载。
|
||||
if (!skeletonData || !skeletonData.bones || skeletonData.bones.length === 0) {
|
||||
const name = path.basename(skeletonPath);
|
||||
throw new Error(version && parseFloat(version) < 3.8
|
||||
? 'Spine ' + version + ' 的二进制骨骼(' + name + ')无法由官方 JS 运行时解析,请改用 .json 格式导出。'
|
||||
: '骨骼数据为空:' + name);
|
||||
throw new Error('骨骼数据为空:' + name);
|
||||
}
|
||||
const skeleton = new spine.Skeleton(skeletonData);
|
||||
|
||||
|
||||
Reference in new issue
Block a user