用过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);
}