使用entities、primitives添加的模型,如何在鼠标右键事件中改变模型颜色??
viewer.scene.primitives.add(
Cesium.Model.fromGltf({
id: attat.modelguid,
url: '/model/' + _that.fileglb + '/' + attat.attachedmodelname + '.glb', // 本地文件
modelMatrix: towerattamatrix,
scale: 1, // 放大倍数
})
);
viewer.entities.add({
guid:crossguid,
polyline: {
width: 1,
material: Cesium.Color.DEEPSKYBLUE,
show: true,
positions: Cesium.Cartesian3.fromDegreesArrayHeights(nodePositionArr),
distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0, 10000),
heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
},
});
使用过这种方法不过没有效果,并且报错属性不存在?
// 鼠标右键获取属性
handler.setInputAction(function (click) {
// 禁止浏览器鼠标右键菜单
document.oncontextmenu = function () {
return false;
};
const pickModel = Winviewer.scene.pick(click.position);
_that.position = Winviewer.scene.pickPosition(click.position);
if (pickModel) {
// 属性按钮
var Attribute = document.getElementById('attribute');
Attribute.style.display = "none";
// 属性面板
var viewproperties = document.getElementById('viewproperties');
viewproperties.style.display = "block";
_that.addEventPreRender(viewproperties);
if (pickModel.id.guid) {
console.log(pickModel,'pickModel')
//pickModel.id.point.color=new Cesium.Color(1.0, 0.0, 0.0, 1);
_that.modelguid = pickModel.id.guid;
} else {
console.log(pickModel,'pickModel')
//pickModel.primitive.appearance.material.uniforms.color=Cesium.Color.BLUE
_that.modelguid = pickModel.id;
}
} else {
// 属性按钮
var viewproperties = document.getElementById('viewproperties');
viewproperties.style.display = "none";
}
}, Cesium.ScreenSpaceEventType.RIGHT_CLICK);