# can gltf model geometries be combined / instanced?

**URL:** https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111
**Category:** CesiumJS
**Created:** [February 3, 2017, 2:25pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111 "2017-02-03T14:25:50Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Frederic\_Brodbeck](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@Frederic\_Brodbeck](https://community.cesium.com/u/Frederic_Brodbeck)
#### Post date: [February 3, 2017, 2:25pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/1 "2017-02-03T14:25:50Z")

</div>

hi,

I have a gltf model that needs to be statically displayed many (tens of) thousand times on the surface of the globe. I'm looking into ways to ensure the best possible performance.

what I am currently doing is (in a loop):

---

<div class="post-metadata">

### Author: ![hannah](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/hannah/32/4509_2.png) [@hannah](https://community.cesium.com/u/hannah)
#### Post date: [February 3, 2017, 4:00pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/2 "2017-02-03T16:00:02Z")

</div>

Hello,

We don’t have model instancing support in the Cesium release yet, but it has been added to our 3d-tiles branch: [https://github.com/AnalyticalGraphicsInc/cesium/tree/3d-tiles](https://github.com/AnalyticalGraphicsInc/cesium/tree/3d-tiles)

You can see a code example for instancing models using that branch here: [https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/Apps/Sandcastle/gallery/development/3D%20Models%20Instancing.html](https://github.com/AnalyticalGraphicsInc/cesium/blob/3d-tiles/Apps/Sandcastle/gallery/development/3D%20Models%20Instancing.html)

And we have instructions for cloning and building the code base here: [https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/BuildGuide](https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/BuildGuide)

Best,

Hannah

---

<div class="post-metadata">

### Author: ![Frederic\_Brodbeck](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@Frederic\_Brodbeck](https://community.cesium.com/u/Frederic_Brodbeck)
#### Post date: [February 3, 2017, 6:22pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/3 "2017-02-03T18:22:46Z")

</div>

thanks a lot hannah. — what a difference that makes!

there is two new problems though:

1. picking does not work anymore

const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);

handler.setInputAction(

(action) =\> {

const pickedObject = scene.pick(action.position);

console.log(pickedObject); // → is `undefined`, although mouse pointer is definitely over a model

},

Cesium.ScreenSpaceEventType.LEFT\_CLICK

);

![Screen Shot 2017-02-03 at 19.21.59.png](https://global.discourse-cdn.com/cesium/original/2X/9/9500f3974d14bae58f062fb9965ea02fd93b4c26.png)

---

<div class="post-metadata">

### Author: ![sean\_lilley](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sean_lilley/32/2083_2.png) [@sean\_lilley](https://community.cesium.com/u/sean_lilley)
#### Post date: [February 6, 2017, 4:24am UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/4 "2017-02-06T04:24:08Z")

</div>

Yeah picking does not seem to be working for ModelInstanceCollection. Looking at the code I see the root cause but it may be a little while before I get to fixing it. I would like to revamp the system a bit to be able to pick instances and modify their model matrices, rather than the default picking behavior for models.

I’m not sure what’s causing the difference in color, are you able to send over the model you’re using?

---

<div class="post-metadata">

### Author: ![Frederic\_Brodbeck](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@Frederic\_Brodbeck](https://community.cesium.com/u/Frederic_Brodbeck)
#### Post date: [February 6, 2017, 9:40am UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/5 "2017-02-06T09:40:10Z")

</div>

> Yeah picking does not seem to be working for ModelInstanceCollection.  
> Looking at the code I see the root cause but it may be a little while  
> before I get to fixing it.

could you point me to what you think the root cause is?  
for the project I am working on I will definitely need picking – maybe I  
can have a stab at it.

> I would like to revamp the system a bit to be able to pick instances and  
> modify their model matrices, rather than the default picking behavior for  
> models.
> 
> I'm not sure what's causing the difference in color, are you able to send  
> over the model you're using?

not sure why it looked different before, but changing the diffuse color of  
the material fixed it.

---

<div class="post-metadata">

### Author: ![sean\_lilley](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sean_lilley/32/2083_2.png) [@sean\_lilley](https://community.cesium.com/u/sean_lilley)
#### Post date: [February 8, 2017, 5:24am UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/6 "2017-02-08T05:24:19Z")

</div>

The root cause is the model options set pickVertexShaderLoaded, pickFragmentShaderLoaded, pickUniformMapLoaded which override the model’s default picking behavior. However unless the ModelInstanceCollection is backed by a batchTable for Instanced3DModel3DTileContent the pick ids/shaders are not being set. I was going to look into this issue during the bug bash this week, but if I don’t get to it feel free to take it up.

---

<div class="post-metadata">

### Author: ![patrick](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/patrick/32/2045_2.png) [@patrick](https://community.cesium.com/u/patrick)
#### Post date: [February 10, 2017, 2:02pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/7 "2017-02-10T14:02:44Z")

</div>

This was added in [#4975](https://github.com/AnalyticalGraphicsInc/cesium/pull/4975) at the bug bash.

Patrick

---

<div class="post-metadata">

### Author: ![Frederic\_Brodbeck](https://avatars.discourse-cdn.com/v4/letter/f/c68b51/32.png) [@Frederic\_Brodbeck](https://community.cesium.com/u/Frederic_Brodbeck)
#### Post date: [February 10, 2017, 2:05pm UTC](https://community.cesium.com/t/can-gltf-model-geometries-be-combined-instanced/5111/8 "2017-02-10T14:05:15Z")

</div>

thanks so much!
