1.在做挖洞面或者是回字型效果的时候,这个出现穿透的效果
相关代码:
说明:
1.此时加上一个贴地的参数即可处理穿透漂移的现象
function addDemoGraphic6(graphicLayer) {
const graphic = new mars3d.graphic.PolygonEntity({
positions: [
[
[-61, 86, 0],
[10, 79, 0],
[18, 69, 0],
[20, 60, 0],
[21, 50, 0],
[22, 40, 0],
[21, 30, 0],
[21, 20, 0],
[20, 10, 0],
[20, 0, 0],
[18, -9, 0],
[17, -18, 0],
[15, -28, 0],
[12, -38, 0],
[9, -47, 0],
[3, -56, 0],
[7, -65, 0],
[-26, -72, 0],
[-61, -75, 0],
[-95, -72, 0],
[-115, -65, 0],
[-125, -56, 0],
[-131, -47, 0],
[-135, -38, 0],
[-137, -28, 0],
[-139, -18, 0],
[-141, -9, 0],
[-142, 0, 0],
[-143, 10, 0],
[-143, 20, 0],
[-144, 30, 0],
[-144, 40, 0],
[-144, 50, 0],
[-143, 60, 0],
[-140, 70, 0],
[-132, 80, 0],
[-61, 86, 0]
],
[
[-60, -3, 0],
[-70, -12, 0],
[-52, -17, 0],
[-37, -8, 0]
]
],
style: {
color: "#ffff00",
opacity: 0.6,
clampToGround: true,
},
attr: { remark: "示例6" }
})
graphicLayer.addGraphic(graphic) // 还可以另外一种写法: graphic.addTo(graphicLayer)
setTimeout(() => {
alert("打点测试")
const bbox = [
[-61, 86, 0],
[10, 79, 0],
[18, 69, 0],
[20, 60, 0],
[21, 50, 0],
[22, 40, 0],
[21, 30, 0],
[21, 20, 0],
[20, 10, 0],
[20, 0, 0],
[18, -9, 0],
[17, -18, 0],
[15, -28, 0],
[12, -38, 0],
[9, -47, 0],
[3, -56, 0],
[7, -65, 0],
[-26, -72, 0],
[-61, -75, 0],
[-95, -72, 0],
[-115, -65, 0],
[-125, -56, 0],
[-131, -47, 0],
[-135, -38, 0],
[-137, -28, 0],
[-139, -18, 0],
[-141, -9, 0],
[-142, 0, 0],
[-143, 10, 0],
[-143, 20, 0],
[-144, 30, 0],
[-144, 40, 0],
[-144, 50, 0],
[-143, 60, 0],
[-140, 70, 0],
[-132, 80, 0],
[-61, 86, 0],
[-60, -3, 0],
[-70, -12, 0],
[-52, -17, 0],
[-37, -8, 0]
]
for (let j = 0; j < bbox.length; ++j) {
const position = bbox[j]
const index = j + 1
const graphic1 = new mars3d.graphic.PointEntity({
position,
style: {
color: "#00ffff",
pixelSize: 10,
outlineColor: "#ffffff",
outlineWidth: 2,
label: {
text: index,
pixelOffsetY: -10
},
}
})
graphicLayer.addGraphic(graphic1)
}
const graphic2 = new mars3d.graphic.PolylineEntity({
positions: bbox,
style: {
width: 5,
color: "#3388ff",
}
})
graphicLayer.addGraphic(graphic2)
}, 500)
}