Commit a0d59dee authored by Luna Riegel's avatar Luna Riegel
Browse files

Make loading continue with missing objects

Loading a placement file now continues even if some of the referenced
objects have not been uploaded.
parent c8ae5ff2
...@@ -353,6 +353,7 @@ export default function smartVillagesPlugin(config, baseUrl) { ...@@ -353,6 +353,7 @@ export default function smartVillagesPlugin(config, baseUrl) {
const content = readerEvent.target.result; const content = readerEvent.target.result;
const objects = JSON.parse(content); const objects = JSON.parse(content);
const vcMap = app.maps.activeMap; const vcMap = app.maps.activeMap;
let missingModels = [];
for (const loadingObject of objects.placedObjects) { for (const loadingObject of objects.placedObjects) {
let objectUrl; let objectUrl;
for (const loadedObject of pluginState.objects) { for (const loadedObject of pluginState.objects) {
...@@ -378,12 +379,9 @@ export default function smartVillagesPlugin(config, baseUrl) { ...@@ -378,12 +379,9 @@ export default function smartVillagesPlugin(config, baseUrl) {
objectUrl = model.url; objectUrl = model.url;
} }
}else { }else {
app.notifier.add({ missingModels.push(loadingObject.name);
type: NotificationType.ERROR, // go to next model
message: "Objekt mit dem namen: " + loadingObject.name + " konnte nicht in den geladenen Objekten gefunden werden. Konfiguration konnte nicht vollständig geladen werden.", continue;
});
// abort
return;
} }
} }
const cartPos = Cartesian3.fromDegrees(loadingObject.position[0], loadingObject.position[1], loadingObject.position[2]); const cartPos = Cartesian3.fromDegrees(loadingObject.position[0], loadingObject.position[1], loadingObject.position[2]);
...@@ -408,7 +406,18 @@ export default function smartVillagesPlugin(config, baseUrl) { ...@@ -408,7 +406,18 @@ export default function smartVillagesPlugin(config, baseUrl) {
name: loadingObject.name, name: loadingObject.name,
}); });
} }
if (missingModels.length > 0) {
let objects = '';
for (const objectName of missingModels) {
objects += ' ' + objectName + ',';
}
objects = objects.substring(1, objects.length-1);
app.notifier.add({
type: NotificationType.ERROR,
message: "Konfiguration konnte nicht vollständig geladen werden. Folgende Modelle fehlen in der Objektliste:" + objects,
});
window.alert("Konfiguration konnte nicht vollständig geladen werden. Folgende Modelle fehlen in der Objektliste: \n" + objects);
}
for (const objectToHide of objects.hiddenObjects) { for (const objectToHide of objects.hiddenObjects) {
hidingFeatures.push({ hidingFeatures.push({
id: objectToHide, id: objectToHide,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment