modelstage 0.11.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/package.json +1 -1
- package/plugins/unity-live2d-bundle/index.js +51 -37
- package/plugins/unity-live2d-bundle/lib/astc.js +10 -2
- package/plugins/unity-spine-bundle/index.js +43 -2
- package/plugins/unity-spine-bundle/lib/astc.js +10 -2
- package/plugins/unity-spine-bundle/lib/extract.js +69 -0
- package/src/server/unpack/plugin-runner.mjs +39 -5
- package/src/web/infra/plugin-host-unpack.mjs +29 -4
- package/src/web/main.js +42 -2
- package/src/web/render/camera/constants.js +41 -3
- package/src/web/render/demo-3d.js +131 -0
- package/src/web/render/interaction.js +129 -12
- package/src/web/render/surfaces.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
| 版本 | 日期 | 要点 |
|
|
11
11
|
|---|---|---|
|
|
12
|
+
| 0.11.2 | 2026-12-01 | **`_AlphaTex` 遮罩合成(修黑块)+ 两处缓存/作用域缺陷**<br>· **黑块修复**:部分资源的主图是 `ETC_RGB4`(无 alpha 通道),透明度在另一张纹理里、由 **Material 的 `_AlphaTex`** 引用。此前只导出 `_MainTex`,导致 alpha 全填 255 ⇒ 本应透明的区域显示为纯黑。现按引用链(`skel → SkeletonDataAsset.skeletonJSON → atlasAssets[] → AtlasAsset.materials[] → Material.m_TexEnvs`)取 `_MainTex`/`_AlphaTex` 并逐像素合成,**服务端 worker 与前端插件同口径**<br>· **不接受名字配对**:同一包里 `xxx` 与 `xxx[alpha]` 各有多份同名且内容不同,名字无法唯一标识;配对只走 pathID 引用<br>· **边界**:无 `_AlphaTex` 原样导出;尺寸不一致最近邻缩放 + warn;`_AlphaTex` 解码失败回退主图 + warn;主图自带 alpha 时**不合成**(防二次乘算)<br>· 实测:`char_1001_amiya2` 主图 alpha 由 **100% 全 255 → 13.3% 不透明 / 83.1% 全透明 / 9429 中间值**,「纯黑且不透明」由 85.2% 降到 **0.3%**,页面 `stageReady=1`、黑块消失;`char_010_chen` 同样受益(alpha 100%→27.7%,渲染正常)<br>· **缓存指纹计入插件源码 stat**(`providerFingerprint`):此前只含手写的 `id@version`,改代码不升版本时缓存键不变 ⇒ 产物永远命中旧缓存(实测导致"代码已修好、页面仍是 4 文件残缺产物")。现 `files[]` 与 `entry` 两种形态都计入,代码变动即失效<br>· **live2d `putFile` 作用域修复**:`sameBytes`/`putFile` 定义在 `install()` 内却被 `createContainerTools` 调用 ⇒ `putFile is not defined`(`ULB_WORKER_FAIL`)。已提到模块级,并新增 `DEFAULT_MIME_OCTET` 常量<br>· 测试:新增 `alpha-mask`(5);`live2d-files`/`camera-capability`/`surfaces`/`renderer-contract`/`astc-*` 合计 **51/51**,含红绿自证 |
|
|
12
13
|
| 0.11.1 | 2026-11-26 | **live2d 侧同名资源冲突检测(防御性)+ 收尾文档**<br>· `unity-live2d-bundle/index.js` 新增 `putFile` / `sameBytes`:同名且**内容相同**→ 无损合并;同名但**内容不同**→ 抛 `ULB_ERR_MODEL_BUILD`(文案带资源名),不再静默覆盖。3 处 `files.set` 收口到唯一入口 `put`<br>· **为什么 live2d 不能像 spine 那样改名**:`model3.json` 是包内原有文件,`FileReferences` 写的是原始文件名,插件改名就断了引用(除非同时重写 model3.json)⇒ 所以只能"拒绝覆盖"而非"改名区分"<br>· 新增 `test/live2d-files.test.mjs`(4 条 + 1 条源码契约断言"`files.set` 只允许出现 1 次",防未来绕过冲突检测);加载方式用 vm 沙箱 IIFE(`new Function` 被审计判为 `security/no-eval`)<br>· 文档:ASTC 计划追加「十一、后续优化清单」(性能 2560²≈2.4s / 8→4 文件 / 51~59 块尺寸无样本);`chararts/char_003_kalts.ab` 未进角色树**已查清为显示名替换(非缺陷)**——4 个变体都在,`displayName` 把文件名换成骨架名,按文件名找会找不到,搜索仍能命中<br>· 实测:live2d 抽查 19 个包**无同名命中**(防御性修复);`files.set` 实测仅 1 处;相关套件 44/44 |
|
|
13
14
|
| 0.11.0 | 2026-11-26 | **支持 ASTC 纹理(含四层同名覆盖修复)**<br>· 新增 `plugins/*/lib/astc.js`(1304 行,纯 JS 零依赖,输出 RGBA):块尺寸 4x4/5x5/6x6/8x8/10x10/12x12,LDR 单/双平面;与 `texture2ddecoder` **逐字节等价**(差异仅在通道序:本实现 RGBA、参考 BGRA,交换 R/B 后 774400/774400 完全一致)<br>· `texdecode.js`:`FORMATS` 48~59 全部补齐(带 `bw/bh`)、`DECODERS` 48~59 注册 `astcDecoder`、`expectedSize` 改用块边长(ETC/BC 全 4x4 走默认 ⇒ 零回归)<br>· **格式号纠错**(三方证据:UnityPy 枚举 + 真库枚举 + 真实包 `m_CompleteImageSize` 算术反推,16 条 0 不一致):`48` 由 `ETC2_RGBA1` 改为 **`ASTC_RGB_4x4`**(并删除其错误的 etc2 解码器)、补 `46 ETC2_RGBA1`、`49/50` 确认为 `ASTC_RGB_5x5/6x6`;顺带纠正文档里 `PVRTC(49)` 的错误(PVRTC 实为 30~33)<br>· **同名资源被当唯一键的七处修复**(同一根因:Unity `m_Name` 不保证唯一):`worker.py` 的 `texts` / `page_to_atlas` / `_find_texture`、`exec.mjs` 的 `out[name]`、`index.js` 的 `files` 表 → 统一改为 `<stem>__<pathId><ext>`(顺序无关、可复现;单份保持原名 ⇒ 零回归);配对改为 **region 命中率**(`3969` 那份 hits=0,明确是错配套)、贴图改为 **atlas 页 size ↔ 纹理 w/h** 尺寸优先<br>· 测试:新增 `astc-decoder`(10) / `astc-decode`(7) / `spine-bundle-plugin`(+7→17) / `unitypy-worker-naming`(14);`etc2-rgba1` 的 48 号断言随格式表纠错同步<br>· **实测**:`chararts/char_010_chen.ab`(ASTC 6x6)→ 页面 `stageReady=1`(13 动作 / 244 帧 / reason=null,VFS 8 个文件、entry 指向含 BG 的 `6703` 那份 atlas);BD2 `npc_ellin` 零回归仍 `stageReady=1`<br>· 遗留:`chararts/char_003_kalts.ab` 页面未验(该变体未进角色树,属扫描器/列表问题,另开一批) |
|
|
14
15
|
| 0.10.2 | 2026-11-17 | **文档:ASTC 纹理解码支持计划**(本轮只写计划,不改代码):<br>· 实测:明日方舟 75 个 `.ab` 中 **68 个容器可解析**(2 个为 LZHAM 压缩不支持),但多数渲染失败——关键纹理是 **ASTC(50)**,`texdecode` 未实现<br>· 根因定位到具体纹理:`char_010_chen.ab` 里 atlas 需要的 `build_char_010_chen` 是 ASTC,而同名的 `char_010_chen` 是 ETC_RGB4(可解)<br>· 仅 6 个包不含 ASTC,其中 `char_1012_skadi2.ab` 实测出画(`stageReady=1`)<br>· 计划含:格式号核实(项目口径 ASTC(50)/PVRTC(49) 与 Unity 官方枚举的潜在冲突)、解码器来源 A/B 方案对比、6 步实施与验收判据、性能预算、风险、明确不做项 |
|
package/package.json
CHANGED
|
@@ -845,6 +845,54 @@ function registerWithHost({ host, PLUGIN_ID, api }) {
|
|
|
845
845
|
* 插件安装:环境探测 → 装配各职责块 → 宿主注册 → 返回解析入口。
|
|
846
846
|
* 只做编排;具体实现在上面的 createXxx 工厂里。
|
|
847
847
|
*/
|
|
848
|
+
/**
|
|
849
|
+
* 未指定 MIME 时的兜底类型(Cubism 的 moc3 等二进制内容)。
|
|
850
|
+
*
|
|
851
|
+
* 为什么要在模块级单独一份:写文件表的函数(putFile)被多个函数调用,
|
|
852
|
+
* 而各调用方传入的 MIME 常量是在 install() 内定义的局部量 ——
|
|
853
|
+
* 模块级函数不能依赖它们的可见性,否则会变成运行期 ReferenceError。
|
|
854
|
+
*/
|
|
855
|
+
const DEFAULT_MIME_OCTET = 'application/octet-stream';
|
|
856
|
+
|
|
857
|
+
/**
|
|
858
|
+
* 逐字节比较(只在同名时调用,正常包零开销)。
|
|
859
|
+
* 放在模块级是为了可被单测直接验证 —— 这条判据是"防静默覆盖"的核心,不能被闭包埋掉。
|
|
860
|
+
*/
|
|
861
|
+
function sameBytes(a, b) {
|
|
862
|
+
if (a === b) return true;
|
|
863
|
+
if (!a || !b || a.length !== b.length) return false;
|
|
864
|
+
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* 写入文件表;**同名不再静默覆盖**(与 spine 的 pathID 改名是两种不同修法)。
|
|
870
|
+
*
|
|
871
|
+
* 为什么不照 spine 那样加 pathID:spine 的 entry.json 是插件自己生成的,名字随便定;
|
|
872
|
+
* Cubism 的 model3.json 是**包内原有文件**,它的 FileReferences 写的是原始文件名 ——
|
|
873
|
+
* 插件改了名,模型就找不到纹理/moc3,除非同时重写 model3.json(那是更大的改动,
|
|
874
|
+
* 且会改变包内文件的原始语义)。所以这里只能"判断是不是同一份",不能"改名区分"。
|
|
875
|
+
*
|
|
876
|
+
* 同名 + 字节相同 ⇒ 合并(同内容重复出现合法,不报错)
|
|
877
|
+
* 同名 + 字节不同 ⇒ 抛可读错误(而不是让后写的悄悄赢 —— 那样只表现为"纹理缺失/渲染错乱",
|
|
878
|
+
* 日志看不出原因,正是要多轮才能定位的那类静默失败)
|
|
879
|
+
*
|
|
880
|
+
* 参数用 `ns` 显式传入而不是闭包取:调用方分布在不同函数里,闭包会让它们各自绑定不同实例。
|
|
881
|
+
*/
|
|
882
|
+
function putFile(files, written, key, bytes, mime, ns) {
|
|
883
|
+
const prev = written.get(key);
|
|
884
|
+
if (prev) {
|
|
885
|
+
if (!sameBytes(prev, bytes)) {
|
|
886
|
+
throw ns.errors.fail('ULB_ERR_MODEL_BUILD',
|
|
887
|
+
`包内存在同名资源 ${key} 且内容不同(Cubism 按 model3.json 的原始文件名引用,插件无法改名区分)——当前不支持,需要人工确认用哪一份`);
|
|
888
|
+
}
|
|
889
|
+
return key; // 同内容重复写入:无害,保留已写的那份
|
|
890
|
+
}
|
|
891
|
+
written.set(key, bytes);
|
|
892
|
+
files.set(key, new Blob([bytes], { type: mime || DEFAULT_MIME_OCTET }));
|
|
893
|
+
return key;
|
|
894
|
+
}
|
|
895
|
+
|
|
848
896
|
function install() {
|
|
849
897
|
const hasDom = typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
850
898
|
|
|
@@ -861,43 +909,9 @@ function install() {
|
|
|
861
909
|
// 所以统一从 globalThis 取即可(node 侧同样落在 globalThis)。
|
|
862
910
|
const NS = (typeof globalThis !== 'undefined' && globalThis.__ULB__) || null;
|
|
863
911
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
*/
|
|
868
|
-
function sameBytes(a, b) {
|
|
869
|
-
if (a === b) return true;
|
|
870
|
-
if (!a || !b || a.length !== b.length) return false;
|
|
871
|
-
for (let i = 0; i < a.length; i += 1) if (a[i] !== b[i]) return false;
|
|
872
|
-
return true;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
/**
|
|
876
|
-
* 写入文件表;**同名不再静默覆盖**(与 spine 的 pathID 改名是两种不同修法)。
|
|
877
|
-
*
|
|
878
|
-
* 为什么不照 spine 那样加 pathID:spine 的 entry.json 是插件自己生成的,名字随便定;
|
|
879
|
-
* Cubism 的 model3.json 是**包内原有文件**,它的 FileReferences 写的是原始文件名 ——
|
|
880
|
-
* 插件改了名,模型就找不到纹理/moc3,除非同时重写 model3.json(那是更大的改动,
|
|
881
|
-
* 且会改变包内文件的原始语义)。所以这里只能"判断是不是同一份",不能"改名区分"。
|
|
882
|
-
*
|
|
883
|
-
* 同名 + 字节相同 ⇒ 合并(同内容重复出现合法,不报错)
|
|
884
|
-
* 同名 + 字节不同 ⇒ 抛可读错误(而不是让后写的悄悄赢 —— 那样只表现为"纹理缺失/渲染错乱",
|
|
885
|
-
* 日志看不出原因,正是要多轮才能定位的那类静默失败)
|
|
886
|
-
*/
|
|
887
|
-
function putFile(files, written, key, bytes, mime, ns) {
|
|
888
|
-
const prev = written.get(key);
|
|
889
|
-
if (prev) {
|
|
890
|
-
if (!sameBytes(prev, bytes)) {
|
|
891
|
-
throw ns.errors.fail('ULB_ERR_MODEL_BUILD',
|
|
892
|
-
`包内存在同名资源 ${key} 且内容不同(Cubism 按 model3.json 的原始文件名引用,插件无法改名区分)——当前不支持,需要人工确认用哪一份`);
|
|
893
|
-
}
|
|
894
|
-
return key; // 同内容重复写入:无害,保留已写的那份
|
|
895
|
-
}
|
|
896
|
-
written.set(key, bytes);
|
|
897
|
-
files.set(key, new Blob([bytes], { type: mime || MIME_OCTET }));
|
|
898
|
-
return key;
|
|
899
|
-
}
|
|
900
|
-
|
|
912
|
+
// 同名冲突判定与写入逻辑在模块级(见 sameBytes / putFile 的定义):
|
|
913
|
+
// 它们被 createContainerTools 与 buildFileSet 等**多个函数**调用,
|
|
914
|
+
// 定义在 install() 内会因作用域隔离而取不到(函数声明只在自己的函数体内提升)。
|
|
901
915
|
if (NS) NS.live2dFiles = { sameBytes, putFile }; // live2d 前缀,避免污染共享命名空间
|
|
902
916
|
|
|
903
917
|
if (!NS || !NS.unityfs || !NS.serialized || !NS.extract) {
|
|
@@ -286,7 +286,10 @@
|
|
|
286
286
|
|
|
287
287
|
/** 向上取整的整除(参考实现的 deDivRoundUp32) */
|
|
288
288
|
function divRoundUp(value, divisor) {
|
|
289
|
-
|
|
289
|
+
// 用 `| 0` 而不是 Math.floor:入参都是非负整数(纹素数/宽高/块数),
|
|
290
|
+
// 两者对非负数同样向零截断;实测 CPU 时间 170ms → 155ms(1024² 5x5,约 1.10×),输出逐字节不变。
|
|
291
|
+
// 注意:若将来传入负数,`| 0` 是向零截断、Math.floor 是向下取整 —— 那时语义会变,需要回到 Math.floor。
|
|
292
|
+
return ((value + divisor - 1) / divisor) | 0;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
/**
|
|
@@ -1199,7 +1202,12 @@
|
|
|
1199
1202
|
const endpoint1 = endpointPairs[endpointBase + 4 + channel];
|
|
1200
1203
|
const blended16 = (((endpoint0 << 8) | endpoint0) * (64 - weightValue)
|
|
1201
1204
|
+ ((endpoint1 << 8) | endpoint1) * weightValue + 32) >> 6;
|
|
1202
|
-
|
|
1205
|
+
// 用整数移位而不是 Math.floor(x / 65536):
|
|
1206
|
+
// blended16 是 16 位无符号插值结果(0~65535),乘 255 再加 32768 后最大约 16.7M,
|
|
1207
|
+
// 远小于 2^31 且非负 ⇒ `>>16` 与 floor(x/65536) 逐位等价(已用 1024² 全图逐字节对照验证)。
|
|
1208
|
+
// 这一行在内层按「每像素 × 每通道」执行(1024² 就是 400 万次),
|
|
1209
|
+
// 浮点除法 + Math.floor 换取单条整数移位,实测 CPU 时间 803ms → 237ms。
|
|
1210
|
+
destination[texelIndex * 4 + channel] = (blended16 * 255 + 32768) >> 16;
|
|
1203
1211
|
}
|
|
1204
1212
|
}
|
|
1205
1213
|
}
|
|
@@ -426,6 +426,8 @@ function install() {
|
|
|
426
426
|
const pages = parseAtlasPagesDetailed(atlasPick.bytes);
|
|
427
427
|
if (!pages.length) throw NS.errors.fail(NS.errors.CODES.NO_ATLAS, 'atlas 里没有解析到贴图页名');
|
|
428
428
|
const allTextures = NS.extract.findTextures(sf);
|
|
429
|
+
// 只算一次:Material 数量很少,纹理页可能多页
|
|
430
|
+
const alphaPairs = NS.extract.collectAlphaPairs(sf);
|
|
429
431
|
|
|
430
432
|
const files = new Map();
|
|
431
433
|
const textureFiles = [];
|
|
@@ -441,11 +443,45 @@ function install() {
|
|
|
441
443
|
// 取压缩数据(.resS 切片或对象内联)→ 解码成 RGBA(flipY: Unity 自下而上存储,
|
|
442
444
|
// atlas 坐标自上而下,翻过来才是正确朝向)→ 编 PNG
|
|
443
445
|
const compressed = NS.extract.textureCompressedBytes(tex, resSBytes);
|
|
444
|
-
|
|
446
|
+
let rgba = NS.texdecode.decode(
|
|
445
447
|
{ format: tex.format, width: tex.width, height: tex.height, name: tex.name },
|
|
446
448
|
compressed,
|
|
447
449
|
{ flipY: true },
|
|
448
450
|
);
|
|
451
|
+
// 主图的透明度可能不在它自己的 alpha 通道里:有的包主图是 ETC_RGB4(没有 alpha),
|
|
452
|
+
// 有的甚至是 RGBA32 但 alpha 整幅 255 —— 两种情况真正的透明度都在 Material
|
|
453
|
+
// 引用的 `_AlphaTex` 灰度里。所以判据看**内容**(alpha 是否有真实透明像素),不看格式。
|
|
454
|
+
// 配对只认 Material 的 PPtr pathID —— 同名贴图在包里可以有多份且内容不同,
|
|
455
|
+
// 名字无法唯一标识(与 Python worker 同一口径,否则前后端结论会漂移)。
|
|
456
|
+
const alphaId = alphaPairs.get(String(tex.object && tex.object.pathID));
|
|
457
|
+
if (alphaId && !NS.extract.alphaIsEffective(rgba)) {
|
|
458
|
+
const alphaTex = allTextures.find(
|
|
459
|
+
(t) => String(t.object && t.object.pathID) === alphaId,
|
|
460
|
+
);
|
|
461
|
+
if (!alphaTex) {
|
|
462
|
+
ulbLog('warn', `贴图页 ${page}:找不到 _AlphaTex 对象 ${alphaId},回退主图`);
|
|
463
|
+
} else {
|
|
464
|
+
try {
|
|
465
|
+
const alphaCompressed = NS.extract.textureCompressedBytes(alphaTex, resSBytes);
|
|
466
|
+
const alphaRgba = NS.texdecode.decode(
|
|
467
|
+
{ format: alphaTex.format, width: alphaTex.width, height: alphaTex.height, name: alphaTex.name },
|
|
468
|
+
alphaCompressed,
|
|
469
|
+
{ flipY: true },
|
|
470
|
+
);
|
|
471
|
+
const masked = NS.extract.applyAlphaMask(
|
|
472
|
+
rgba, tex.width, tex.height, alphaRgba, alphaTex.width, alphaTex.height,
|
|
473
|
+
);
|
|
474
|
+
rgba = masked.rgba;
|
|
475
|
+
if (masked.scaled) {
|
|
476
|
+
ulbLog('warn', `贴图页 ${page}:_AlphaTex 尺寸 ${alphaTex.width}x${alphaTex.height} `
|
|
477
|
+
+ `≠ 主图 ${tex.width}x${tex.height},已最近邻缩放`);
|
|
478
|
+
}
|
|
479
|
+
} catch (e) {
|
|
480
|
+
// 不中断:回退主图比整包失败更好,但必须留痕
|
|
481
|
+
ulbLog('warn', `贴图页 ${page}:_AlphaTex 解码失败(${e.code || e.message}),回退主图`);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
449
485
|
let pngBytes;
|
|
450
486
|
try {
|
|
451
487
|
pngBytes = await NS.png.encodePngAsync(rgba, tex.width, tex.height);
|
|
@@ -474,7 +510,12 @@ function install() {
|
|
|
474
510
|
if ((nameCount.get(t.name) || 1) <= 1) return t.name;
|
|
475
511
|
return disambiguateKey(t.name, t.pathId);
|
|
476
512
|
};
|
|
477
|
-
|
|
513
|
+
// **只写选中的那一套**(未选中的同名副本不落盘):
|
|
514
|
+
// 产物因此是 4 个文件(skel + atlas + 贴图 + entry),而不是把包内所有文本资源都存一遍。
|
|
515
|
+
// 但文件名仍带 pathID —— 同名文件在包里确实存在,名字必须能区分,
|
|
516
|
+
// 否则前端拿到 `char_010_chen.atlas` 这种歧义名,无法自证用的是哪一份。
|
|
517
|
+
for (const t of [skelPick, atlasPick]) {
|
|
518
|
+
if (!t) continue;
|
|
478
519
|
const key = fileKeyOf(t);
|
|
479
520
|
if (key && !files.has(key)) files.set(key, new Blob([t.bytes], { type: 'application/octet-stream' }));
|
|
480
521
|
}
|
|
@@ -286,7 +286,10 @@
|
|
|
286
286
|
|
|
287
287
|
/** 向上取整的整除(参考实现的 deDivRoundUp32) */
|
|
288
288
|
function divRoundUp(value, divisor) {
|
|
289
|
-
|
|
289
|
+
// 用 `| 0` 而不是 Math.floor:入参都是非负整数(纹素数/宽高/块数),
|
|
290
|
+
// 两者对非负数同样向零截断;实测 CPU 时间 170ms → 155ms(1024² 5x5,约 1.10×),输出逐字节不变。
|
|
291
|
+
// 注意:若将来传入负数,`| 0` 是向零截断、Math.floor 是向下取整 —— 那时语义会变,需要回到 Math.floor。
|
|
292
|
+
return ((value + divisor - 1) / divisor) | 0;
|
|
290
293
|
}
|
|
291
294
|
|
|
292
295
|
/**
|
|
@@ -1199,7 +1202,12 @@
|
|
|
1199
1202
|
const endpoint1 = endpointPairs[endpointBase + 4 + channel];
|
|
1200
1203
|
const blended16 = (((endpoint0 << 8) | endpoint0) * (64 - weightValue)
|
|
1201
1204
|
+ ((endpoint1 << 8) | endpoint1) * weightValue + 32) >> 6;
|
|
1202
|
-
|
|
1205
|
+
// 用整数移位而不是 Math.floor(x / 65536):
|
|
1206
|
+
// blended16 是 16 位无符号插值结果(0~65535),乘 255 再加 32768 后最大约 16.7M,
|
|
1207
|
+
// 远小于 2^31 且非负 ⇒ `>>16` 与 floor(x/65536) 逐位等价(已用 1024² 全图逐字节对照验证)。
|
|
1208
|
+
// 这一行在内层按「每像素 × 每通道」执行(1024² 就是 400 万次),
|
|
1209
|
+
// 浮点除法 + Math.floor 换取单条整数移位,实测 CPU 时间 803ms → 237ms。
|
|
1210
|
+
destination[texelIndex * 4 + channel] = (blended16 * 255 + 32768) >> 16;
|
|
1203
1211
|
}
|
|
1204
1212
|
}
|
|
1205
1213
|
}
|
|
@@ -106,6 +106,74 @@
|
|
|
106
106
|
* completeImageSize:number,mipCount:number,stream:{offset:number,size:number,path:string}|null,
|
|
107
107
|
* inline:Uint8Array|null, raw:object}>}
|
|
108
108
|
*/
|
|
109
|
+
/**
|
|
110
|
+
* 主图解码后的 alpha 通道里是否含**真实透明像素**。
|
|
111
|
+
*
|
|
112
|
+
* 为什么不看纹理格式:格式"带 alpha"不等于内容真有 alpha。实测有包主图是 RGBA32,
|
|
113
|
+
* 但 alpha 整幅都是 255 —— 透明度被美工单独画在 `_AlphaTex` 的灰度里。
|
|
114
|
+
* 只按格式跳过合成,这类包就会整幅不透明、该透明处显示成黑块。
|
|
115
|
+
* 提前返回:遇到第一个非 255 就判定有效,正常带 alpha 的图不必扫完。
|
|
116
|
+
*/
|
|
117
|
+
function alphaIsEffective(rgba) {
|
|
118
|
+
if (!rgba || !rgba.length) return false;
|
|
119
|
+
for (let i = 3; i < rgba.length; i += 4) if (rgba[i] !== 255) return true;
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 从 Material 的 `m_SavedProperties.m_TexEnvs` 建立 `_MainTex pathID → _AlphaTex pathID`。
|
|
125
|
+
*
|
|
126
|
+
* 为什么用引用而不是贴图名:同名资源在包里可以有多份且内容不同(实测 `char_x` 与
|
|
127
|
+
* `char_x[alpha]` 各 2 份、md5 各异)—— 名字无法唯一标识,靠名字必然配错套。
|
|
128
|
+
* 权威依据只能是 Material 里的 PPtr pathID;该口径与 Python worker 完全一致,
|
|
129
|
+
* 否则前后端对同一个包会给出不同结论。
|
|
130
|
+
*
|
|
131
|
+
* 多个 Material 时只取**同时含 `_MainTex` 与 `_AlphaTex`** 的;同一 `_MainTex`
|
|
132
|
+
* 被多个 Material 引用时保留先遇到的(顺序稳定)。
|
|
133
|
+
*/
|
|
134
|
+
function collectAlphaPairs(sf) {
|
|
135
|
+
const pairs = new Map();
|
|
136
|
+
for (const obj of NS.serialized.byClass(sf, 21)) { // 21 = Material
|
|
137
|
+
let tree;
|
|
138
|
+
try { tree = NS.typetree.readObject(sf, obj); } catch { continue; }
|
|
139
|
+
const texenvs = ((tree.m_SavedProperties || {}).m_TexEnvs) || [];
|
|
140
|
+
const found = new Map();
|
|
141
|
+
for (const entry of texenvs) {
|
|
142
|
+
const key = entry && (entry.first !== undefined ? entry.first : entry[0]);
|
|
143
|
+
const value = entry && (entry.second !== undefined ? entry.second : entry[1]);
|
|
144
|
+
const keyText = (key && typeof key === 'object')
|
|
145
|
+
? String(key.text !== undefined ? key.text : (key.m_String !== undefined ? key.m_String : ''))
|
|
146
|
+
: String(key === undefined || key === null ? '' : key);
|
|
147
|
+
const tex = value && value.m_Texture;
|
|
148
|
+
const pathId = tex && (tex.m_PathID !== undefined ? tex.m_PathID : tex.pathID);
|
|
149
|
+
if (keyText && pathId !== undefined && pathId !== null) found.set(keyText, String(pathId));
|
|
150
|
+
}
|
|
151
|
+
const mainId = found.get('_MainTex');
|
|
152
|
+
const alphaId = found.get('_AlphaTex');
|
|
153
|
+
if (mainId && alphaId && !pairs.has(mainId)) pairs.set(mainId, alphaId);
|
|
154
|
+
}
|
|
155
|
+
return pairs;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 把 `_AlphaTex` 的灰度值写进主图 RGBA 的 alpha 通道。
|
|
160
|
+
* 尺寸不一致时用**最近邻**(不引入插值模糊,遮罩边缘该硬就硬)。
|
|
161
|
+
* @returns {{rgba: Uint8Array, scaled: boolean}}
|
|
162
|
+
*/
|
|
163
|
+
function applyAlphaMask(rgba, width, height, maskRgba, maskWidth, maskHeight) {
|
|
164
|
+
const out = new Uint8Array(rgba);
|
|
165
|
+
const scaled = maskWidth !== width || maskHeight !== height;
|
|
166
|
+
for (let y = 0; y < height; y += 1) {
|
|
167
|
+
const sy = scaled ? Math.min(maskHeight - 1, Math.floor(y * maskHeight / height)) : y;
|
|
168
|
+
for (let x = 0; x < width; x += 1) {
|
|
169
|
+
const sx = scaled ? Math.min(maskWidth - 1, Math.floor(x * maskWidth / width)) : x;
|
|
170
|
+
// 灰度遮罩三通道相同,取 R 当 alpha
|
|
171
|
+
out[(y * width + x) * 4 + 3] = maskRgba[(sy * maskWidth + sx) * 4];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return { rgba: out, scaled };
|
|
175
|
+
}
|
|
176
|
+
|
|
109
177
|
function findTextures(sf) {
|
|
110
178
|
if (!NS.typetree) throw NS.errors.fail('ULB_ERR_EXTRACT', '缺少 lib/typetree.js,无法读取 Texture2D 字段');
|
|
111
179
|
// 字段名在类型树里可能是带空格的可读名(如 "image data"),也可能是 m_ 前缀名;
|
|
@@ -237,6 +305,7 @@
|
|
|
237
305
|
|
|
238
306
|
NS.extract = {
|
|
239
307
|
findMoc3, findTextAssets, findTextures, findNativeCubismFiles,
|
|
308
|
+
collectAlphaPairs, applyAlphaMask, alphaIsEffective,
|
|
240
309
|
extractAll, textureCompressedBytes, indexOfMagic, decodeUtf8, moc3NameCandidates,
|
|
241
310
|
};
|
|
242
311
|
}
|
|
@@ -76,17 +76,51 @@ export function listProviderPlugins() {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
*
|
|
79
|
+
* 插件的**源码指纹**:`files[]` 里每个随包脚本的 size + mtime 摘要。
|
|
80
80
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
81
|
+
* 为什么需要它:providerFingerprint 原先只含 `id@version`,而 version 是插件作者
|
|
82
|
+
* 手写的声明值 —— 改了插件代码但没升版本时,解包缓存键不变,产物永远命中旧缓存。
|
|
83
|
+
* 这会造成"代码明明修好了、页面还是旧结果",而且排查时看不到线索:缓存命中本身
|
|
84
|
+
* 是正常路径,日志里只有一句 hit。
|
|
85
|
+
* 把脚本 stat 计入后,"代码变了"本身就成为失效条件,不依赖作者记得升版本。
|
|
86
|
+
*
|
|
87
|
+
* exec 运行时(如 Python worker)的 `files` 通常为空,此时退到 `entry` —— 那才是
|
|
88
|
+
* 真正会被执行的入口脚本;不把它算进去等于漏掉整个插件。
|
|
89
|
+
*/
|
|
90
|
+
function pluginSourceStamp(meta) {
|
|
91
|
+
const list = Array.isArray(meta.files) && meta.files.length
|
|
92
|
+
? meta.files
|
|
93
|
+
: (meta.entry ? [meta.entry] : []);
|
|
94
|
+
const parts = [];
|
|
95
|
+
for (const rel of list) {
|
|
96
|
+
// 两种形态并存:`files[]` 来自插件清单,**已带插件 id 前缀**(`<id>/lib/x.js`);
|
|
97
|
+
// `entry` 是裸文件名(`worker.py`)。混用拼接必然 ENOENT,所以两种都试。
|
|
98
|
+
const withId = path.join(PLUGINS_DIR, meta.id, rel);
|
|
99
|
+
const bare = path.join(PLUGINS_DIR, rel);
|
|
100
|
+
let st = null;
|
|
101
|
+
try { st = fs.statSync(withId); } catch { try { st = fs.statSync(bare); } catch { st = null; } }
|
|
102
|
+
if (!st) continue; // 缺文件交给装载阶段报错;这里只负责算指纹
|
|
103
|
+
parts.push(`${rel}:${st.size}:${Math.round(st.mtimeMs)}`);
|
|
104
|
+
}
|
|
105
|
+
return parts.join(',');
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* provider 集合的指纹段(写进解包缓存键:插件增减、升级、**源码变动**都会让它失效)。
|
|
110
|
+
*
|
|
111
|
+
* 形态 `<id>@<version>#<源码摘要>`;多插件时各自算出后排序拼接(顺序无关)。
|
|
83
112
|
* @returns {string}
|
|
84
113
|
*/
|
|
85
114
|
export function providerFingerprint() {
|
|
86
115
|
const list = listProviderPlugins();
|
|
87
116
|
if (!list.length) return 'none';
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
const seg = (m) => {
|
|
118
|
+
const v = m.version === null || m.version === undefined ? '0' : m.version;
|
|
119
|
+
const stamp = pluginSourceStamp(m);
|
|
120
|
+
return stamp ? `${m.id}@${v}#${stamp}` : `${m.id}@${v}`;
|
|
121
|
+
};
|
|
122
|
+
if (list.length === 1) return seg(list[0]);
|
|
123
|
+
return list.map(seg).sort().join('+');
|
|
90
124
|
}
|
|
91
125
|
|
|
92
126
|
/**
|
|
@@ -761,6 +761,9 @@ async function materialize(file, opts = {}) {
|
|
|
761
761
|
if (bundleCands.length) {
|
|
762
762
|
let fellBack = '';
|
|
763
763
|
let anyProbed = false; // 有没有任何一个 worker 真的判过"不认这个包"
|
|
764
|
+
// worker 的失败原因先存着,等主线程结果出来再决定发"已恢复"还是"真失败":
|
|
765
|
+
// 在中间态就报红会让用户以为坏了(画面其实可能马上正常)。
|
|
766
|
+
let pendingWorkerError = '';
|
|
764
767
|
for (const cand of bundleCands) {
|
|
765
768
|
// 有内联字节就直投;否则把 URL 交给 worker 自己拉(主线程零字节搬运)。
|
|
766
769
|
// ?workerFetch=0 时故意先读一遍,用来量"改造前"那一段的耗时。
|
|
@@ -793,9 +796,16 @@ async function materialize(file, opts = {}) {
|
|
|
793
796
|
// 交给下面的同步路径去给出正确的"没有插件能处理"错误,不该谎报成后台不可用
|
|
794
797
|
if (!fellBack && !anyProbed) fellBack = '所有候选插件的 worker 都不可用';
|
|
795
798
|
if (fellBack) {
|
|
796
|
-
//
|
|
797
|
-
|
|
798
|
-
|
|
799
|
+
// 降级**不静默**:告诉用户"后台解包用不了,接下来会卡数秒"。
|
|
800
|
+
// 但**不要把 worker 的原始异常原文塞进这句文案**:它通常只是"某个候选插件在这个包上失败"
|
|
801
|
+
// (例如 live2d 插件撞到包内同名贴图),紧接着主线程很可能解包成功。
|
|
802
|
+
// 把 `ULB_ERR_MODEL_BUILD: ...` 这类原文摆在状态栏,用户看到的是"功能坏了",
|
|
803
|
+
// 实际画面马上就出来了 —— 原文仍留在诊断事件的 detail 里,排查要看得到。
|
|
804
|
+
say.warn('后台解包不可用,回落主线程解包 —— 这次会慢几秒');
|
|
805
|
+
// worker 失败这件事**此刻还只是中间态**:下面主线程还会再试一次,很可能成功。
|
|
806
|
+
// 早先是在这里就 emit('unpack.worker-fallback', {error}),于是诊断面板先落一条带错误的事件,
|
|
807
|
+
// 哪怕随后主线程装好了也不会收回。现在先记住,等主线程结果出来再按「最终成败」发事件。
|
|
808
|
+
pendingWorkerError = fellBack;
|
|
799
809
|
}
|
|
800
810
|
}
|
|
801
811
|
// 同步解压前让出一帧:DOM 改了但主线程随即冻住,浏览器不会给你渲染机会。
|
|
@@ -808,7 +818,22 @@ async function materialize(file, opts = {}) {
|
|
|
808
818
|
const read = await ensureBytes();
|
|
809
819
|
const got = await resolveViaProvider(file, read.bytes);
|
|
810
820
|
if (mon.checkNow()) throw Object.assign(new Error(mon.reason()), { reason: 'memory-guard' });
|
|
811
|
-
if (!got.ok)
|
|
821
|
+
if (!got.ok) {
|
|
822
|
+
// 主线程也失败 ⇒ 这才是**真失败**:把前面 worker 的失败原因一并带上,便于定位
|
|
823
|
+
if (pendingWorkerError) {
|
|
824
|
+
emit('unpack.worker-fallback', {
|
|
825
|
+
rootId: file.rootId, rel: file.rel, error: pendingWorkerError, finalError: got.message || got.reason || null,
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
throw Object.assign(new Error(got.message || '本地解包失败'), { reason: got.reason, passthrough: got });
|
|
829
|
+
}
|
|
830
|
+
if (pendingWorkerError) {
|
|
831
|
+
// 回退成功:worker 那次失败只是中间态。发一条**不带 error 字段**的恢复事件,
|
|
832
|
+
// 面板据此显示成信息而不是红字;worker 的原始原因留在 workerError 里供排查。
|
|
833
|
+
emit('unpack.worker-recovered', {
|
|
834
|
+
rootId: file.rootId, rel: file.rel, workerError: pendingWorkerError, provider: got.provider,
|
|
835
|
+
});
|
|
836
|
+
}
|
|
812
837
|
return { ...got.res, provider: got.provider, src: 'local' };
|
|
813
838
|
};
|
|
814
839
|
|
package/src/web/main.js
CHANGED
|
@@ -25,6 +25,7 @@ import { createSpineStage } from './spine/canvas.js';
|
|
|
25
25
|
import { createStageSurface } from './render/surface.js';
|
|
26
26
|
import { createSpineRenderer } from './render/spine.js';
|
|
27
27
|
import { createLive2DRenderer } from './render/live2d.js';
|
|
28
|
+
import { createThreeRenderer } from './render/demo-3d.js';
|
|
28
29
|
import { createLive2DStage } from './live2d/stage.js';
|
|
29
30
|
import { attachStageInteraction } from './render/interaction.js';
|
|
30
31
|
import { dom, setStage, stage, state } from './app/context.js';
|
|
@@ -147,9 +148,16 @@ function initRenderer() {
|
|
|
147
148
|
const surface = createStageSurface({ log: (message, level) => stageStatus(message, level === 'error' ? 'error' : level === 'warn' ? 'warn' : 'info') });
|
|
148
149
|
surface.register(createSpineRenderer({ stage, onMsaa: applyMsaa }));
|
|
149
150
|
surface.register(createLive2DRenderer({ live2d: ensureLive2DStage() }));
|
|
151
|
+
// 三维预留面:**注册但不激活**。没有任何内容类型会产出 kind='three',
|
|
152
|
+
// 所以它不会改变用户可见的默认面;注册它的价值是让"新面插得进来"这件事
|
|
153
|
+
// 处于可运行状态(面元数据、注册校验、相机语义分派全链路都在位)。
|
|
154
|
+
surface.register(createThreeRenderer({
|
|
155
|
+
log: (message, level) => stageStatus(message, level === 'warn' ? 'warn' : 'info'),
|
|
156
|
+
}));
|
|
150
157
|
// 就绪信号 renderer 阶段(契约 §三):两面都注册完 = 已实例化;
|
|
151
158
|
// 能力声明可读 = settled;能拿到 activeRenderer 且可下发设置 = interactive
|
|
152
|
-
|
|
159
|
+
// faces 取实际注册数(不写死,加面时诊断字段自动跟上)
|
|
160
|
+
markStage('renderer', 'mounted', { faces: typeof surface.renderers === 'function' ? surface.renderers().length : null });
|
|
153
161
|
const twoFrames = (fn) => requestAnimationFrame(() => requestAnimationFrame(fn));
|
|
154
162
|
twoFrames(() => {
|
|
155
163
|
const caps = (() => { try { return surface.capabilities ? surface.capabilities() : null; } catch { return null; } })();
|
|
@@ -291,6 +299,19 @@ function cameraProxy() {
|
|
|
291
299
|
zoomStep: forward('zoomStep'),
|
|
292
300
|
zoomTo: forward('zoomTo'),
|
|
293
301
|
panBy: forward('panBy'),
|
|
302
|
+
// 3D 面的相机用 orbitBy 表达"拖动 = 绕轨道转";2D 面没有这个方法,
|
|
303
|
+
// 转发后取到 null,交互层据此判定该面不支持轨道语义(而不是猜一个近似动作)。
|
|
304
|
+
orbitBy: forward('orbitBy'),
|
|
305
|
+
/**
|
|
306
|
+
* 当前相机是否真的提供 orbitBy。
|
|
307
|
+
* 为什么要单独一个探针:门面是固定形状的代理,2D 相机上也存在 `orbitBy` 这个键
|
|
308
|
+
* (转发后返回 null)。交互层若只看"有没有这个函数",在 2D 面上会误判成支持轨道,
|
|
309
|
+
* 把拖动变成静默无效。探针让"支不支持"由真实相机决定。
|
|
310
|
+
*/
|
|
311
|
+
hasOrbit: () => {
|
|
312
|
+
const cam = pick();
|
|
313
|
+
return !!(cam && typeof cam.orbitBy === 'function');
|
|
314
|
+
},
|
|
294
315
|
reset: forward('reset'),
|
|
295
316
|
scale: forward('scale'),
|
|
296
317
|
note: forward('note'),
|
|
@@ -302,6 +323,19 @@ function cameraProxy() {
|
|
|
302
323
|
function interactionStage() {
|
|
303
324
|
return {
|
|
304
325
|
camera: cameraProxy(),
|
|
326
|
+
/**
|
|
327
|
+
* 当前渲染面声明的相机语义(`capabilities.camera`)。
|
|
328
|
+
*
|
|
329
|
+
* 交付给交互层的是**值**而不是能力表:交互层只需知道"这一面是平面还是绕轨道",
|
|
330
|
+
* 给它整份能力表会让它有机会去读与本层无关的字段。做成 getter 是因为切面后
|
|
331
|
+
* 语义会变,而交互层只在挂载时拿一次门面(每次调用现取才不会停在旧面上)。
|
|
332
|
+
*/
|
|
333
|
+
get cameraCapability() {
|
|
334
|
+
const caps = state.surface && typeof state.surface.capabilities === 'function'
|
|
335
|
+
? state.surface.capabilities()
|
|
336
|
+
: null;
|
|
337
|
+
return caps && typeof caps.camera === 'string' ? caps.camera : null;
|
|
338
|
+
},
|
|
305
339
|
getView: (...args) => (stage && stage.getView ? stage.getView(...args) : null),
|
|
306
340
|
setView: (...args) => (stage && stage.setView ? stage.setView(...args) : null),
|
|
307
341
|
resetView: (...args) => (stage && stage.resetView ? stage.resetView(...args) : null),
|
|
@@ -318,7 +352,13 @@ function attachInteraction() {
|
|
|
318
352
|
const target = (state.surface && state.surface.interactionTarget) || null;
|
|
319
353
|
if (!target || !stage) return null;
|
|
320
354
|
try {
|
|
321
|
-
detachInteraction = attachStageInteraction({
|
|
355
|
+
detachInteraction = attachStageInteraction({
|
|
356
|
+
canvas: target,
|
|
357
|
+
stage: interactionStage(),
|
|
358
|
+
// 交互层的告警要有出口:相机缺能力(例如 3D 面没实现 orbitBy)时,
|
|
359
|
+
// 只写相机内部日志会静默(相机 logger 未挂),用户只看到"拖不动"。
|
|
360
|
+
options: { log: (message, level) => stageStatus(message, level === 'info' ? 'info' : 'warn') },
|
|
361
|
+
});
|
|
322
362
|
} catch (err) {
|
|
323
363
|
state.stageError = formatError(err);
|
|
324
364
|
}
|
|
@@ -34,12 +34,39 @@ export const LIVE2D_OVERRIDE = Object.freeze({});
|
|
|
34
34
|
*/
|
|
35
35
|
export const SUBJECT_EXCLUDE = Object.freeze(['bg', 'back', 'background', 'effect', 'mask', 'scene', 'kazari']);
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* 三维(轨道相机)面的边界承载位:距离与俯仰。
|
|
39
|
+
*
|
|
40
|
+
* 本字段只是**结构就位**:当前没有任何实现消费它(没有 3D 渲染器),
|
|
41
|
+
* 目的是让 `limitsFor` 的形状在接入 3D 之前就稳定下来 —— 将来写轨道相机时
|
|
42
|
+
* 数值往这里填,不必回头改 `limitsFor` 的返回形状与所有调用点。
|
|
43
|
+
* 与契约里 `capabilities.camera = 'orbit-3d'` 是同一个语义键,两处必须一致。
|
|
44
|
+
*/
|
|
45
|
+
export const ORBIT = Object.freeze({
|
|
46
|
+
/** 最近距离(推拉到最近处仍能看到主体) */
|
|
47
|
+
MIN_DISTANCE: 0.5,
|
|
48
|
+
/** 最远距离(再远就只剩一个小点,收益极低) */
|
|
49
|
+
MAX_DISTANCE: 12,
|
|
50
|
+
/** 最低俯仰角(弧度):约 8.6°,再低会看到地平面以下 */
|
|
51
|
+
MIN_POLAR: 0.15,
|
|
52
|
+
/** 最高俯仰角(弧度):约 83°,避免与极点重合导致万向锁抖动 */
|
|
53
|
+
MAX_POLAR: 1.45,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 面元数据表里 `cameraKind` 取这个值表示"该面用轨道相机"。
|
|
58
|
+
* 数值/形状由 ORBIT 承载;这里只是判定键。
|
|
59
|
+
*/
|
|
60
|
+
export const ORBIT_CAMERA_KIND = 'orbit-3d';
|
|
61
|
+
|
|
37
62
|
/**
|
|
38
63
|
* 各面的相机覆盖值表(键 = 面元数据表的 cameraKind)。
|
|
39
64
|
* 加新面时若要限制它的缩放范围,在这里加一个键 —— 不必改 limitsFor 的判断。
|
|
40
65
|
*/
|
|
41
66
|
const CAMERA_OVERRIDES = Object.freeze({
|
|
42
67
|
live2d: LIVE2D_OVERRIDE,
|
|
68
|
+
// 3D 面的缩放落在"距离"上,量级与 2D 的 userScale 不同,因此给一份独立覆盖值
|
|
69
|
+
[ORBIT_CAMERA_KIND]: Object.freeze({ MIN: ORBIT.MIN_DISTANCE, MAX: ORBIT.MAX_DISTANCE }),
|
|
43
70
|
});
|
|
44
71
|
|
|
45
72
|
/**
|
|
@@ -48,13 +75,24 @@ const CAMERA_OVERRIDES = Object.freeze({
|
|
|
48
75
|
* 覆盖关系查 render/surfaces.js 的 cameraKind,不再写 `kind === 'live2d'`:
|
|
49
76
|
* 未知 kind ⇒ 不叠加覆盖、直接用通用值。这里刻意**不抛错**:
|
|
50
77
|
* 相机范围有通用兜底,不像画布/面模式那样写错就错乱,所以"查不到覆盖表键"等同于"这个面没有特殊限制"。
|
|
51
|
-
*
|
|
52
|
-
*
|
|
78
|
+
*
|
|
79
|
+
* 2D 面返回形状**只有 { min, max }**(一个字段都不多):交互/相机层按此读写缩放,
|
|
80
|
+
* 多给字段不会报错但会让"3D 结构已就位"这件事看不出边界;只有声明了轨道相机的面
|
|
81
|
+
* 才额外带 `orbit`(距离/俯仰),且该字段当前无人消费。
|
|
82
|
+
* @param {'spine'|'live2d'|'three'} kind
|
|
83
|
+
* @returns {{min: number, max: number, orbit?: {distance: {min: number, max: number}, polar: {min: number, max: number}}}}
|
|
53
84
|
*/
|
|
54
85
|
export function limitsFor(kind) {
|
|
55
86
|
const meta = byKind(kind);
|
|
56
87
|
const override = meta ? (CAMERA_OVERRIDES[meta.cameraKind] || null) : null;
|
|
57
88
|
const min = override && typeof override.MIN === 'number' ? override.MIN : CAMERA.MIN;
|
|
58
89
|
const max = override && typeof override.MAX === 'number' ? override.MAX : CAMERA.MAX;
|
|
59
|
-
|
|
90
|
+
const limits = { min, max };
|
|
91
|
+
if (meta && meta.cameraKind === ORBIT_CAMERA_KIND) {
|
|
92
|
+
limits.orbit = {
|
|
93
|
+
distance: { min: ORBIT.MIN_DISTANCE, max: ORBIT.MAX_DISTANCE },
|
|
94
|
+
polar: { min: ORBIT.MIN_POLAR, max: ORBIT.MAX_POLAR },
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return limits;
|
|
60
98
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// render/demo-3d.js —— 三维渲染面(id: 'three')的**占位实现**
|
|
2
|
+
//
|
|
3
|
+
// 这个文件不画 3D,也不引 three.js/glTF:它存在的唯一目的是证明
|
|
4
|
+
// 「契约里预留的三维位真的插得进来」—— 能注册、能被 activate、相机语义是 orbit-3d、
|
|
5
|
+
// 拖动会走轨道分支而不是平移。等真写 3D 渲染时,替换本文件的 mount/render 即可,
|
|
6
|
+
// 注册、面元数据、相机语义分派这些外围都已经就位。
|
|
7
|
+
//
|
|
8
|
+
// 为什么让相机走统一 createCamera:3D 面的边界值(距离/俯仰)已经在
|
|
9
|
+
// camera/constants.js 的 ORBIT 里备好,走同一条入口才能顺带验证那份结构的形状。
|
|
10
|
+
// 本面的缩放落在"距离"量级上,与 2D 的 userScale 不是一回事,覆盖值由
|
|
11
|
+
// cameraKind='orbit-3d' 单独给。
|
|
12
|
+
|
|
13
|
+
import { createCamera } from './camera/index.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 创建占位三维渲染器。
|
|
17
|
+
* @param {{log?: (message: string, level?: 'info'|'warn'|'error') => void}} [options]
|
|
18
|
+
*/
|
|
19
|
+
export function createThreeRenderer({ log } = {}) {
|
|
20
|
+
const note = (message, level = 'info') => {
|
|
21
|
+
if (typeof log !== 'function') return;
|
|
22
|
+
try { log(message, level); } catch { /* 日志失败不影响渲染面 */ }
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** 轨道状态:占位实现只累计角度,不产生任何画面(真实现会把它换成相机的球坐标) */
|
|
26
|
+
const orbit = { yaw: 0, pitch: 0 };
|
|
27
|
+
/** 占位缩放:与 2D 的 userScale 同义(这里代表"距离") */
|
|
28
|
+
let distance = 1;
|
|
29
|
+
let mountedDocument = null;
|
|
30
|
+
let targetCanvas = null;
|
|
31
|
+
let offResize = null;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 把逻辑尺寸落到画布 backing store。
|
|
35
|
+
*
|
|
36
|
+
* 为什么占位面也要做这一步:像素尺寸由渲染器/引擎拥有(Surface 只给 geometry),
|
|
37
|
+
* 不做的话画布会停在浏览器默认的 300×150,看起来"这个面根本没接上"。
|
|
38
|
+
* 这里只改像素尺寸,CSS 尺寸仍由舞台的样式表决定。
|
|
39
|
+
*/
|
|
40
|
+
function applyGeometry(handle) {
|
|
41
|
+
const size = handle && handle.size;
|
|
42
|
+
const dpr = handle && handle.dpr ? handle.dpr : 1;
|
|
43
|
+
if (!targetCanvas || !size) return null;
|
|
44
|
+
const width = Math.max(1, Math.round(size.width * dpr));
|
|
45
|
+
const height = Math.max(1, Math.round(size.height * dpr));
|
|
46
|
+
if (targetCanvas.width !== width) targetCanvas.width = width;
|
|
47
|
+
if (targetCanvas.height !== height) targetCanvas.height = height;
|
|
48
|
+
return { width, height, dpr };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const baseCamera = createCamera({
|
|
52
|
+
kind: 'three',
|
|
53
|
+
log: (message, level) => note(`[three] ${message}`, level),
|
|
54
|
+
backend: {
|
|
55
|
+
getScale: () => distance,
|
|
56
|
+
setScale: (value) => { distance = value; },
|
|
57
|
+
// 平移在轨道相机里没有对应动作:拖动语义由 orbitBy 承担,
|
|
58
|
+
// 这里保持空实现而不是转成平移,避免"位移看起来生效但视角没动"的假象。
|
|
59
|
+
pan: () => { note('pan 在轨道相机上不生效(拖动请走 orbitBy)', 'warn'); },
|
|
60
|
+
resetView: () => { orbit.yaw = 0; orbit.pitch = 0; distance = 1; },
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const camera = {
|
|
65
|
+
...baseCamera,
|
|
66
|
+
/**
|
|
67
|
+
* 拖动 → 绕轨道转(占位:只累计角度)。
|
|
68
|
+
* 屏幕像素按固定灵敏度换算成弧度,真实现应改为按视口高度换算。
|
|
69
|
+
*/
|
|
70
|
+
orbitBy(dx, dy) {
|
|
71
|
+
const limits = baseCamera.info().limits;
|
|
72
|
+
const polar = limits && limits.orbit ? limits.orbit.polar : null;
|
|
73
|
+
orbit.yaw += Number(dx) || 0;
|
|
74
|
+
orbit.pitch += Number(dy) || 0;
|
|
75
|
+
if (polar) orbit.pitch = Math.min(polar.max, Math.max(polar.min, orbit.pitch));
|
|
76
|
+
note(`orbitBy(${Math.round(dx)}, ${Math.round(dy)}) → yaw=${orbit.yaw.toFixed(1)} pitch=${orbit.pitch.toFixed(3)}`);
|
|
77
|
+
return { ...orbit };
|
|
78
|
+
},
|
|
79
|
+
/** 只读轨道状态(验收/排查读它;真实现应返回相机姿态) */
|
|
80
|
+
orbitState: () => ({ ...orbit, distance }),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
id: 'three',
|
|
85
|
+
kind: 'three',
|
|
86
|
+
capabilities: {
|
|
87
|
+
// 占位面不声明任何设置项:没有实现却声明,面板就会给用户一个点了没反应的开关
|
|
88
|
+
settings: [],
|
|
89
|
+
debugDraw: [],
|
|
90
|
+
camera: 'orbit-3d',
|
|
91
|
+
},
|
|
92
|
+
camera,
|
|
93
|
+
/**
|
|
94
|
+
* 装载:占位实现只记录状态。
|
|
95
|
+
* 刻意沿用其它渲染器的入参形状(ready Document + Surface 句柄),
|
|
96
|
+
* 这样将来换真实现时调用方一行都不用改。
|
|
97
|
+
*/
|
|
98
|
+
async mount(document, handle) {
|
|
99
|
+
mountedDocument = document || null;
|
|
100
|
+
targetCanvas = handle && handle.canvas ? handle.canvas : null;
|
|
101
|
+
const geometry = applyGeometry(handle);
|
|
102
|
+
// 尺寸变化订阅:与真渲染器同一条路径(Surface 是尺寸唯一来源,渲染器只消费)
|
|
103
|
+
offResize = handle && typeof handle.onResize === 'function'
|
|
104
|
+
? handle.onResize(() => applyGeometry(handle))
|
|
105
|
+
: null;
|
|
106
|
+
note(`mount(占位)kind=${(document && document.kind) || '?'} canvas=${targetCanvas ? 'yes' : 'no'}`
|
|
107
|
+
+ ` size=${geometry ? `${geometry.width}x${geometry.height}` : 'n/a'}`);
|
|
108
|
+
return { kind: 'three', stub: true, camera: camera.info(), geometry };
|
|
109
|
+
},
|
|
110
|
+
unmount() {
|
|
111
|
+
if (typeof offResize === 'function') { try { offResize(); } catch { /* 退订失败不影响卸载 */ } }
|
|
112
|
+
offResize = null;
|
|
113
|
+
targetCanvas = null;
|
|
114
|
+
mountedDocument = null;
|
|
115
|
+
note('unmount(占位)');
|
|
116
|
+
},
|
|
117
|
+
dispose() {
|
|
118
|
+
if (typeof offResize === 'function') { try { offResize(); } catch { /* 同上 */ } }
|
|
119
|
+
offResize = null;
|
|
120
|
+
targetCanvas = null;
|
|
121
|
+
mountedDocument = null;
|
|
122
|
+
orbit.yaw = 0;
|
|
123
|
+
orbit.pitch = 0;
|
|
124
|
+
distance = 1;
|
|
125
|
+
note('dispose(占位)');
|
|
126
|
+
},
|
|
127
|
+
isActive: () => mountedDocument !== null,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export default createThreeRenderer;
|
|
@@ -49,33 +49,94 @@ function midpoint(a, b) {
|
|
|
49
49
|
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 相机语义取值:来自渲染器声明的 `capabilities.camera`。
|
|
54
|
+
* 取值集合与契约文档一致,未知值一律按 2D 处理。
|
|
55
|
+
*/
|
|
56
|
+
export const CAMERA_SEMANTICS = Object.freeze({
|
|
57
|
+
ORTHO_2D: 'ortho-2d',
|
|
58
|
+
ORBIT_3D: 'orbit-3d',
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 读舞台门面声明的相机语义。
|
|
63
|
+
*
|
|
64
|
+
* 为什么在这里归一而不是让调用方各自判断:门面上的取值直接来自渲染器声明的能力,
|
|
65
|
+
* 旧渲染面/旧门面可能压根没有这个字段,未来也可能出现新语义。把"缺失/未知 ⇒ 2D"
|
|
66
|
+
* 这条兜底钉在一个函数里,2D 面的既有行为才不会因为字段缺省而改变。
|
|
67
|
+
* 也支持传函数(门面动态取当前激活面的能力,切面后无需重建桥)。
|
|
68
|
+
*
|
|
69
|
+
* @param {object} stage
|
|
70
|
+
* @returns {'ortho-2d'|'orbit-3d'}
|
|
71
|
+
*/
|
|
72
|
+
export function readCameraSemantics(stage) {
|
|
73
|
+
const raw = stage && stage.cameraCapability;
|
|
74
|
+
let value = raw;
|
|
75
|
+
if (typeof raw === 'function') {
|
|
76
|
+
try { value = raw(); } catch { value = null; }
|
|
77
|
+
}
|
|
78
|
+
return value === CAMERA_SEMANTICS.ORBIT_3D ? CAMERA_SEMANTICS.ORBIT_3D : CAMERA_SEMANTICS.ORTHO_2D;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* 相机是否真的支持轨道转动。
|
|
83
|
+
*
|
|
84
|
+
* 先问 `hasOrbit()`:门面是固定形状的代理,键总是存在(转发不存在的实现会返回 null),
|
|
85
|
+
* 只看键会让 2D 面被误判成 3D 面。真实相机没有探针时退回看方法本身。
|
|
86
|
+
* @param {object} camera
|
|
87
|
+
* @returns {boolean}
|
|
88
|
+
*/
|
|
89
|
+
function supportsOrbit(camera) {
|
|
90
|
+
if (camera && typeof camera.hasOrbit === 'function') {
|
|
91
|
+
try { return camera.hasOrbit() === true; } catch { return false; }
|
|
92
|
+
}
|
|
93
|
+
return !!(camera && typeof camera.orbitBy === 'function');
|
|
94
|
+
}
|
|
95
|
+
|
|
52
96
|
/**
|
|
53
97
|
* 相机桥:把交互动作落到 stage.camera(薄转发),缺失时退到 stage 的兼容入口。
|
|
98
|
+
*
|
|
99
|
+
* 为什么要按语义分策略:契约早已把 `capabilities.camera` 声明出来,但此前没人消费,
|
|
100
|
+
* 于是"拖动 = 平移"被写死在桥里,3D 面即使声明了 orbit 也只会平移。
|
|
101
|
+
* 这里把两种语义做成策略对象,桥只按当前面的声明选一个。
|
|
102
|
+
*
|
|
103
|
+
* **2D 策略的五个方法逐字保留改造前的实现**:滚轮一档 ±10%、拖动跟手、捏合中点平移、
|
|
104
|
+
* 复位重新 fit 全部依赖这条路径,任何"顺手优化"都会变成手感回归。
|
|
105
|
+
*
|
|
54
106
|
* @param {object} stage
|
|
107
|
+
* @param {{log?: (message: string, level?: 'info'|'warn') => void}} [options] 日志出口(缺省退到控制台)
|
|
55
108
|
*/
|
|
56
|
-
function createCameraBridge(stage) {
|
|
109
|
+
export function createCameraBridge(stage, options = {}) {
|
|
57
110
|
const camera = stage && stage.camera;
|
|
58
|
-
|
|
59
|
-
|
|
111
|
+
const outerLog = typeof options.log === 'function' ? options.log : null;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 日志:优先外部出口(应用侧的状态栏),其次相机自己的 note,最后控制台。
|
|
115
|
+
*
|
|
116
|
+
* 为什么要有控制台兜底:相机的 note 在没有挂 logger 时是静默的,
|
|
117
|
+
* "这台相机不支持轨道转动"这类信息一旦静默,用户只看到"拖不动",排查只能靠猜。
|
|
118
|
+
*/
|
|
60
119
|
function note(message, data) {
|
|
120
|
+
if (outerLog) {
|
|
121
|
+
try { outerLog(message, data && data.level ? data.level : 'warn'); return; } catch { /* 落到下一档 */ }
|
|
122
|
+
}
|
|
61
123
|
if (camera && typeof camera.note === 'function') {
|
|
62
|
-
try { camera.note(message, data); } catch { /*
|
|
124
|
+
try { camera.note(message, data); return; } catch { /* 落到下一档 */ }
|
|
63
125
|
}
|
|
126
|
+
try { console.warn(`[camera] ${message}`, data || ''); } catch { /* 日志失败不影响交互 */ }
|
|
64
127
|
}
|
|
65
128
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
129
|
+
/** 2D:拖动即平移,缩放作用在 userScale 上(改造前行为,禁止改动) */
|
|
130
|
+
const orthoStrategy = {
|
|
131
|
+
semantics: CAMERA_SEMANTICS.ORTHO_2D,
|
|
69
132
|
zoomStep(dir) {
|
|
70
133
|
if (camera && typeof camera.zoomStep === 'function') return camera.zoomStep(dir);
|
|
71
134
|
return null;
|
|
72
135
|
},
|
|
73
|
-
/** 缩放到绝对 userScale(捏合:起始 userScale × 距离比) */
|
|
74
136
|
zoomTo(scale) {
|
|
75
137
|
if (camera && typeof camera.zoomTo === 'function') return camera.zoomTo(scale);
|
|
76
138
|
return null;
|
|
77
139
|
},
|
|
78
|
-
/** 平移:原始屏幕像素差值 */
|
|
79
140
|
panBy(dx, dy) {
|
|
80
141
|
if (camera && typeof camera.panBy === 'function') return camera.panBy(dx, dy);
|
|
81
142
|
// 回退:仅有 setView 的旧契约,本地累计后按绝对量下发(不做任何换算)
|
|
@@ -85,18 +146,71 @@ function createCameraBridge(stage) {
|
|
|
85
146
|
}
|
|
86
147
|
return null;
|
|
87
148
|
},
|
|
88
|
-
/** 复位:交给引擎 resetCamera(重新 fit) */
|
|
89
149
|
reset() {
|
|
90
150
|
if (camera && typeof camera.reset === 'function') return camera.reset();
|
|
91
151
|
if (typeof stage.resetView === 'function') return stage.resetView();
|
|
92
152
|
return null;
|
|
93
153
|
},
|
|
94
|
-
/** 当前 userScale(捏合起点用);拿不到时返回 null */
|
|
95
154
|
scale() {
|
|
96
155
|
if (camera && typeof camera.scale === 'function') return camera.scale();
|
|
97
156
|
return null;
|
|
98
157
|
},
|
|
99
158
|
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 3D:拖动 = 绕轨道转,其余(缩放/复位/读值)仍走统一相机。
|
|
162
|
+
*
|
|
163
|
+
* 相机没有 orbitBy 时不把它近似成 panBy:那样界面看起来"能拖",但视角其实没转,
|
|
164
|
+
* 是最难发现的静默降级。这里只记一条日志并忽略,把"能力缺失"暴露出来。
|
|
165
|
+
*/
|
|
166
|
+
const orbitStrategy = {
|
|
167
|
+
semantics: CAMERA_SEMANTICS.ORBIT_3D,
|
|
168
|
+
zoomStep(dir) {
|
|
169
|
+
if (camera && typeof camera.zoomStep === 'function') return camera.zoomStep(dir);
|
|
170
|
+
return null;
|
|
171
|
+
},
|
|
172
|
+
zoomTo(scale) {
|
|
173
|
+
if (camera && typeof camera.zoomTo === 'function') return camera.zoomTo(scale);
|
|
174
|
+
return null;
|
|
175
|
+
},
|
|
176
|
+
panBy(dx, dy) {
|
|
177
|
+
if (supportsOrbit(camera)) {
|
|
178
|
+
try { return camera.orbitBy(dx, dy); } catch (err) { note(`orbitBy 失败:${err && err.message}`); return null; }
|
|
179
|
+
}
|
|
180
|
+
note('orbit-3d:相机未提供 orbitBy,本次拖动已忽略', { dx, dy });
|
|
181
|
+
return null;
|
|
182
|
+
},
|
|
183
|
+
reset() {
|
|
184
|
+
if (camera && typeof camera.reset === 'function') return camera.reset();
|
|
185
|
+
if (typeof stage.resetView === 'function') return stage.resetView();
|
|
186
|
+
return null;
|
|
187
|
+
},
|
|
188
|
+
scale() {
|
|
189
|
+
if (camera && typeof camera.scale === 'function') return camera.scale();
|
|
190
|
+
return null;
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** 每次调用现取语义:切面后同一座桥自动切策略,不需要重建(重建会丢进行中的手势) */
|
|
195
|
+
function strategy() {
|
|
196
|
+
return readCameraSemantics(stage) === CAMERA_SEMANTICS.ORBIT_3D ? orbitStrategy : orthoStrategy;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
note,
|
|
201
|
+
/** 当前生效的相机语义(验收与排查读它) */
|
|
202
|
+
get semantics() { return readCameraSemantics(stage); },
|
|
203
|
+
/** 缩放一档(dir=±1,由引擎处理 ±10% 与 clamp) */
|
|
204
|
+
zoomStep(dir) { return strategy().zoomStep(dir); },
|
|
205
|
+
/** 缩放到绝对 userScale(捏合:起始 userScale × 距离比) */
|
|
206
|
+
zoomTo(scale) { return strategy().zoomTo(scale); },
|
|
207
|
+
/** 平移(2D)/ 绕轨道转(3D):原始屏幕像素差值 */
|
|
208
|
+
panBy(dx, dy) { return strategy().panBy(dx, dy); },
|
|
209
|
+
/** 复位:交给引擎 resetCamera(重新 fit) */
|
|
210
|
+
reset() { return strategy().reset(); },
|
|
211
|
+
/** 当前 userScale(捏合起点用);拿不到时返回 null */
|
|
212
|
+
scale() { return strategy().scale(); },
|
|
213
|
+
};
|
|
100
214
|
}
|
|
101
215
|
|
|
102
216
|
/**
|
|
@@ -468,7 +582,7 @@ export function attachStageInteraction({ canvas, stage, options } = {}) {
|
|
|
468
582
|
throw new Error('attachStageInteraction: 需要提供 camera 入口或 getView/setView 的 stage');
|
|
469
583
|
}
|
|
470
584
|
|
|
471
|
-
const camera = createCameraBridge(stage);
|
|
585
|
+
const camera = createCameraBridge(stage, { log: (options && options.log) || null });
|
|
472
586
|
const ctx = {
|
|
473
587
|
canvas,
|
|
474
588
|
camera,
|
|
@@ -486,6 +600,8 @@ export function attachStageInteraction({ canvas, stage, options } = {}) {
|
|
|
486
600
|
window.__WEB__.zoomStats = () => zoomScheduler.stats();
|
|
487
601
|
// 最近一次手势的汇总(含真实 calls);stats 每轮手势后清零,验收读这个更稳
|
|
488
602
|
window.__WEB__.zoomLast = () => zoomReporter.last();
|
|
603
|
+
// 当前生效的相机语义('ortho-2d' / 'orbit-3d'):验收与排查时不靠猜,直接读
|
|
604
|
+
window.__WEB__.cameraSemantics = () => camera.semantics;
|
|
489
605
|
}
|
|
490
606
|
const zoomReporter = createZoomReporter(ctx, zoomScheduler);
|
|
491
607
|
const handler = createPointerHandler(ctx, panScheduler, zoomScheduler, zoomReporter);
|
|
@@ -511,6 +627,7 @@ export function attachStageInteraction({ canvas, stage, options } = {}) {
|
|
|
511
627
|
if (typeof window !== 'undefined' && window.__WEB__) {
|
|
512
628
|
delete window.__WEB__.zoomStats;
|
|
513
629
|
delete window.__WEB__.zoomLast;
|
|
630
|
+
delete window.__WEB__.cameraSemantics;
|
|
514
631
|
}
|
|
515
632
|
canvas.removeEventListener('pointerdown', handler.onDown);
|
|
516
633
|
canvas.removeEventListener('pointermove', handler.onMove);
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
export const SURFACES = [
|
|
26
26
|
{ id: 'spine', kind: 'spine', label: 'Spine', badge: 'spine', stageMode: 'spine', overlay: null, overlayVisible: false, cameraKind: 'spine', deepLink: true },
|
|
27
27
|
{ id: 'live2d', kind: 'live2d', label: 'Live2D', badge: 'live2d', stageMode: 'live2d', overlay: 'canvas', overlayVisible: true, cameraKind: 'live2d', deepLink: true },
|
|
28
|
+
// 三维预留面:用来证明"新面能注册、相机语义能派发",本身不含任何 3D 渲染。
|
|
29
|
+
// 默认不使用(没有内容类型会产出 kind=three),deepLink=false 表示不接受 ?model= 深链,
|
|
30
|
+
// 避免它被当成"可以用深链打开的面"而让用户撞到空实现。
|
|
31
|
+
{ id: 'three', kind: 'three', label: '三维(预留)', badge: 'three', stageMode: 'three', overlay: null, overlayVisible: false, cameraKind: 'orbit-3d', deepLink: false },
|
|
28
32
|
];
|
|
29
33
|
|
|
30
34
|
/** 按 kind 查(未知 → null) */
|