# 3dsmax exporter to gltf with instances

**URL:** <https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381>\
**Category:** Content creation (3dsMax, Maya, Blender, glTF)\
**Created:** [December 4, 2019, 5:47pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381 "2019-12-04T17:47:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 4, 2019, 5:47pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/1 "2019-12-04T17:47:24Z")

</div>

Hi all,

I’m currently working on a project and exporting from 3dsmax to gltf with the babylon exporter (versino v20191203.3).

I’m using lots of instances in order to minimize the size of my gltf file. I think that the exporter used to skip instances (or at least export only one of them) in order to save filesize so the gltf file would be the same size if I had one object or 10 times the same object instanced.

It doesn’t seem to be the case with this version anymore.

Did anyone run into that issue?

Thanks!

Chris

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 4, 2019, 5:48pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/2 "2019-12-04T17:48:05Z")

</div>

Pinging @Drigax

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 6, 2019, 5:00am UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/3 "2019-12-06T05:00:42Z")

</div>

Thanks for the report @christopheC,

I ran the latest exporter against my Instance testing scene, but I don’t notice any regressions. What specifically is happening with your instance export? Do you have a scene that may show this?

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 6, 2019, 8:30pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/4 "2019-12-06T20:30:24Z")

</div>

Hi Drigax,

please see on Mediafire a few files that you can use to reproduce my problem.

> **[MediaFire](https://www.mediafire.com/folder/k7smyi9ljhsxq/191206)**
>
> MediaFire is a simple to use free service that lets you put all your photos, documents, music, and video in a single place so you can access them anywhere and share them everywhere.

InstancesToExport.max contains grouped geometries which I instanced and am trying to export  
“one floor.gltf” and “one floor.bin” is the export of only one floor and is 880kb  
“all floor.gltf” and “all floor.bin” is the export of all the floors and is 12mb

My understanding is that the exporter would leverage the power of instancing and only export a file a bit bigger than 880kb (basically only one floor) and then instance/clone the rest back in Babylon.

Please let me know if you have any question.

Thanks,

Chris

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 10, 2019, 1:54am UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/5 "2019-12-10T01:54:02Z")

</div>

Thanks for sharing. This looks like a blast from the past in [Instances with unique materials not working if exported in one file · Issue #541 · BabylonJS/Exporters · GitHub](https://github.com/BabylonJS/Exporters/issues/541), where we preserved instances, but only for meshes that don’t share materials. At the time, I assume that the babylon engine did not fully support mesh instances that did not share materials.

Not the best solution in retrospect.

@Deltakosh, what are the current limitations of instances in Babylon? Should we modify the format to add an “overrideMaterialId” field to mesh instances that contains a material GUID to support this case? It would also make it trivial to support proper instances in glTF as well.

otherwise, it would also be easily addressable by adding this field to be exporter-only, to pass to the glTF exporter

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 10, 2019, 3:51pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/6 "2019-12-10T15:51:04Z")

</div>

Instances must share the same material of their root. If they are not sharing the material then we must clone them and this is less efficient

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 10, 2019, 4:16pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/7 "2019-12-10T16:16:41Z")

</div>

Thanks for the info. The objects I’m trying to instance do share the same materials though so I’m not sure why it behaves this way.

I created the main object, applied a material and then instanced it so they should be exactly the same.

Chris

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 10, 2019, 4:43pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/8 "2019-12-10T16:43:00Z")

</div>

Yep this is the correct expected behavior

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 10, 2019, 6:17pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/9 "2019-12-10T18:17:09Z")

</div>

so should all these objects be imported as instances or as copies (in which case the file size is much bigger)?  
Currently they seem to be imported as copies as the filesize increases by the amount of geometry I export.

I would expect that only one piece of geometry is exported by instance.

Please let me know what you think.

Thanks,

Chris

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 10, 2019, 6:26pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/10 "2019-12-10T18:26:13Z")

</div>

I agree with that expectation, if they’re all sharing material and textures and are configured as instances in 3dsMax, then they should be exported as instances as well.

I’ll have to look at our export process to see why this isn’t the case.

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 11, 2019, 12:35am UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/11 "2019-12-11T00:35:09Z")

</div>

Hi @christopheC, looking at the scene, I’m not sure if the meshes are properly instanced:

If I compare with my test scene, I am able to select a single mesh in scene, and using Edit-\>Select instances to select the rest of the meshes in scene.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/c/c741a9709d973ed52e90ac66320df2f9d17b709b.png)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/7bdab8692a644c3baf25091928073d0ab12ed8fc.png)

But I don’t seem to be able to do the same for any mesh used in the scene you shared:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/5/5b61127a3f292ad60f04be0f14c5f446979c7452.png)

Can you double check to see if your meshes are properly instanced in the 3dsMax scene?

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 11, 2019, 2:30pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/12 "2019-12-11T14:30:44Z")

</div>

Hi Drigax,

By default max won’t allow you to select instances of multiple objects selected (not sure why).

 ![Multiple instances selection A](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/b/b145b347bac2a86107c28fcdc534f8914de5e824.jpeg)  
In this example I have a box and a sphere which I instanced a few times. If I select one instance of each the menu is greyed out.

 ![Multiple instances selection B](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/e/e6bfd4f76d5876e74d1bdad1f45ed8f5eed5ff55.jpeg)  
In the same context if I only select the box then I can select its instances.

In my file, each floor is a grouping of several objects which is why 3dsmax won’t let you select instances this way. If you were to open or explode the groups and only select one object then you’ll be able to select its instances this way.

I’d ideally like to preserve my groupings as it should allow me to make floor selections more easily.  
I did try to break the groups and do an export but the instances are still not exported properly.

Thanks for your help on this.

Chris

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 11, 2019, 5:50pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/13 "2019-12-11T17:50:49Z")

</div>

Hey guys,

I have a problem which I think is related to the instancing export from 3dsmax.

Please let me know if you’d prefer me to open a new thread for it.

I’m working with instances of multiple floors of a tower. Each floor is a group of object (mullions, floor, walls, glass, etc.)

What I’d like to do is that when I click on one of the floor, all of the other ones disappear.

My problem is that it seems like babylon is hiding some objects when I run the script that it shouldn’t.

Please let me know what you think or if you see a better way to do it.  
[https://playground.babylonjs.com/#BA2ASU#1](https://playground.babylonjs.com/#BA2ASU#1)

Thanks,

Chris

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [December 11, 2019, 6:16pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/14 "2019-12-11T18:16:12Z")

</div>

Ping @Drigax

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 11, 2019, 9:18pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/15 "2019-12-11T21:18:51Z")

</div>

Hey again Chris!

Regarding your playground scene, I made some modifications to the visibility setting logic, instead of setting visibility, I use the isVisible property to control this, I also added some logic to make it easier to test by resetting the visibility of all floors on nothing being picked. (this second behavior may need to be tweaked, we don’t want to reset visibility when the user click+drags) Is this closer to the behavior you want?

[https://playground.babylonjs.com/#BA2ASU#2](https://playground.babylonjs.com/#BA2ASU#2)

Regarding the 3dsMax export step, I think I understand what’s happening now. The materials used for my test scene were too simple, you use a Shell material in your scene, and that tricks the exporter, as we then export the meshes using the baked material input, but compare against other meshes in scene using that material, so each mesh is still exported.

I’ll open [Instances of Meshes using Shell materials are exported as separate meshes. · Issue #709 · BabylonJS/Exporters · GitHub](https://github.com/BabylonJS/Exporters/issues/709), I’m almost done with a fix, so I should be able to address this shortly.

---

<div class="post-metadata">

**Author:** ![christopheC](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/christophec/32/19780_2.png) [@christopheC](https://forum.babylonjs.com/u/christopheC)\
**Post date:** [December 11, 2019, 9:39pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/16 "2019-12-11T21:39:03Z")

</div>

Thanks Drigax that’s exactly what I was trying to do and the problem for the exporter does make sense.  
I guess until that is fixed I can just apply the baked material on to my object instead of the shell to bypass the issue.

When it comes to isVisible and visibility, what’s the main difference? does visibility impact other instances when isVisible only affect one object?

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 11, 2019, 9:39pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/17 "2019-12-11T21:39:54Z")

</div>

I’m not totally sure. hey @Deltakosh, why should we use isVisible instead of directly changing visibility?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [December 11, 2019, 9:59pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/18 "2019-12-11T21:59:10Z")

</div>

isVisible is a boolean: Fast but does not allow intermediate value. Visibility === 0 is equivalent to isVisible === false

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 11, 2019, 10:22pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/19 "2019-12-11T22:22:49Z")

</div>

Ok, @christopheC fix is going out soon. I just tested your scene against my fix, and we’re down to 880kb buffer size!  
[allFloors.zip](https://forum.babylonjs.com/uploads/short-url/snJxn3AWwYwSC92T9Cvihq3s0KC.zip) (162.5 KB)

---

<div class="post-metadata">

**Author:** ![Drigax](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/drigax/32/16585_2.png) [@Drigax](https://forum.babylonjs.com/u/Drigax)\
**Post date:** [December 11, 2019, 10:31pm UTC](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381/20 "2019-12-11T22:31:13Z")

</div>

Fix is available now:

> **[BabylonJS/Exporters](https://github.com/BabylonJS/Exporters/releases/tag/Release20191211.8)**
>
> Exporters for Babylon.js and gltf file formats. Contribute to BabylonJS/Exporters development by creating an account on GitHub.

[Next page](https://forum.babylonjs.com/t/3dsmax-exporter-to-gltf-with-instances/7381.md?page=2)
