Occasionally when exporting I get the error
Unable to load from file:filename.glb: /meshes/0/primitives/0/material: Failed to find index (0)
This is shown when dropping the file into the babylon sandbox platform.
Any chance someone knows what’s this is about?
So I can try to avoid this in the future?
I guess you mean when trying to load the .glb by drag & dropping it into the sandbox?
Do you have a clue here @bghgary ?
Indeed that’s right.
It seems that I had turned on the
Try reuse texture option
Any idea what this is meant for?
When this option is turned off my model exports correctly and gets loaded without issues.
I’ve attached a previous file export which had the error.
05_basetest_issue_export_failedtofindindex0.zip (84.1 KB)
@bghgary and @PatrickRyan might know as well.
@Pieter_van_Stee, in looking at the json for your glTF I see a couple of things immediately. It seems from the naming of your primitives that you may have constructed your mesh from rectangle splines and then converted them since your meshes are named things like “Rectangle070”. I noticed in this workflow that when you add a
Turn to Mesh modifier on a spline there is no material automatically assigned to it. Exporting this mesh will export and render correctly, even though there is no material assigned and hence there will be no material in the export. The loader will realize that there is no material assigned to the mesh and assign a default material just so it can render correctly.
In the file that you linked, there are references to a material on each of your primitives:
But there are no material definitions in the glTF file. This is why you are getting the error but I have no idea how you are getting into this state. If you don’t have any materials in your scene, you won’t get a material reference on a mesh and no material definition exported. If you do have a material assigned to a mesh, it will create the reference and definition in the export.
Can you explain how you are creating your meshes and assigning your materials? I not sure this has anything to do specifically with
Try reuse texture. As I remember, this parameter will try to see if a single texture is assigned to multiple material inputs and then export the texture only once. This may be exposing an incompatibility in your file, but I am curious how your file is built to understand the problem better.