新增兼容层,适配WebCAD v16材质版本

This commit is contained in:
CZY committed 2026-10-28 15:06:27 +08:00
1 parent ae9d88c6d7
commit fc94b6721a
10 files changed
+516 -29

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
import original from "./fixtures/material-v24-v16.json";
/** 这些下标只用于构造已知回归样例,生产读取器按记录协议顺序读取。 */
export function versionedFixture(version: 14 | 15): any[] {
const data: any[] = [...original.slice(0, version === 14 ? 145 : 146), ...original.slice(149)];
data[60] = version;
return data;
}
// WebCAD f17fb3013 的反面材质顺序:20 个标量、map2、16 个标量。
const reverseBeforeMap = [
"#123456", 0.25, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 1.2,
true, 0.7, 0.8, 0.9, 1.3, 0.4, 0.5, 0.6, 0.7, 2.5, true,
];
const reverseAfterMap = [false, 1, 1.1, 1.2, 1.3, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 2, 3, 45, 0.25, 0.75];
export const textureIdSlots = [21, 39, 42, 44, 46];
export const extendedTail = [
true, ...reverseBeforeMap, 102, ...reverseAfterMap,
true, 103, false, // 正面高光贴图及 syncUV
true, 104, true, 105, true, 106, false, // 反面附加贴图及 syncUV2
];
export function doubleSidedFixture(): any[] {
const extraTextures = [102, 103, 104, 105, 106].flatMap(id => {
const texture: any[] = original.slice(31, 47);
texture[2] = id;
texture[6] = `贴图-${id}`;
texture[13] = `texture-${id}.png`;
return texture;
});
const data: any[] = [
...original.slice(0, 47), ...extraTextures,
...original.slice(47, 145), ...extendedTail, ...original.slice(149),
];
data[1] = 107; // 下一个 ObjectId
data[30] = 6; // TextureTable 中的记录数量
return data;
}