chore: remove legacy blender compression path
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import { join } from 'path'
|
||||
import { existsSync } from 'fs'
|
||||
import { execFile } from 'child_process'
|
||||
import { promisify } from 'util'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
/**
|
||||
* Compress a GLTF/GLB model using Blender's Draco compression.
|
||||
* Returns { success: true } on success, or { success: false, error } on failure.
|
||||
* Callers should fall back to the original file on failure.
|
||||
*/
|
||||
export async function compressWithBlender(
|
||||
inputPath: string,
|
||||
outputPath: string,
|
||||
): Promise<{ success: boolean; error?: string }> {
|
||||
const blenderPath = process.env.BLENDER_PATH || 'blender'
|
||||
const scriptPath = join(process.cwd(), 'scripts', 'compress.py')
|
||||
|
||||
if (!existsSync(scriptPath)) {
|
||||
return { success: false, error: 'scripts/compress.py introuvable' }
|
||||
}
|
||||
|
||||
try {
|
||||
await execFileAsync(
|
||||
blenderPath,
|
||||
[
|
||||
'--background',
|
||||
'--python', scriptPath,
|
||||
'--',
|
||||
'-i', inputPath,
|
||||
'-o', outputPath,
|
||||
'--draco-level', '7',
|
||||
'--texture-size', '512',
|
||||
'-q',
|
||||
],
|
||||
{ timeout: 120_000 },
|
||||
)
|
||||
|
||||
if (!existsSync(outputPath)) {
|
||||
return { success: false, error: "Blender n'a pas produit de fichier compresse" }
|
||||
}
|
||||
|
||||
return { success: true }
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : String(err)
|
||||
return { success: false, error: `Compression Blender echouee: ${message}` }
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,7 @@ export async function prepareGitAssets({
|
||||
|
||||
const textureResult = await compressTextureBuffer(pf.filename, pf.buffer)
|
||||
content = textureResult.buffer
|
||||
compressed ||= textureResult.compressed
|
||||
|
||||
if (textureResult.error && !compressionError) {
|
||||
compressionError = textureResult.error
|
||||
|
||||
+1
-10
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from 'crypto'
|
||||
import { dirname, join } from 'path'
|
||||
import { mkdir, readdir, readFile, rm, stat, writeFile } from 'fs/promises'
|
||||
import { mkdir, readdir, readFile, rm, writeFile } from 'fs/promises'
|
||||
import { existsSync } from 'fs'
|
||||
import { TMP_DIR } from '@/lib/constants'
|
||||
import { prepareGitAssets } from '@/lib/prepare-git-assets'
|
||||
@@ -203,12 +203,3 @@ export async function readStagedOriginalFiles(stagingId: string): Promise<{ fold
|
||||
export async function cleanupStagingUpload(stagingId: string) {
|
||||
await rm(getStageDir(stagingId), { recursive: true, force: true })
|
||||
}
|
||||
|
||||
export async function stagingExists(stagingId: string): Promise<boolean> {
|
||||
try {
|
||||
const info = await stat(getStageDir(stagingId))
|
||||
return info.isDirectory()
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user