-
Notifications
You must be signed in to change notification settings - Fork 63
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
add gltf.openGlbFile #222
base: master
Are you sure you want to change the base?
add gltf.openGlbFile #222
Conversation
Oh wow, this got buried in my GitHub notifications overload, but it looks impressive, thank you! I'll try to get this reviewed soon. @bghgary if you or a coworker would be willing to take a look, feedback welcome. Thanks! |
@ousttrue This is pretty amazing, thank you. I do have a concern about one aspect of the new behavior here: "Save As." When you load a GLB file, it shows the JSON portion of the file in a read-only editor. But if you click "Save As..." on that read-only editor, it will save the JSON only to a new file. The new file is likely to have a .GLB extension with JSON-only contents, which is not good, and the new file will be missing all of the mesh, textures, and other binary data from the original GLB file, which means it's invalid regardless of which file extension it uses. Is there any way to control the behavior of the "Save As" function here? Or could we somehow avoid opening the text editor at all, and just show the 3D preview window, or show an option to run the GLB to glTF importer on it? I'll think about all this more too, but if you have any ideas on this I'd be eager to hear. |
@emackey Since GlbProvider supplies json chunk of glb, I added ".json" to path to make it clear that the content is json. |
I probably can't review this any time soon, but I will put it on my list :-) |
@emackey Since there is no recent activity I am going to ask this: Is there any chance of this ever being merged so that we can easily look at .glb files exported from Blender? |
While I love the ease of GLB previews here, I'm very concerned about giving users a writable (after Save-As...) copy of the raw JSON from within the GLB itself. Most users don't know or realize that the JSON in a If users really want to examine and possibly edit the JSON document, they should really use the "Import from GLB..." option instead of this, so they receive a valid glTF as an editable file, that the glTF Validator can confirm. They can then use "Export to GLB..." when done hand-editing, which will will produce a new valid GLB file, unlike what might come from hand-editing the JSON directly in a GLB. Maybe there could be a read-only GLB 3D preview that doesn't show the JSON, but offered the "Import" button as a way to get the valid JSON? That preview is really great, but users are going to shoot themselves in the foot if we give them raw GLB contents that haven't been properly imported. |
@emackey how about you just combine the two steps you suggest (1. Import, 2. Preview) in a single convenience command. Also when doing so you can just open the resulting. gltf file in the editor without storing it (if that is possible). So the user does not have to deal with deleting that temporary copy or having another file with the same name accidentally overwriten. Then if he DOES decide he wants to save it he can still press Ctrl+S on it. |
It's a good thought, but the process of importing writes multiple files to disk. The JSON alone could be an unsaved preview, but it needs to have a relative path to a saved There's actually a way to base64-encode all that into the temporary unsaved JSON, but for real-world models the resulting hunk of text is too large for VSCode to offer in its text editor window. Saving those data files to disk, and referencing them using relative URI paths in the imported JSON, is the only reliable way to import a GLB into an editable window. |
Can't you write all or some of the files to tmp maybe? |
This pull request implement #218.
I was able to implement a glb preview by manipulating the offset so that the
buffer view
references the glb's bin chunk.context_menu