三维场景 绘制 动态的圆 显示不出来

0 投票
function drawCircle()
{
    if(sceneControl.get_scene().get_trackingLayer3D().get_count()!=0)
    {
        sceneControl.get_scene().get_trackingLayer3D().removeAll();
    }
    var drawCircleAction = new SuperMap.Web.UI.Action3Ds.MyAction(sceneControl);
    sceneControl.set_sceneAction(drawCircleAction);
}
/**************************** 绘制圆形 start ****************************/

SuperMap.Web.UI.Action3Ds.MyAction = function (sceneControl) {
    SuperMap.Web.UI.Action3Ds.MyAction.initializeBase(this);
    this._name = "myAction";
    this._sceneControl = sceneControl;
    this._type = SuperMap.Web.UI.Action3Ds.SceneActionType.POINTSELECT;
};

var drawEnd = true; //判断是否结束绘制图形
var isDrawing = false; //判断是否正在绘制图形
var point3D = null; //绘制图形的起始点
var geoBoundObj = null;


SuperMap.Web.UI.Action3Ds.MyAction.prototype = {

    dispose: function () {
    },
    onMouseUp: function (e) {
    },
    onMouseDown: function (e) {
        if (drawEnd)
        {
            var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
            var tempPoint = this._sceneControl.pixelToGlobe(pt, SuperMap.Web.Realspace.PixelToGlobeMode.TerrainAndModel);
            point3D = new SuperMap.Web.Core.Point3D(tempPoint.x, tempPoint.y,tempPoint.z);
            isDrawing = true;
            drawEnd = false;
        }
        else {
            drawEnd = true; //结束绘制
            isDrawing = false; //绘制状态变为 false
            pan();
        }
    },
    onMouseMove: function (e) {
        if (isDrawing && point3D != null) {
            var pnt1 = point3D;
            var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
            var tempPoint = this._sceneControl.pixelToGlobe(pt, 0);

            var point1=pointConverter(pnt1);
            var point2=pointConverter(tempPoint);
            var R=Math.sqrt(Math.pow((point1.x-point2.x),2)+Math.pow((point1.y-point2.y),2));

            var GeoCircle3D = new SuperMap.Web.Core.GeoCircle3D(R);
            GeoCircle3D.set_position(pnt1);
            var GeoModel = new SuperMap.Web.Core.GeoModel();
            GeoModel=GeoCircle3D.getGeoModel(100,100);

            var feature = new SuperMap.Web.Core.Feature3D();
            feature.set_geometry(GeoModel);
            var style = new SuperMap.Web.Core.Style3D();
            style.set_fillForeColor(new SuperMap.Web.Core.Color(255, 0, 0, 180));
            style.set_lineColor(new SuperMap.Web.Core.Color(0, 0, 255, 100));
            style.set_lineWidth(1);
            style.set_altitudeMode(0);
            style.set_bottomAltitude(1000);
            style.set_extendHeight(800);
            feature.set_style3D(style);
            this._sceneControl.get_scene().get_trackingLayer3D().removeAll(); //删除跟踪图层上的图像
            this._sceneControl.get_scene().get_trackingLayer3D().add(feature, "GeoCircle3D");
            this._sceneControl.get_scene().get_trackingLayer3D().refresh();
        }
    }
};

SuperMap.Web.UI.Action3Ds.MyAction.registerClass('SuperMap.Web.UI.Action3Ds.MyAction', SuperMap.Web.UI.Action3Ds.SceneAction, Sys.IDisposable);
function pan(){
    //设置控件的当前操作为漫游
    var panAction = new SuperMap.Web.UI.Action3Ds.Pan(sceneControl);
    sceneControl.set_sceneAction(panAction);
}

/**************************** 绘制圆形 end ****************************/
//wgs84经纬度坐标转UTM投影坐标
function pointConverter(point3D)
{

    var xy = new Array(2);
    var zone = Math.floor ((point3D.x + 180.0) / 6) + 1;
    zone = LatLonToUTMXY (DegToRad(point3D.y),DegToRad(point3D.x), zone, xy);
    var point3Dnew=new SuperMap.Web.Core.Point3D(xy[0], xy[1], point3D.z);
    return point3Dnew;

}


function DegToRad (deg)
{
    return (deg / 180.0 * pi);
}




/*
 * RadToDeg
 *
 * Converts radians to degrees.
 *
 */
function RadToDeg (rad)
{
    return (rad / pi * 180.0);
}
8月 28, 2018 分类:  299次浏览 | 用户: 姓白的白 (1 分)

1个回答

0 投票

您好,您主要调试查看这两句代码:

 var GeoCircle3D = new SuperMap.Web.Core.GeoCircle3D(R);
 GeoCircle3D.set_position(pnt1);

里面传的参数是否是正常合理的,R的值是多少,pnt1坐标是否在经纬度坐标范围内?

另外尝试直接把GeoCircle3D加到featrue,然后添加到跟踪图层,看能否显示出来。

8月 29, 2018 用户: 胡林 登峰造极 (5,972 分)

我试过把GeoCircle3D加到featrue也是无用的,这是我在网上找的8C的三维绘画方式,应该是superMap官方给出的示例,用8C的插件运行时正常的,但是我们现在用9D的插件版,我把代码放在我们项目中就不行了

我稍后看看
已经报缺陷,缺陷号:ICRS-424
...