fix: vue de face de l'échantillon virtuel quand xMax est pair (#188)
All checks were successful
Deploy Production / Build and Deploy to Production (push) Successful in 31s
Deploy Preprod / Build and Deploy to Preprod (push) Successful in 37s

La division (xMax + 1) / 2 produisait un float (ex: 4.5) quand xMax
est pair, générant un nom de fichier introuvable et un undefined dans
le tableau images, ce qui plantait le rendu entier.

- Math.round() pour obtenir un index entier
- fallback sur le premier fichier si la vue de face est introuvable
- filter(Boolean) en défense sur le tableau images
- console.warn pour signaler les cas de nommage non conforme

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-04-15 18:27:01 +02:00
parent a4cc5c8efe
commit 9ee827c106

View file

@ -25,7 +25,7 @@ const images = computed(() => {
},
];
}
return allVariations.value.map((variation) => getFrontView(variation)) ?? [];
return allVariations.value.map((variation) => getFrontView(variation)).filter(Boolean) ?? [];
});
const uri = addLocalePrefix(step.uri);
@ -35,10 +35,13 @@ function getFrontView(variation) {
const xMax = parseInt(
variation.files[variation.files.length - 1].name.split('_')[1].split('.')[0]
);
const xFrontView = (xMax + 1) / 2;
const xFrontView = Math.round((xMax + 1) / 2);
const extension = variation.files[0].name.split('.')[1];
const frontViewName = '0_' + xFrontView + '.' + extension;
const frontView = variation.files.find((file) => file.name === frontViewName);
return frontView;
if (!frontView) {
console.warn(`[VirtualSample] Front view "${frontViewName}" not found in variation "${variation.title}", falling back to first file.`);
}
return frontView ?? variation.files[0];
}
</script>