增加对3.7 3.8的二进制读取

This commit is contained in:
tianmo committed 2026-09-09 21:56:13 +08:00
1 parent 1b67933cac
commit 4c5033d2f9
10 files changed
+526 -52

No files matched your search

+1 -21
View File
@@ -97,13 +97,12 @@ function detectVersion(filePath) {
/**
* 根据检测到的版本与文件类型,选择本地运行时目录。
* - 3.x 只有 3.8 的 JS 构建包含二进制解析器,因此二进制使用 3.8 运行时
* - 3.6/3.7 二进制通过本地兼容解析器加载,始终使用对应版本运行时
*/
function chooseRuntimeDir(version, isBinary) {
if (!version) return null;
const major = parseInt(version.split('.')[0], 10);
if (major === 3) {
if (isBinary) return '3.8';
const minor = parseFloat(version);
if (minor <= 3.6) return '3.6';
if (minor <= 3.7 + 0.0001) return '3.7';
@@ -412,7 +411,6 @@ function resolveRealSource(filePath) {
function discoverAssets(filePath, options) {
options = options || {};
const strictStem = !!options.strictStem;
const preferCompatibleJson = !!options.preferCompatibleJson;
const requestedCrossBatch = !!options.allowCrossBatch;
const maxCrossBatchDeltaMs = Math.max(30000, Number(options.maxCrossBatchDeltaMs) || 5 * 60 * 1000);
filePath = resolveRealSource(filePath);
@@ -518,24 +516,6 @@ function discoverAssets(filePath, options) {
}
}
// Spine 3.6/3.7 的官方 JS 运行时不能读取对应二进制格式。若同批导入中
// 同时带有 JSON,则 atlas 和 skel 条目都用该 JSON 渲染真实缩略图。
if (preferCompatibleJson && skeleton && isSkeletonFile(skeleton.name)) {
let selectedVersion = null;
try { selectedVersion = detectVersion(skeleton.fullPath); } catch (e) { /* ignore */ }
const isOldBinary = /\.skel(?:\.bytes)?$/i.test(skeleton.name) && selectedVersion && parseFloat(selectedVersion) < 3.8;
if (isOldBinary) {
const stem = normalizeStem(skeleton.name);
const jsonCands = realSkeletonFiles.filter((f) =>
f.name.toLowerCase().endsWith('.json') &&
normalizeStem(f.name) === stem &&
familyOfSkel(f) === familyOfSkel(skeleton) &&
(!strictStem || Math.abs(importTimeOf(f.fullPath) - importTimeOf(skeleton.fullPath)) <= allowedImportDelta)
);
const jsonFallback = selectBest(jsonCands, skeleton.fullPath);
if (jsonFallback) skeleton = jsonFallback;
}
}
// 2) atlas 文件 —— 优先与骨骼版本家族一致(3x/4x),避免 3.8 骨骼配 4x atlas
let atlas = null;