Log in or register to post comments

why camera is freezing while loading the 3D model

January 22, 2015 - 4:39am #1

I'm loading the 3D model from server and when my target found the loading text will start to display the percentage of load and if it comes at 99% and the camera is freezing to load the model. I'm not sure why the camera is freezing. How can we load model without freeze the camera?

why camera is freezing while loading the 3D model

January 26, 2015 - 9:50am #4

As I said, if you debug (e.g. put a breakpoint or check the logs), what do you see ?  

For example, does the app gets beyond the code in your  while (!objData.isDone) ?  

 

why camera is freezing while loading the 3D model

January 26, 2015 - 4:48am #3

Below is the code i'm using and my model size is 3 or 4 or 5MB only

if(typeString == "3d"){
modelGUI = true;
modelString = linkString;
newImageTarget = Instantiate (ImageTargetTemplate.gameObject) as GameObject;
 
ImageTracker tracker = TrackerManager.Instance.GetTracker<ImageTracker> ();
ImageTargetBehaviour imageTargetBehaviour = (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking 
(targetSearchResult, newImageTarget);
Debug.Log (imageTargetBehaviour);
StartCoroutine(loadModel(targetSearchResult.UniqueTargetId,imageTargetBehaviour));
}
 
 
IEnumerator loadModel(string targetIDModel, ImageTargetBehaviour itbModel ){
 
if(modelGUI){
 
Debug.Log (targetIDModel);
 
//Check if model is available in the scene 
 
GameObject model = GameObject.Find (targetIDModel);
 
Debug.Log (targetIDModel);
 
if (!model) { //fetch model from the URL
 
loadingText.enabled = true;
Debug.Log ("fetching 3d");
 
var objData = ObjReader.use.ConvertFileAsync (modelString, true, standardMaterial);
 
while (!objData.isDone) {
Debug.Log (" objData is not there");
loadingText.text = "Loading... " + (objData.progress*100).ToString("f0") + "%";
yield return loadingText.text;
}
//myHealth.Progress (100); // done
loadingText.enabled = false;
string modelName = objData.gameObjects [0].name;
 
model = GameObject.Find (modelName); // find the model reference
 
model.name = targetIDModel; // change the model name to targetID !!!
 
}
 
GameObject modelClone = Instantiate( model ) as GameObject; //clone the model 
modelClone.transform.parent = itbModel.gameObject.transform; // pair the clone to the instantiated image target
GameObject.Find(targetIDModel+"(Clone)").transform.localScale = Vector3.one;
 
modelClone.transform.localPosition = new Vector3(0,0,0);
 
 
}
 
}
 

 

why camera is freezing while loading the 3D model

January 23, 2015 - 12:36pm #2

You could perform the loading task asynchronously using Unity Coroutines: 

http://docs.unity3d.com/Manual/Coroutines.html

If the camera still freezes before completing the model (e.g. at 99%), this might be an indication of a memory or CPU consumption issue (e.g. perhaps the model is too large/heavy for your device ?)  or more simply there could be some kind of bug in the application code that results in stalling your app (and ths the camera).   A bit of debugging and/or logs checking might help identifying the actual root cause of the issue.

 

 

Log in or register to post comments