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
+20 -3
View File
@@ -3,6 +3,19 @@ import type { FolderEntry } from '@/lib/client-types'
import { validateFolder } from '@/lib/validate-folder'
import { FolderIcon } from '@/components/ui/icons'
function buildAssetUrls(model: File, supportFiles: File[]) {
const assetUrls: Record<string, string> = {}
const modelUrl = URL.createObjectURL(model)
assetUrls[model.name.toLowerCase()] = modelUrl
for (const file of supportFiles) {
assetUrls[file.name.toLowerCase()] = URL.createObjectURL(file)
}
return { modelUrl, assetUrls }
}
function readDroppedFile(entry: FileSystemFileEntry) {
return new Promise<File>((resolve, reject) => {
entry.file(resolve, reject)
@@ -60,6 +73,11 @@ export default function FolderDropzone({
return
}
const { modelUrl, assetUrls } = buildAssetUrls(
validation.model,
validation.textures.map((texture) => texture.file),
)
const entry: FolderEntry = {
folderName,
modelFile: validation.model,
@@ -67,9 +85,8 @@ export default function FolderDropzone({
status: 'pending',
progress: 0,
warnings: validation.warnings,
modelUrl: validation.model.name.toLowerCase() === 'model.glb'
? URL.createObjectURL(validation.model)
: undefined,
modelUrl,
assetUrls,
viewerOpen: true,
}