Open more model formats directly - #3694
Open
ewanhowell5195 wants to merge 30 commits into
Open
Conversation
opens as a generic model, reusing the importer from the obj dialog.
they were left visible on creation, so meshes built outside the usual draw flow rendered black points over every vertex.
binary formats were previously always read as text, in all four places that open a model.
adds the shared three.js to blockbench converter that the other formats reuse.
three misdetects and then chokes on ascii fbx, so it is sanitised before parsing.
their inherited compile returns an empty string, so saving would have blanked the file that was opened.
some loaders attach images through their own manager once parse has returned. decoding runs concurrently so a texture that never arrives costs one wait, not one per material.
the chevrotain parser it needs adds about 180kb to the bundle.
✅ Deploy Preview for blockbench-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
importing adds to the current project inside an undo step, rather than opening a new one.
matches the obj import dialog. gltf has no unit field, so files not authored in metres need this.
# Conflicts: # js/io/codec.ts # types/custom/codec.d.ts
|
There's an issue. The textures never load, presumably since the web version can't access local files that aren't chosen. In the web version, it should ask for the MTL and all the textures as well. |
Contributor
Author
|
Hey @EJD799, this is fixed now! If a model uses files that cannot be found, a dialog asks you to provide them. In the web version it asks for the MTL, and picking one adds any textures it needs to the same dialog. On desktop it only asks for files that are actually missing next to the model. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds direct opening for obj, gltf, glb, fbx, dae, stl, ply, 3mf, amf, 3ds, kmz, md2 and wrl, through normal file opening (Ctrl+O, drag and drop, recent files, file associations). They load into a generic model project.
OBJ reuses the importer from the OBJ dialog so it keeps its quads. The rest go through three.js loaders and a shared converter in
js/io/three_import.ts, and import as triangles.Codecs can now declare how their file should be read, since the binary formats were previously read as text.
GLTF and FBX are also in File > Import, with a scale option, adding to the current project inside an undo step instead of opening a new one.
The new formats are import only. Opening one deliberately does not set an export path, so saving cannot overwrite the source file.
Also fixes mesh vertex points being left visible on creation, which only showed on meshes built outside the usual draw flow.
The import OBJ dialog now fills in the MTL field from the
mtllibline or a matching file name.If a model uses files that cannot be found, eg an OBJ's MTL or its textures, a dialog now asks you to provide them. On desktop this only asks for files that are actually missing. The web version cannot read files that were not chosen, so it always asks. Picking an MTL in the dialog checks what textures it needs, and adds any missing ones to the same dialog.
Also fixes drag and drop in the web app, which has been broken for all file types since d68d6f1. Dropping a file crashed before any handler ran. This is because the drop handler calls string methods on the dropped files, and the web version has File objects rather than paths. There were two older bugs underneath that as well, meaning that on the live site every drop still throws an error in the console after the file loads.