Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will the ModelInstanceCollection class be restored? #10846

Open
zhwy opened this issue Oct 8, 2022 · 31 comments
Open

Will the ModelInstanceCollection class be restored? #10846

zhwy opened this issue Oct 8, 2022 · 31 comments

Comments

@zhwy
Copy link

zhwy commented Oct 8, 2022

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?

@ggetz
Copy link
Contributor

ggetz commented Oct 10, 2022

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?

@j9liu
Copy link
Contributor

j9liu commented Oct 10, 2022

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?

@zhwy
Copy link
Author

zhwy commented Oct 11, 2022

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.

@j9liu
Copy link
Contributor

j9liu commented Oct 12, 2022

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.

@kikitte
Copy link

kikitte commented Dec 7, 2022

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

@lhgbird1206
Copy link

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

@abearxiong
Copy link

has other way ?

@ggetz
Copy link
Contributor

ggetz commented Dec 15, 2022

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

@yjwbill
Copy link

yjwbill commented Jan 1, 2023

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.

@ptrgags
Copy link
Contributor

ptrgags commented Jan 2, 2023

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).
@llauren48
Copy link

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!

@lhgbird1206
Copy link

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

@lucy1564351
Copy link

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

@MeanYou
Copy link

MeanYou commented Jul 25, 2023

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

@LastPoem
Copy link

hope to see it come back, we need this

@vsharma-next
Copy link

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 !

@javagl
Copy link
Contributor

javagl commented Mar 6, 2024

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

@mickae1
Copy link

mickae1 commented Mar 14, 2024

Hi I'm also interesting of this feature.

Thanks,

@vsharma-next
Copy link

Bump :)

@lqzv
Copy link

lqzv commented Apr 16, 2024

badly needed

@shaonianla1997
Copy link

How is the progress?

@ggetz
Copy link
Contributor

ggetz commented Apr 17, 2024

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.

@lucy1564351
Copy link

badly needed

@giswrok
Copy link

giswrok commented May 17, 2024

badly needed +1

@lucy1564351
Copy link

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
Copy link

really need it!

@javagl
Copy link
Contributor

javagl commented Jul 9, 2024

@mulfvik
Copy link

mulfvik commented Jul 17, 2024

Needed feature

@SuperMarioStack
Copy link

badly needed +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment