I’m not sure if I’ve found a bug or if I’m missing something. I’m exporting a GLB object from my own GLTF class, but if I include more than 1 scene in the json list Three.JS will not show the model. I have set the scene property (i.e. the default scene) to 0 so there should be no confusion.
I was using the GLTF extensions for Visual Studio code so I could also try other GLTF viewers like Babylon and Cesium and they show my model just fine, but since Three.JS is quite popular I would want it to be compatible as well.
So my question is basically does Three.JS GLTF viewer simply not support multiple scenes, or is there some special syntax for these scenes that I don’t know about?
Three.JS GLTF viewer
Do you mean threejs.org/editor?
three.js supports multiple scenes in a single glTF file, but I’m not sure whether the glTF VSCode extension (GitHub - AnalyticalGraphicsInc/gltf-vscode: This is an extension for Visual Studio Code to add support for editing glTF files.) embedded three.js viewer has implemented it, or implemented it correctly. We don’t maintain that extension here, but if the other engines in the extension support it and threejs doesn’t I’d recommend filing an issue on their github repository.
Thanks for your response.
You are correct that’s the VSCode extension I am talking about, I also had the same issue with the https://threejs.org/editor/ linked by @looeee and the https://gltf-viewer.donmccurdy.com/ (which I suspect you maintain?). If I change nothing else but add an extra scene (and specify that the default scene is 0, i.e. the same in both) nothing shows up when I try to import it.
If the edited multi-scene file passes validation (http://github.khronos.org/glTF-Validator/) then I’d suggest filing bugs on those viewers. I’ve never seen a file with multiple scenes in it before, so I created one and tested quickly on https://gltf-viewer.donmccurdy.com/ which worked fine, but the example was very simple.
Archive.zip (96.2 KB)
So indeed you are right for simple models, or indeed the project-polly model it seems fine.
So I am still having issues but not quite the same. So now it does render a scene, just not all the elements in the scene. So this only renders a head, but in the scene the hat should also be visible. If you remove the other two scenes, it correctly renders the head and the hat.
Since I’m not allowed to share this model publically I sent you a DM on twitter with a box link, could use some other non-public communication method if you want.
The model passes the GLTF validator (level 2 warnings which afaiu should not cause issues of this nature) and can be rendered correctly if there is only one scene present.
The issue here is that the different scenes are referencing the same nodes. The threejs loader only allows nodes to have a single parent, but i’m not entirely sure if it’s a bug in the loader, or if it’s disallowed by the glTF spec. I’ll look into that.