Cesium 动态Polyline绘制

Cesium 用Entity绘制polyline,如果使用CallbackProperty方法进行动态绘制,depthFailMaterial属性将失效。
从官方github上的issue找了替代的方法。

动态Primitive线的绘制

// 绘制方法
this._candidateLinePrimitive = this.scene.primitives.add(
  new Cesium.Primitive({
    geometryInstances: new Cesium.GeometryInstance({
      geometry: new Cesium.PolylineGeometry({
        positions: this._candidateLinePositions,
        width: this.defaultLineWidth,
        vertexFormat: Cesium.PolylineMaterialAppearance.VERTEX_FORMAT
      })
    }),
    appearance: new Cesium.PolylineMaterialAppearance({
      material: new Cesium.Material({
        fabric: {
          type: "PolylineDash",
          uniforms: {
            color: (() => {
              let c = this.lineMaterial.color.getValue();
              return new Cesium.Color(c.red, c.green, c.blue, 1.0);
            })()
          }
        }
      }),
      renderState: {
        depthTest: {
          enabled: false  // shut off depth test
        }
      }
    }),
    asynchronous: false   // block or not
  })
);
// 动态刷新,remove 再 add
if (!_.isEmpty(this._candidateLinePrimitive)) {
    this.scene.primitives.remove(this._candidateLinePrimitive);
}
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值