Questions about ModelInstanceCollection and PrimitiveCollection as an alternative

Hi Cesium team and community,

I have a couple of questions about model instancing in Cesium.

I noticed that ModelInstanceCollection is no longer available in the latest versions.

Will this feature ever come back? It used to be super helpful when placing lots of identical glTF models—great performance, low GPU usage, and fewer draw calls.

Also, I’m currently trying to load about 5,000 identical glTF models (fire extinguisher boxes, ~370KB each) into a Cesium scene. Each model needs to be editable and movable individually, not just displayed.

Can PrimitiveCollection be used for this kind of scenario? Or is there a better way to do this now?

Would love to hear what the best practice is with the current Cesium setup.

Thanks a lot!

— Hang

Hi @hh_q ,

Thanks for your post and for being part of the Cesium community.

We will be bringing back ModelInstanceCollection very soon. We have a PR to add it back that is very far along Add back ModelInstance class by lukemckinstry · Pull Request #12588 · CesiumGS/cesium · GitHub but did not quite make this month’s release. It is likely to be in the next release at the start of September. Feel free to checkout the branch if you want to see the sandcastle example. And even better try the code with your glTF and anticipated scene and let us know if you have any feedback regarding how easy or hard it is to use the new API to create your scene and move the model instances as you envision. You can leave feedback here or on the PR.

Thanks,
Luke

1 Like

Thanks so much for all your hard work, team! :folded_hands:

Big thanks to Luke for the quick reply and for bringing back ModelInstanceCollection —I’m really looking forward to testing it in my project. I’ll be sure to let you know right away if I run into any issues during testing.

Thanks again!

— Hang

Hi, after debugging the sandbox project on GitHub, I found that when rendering 5,000 models simultaneously, ModelInstanceCollection reduces GPU usage by about 60% compared to PrimitiveCollection, which is indeed a great performance optimization.

However, I have a question. In Three.js, similar InstancedMesh does not support adding or removing individual instances. So, will ModelInstanceCollection support adding/removing individual instances in the future, dynamically editing the position of a single model, and storing properties for each individual model?

Thank you,
Hang.

Glad to hear the performance improvement.

The ModelInstanceCollection class will support adding or removing instances (which are specified with the ModelInstance class) from the collection. Each instance will have its transform stored individually, so you can edit the transform of a specific instance.

Thanks for mentioning needing to debug the sandcastle, I pushed up a fix that should correctly scale the wind turbine model in the 3D Model Instancing Terrain example so it appears as expected on initial load. If you look at the 3D Model Instancing sandcastle, you can see in the setTimeout loop how the transform for each instance is being recalculated and reset 6 seconds after it loads.

You can also see documentation for the new classes in the branch when running the dev local server, you just need to run npm run build-docs to build the documentation pages.

Thanks again for the feedback and let us know if you have more!
Best,
Luke

Thanks, Luke! I’ll dive in, test it thoroughly, and let you know if I spot any issues. Really appreciate your help!

Many people are really looking forward to this feature. May I ask if this feature will be added again in the future? Thank you.

I noticed the relevant branch is currently in PR status. Could you kindly share why it hasn’t been merged yet?