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
+9 -3
View File
@@ -2415,6 +2415,11 @@
return sanitizeFilePart(String(name).replace(/\.geo\.json$/i, '').replace(/\.json$/i, '')) || 'model';
}
function normalizeGeckoExportName(name) {
return String(name || '').trim().replace(/\.(?:bbmodel|bbench)$/i, '')
.replace(/\.json$/i, '').replace(/(?:\.geo)+$/i, '');
}
async function cemTemplateCatalog() {
if (typeof window === 'undefined' || typeof window.loadCEMTemplateModels !== 'function') {
throw new Error('Install and enable CEM Template Loader before creating a JEM model.');
@@ -2909,8 +2914,9 @@
const bones = jem ? jemVariantBones(output) : [...new Map((output['minecraft:geometry'] || [])
.flatMap((geometry) => geometry.bones || []).map((bone) => [bone.name, bone])).values()];
const form = {
name: { type: 'text', label: 'Base model filename', value: saved.name || (jem
? getModelExportFileName().replace(/\.jem$/i, '').replace(/[123]$/, '') : getModelExportFileName().replace(/\.(m|f|mf)$/i, '')) },
name: { type: 'text', label: 'Base model filename', value: jem
? saved.name || getModelExportFileName().replace(/\.jem$/i, '').replace(/[123]$/, '')
: normalizeGeckoExportName(saved.name || normalizeGeckoExportName(getModelExportFileName()).replace(/\.(m|f|mf)$/i, '')) },
base: { type: 'checkbox', label: `Export unqualified model (.${extension})`, value: saved.base ?? true },
info: { type: 'info', text: 'Export one or more variants from this model. Excluded bones and their descendants are completely omitted, including geometry and locators. The source project is unchanged.' },
};
@@ -2930,7 +2936,7 @@
onConfirm(result) {
try {
if (Project !== sourceProject) throw new Error('Return to the source model project and retry.');
const name = String(result.name || '').trim().replace(jem ? /\.jem$/i : /\.geo\.json$/i, '');
const name = jem ? String(result.name || '').trim().replace(/\.jem$/i, '') : normalizeGeckoExportName(result.name);
if (!name || /[<>:"/\\|?*]/.test(name)) throw new Error('Choose a valid base model filename without a folder path.');
const genders = ['m', 'f', 'mf'].filter((gender) => result[gender]);
if (!result.base && !genders.length) throw new Error('Select at least one model to export.');