Closed SolarLune closed 1 year ago
OK, so I tested again and it doesn't have to be an instanced collection - any object can be in the second scene. If you export from Scene A, then both scenes will have the cube from Scene A. If you export from Scene B, then both scenes will have whatever object is in Scene B.
Hello, Can you please share the .blend file(s) You zip contains only the glTF. I need the .blend file to reproduce your issue. Thanks!
Whoops, my mistake! Here you go:
Just to sum up the problem demonstrated in this blend file:
When exporting a GLTF file from the menu, everything's fine.
However, when exporting a GLTF file from an operator, the objects exported for each scene are just duplicates of the ones in the current scene.
To see this, unzip the blend file and run the "Text" script. Press the "test export" button in the object panel, and examine the outputted "exportTest.gltf" file (which will be in the same directory as the blend file wherever you unzipped it). The object information in the GLTF file will be incorrect for whichever scene is not selected when exporting.
Confirmed
Hey, thanks for fixing this - I tested out the fix and it resolves the issue. Thanks a lot!
Hello! First of all, thank you all for the work you do in maintaining and working on the GLTF exporter - it's a real life-saver when it comes to getting data out of Blender in a comfortable and customizeable way. Really appreciate it!
As for the core issue, I'm running into this problem with my add-on that makes use of the GLTF exporter for my homemade 3D renderer, Tetra3D. I'm running Blender 3.2.1, with the packaged GLTF exporter.
When I export a GLTF file from the menu, the resulting file seems to be fine. However, when I call to export a GLTF file from the exporter operator (either triggered through GUI button press or through a save_post handler), the exporter doesn't export the right objects in the right slots (in this particular example, collection instances across multiple scenes). I believe at its core, the GLTF exporter isn't looking at the scene it should be when exporting through an operator, and may be tied to issue #1073 - I'm not sure on this one.
Here's a simple example blend file that exemplifies the issue - I have a Cube in Scene A, and in Scene B a collection instance of that same Cube.
exportTest.zip
If you export the blend file as a GLTF file from the menu, you'll get something like this:
Which is, to my understanding, correct. However, the bug arises when exporting through the
bpy.ops.export_scene.gltf()
operator. So, I've also packaged in the blend file a script that you can run in the text editor that will add a "test export" button to the object's Properties panel, which you can press to export the GLTF file through code (to a file namedexportTest.gltf
) and thereby recreate the bug. Pressing the button will export the GLTF file as before, but the contents will be incorrect and change depending on which scene you have selected.If you have Scene A selected, you'll get this output:
Note that the instanced collection is no longer there.
If you have Scene B selected, you'll get the following output:
Note here that both objects have been replaced with instanced collections.
Also, in both of the above outputs, the "scene" property is incorrect and points to the last scene in the blend file, rather than whichever one you have selected when running the operator.
As an aside, in my own testing, I don't believe this is a problem if you run the operator with the mouse hovering over the 3D view, which may help to indicate where the issue may lie.