fix: support gltf uploads with local preview

This commit is contained in:
Tom Boullay
2026-04-27 11:07:16 +02:00
parent 078e687e86
commit 4c3a687ff8
19 changed files with 136 additions and 98 deletions
+6 -6
View File
@@ -2,10 +2,10 @@
// Client-side folder validation
// ---------------------------------------------------------------------------
import { TEXTURE_EXTENSIONS } from '@/lib/constants'
import { ASSET_EXTENSIONS, TEXTURE_EXTENSIONS } from '@/lib/constants'
import type { TextureFile } from '@/lib/client-types'
const TEXTURE_EXT_ARRAY = [...TEXTURE_EXTENSIONS]
const SUPPORT_FILE_EXT_ARRAY = [...TEXTURE_EXTENSIONS, ...ASSET_EXTENSIONS]
/** Discriminated union: either valid (with model) or invalid (with errors). */
export type ValidationResult =
@@ -18,20 +18,20 @@ export function validateFolder(files: File[]): ValidationResult {
const modelFiles = files.filter((f) => {
const name = f.name.toLowerCase()
return name === 'model.glb'
return name === 'model.gltf'
})
if (modelFiles.length === 0) {
return { ok: false, errors: ['model.glb manquant (obligatoire)'] }
return { ok: false, errors: ['model.gltf manquant (obligatoire)'] }
}
if (modelFiles.length > 1) {
return { ok: false, errors: ['Un seul fichier model.glb est autorise'] }
return { ok: false, errors: ['Un seul fichier model.gltf est autorise'] }
}
const textureFiles = files.filter((f) => {
const ext = f.name.slice(f.name.lastIndexOf('.')).toLowerCase()
return TEXTURE_EXT_ARRAY.includes(ext)
return SUPPORT_FILE_EXT_ARRAY.includes(ext)
})
for (const tf of textureFiles) {