Avoid GLTF external-resource fetch failures in MapLibre model rendering.
CI / test (push) Successful in 4s
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:
+10
-1
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user