首页 / 浏览问题 / 组件GIS / 问题详情
三维场景中实时更新三维模型位置报错
10EXP 2022年05月23日

使用产品:iobject net 10i 操作系统:win10 x64
数据类型:  文件型
问题详细描述:在三维场景中加载三维模型,然后通过线程实时更新模型位置报错
问题重现步骤: 

报错信息:“System.AccessViolationException”类型的未经处理的异常在 SuperMap.Data.dll 中发生 

报错代码:

        //这是一个线程函数
        private void ShowModelFun()
        {
            while (true)
            {
                try
                {
                    foreach (UAVInfo item in GlobalInstance._uavInfos.Values)
                    {
                        GeoModel geoModel = GlobalInstance._uavGeoModel[item.ID];

                        TrackInfo trackInfo = GlobalInstance._uavTrackInfo[item.ID].TracInfo;
                        Point3D point = new Point3D(trackInfo.Longitude, trackInfo.Latitude, trackInfo.Altitude);
                        geoModel.Position = point;

                        //该区域造成报错
                        int index = GlobalInstance._sceneControl.Scene.TrackingLayer.IndexOf(item.ID);
                        GlobalInstance._sceneControl.Scene.TrackingLayer.Set(index, geoModel);

                        GeoLine3D geoLine = CreateGeoLine3D(point);
                        string lineTag = string.Format("line_{0}", item.ID);
                        int lineIndex = GlobalInstance._sceneControl.Scene.TrackingLayer.IndexOf(lineTag);
                        if (lineIndex >= 0)
                        {
                            GlobalInstance._sceneControl.Scene.TrackingLayer.Remove(lineIndex);
                            GlobalInstance._sceneControl.Scene.TrackingLayer.Add(geoLine, lineTag);
                        }
                        else
                        {
                            GlobalInstance._sceneControl.Scene.TrackingLayer.Add(geoLine, lineTag);
                        }

                    }
                    //GlobalInstance._sceneControl.Scene.Refresh();

                    Thread.Sleep(500);
                }
                catch { }

            }
        }

1个回答

您好,TrackingLayer 是支持后台线程删减的,我在本机参考您上面的代码编写对应的逻辑无法复现“System.AccessViolationException”异常。麻烦截图一下您那边调试的时候抛异常的情况,或者私信我您的联系方式(QQ),我远程帮您看一下。

希望可以帮到您。
2,158EXP 2022年05月23日
该问题已解决,跟踪图层的设计初衷是用来显示静态数据的,很少会用来实现动画效果,动画效果的话建议使用动态图层,切换动态图层后解决。
...