Avoid GLTF external-resource fetch failures in MapLibre model rendering.
CI / test (push) Successful in 4s

This limits live 3D model loading to self-contained GLB assets and falls back gracefully for GLTF assets, with guidance to prefer GLB for reliable /download rendering.

Made-with: Cursor
This commit is contained in:
2026-03-02 22:55:00 +00:00
parent 63e7e73360
commit e3ccd9d252
+10 -1
View File
@@ -140,7 +140,7 @@ function is3DAsset(asset) {
if (!asset) return false; if (!asset) return false;
const kind = String(asset.kind || "").toLowerCase(); const kind = String(asset.kind || "").toLowerCase();
const ext = normalizeExt(asset.ext) || extFromLink(asset.link); const ext = normalizeExt(asset.ext) || extFromLink(asset.link);
return kind === "3d" && (ext === "glb" || ext === "gltf"); return kind === "3d" && ext === "glb";
} }
async function renderSharedAssetFromQuery() { async function renderSharedAssetFromQuery() {
@@ -344,6 +344,12 @@ async function addObjectMeshFromAsset(featureId, lng, lat, asset, cycleID) {
} }
if (!is3DAsset(asset) || !asset.link) { if (!is3DAsset(asset) || !asset.link) {
const ext = normalizeExt(asset.ext) || extFromLink(asset.link);
if (String(asset.kind || "").toLowerCase() === "3d" && ext === "gltf") {
console.warn(
`Feature ${featureId} uses .gltf. Map rendering supports self-contained .glb via /download; using fallback shape.`
);
}
addFallbackMesh(featureId, lng, lat, Boolean(asset.isPublic), asset.kind || "3d"); addFallbackMesh(featureId, lng, lat, Boolean(asset.isPublic), asset.kind || "3d");
return false; return false;
} }
@@ -542,6 +548,9 @@ async function createFeatureAndUpload() {
if (!ext) { if (!ext) {
throw new Error("File extension is required."); throw new Error("File extension is required.");
} }
if (ext === "gltf") {
setStatus("Note: .gltf may fail on map if it references external files. Prefer .glb for reliable 3D rendering.");
}
await ensureCollection(); await ensureCollection();
const featureName = assetNameEl.value.trim() || file.name; const featureName = assetNameEl.value.trim() || file.name;