合并primitive,polygon,polyline,设置贴地,设置distanceDisplayCondition

const polylinePrimitives = new Cesium.GroundPolylinePrimitive({
  geometryInstances: [],
  appearance: new Cesium.PolylineColorAppearance(),
});

const polygonPrimitives = new Cesium.GroundPrimitive({
  geometryInstances: [],
  appearance: new Cesium.PerInstanceColorAppearance({
    closed: false,
  }),
});

polygonPrimitives.geometryInstances.push(
  new Cesium.GeometryInstance({
    geometry: Cesium.PolygonGeometry.fromPositions({
      positions: Cesium.Cartesian3.fromDegreesArray([...]),
      // vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT,
    }),
    attributes: {
      color: Cesium.ColorGeometryInstanceAttribute.fromColor(
        Cesium.Color.fromCssColorString('RGBA(41,98,255, 0.3)')
      ),
      distanceDisplayCondition: new Cesium.DistanceDisplayConditionGeometryInstanceAttribute(
        0,
        600.0
      ),
    },
  })
);

polylinePrimitives.geometryInstances.push(
  new Cesium.GeometryInstance({
    geometry: new Cesium.GroundPolylineGeometry({
      positions: Cesium.Cartesian3.fromDegreesArray([...]),
      width: 5.0,
    }),
    attributes: {
      color: Cesium.ColorGeometryInstanceAttribute.fromColor(
        Cesium.Color.fromCssColorString('RGBA(41,98,255, 0.6)')
      ),
      distanceDisplayCondition: new Cesium.DistanceDisplayConditionGeometryInstanceAttribute(
        0,
        600.0
      ),
    },
  })
);

scene.primitives.add(polylinePrimitives);
scene.primitives.add(polylinePrimitives);

你可能感兴趣的:(合并primitive,polygon,polyline,设置贴地,设置distanceDisplayCondition)