JavaScript SDK版本3.6.299
2024-12-25
// 加载三维图纸后,获取指定图元的ObjectData信息,包含图元所属的图层id和name等属性
viewer3D.getModel().getObjectDataById('图元ID');
// 对图层id为1189的所有图元进行隐藏
viewer3D.getModel().hideComponentsByObjectData([{layerId:'1189'}]);
// 对图层名称为"A-AREA"的所有图元进行着色
viewer3D.getModel().overrideComponentsColorByObjectData([{layerName:'A-AREA'}],new Glodon.Web.Graphics.Color(255,0,0,1));
// 添加splineCurve
let splineCurve = new Glodon.Bimface.Earth.Plugins.Geometry.SplineCurve({
points:[
curvePt0= {lat: 39.90872242500939, lon: 116.39725156611851, alt: 0.5},
curvePt1 = {lat:39.90817485178061, lon: 116.39841706514225,alt:0.5}
],
viewer:viewerGIS
});
// 构造外部构件图层,添加对应的曲线对象
let extLayer = new Glodon.Bimface.Earth.Layer.ExternalObjectLayer({id:'ext',name:'exename'});
viewer.getLayerManager().addLayer(extLayer);
// 获取对应外部构件管理器对象
let extMng = viewer.getLayerManager().getLayer('ext').getExternalObjectManager();
// 将曲线添加至场景中
extMng.loadObject({ name: "splineCurve", object: splineCurve },function(){console.log(extMng.getObjectIdByName('splineCurve'))});
splineCurve.setWidth(2);
// 拉伸曲线
splineCurve.stretch(0.5);
// 设置曲线贴图,便于后续进行曲线动画的构造显示
splineCurve.setMap({src: "https://static.bimface.com/attach/f4b5c5e71fce4090a63fc1c2e3839bd2_dynamic(1).png", enableColorOverride: false});
// 构造曲线动画的配置项
let curveAnimationConfig = new Glodon.Bimface.Earth.Plugins.Animation.CurveAnimationConfig();
// 配置Viewer对象、曲线对象、动画时间、动画循环、动画类型等参数
curveAnimationConfig.viewer = viewer;
curveAnimationConfig.curves = [splineCurve];
curveAnimationConfig.time = 2000;
curveAnimationConfig.loop = true;
curveAnimationConfig.type = "flow";
// 构造曲线动画对象并播放动画
curveAnimation = new Glodon.Bimface.Earth.Plugins.Animation.CurveAnimation(curveAnimationConfig);
curveAnimation.play();
BIMFACE智能客服
7*24提供专业的BIMFACE使用支持与帮助