refactored async 3d model loading error handling

removed done //TODO comments
This commit is contained in:
2018-10-12 16:05:14 +02:00
parent d51cdf5a97
commit 6a1775efe2
6 changed files with 26 additions and 13 deletions

View File

@@ -48,7 +48,6 @@ namespace RothenburgAR.Exhibition
if (newTitle.Position.HasValue)
TitleBehaviour.transform.localPosition = newTitle.Position.Value;
//TODO set scale to resize the title relative to tracker size
TitleBehaviour.DataText = newTitle.Text;
}

View File

@@ -77,7 +77,6 @@ namespace RothenburgAR.PointOfInterest
var modelDescription = new PoiModelDescription();
modelDescription.ModelPath = PathHelper.CombinePaths(PathHelper.MediaPath, mediaID, mediaID + ".obj");
//TODO dont have model size information, find a way to scale model to fit into view?
modelDescription.ModelPrefabName = string.Empty;
modelDescription.Scale = Vector3.one;
modelDescription.Position = Vector3.zero;

View File

@@ -32,11 +32,16 @@ namespace RothenburgAR.PointOfInterest
}
}
public bool ModelLoadFailed { get; private set; }
public IEnumerator LoadModel()
{
ModelLoadFailed = false;
if (!File.Exists(ModelDescription.ModelPath))
{
throw new FileNotFoundException(ModelDescription.ModelPath + " does not exist;");
Debug.LogError(ModelDescription.ModelPath + " does not exist;");
ModelLoadFailed = true;
yield break;
}
var loader = new OBJLoader(ModelDescription.ModelPath);
@@ -49,10 +54,18 @@ namespace RothenburgAR.PointOfInterest
yield return new WaitForSecondsRealtime(.1f);
}
var model = loader.BuildUnityObjects();
try
{
var model = loader.BuildUnityObjects();
model.SetActive(false);
_modelPrefab = model;
model.SetActive(false);
_modelPrefab = model;
}
catch (System.Exception)
{
ModelLoadFailed = true;
yield break;
}
}
public GameObject GetModelPrefab()

View File

@@ -60,12 +60,19 @@ namespace RothenburgAR.UI
Icon3D.SetActive(true);
IconLoading.SetActive(true);
while (!data.IsModelLoaded)
while (!data.IsModelLoaded && !data.ModelLoadFailed)
{
yield return new WaitForSecondsRealtime(.1f);
}
}
if (data.ModelLoadFailed)
{
//TODO maybe display error message to user
RemoveModel();
yield break;
}
try
{
SetModel(data.InstantiateModelPrefab());
@@ -87,7 +94,7 @@ namespace RothenburgAR.UI
var mesh = meshFilter.mesh;
if (mesh == null) throw new Exception("No Mesh in Model!");
//TODO remove when model metadata rotation is no longer a thing
//TODO remove when metadata model rotation is no longer a thing
mesh.RecalculateBounds();
var scale = 1f / Mathf.Max(mesh.bounds.size.x, mesh.bounds.size.y, mesh.bounds.size.z);

View File

@@ -57,7 +57,6 @@ namespace RothenburgAR.Updater
{
get
{
//TODO read documentation
return Operation.isDone && Request.isDone;
}
}

View File

@@ -26,10 +26,6 @@ namespace RothenburgAR.Updater
void Start()
{
/* TODO: allg. fragen
punkt zum eintragen der credentials?
*/
#if !UNITY_EDITOR
logFileHandler = new LogFileHandler();
#else