how can i display multiple color polyline entity?

1. A concise explanation of the problem you’re experiencing.

2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.

3. Context. Why do you need to do this? We might know a better way to accomplish your goal.

4. The Cesium version you’re using, your operating system and browser.

i want to display multiple color polyline in cesium。

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

var viewer = new Cesium.Viewer(‘cesiumContainer’);

var primitive = new Cesium.Primitive({

geometryInstances : new Cesium.GeometryInstance({

geometry : new Cesium.PolylineGeometry({

  positions : [

    Cesium.Cartesian3.fromElements(-2822918.76, -1347627.64, 5539750.33),

    Cesium.Cartesian3.fromElements(-2860091, -1790883.7, 6104936.09),

    Cesium.Cartesian3.fromElements(-2869994.31, -2212991.67, 6598178.01)

  ],

  width : 2.0,

  vertexFormat : Cesium.PolylineColorAppearance.VERTEX_FORMAT,

  colors: [Cesium.Color.RED, Cesium.Color.BLUE],

  colorsPerVertex: false

})

}),

appearance : new Cesium.PolylineColorAppearance({

translucent : false

})

});

viewer.scene.primitives.add(primitive);

but can’t chang primitive positions at run time;

entity can chang positions at runtime with callback,but can’t display multiple color。

how can i do this?

Hi there,

Under the hood, entities are represented as primitives, When an entity’s property changes, we update or destroy the old primitive and create a new one. You would do something similar to update a polyline geometry. Take a look at Geometry and setting the attributes.

Thanks,

Gabby

i write code like this:

var newPrimitive = new Cesium.Primitive({

geometryInstances: new Cesium.GeometryInstance({

geometry: new Cesium.PolylineGeometry({

positions: Cesium.Cartesian3.fromDegreesArray(that.vps),

width: that.linewidth,

vertexFormat: Cesium.PolylineColorAppearance.VERTEX_FORMAT,

colors: that.colors,

colorsPerVertex: false

}),

}),

appearance: new Cesium.PolylineColorAppearance({

translucent: true

}),

** asynchronous: false**

});

when asynchronous: false, the viewer not flash,but Primitive count more than 30,the viewer slower.

when asynchronous: true, the viewer flash.

在 2018年1月22日星期一 UTC+8下午11:14:24,Gabby Getz写道:

The asynchronous property determines how the primitive is created (asynchronous task are processed in a web worker to avoid slowing down the viewer render loop), not how they are updated. I think you’ll need to modify the geometry attributes instead.