fix: normalize exported texture filenames

This commit is contained in:
Tom Boullay
2026-04-28 15:51:15 +02:00
parent 497b0853c5
commit 41e04002b8
9 changed files with 188 additions and 16 deletions
+4
View File
@@ -65,6 +65,10 @@ export default function ModelViewer({ url, assetUrls, filename, size }: ModelVie
<span className="text-gray-500">Draw calls</span>
<span className="font-mono text-gray-200">{stats.drawCalls}</span>
</span>
<span className="flex justify-between gap-3">
<span className="text-gray-500">Children</span>
<span className="font-mono text-gray-200">{stats.childObjects}</span>
</span>
<span className="flex justify-between gap-3">
<span className="text-gray-500">Meshes</span>
<span className="font-mono text-gray-200">{stats.meshes}</span>
+5 -1
View File
@@ -7,8 +7,10 @@ import { useLoader } from '@react-three/fiber'
import { CanvasTexture, Mesh, TextureLoader } from 'three'
import type { Material, Object3D, Texture } from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
import { normalizeTextureFilename } from '@/lib/asset-naming'
export interface ModelStats {
childObjects: number
drawCalls: number
materials: number
meshes: number
@@ -55,7 +57,8 @@ function resolveAssetUrl(requestedUrl: string, assetUrls: Record<string, string>
function getOpacityMapEntries(assetUrls: Record<string, string>) {
return Object.entries(assetUrls).reduce<OpacityMapEntry[]>((entries, [filename, url]) => {
const match = filename.toLowerCase().match(/^opacity(?:[_-](.+))?\.(png|jpe?g|webp)$/)
const normalizedFilename = normalizeTextureFilename(filename) || filename
const match = normalizedFilename.toLowerCase().match(/^opacity(?:[_-](.+))?\.(png|jpe?g|webp)$/)
if (!match) return entries
@@ -188,6 +191,7 @@ function getModelStats(scene: Object3D, assetUrls: Record<string, string>): Mode
})
return {
childObjects: scene.children.length,
drawCalls,
materials: materials.size,
meshes,
+3 -1
View File
@@ -91,7 +91,9 @@ export default function UploadZone() {
{' '}par exemple <span className="font-mono text-gray-200">color_porte.jpg</span>,
{' '}<span className="font-mono text-gray-200">roughness_tuyaux.png</span>,
{' '}<span className="font-mono text-gray-200">normal_dashboard.webp</span>
{' '}ou <span className="font-mono text-gray-200">opacity_fenetre.png</span>
{' '}ou <span className="font-mono text-gray-200">opacity_fenetre.png</span>.
{' '}Les exports classiques comme <span className="font-mono text-gray-200">porte_baseColor.png</span>
{' '}ou <span className="font-mono text-gray-200">porte_normal_opengl.png</span> sont normalises automatiquement pour Git.
</p>
)}