Fix preview: map admin raw-row *_path fields to /uploads URLs
The /api/admin/ghosts endpoint returns raw DB rows (webm_path, webp_path, image_path as bare filenames), not the public API's camelCase URL shape. buildGhost now reads those and prefixes /uploads/, so WebM video renders in the preview instead of falling through to the procedural wisp.
This commit is contained in:
+12
-4
@@ -202,9 +202,12 @@
|
|||||||
const color = TYPE_COLORS[data.type] ?? 0xffffff;
|
const color = TYPE_COLORS[data.type] ?? 0xffffff;
|
||||||
let mesh;
|
let mesh;
|
||||||
|
|
||||||
// API field names from rowToGhost: webm / webp / image (URLs or null).
|
// The admin endpoint (/api/admin/ghosts) returns raw DB rows with
|
||||||
const webm = data.webm || null;
|
// snake_case *_path fields holding bare filenames. Map them to /uploads
|
||||||
const image = data.image || data.webp || null;
|
// URLs. (Also tolerate the public API shape: webm / webp / image.)
|
||||||
|
const up = (f) => (f ? (f.startsWith('/') || f.startsWith('http') ? f : `/uploads/${f}`) : null);
|
||||||
|
const webm = up(data.webm_path || data.webm);
|
||||||
|
const image = up(data.image_path || data.image || data.webp_path || data.webp);
|
||||||
|
|
||||||
if (webm && SUPPORTS_WEBM_ALPHA) {
|
if (webm && SUPPORTS_WEBM_ALPHA) {
|
||||||
const vid = document.createElement('video');
|
const vid = document.createElement('video');
|
||||||
@@ -259,7 +262,12 @@
|
|||||||
current = buildGhost(data);
|
current = buildGhost(data);
|
||||||
applyTransform();
|
applyTransform();
|
||||||
scene.add(current);
|
scene.add(current);
|
||||||
$('#pv-hint').textContent = `${data.name}${data.webm ? ' · WebM' + (SUPPORTS_WEBM_ALPHA ? '' : ' (no VP9-alpha -> fallback)') : data.image ? ' · image' : ' · procedural wisp'}`;
|
const hasWebm = !!(data.webm_path || data.webm);
|
||||||
|
const hasImg = !!(data.image_path || data.image || data.webp_path || data.webp);
|
||||||
|
const kind = hasWebm
|
||||||
|
? ' · WebM' + (SUPPORTS_WEBM_ALPHA ? '' : ' (no VP9-alpha fallback)')
|
||||||
|
: hasImg ? ' · image' : ' · procedural wisp';
|
||||||
|
$('#pv-hint').textContent = `${data.name}${kind}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearGhost() {
|
function clearGhost() {
|
||||||
|
|||||||
Reference in New Issue
Block a user