这些年写过的无厘头代码(二)Skyline中js接口控制三维场景模型对象闪烁

用过Skyline 三维平台的都知道,场景中找个模型对象是得多么的耐心和毅力,如何在代码中控制飞行定位后凸显目标对象,下面我们就来试验一下。

首先,加载读取fly中3dml模型,经过多个测试过多个类型下加载模型,发现只有ObjectType == 33条件下的模型可以访问到模型颜色。

    var object = App.SG.ProjectTree.GetObject(SourceObjectID);
    if (object != null) {
       if (object.ObjectType == 33) {
          var selectFeature = App.SG.Creator.GetObject(object.id);
          if (Main.oldselectFeature) { 
             Main.oldselectFeature.Tint.abgrColor = 0x00000000; 
          }
          selectFeature.Tint.abgrColor = 0x7F0000FF;
          Main.oldselectFeature = selectFeature;//用来记录不同模型切换
       }
    } 

这样实现了模型的变色,剩下的就是控制颜色来回切换了。

       //feature.Tint.abgrColor = 0x7F0000FF;
 currentSelectObj = feature;
 featureID = feature.ID;
 flashF = setInterval(function () {
           if (currentSelectObj) {
               currentSelectObj.Tint.abgrColor = bf ? 0x7F0000FF : 0x7F00FFFF;
                bf = !bf;
                fcount++;
                 if (fcount > 30) { 
                    ClearCurrentSelectTint();
                                }
                            }
                        }, 200);

       function ClearCurrentSelectTint() {
            if (currentSelectObj) {
                currentSelectObj.Tint.abgrColor = 0x0000000;
                clearInterval(flashF);
            }
        }

附加点、线、闪烁代码:

 //point闪烁
    PointFlash: function (point) {
        var sgworld = App.SG;
        if (sgworld) {
            var pointHighlight = false;
            var timeon = 0;
            var nRGB_White = 0xFFFFFF
            var nRGB_Red = 0xFF0000;
            cFillStyle = point.FillStyle;

            //点模拟闪烁
            var timeid = window.setInterval(function () {
                timeon++;
                if (timeon < 10) {
                    if (pointHighlight) {
                        cFillStyle.Color.FromRGBColor(nRGB_White);
                        pointHighlight = false;
                    } else {
                        cFillStyle.Color.FromRGBColor(nRGB_Red);
                        pointHighlight = true;
                    }
                } else {
                    clearInterval(timeid);
                    var GroupID = sgworld.ProjectTree.FindItem("高亮");
                    if (GroupID != "" || typeof (GroupID) != "undefined") {
                        sgworld.ProjectTree.DeleteItem(GroupID);
                    }
                    pointHighlight = false;
                }
            }, 100);
        }
    },


    //polyline闪烁
    PolylineFlash: function (polyline) {
        var sgworld = App.SG;
        if (sgworld) {
            var lineHighlight = false;
            var timeon = 0;
            //线模拟闪烁
            var timeid = window.setInterval(function () {
                timeon++;
                if (timeon < 10) {
                    if (lineHighlight) {
                        polyline.LineStyle.Width = 1;
                        lineHighlight = false;
                    } else {
                        polyline.LineStyle.Width = 3;
                        lineHighlight = true;
                    }
                } else {
                    clearInterval(timeid);
                    var GroupID = sgworld.ProjectTree.FindItem("高亮");
                    if (GroupID != "" || typeof (GroupID) != "undefined") {
                        sgworld.ProjectTree.DeleteItem(GroupID);
                    }
                    lineHighlight = false;
                }
            }, 100);
        }
    

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值