cesium icon indicating copy to clipboard operation
cesium copied to clipboard

Will the ModelInstanceCollection class be restored?

Open zhwy opened this issue 3 years ago • 31 comments

I've noticed the ModelInstanceCollection has been removed since 1.96. It used to be placed in the Development category in the Cesium sandcastle. image ModelInstanceCollection is really useful and efficient to display a large amount of same models. Will it be restored in a subsequent version?

zhwy avatar Oct 08 '22 03:10 zhwy

Hi @zhwy, ModelInstanceCollection was marked as a private class, so it was not an official part of the API and was subject to change.

@j9liu Is there anyway for a user to hook into model instancing without 3D Tiles?

ggetz avatar Oct 10 '22 13:10 ggetz

Hi @zhwy,

Models can be instanced on the GPU if they contain the EXT_mesh_gpu_instancing extension, but as of now there's no class to instance models without the extension, or instance them on the CPU.

You can still manually create a collection of Models with different model matrixes -- is there a reason that you needed ModelInstanceCollection in particular?

j9liu avatar Oct 10 '22 14:10 j9liu

Hi @j9liu ,

I use ModelInstanceCollection to generate large batches of models dynamiclly. One application is that I need to display many vehicle models based on GPS data and update each instance's model matrix regularly.

zhwy avatar Oct 11 '22 14:10 zhwy

Hi @zhwy,

Thanks for the response. I'm not sure how much effort this would be to implement since ModelInstanceCollection may not be compatible with the new Model architecture. For now I've marked this as an enhancement to consider adding this in the future.

j9liu avatar Oct 12 '22 14:10 j9liu

+1. The same usage like what zhwy said, displaying large numbers of the same model. It would be nice to see that.

kikitte avatar Dec 07 '22 07:12 kikitte

+1,ModelInstanceCollection is convenient for implementing gltf instance,Look forward to seeing this feature again.

lhgbird1206 avatar Dec 12 '22 01:12 lhgbird1206

has other way ?

abearxiong avatar Dec 15 '22 03:12 abearxiong

@ptrgags Would you be able to advise on how something like ModelInstanceCollection could be implemented with the new model architecture?

ggetz avatar Dec 15 '22 13:12 ggetz

Using ModelInstanceCollection to creating gltf instances is efficient and it can raplace the modelMatrix of each instance.Creating hundreds of moving cars is an easy thing by using ModelInstanceCollection ,but now i cannot do it. Looking forward to seeing this feature again.

yjwbill avatar Jan 01 '23 15:01 yjwbill

Thinking about this a bit, rendering a static set of instances would be relatively straightforward to implement, since all the building blocks exist from the EXT_mesh_gpu_instancing code. However, dynamic updating of the model matrices would take more thought.

Let's start with the static case:

  • When parsing the glTF into a ModelComponents, the main difference is we want to add a ModelComponents.Instances to the result. This is quite similar to how I3dmLoader works (see here), except the attributes/model matrices would now be supplied by the user.
  • This means we might want to create an InstancedModelLoader class that uses a GltfLoader for the basic glTF parsing/loading but then modifies the ModelComponents to add the instances (much like I3dmLoader does, and how B3dmLoader, etc. adds metadata)
  • As far as the entry point goes... not sure the best API for this, perhaps add Model.fromInstances()?

As for the dynamic case (updating the model matrices on the fly):

  • For reference, the old code used ModelInstanceCollection, which contained ModelInstance objects to track the model matrix.
  • ModelInstanceCollection involved a large amount of code duplication of the old Model, let's avoid doing that again.
  • As for ModelInstance, I notice that the old code required allocating separate objects for every single instance. Was this ever a memory issue for large numbers of instances? If so, maybe consider a single "view" like object that lets you update a matrix by index (e.g. modelInstances.setMatrix(index, updatedMatrix). Though that might still require some typed arrays on the CPU...
  • Either way, we'd need to attach this object to the Model, and we'd need a way to update the instancing matrices (when necessary) each frame. Maybe it would be good to look at how we implemented animations (especially handling the node matrices).

ptrgags avatar Jan 02 '23 13:01 ptrgags

Also requested on the forum: https://community.cesium.com/t/the-modelinstancecollection-is-canceled-how-can-i-load-thousands-dynimic-models-in-cesium/21797/2.

ggetz avatar Jan 06 '23 20:01 ggetz

So is that possible to restore the ModelInstanceCollection class or add a class that has similar functionality in the new version of Cesium? Our projects about geographic visualization really need it!

llauren48 avatar Jan 18 '23 09:01 llauren48

hi, @ggetz, Is there a plan to restore this functionality with the new model architecture?

lhgbird1206 avatar Apr 06 '23 04:04 lhgbird1206

地理类项目无比需要这个功能

lucy1564351 avatar May 23 '23 09:05 lucy1564351

This feature is used in many scenarios, hope to see it again.🙂

MeanYou avatar Jul 25 '23 08:07 MeanYou

hope to see it come back, we need this

LastPoem avatar Oct 11 '23 06:10 LastPoem

Also requested in https://community.cesium.com/t/using-modelinstancecollection/7473/6

ggetz avatar Nov 03 '23 13:11 ggetz

Hi, any update on this ? Like many others in this issue thread, I generate glb blobs on the fly and then need a way to make 100s/1000s of instancing of this one model. ThreeJS supports it out of the box as you know and CesiumJS used to ... please bring it back :) Even static model instancing as suggested by @ptrgags is sufficient for now !

vsharma-next avatar Feb 08 '24 09:02 vsharma-next

Sounds like another case where this would be a desired solution: https://community.cesium.com/t/gltf-scenes-to-3d-tiles/30305/4

javagl avatar Mar 06 '24 15:03 javagl

Hi I'm also interesting of this feature.

Thanks,

mickae1 avatar Mar 14 '24 10:03 mickae1

Bump :)

vsharma-next avatar Apr 08 '24 08:04 vsharma-next

badly needed

lqzv avatar Apr 16 '24 01:04 lqzv

How is the progress?

shaonianla1997 avatar Apr 17 '24 01:04 shaonianla1997

There hasn't been any activity on this item recently, but we are definitely receiving the message that this is an important feature!

If you are interesting in contributing, please let us know and we'd be happy to discuss implementation or review a PR.

ggetz avatar Apr 17 '24 13:04 ggetz

badly needed

lucy1564351 avatar Apr 19 '24 01:04 lucy1564351

badly needed +1

giswrok avatar May 17 '24 02:05 giswrok

So is that possible to restore the ModelInstanceCollection class or add a class that has similar functionality in the new version of Cesium? Our projects about geographic visualization really need it!

lucy1564351 avatar Jun 21 '24 05:06 lucy1564351

really need it!

lucy1564351 avatar Jun 21 '24 05:06 lucy1564351

It keeps popping up in the forum: https://community.cesium.com/t/using-modelinstancecollection/7473/7

javagl avatar Jul 09 '24 23:07 javagl

Needed feature

mulfvik avatar Jul 17 '24 13:07 mulfvik