private IEnumerator RenderMeshDataIEnumerator()
        {
            IsCoroutineRunning = true;

            if (IsMeshUpdate == true)
            {
                // it is basically try lock, use try lock to avoid spending too much time in update()
                if (Monitor.TryEnter(MeshLock))
                {
                    try {
                        NumOfActiveGO = 0;
                        if (last_renderMode != renderMode)
                        {
                            HideAllLiveMeshes();
                            last_renderMode = renderMode;
                        }

                        if (renderMode == ReconstructionRenderMode.SECTOR)
                        {
                            for (int i = 0; i < SectorNum; i++)
                            {
                                SetMeshData(SectorIDList[i]);
                            }
                            // Take out key one by one. Either add new mesh or add age of meshes that are not updated.
                            UpdateMeshAge();
                        }
                        else if (renderMode == ReconstructionRenderMode.MODEL_PREVIEW)
                        {
                            SetMeshData(ModelChunkIdx);
                        }
                        else
                        {
                            for (int i = 0; i < NumSubMeshes; i++)
                            {
                                SetMeshData(i);
                            }
                        }

                        foreach (KeyValuePair <int, GameObject> go in ShowGameObjs)
                        {
                            go.Value.GetComponent <MeshRenderer>().sharedMaterial = UsingMaterial;
                        }

                        IsMeshUpdate = false;
                    }
                    finally {
                        Monitor.Exit(MeshLock);
                    }
                }
            }
            IsCoroutineRunning = false;
            yield return(0);
        }
 private void UpdateRenderMode()
 {
     if (ModelChunkNum > 0)
     {
         renderMode = ReconstructionRenderMode.MODEL_PREVIEW; /*Debug.Log("model preview mode");*/
     }
     else if (EnableSector && SectorNum > 0)
     {
         renderMode = ReconstructionRenderMode.SECTOR; /*Debug.Log("sector mode");*/
     }
     else if (!EnableSector && SectorNum == 0)
     {
         renderMode = ReconstructionRenderMode.ALL; /*Debug.Log("default mode"); */
     }
     else
     {
         renderMode = ReconstructionRenderMode.NONE;  // do not render incomplete data
     }
 }