Skip to content

Conversation

@gkjohnson
Copy link
Collaborator

@yomboprime

Follow up to #16183.

We discussed this in the other PR but this updates the LDrawLoader to use asynchronous part processing to avoid stack overflow exceptions and to use lowercased keys in the cache so parts are not missed in the cache when referenced by different names.

This enables the loading of models that couldn't be previously loaded including:

10182-1 - Cafe Corner.mpd
image

10030-1 - Imperial Star Destroyer - UCS.mpd
image

@gkjohnson
Copy link
Collaborator Author

gkjohnson commented Apr 14, 2019

Here's an example from another branch that demonstrates loading some of the more complex models, which are hosted in a separate repo:

https://raw.githack.com/gkjohnson/three.js/fetch-ldraw-example/examples/webgl_loader_ldraw.html

You'll notice that they can be pretty slow to load. One way to speed this up would be to update the loader so that it can load multiple parts at once. At the moment I believe it requires waiting until the previous part is finished because of how scope is managed but maybe that can be updated in another PR. I'm also not sure if there are any rules for loading parts to know which folder it might be in ahead of time but it would be nice to not have so many failed requests when trying to search for a part.

Edit
I wonder if it would be worth allowing the user to load a "parts.lst" file (which is generated from the parts list in the /parts folder) to know whether to search the p or parts folder. That would help cut down on the number of failed fetches, I think.

@yomboprime
Copy link
Collaborator

yomboprime commented Apr 14, 2019

The utility in three.js/utils/packLDrawModel.js can be used already to speed up loading of models by packing all the needed files into one.

Another possibility that I thought when first doing this loader, and that is similar to your idea, was to set a path map in the loader previously to loading files. You can see how it works by searching for the variable fileMap, if the filename exists in the map, the path is taken from there. The user has to create this map, though.

Edit: There are no rules for the paths, the spec says a file can be in any of those library 'standard folders'

@mrdoob mrdoob added this to the r104 milestone Apr 16, 2019
@mrdoob mrdoob merged commit e8d4219 into mrdoob:dev Apr 16, 2019
@mrdoob
Copy link
Owner

mrdoob commented Apr 16, 2019

Thanks!

@gkjohnson gkjohnson deleted the ldraw-fixes branch May 10, 2019 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants