Hi.
I’m learning Primitive API and I’m trying to draw a circleGeometry with it, like this:
var viewer = new Cesium.Viewer('cesiumContainer',{
targetFrameRate :10
});
var scene = viewer.scene;
scene.globe.depthTestAgainstTerrain = true;
var geometry = new Cesium.CircleGeometry({
center: Cesium.Cartesian3.fromDegrees(-100.60777, 40.83),
radius : 500.0
});
var instance = new Cesium.GeometryInstance({
geometry : geometry,
attributes : {
color : Cesium.ColorGeometryInstanceAttribute.fromColor(new Cesium.Color(1.0, 0.0, 0.0, 0.5))
},
id : 'bottom'
});
scene.primitives.add(new Cesium.Primitive({
geometryInstances : instance,
appearance : new Cesium.PerInstanceColorAppearance()
This is happening because you need to specify the vertexFormat for the geometry. The perInstanceColorAppearance requires vertex normals to be computed in order to render correctly.
Here is the updated geometry code:
var geometry = new Cesium.CircleGeometry({
center: Cesium.Cartesian3.fromDegrees(-100.60777, 40.83),
radius : 500.0,
vertexFormat: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT
});
the code work well if I use Cesium.Primitive, if I use **Cesium.GroundPrimitive,**it throws an error :
Uncaught TypeError: Cannot set property color of # which has only a getter
return value of primitive.getGeometryInstanceAttributes(id) contains no setter function.
I read the source code of cesium and find that in GroundPrimitive.js , a param named ‘*readOnlyInstanceAttributesScratch’ *is set to [‘color’], so the Primitive regard it read only.
did I have a wrong usage or it is designed like this on purpose?
Oh, by the way, did I describe it clear? english is not my mother tongue,and my expression may not be correct.