AEB-71: Added 3D navigation in monitoring zones
This commit is contained in:
47
frontend/app/api/big-models/list/route.ts
Normal file
47
frontend/app/api/big-models/list/route.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
export const dynamic = 'force-static';
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const dirPath = path.join(process.cwd(), 'assets', 'big-models');
|
||||
if (!fs.existsSync(dirPath)) {
|
||||
return new Response(JSON.stringify({ models: [] }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(dirPath, { withFileTypes: true });
|
||||
const models = files
|
||||
.filter((ent) => ent.isFile() && (ent.name.toLowerCase().endsWith('.glb') || ent.name.toLowerCase().endsWith('.gltf')))
|
||||
.map((ent) => {
|
||||
const filename = ent.name;
|
||||
const base = filename.replace(/\.(glb|gltf)$/i, '');
|
||||
let title = base;
|
||||
title = title.replace(/^AerBIM-Monitor_ASM-HT-Viewer_/i, '');
|
||||
title = title.replace(/_/g, ' ');
|
||||
title = title.replace(/\bLevel\b/gi, 'Уровень');
|
||||
title = title.replace(/\bcustom\s*prop\b/gi, '');
|
||||
title = title.replace(/\bcustom\b/gi, '');
|
||||
title = title.replace(/\bprop\b/gi, '');
|
||||
title = title.replace(/\s{2,}/g, ' ').trim();
|
||||
|
||||
const pathUrl = `/static-models/${filename}`;
|
||||
return { name: title, path: pathUrl };
|
||||
});
|
||||
|
||||
return new Response(JSON.stringify({ models }), {
|
||||
status: 200,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('[big-models/list] Error listing models:', error);
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
return new Response(JSON.stringify({ error: msg, models: [] }), {
|
||||
status: 500,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user