Changing Cesium Primitives

Hello,

New Cesium programmer here. My prev experience is lower level graphics programming so trying to figure out how to do things with a higher level API like Cesium has been tricky. For instance If I want to change the appearance or modelmatrix of a primitive, it seems like the only way I can accomplish this is to actually remove the instance and create another one with the different appearance or transform is this correct? When I iterate through the scene.primitives there isnt much I can do with the returned object, I cant even see its instances and the id field is invalid. The example code changes the visibility status and that works, but nothing else seems to be available unless I am missing something.

Hi @dchism, welcome to the community!

You should be able to change the appearance or modelMatrix of an existing primitive. See Primitive.prototype.modelMatrix.

How are you iterating through the primitives? Can you share a Sandcastle example?

I’m realizing the documentation for PrimitiveCollection is missing a lot of types of returned objects. Let us know if there is any other place where the documentation could be clearer. Documentation suggestions from new Cesium developers can be very valuable for us, since you’re looking at it with fresh eyes and no prior assumptions.

Thanks for the reply. I have tried changing the modelmatrix and appearance without luck. When I found this discussion

I assumed that the path was to remove and recreate. I have that working as intended. One question I have since you are here is how the primitives are batched. By that I mean, I am assuming that when I create a primitive, its going to fork a web worker and create a bounding volume and organize the vertex and index data, then send that back to the main thread to create VBO’s and IBO’s of the data in world space which are static and thats why these are not able to be modified. The other option would be using instancing with the geometry instance data in object space in which case it would be possible to change the world matrices. I guess I am just looking for further elaboration in how geometry is culled and batched, at which level that is. This will help me decide how to group the primitive data so it runs better and have more accurate visibility testing.