This commit is contained in:
2026-10-01 02:00:33 +02:00
parent 3e26c7a657
commit 8aa71244b6
2 changed files with 21 additions and 5 deletions
+12 -2
View File
@@ -7,12 +7,13 @@ const vm = require('node:vm');
function variantBuilder() {
const source = fs.readFileSync(path.join(__dirname, '..', 'AnimationDirector.js'), 'utf8').replace(
' Plugin.register(PLUGIN_ID, {',
' globalThis.variantTest = { buildGenderModelVariant, refreshModelVariantFields, createModelVariantBoneSections, buildJemModelVariant };\n Plugin.register(PLUGIN_ID, {'
' globalThis.variantTest = { buildGenderModelVariant, refreshModelVariantFields, createModelVariantBoneSections, buildJemModelVariant, normalizeGeckoExportName };\n Plugin.register(PLUGIN_ID, {'
);
const context = { Plugin: { register() {} }, console };
vm.runInNewContext(source, context);
return Object.assign(context.variantTest.buildGenderModelVariant, { refresh: context.variantTest.refreshModelVariantFields,
sections: context.variantTest.createModelVariantBoneSections, jem: context.variantTest.buildJemModelVariant });
sections: context.variantTest.createModelVariantBoneSections, jem: context.variantTest.buildJemModelVariant,
normalizeName: context.variantTest.normalizeGeckoExportName });
}
test('gender variants omit selected bones, descendants, locators and texture overrides without changing source', () => {
@@ -35,6 +36,15 @@ test('gender variants omit selected bones, descendants, locators and texture ove
assert.equal(JSON.stringify(source), before);
});
test('GeckoLib export filenames strip repeated geo and project extensions', () => {
const normalize = variantBuilder().normalizeName;
for (const name of ['horse', 'horse.geo', 'horse.geo.geo', 'horse.geo.json', 'horse.geo.bbench', 'horse.geo.bbmodel']) {
assert.equal(normalize(name), 'horse');
}
assert.equal(normalize('horse.f.geo.geo.json'), 'horse.f');
assert.equal(normalize('geology'), 'geology');
});
test('variant subtree propagation handles nested children and unknown saved selections', () => {
const build = variantBuilder();
const source = { 'minecraft:geometry': [{ bones: [