new mars3d.graphic.PolygonEntity({做环的效果时候出现穿透问题处理

172 篇文章 2 订阅
155 篇文章 0 订阅

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)
}

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值