-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Editor - broken LDRAW support and missing PDB support #26279
Comments
To me, the code required for loading PDB files is too extensive. And since the loader is quite special, I would leave it out until more user request it. Regarding the LDRAW issue, it seems the support in the editor broke with |
Okay, the import should work again. However, there is a runtime error when the editor tries to save the scene after the import.
This only happens with LDRAW models. Other loaders work fine. To be clear the runtime error prevents a safe so when you reload the editor the model is gone. |
The serialization issue also happens with versions earlier than /cc @gkjohnson For testing: https://rawcdn.githack.com/mrdoob/three.js/dev/editor/index.html |
If I am not wrong, without using @gkjohnson parts repository will have the editor be limited to loading only pre-packed I only created this issue so it could be looked at. You guys can handle it and close this at any time. |
Yeah, loading is possible again and that is the most important thing. However, it would be nice if the loader works like any others inside the editor. So let's keep the issue open until it is clear where the error message in #26279 (comment) comes from. |
@gkjohnson When I delete the I have deleted the user data fields with below code. Just put it in if ( data.scene.materials ) {
for ( const material of data.scene.materials ) {
delete material.userData;
}
} |
It looks like the companion edge and line materials are stored in the |
I think the easiest solution is to make the classes If not, then another solution is to put the |
What was the reason for putting the materials into |
A model material related to a mesh has associated the material for the edge lines of the same object. This one in turn can also have associated a conditional edges material (edges with a sort of back-face auto-culling) This is only needed for building the model while parsing so perhaps the second solution I proposed is the best one (I can give it a try) I did put them in If the class |
Another simpler solution is to wipe the |
Okay, thanks for the explanation! Storing things in |
Ok, I'll do the wipe thing at the end of parse in some days. |
It was easy. I've made it by cloning the material (before cloning I unhang temporarily the non-serializable fields, there are only 2 of them) This has the benefit of not touching the materials in the loader library, so the loader is not affected and can be used to parse more files. In
cc @gkjohnson Do you see it okay? |
It might make sense to index the materials differently in the future but this looks good. It might also make sense to |
I was unsure if |
@Mugen87 , this is just an FYI related to PDB support. All of the previously mentioned code can be moved to the PDBLoader.js file itself, which would leave the Loader.js related code as:
Below is my version of the modified PDBLoader.js file just so you can see how I went about changing it (this code can probably be further simplified / improved):
|
Yeah they'll be kept around because you've assigned them to other local variables. |
I'll do a PR with the change. |
@yomboprime Are you still planing to make the PR? I've tried to apply the patch from #26279 (comment) but it didn't solve the runtime error. I've updated Changeset: Mugen87@dc13051 |
@Mugen87 Sorry for the delay, I tried to make the PR but had some git mess/issues. Then came the hot summer. The weak maps seem good idea, although the former solution seems to me simpler and more readable. cc @gkjohnson |
I'll tried it first however it didn't completely solve the issue. I still got runtime errors during serialization. |
All right then, go ahead. |
Description
Using online editor to load LDRAW file ends in error (both Firefox and Chrome browsers on Windows).
The 1st code below is actually what works for loading LDRAW files, with additional .DAT and .L3B formats + using @gkjohnson repository + removed
undefined
parameter from theloader.parse
function call.The 2nd code shows what works if PDB format is to be considered for inclusion, which is mainly the code extracted from the
webgl_loader_pdb.html
example.I can submit a PR if this code is acceptable.
Reproduction steps
https://threejs.org/editor/
Code
Live example
Screenshots
No response
Version
r153
Device
Desktop
Browser
Chrome, Firefox
OS
Windows
The text was updated successfully, but these errors were encountered: