-
Notifications
You must be signed in to change notification settings - Fork 320
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
Multi-scene export fails #1086
Comments
The error in case you want to jump right to line 39 of gltf2_blender_gather.py.
|
it seems like trying to export a .glb is totally broken when multiple scenes are present. I suspect the following code might be usefull.
|
the oddest part about this bug is if I delete all the other scenes from the blender file, then purge all orphan data, and then export with the exact same settings, the exported glb file loads fine.... |
interesting clue about why my gltf files won't load. it looks like blender is exporting every scene in the .blend file into each GLTF file, regardless if it's the active scene or not -or if the objects are visible. I think that might explain the chaos I'm seeing. since only the first scene draws, it can look fine when the glb file loads. But it's a false positive. if I ascii hack the multi scene gltf file to have only one scene, the three GTLFLoader can load it just fine. perhaps an "export only active scene" option might be worth considering. |
Ok. I think I found where the problem is. here's the ascii gltf comparison between the exact same cube scene exported from a blend file with only one scene present in the .blend file. the second file is exported with the exact same settings but from a .blend file with multiple scenes present. what's interesting is that both files look identical in https://gltf-viewer.donmccurdy.com/ and https://threejs.org/editor/ but the multi scene exported file will not load in the three GLTFLoader. |
It's not strictly related to the Blender IO, but there has been some discussion about "Multiple Scenes" in general at KhronosGroup/glTF-Sample-Models#242 (comment) , also pointing to KhronosGroup/glTF#1542 (I'm just mentioning this to avoid putting too much effort into something that might become obsolete at some point, but I'm not up to date with the latest discussions here, admittedly...) |
Well, The crash is not linked to multiscene... A check is missing... |
Describe the bug
a gltf exported from a .blend file that has multiple scenes in it will export every scene into the gltf, regardless if any objects are active. This will cause it the be larger file and cause it to not load correctly with three.js GLTFLoader. etc. Note: The export problems will only occurs when the active scene in blender is not the first scene.
it's also compounded by the fact that some gltf viewers will error and some will load just first scene, so you can think it's working when it's not.
also, there are bunch of secondary issues that seem related to this.
an assert when combining NLA strips
export_nla_strips=False will cause an assert when I have a blend file with multiple scenes and one of the scenes has no action associated with any of it's objects. I shored up this edge case and found other issues all stemming from this central issue.
an assert when applying modifiers
export_apply=True causes an assert. if only one scene is present, this works. if two scenes are present, and any scene but first scene is set to be the active scene, the crash on export will happen.
To Reproduce
Steps to reproduce the behavior:
load the attached blend file and run the script in the text editor. there are 4 scenes in the file. the first has no animation. the gltf gather action script is failing, likely because it wasn't expecting multiple scenes.
note the line comment at:
export_nla_strips=False # <-- Set False will crash or produce duplicate actions
you can also get it to happen in the GUI if you try and export from a scene and uncheck "Group by NLA Track" (same bool)
Expected behavior
I expect to be able to export all scenes and have only action per .glb file, and not have the hidden data from every other scene in the .blend file cluttering up the gltf file.
if no animated elements exist for one of the scenes, I expect it to still export without animation, or create an empy action animation. I do not expect it to crash. I'm writing a hack workaround to save a single keyframe in each scene before export to avoid this error. Be good if it were fixed properly given the awesomeness of GLTF and its likely ubiquity.
.blend file/ .gltf
gltf_crash.zip
Version
Additional context
I also note that I get the same error with apply modifiers. (see comment in text text editor of the blend file to make it happen)
note, if you animate anything in the cube scene (the fist scene, without any animation), the scenes will export and the error will not happen. however, if you inspect in the exported GLTF files, there will be 4 duplicate actions all named "action" instead of just the one action as expected.
The text was updated successfully, but these errors were encountered: