I think preloading is some weird concept from the olden days. I think there were even libraries for “preloading” stuff (what stuff i dont know, i think images and what not).
Im wondering if it’s pre something, what is it pre to.
I think the meaning of “preloading” (in this case) is that @Hoodgail_Benjamin wanted to get the model ready in advance, so that it would be available to render immediately when needed by the application. More than one way to do that of course.
… i was thinking of saving the obj data in a variable and obj.load would load it from that variable
and it would not have to keep loading it from the url each time its requesting it
Am i misunderstanding something or @donmccurdy example is missing an async/await statement. I don’t see much that could be done with the model var until it is set some time in the future.
There are many ways to do this. Promises, async/await, callbacks, etc. I’m not suggesting that those four lines of code are a production-grade preloading system, but a vague question gets vague answers. Seems like the OP is on the right path.
@Hoodgail_Benjamin don’t use base 64 if you don’t have to, it is slow. If you can store the load() output object, rather than the raw string from the OBJ, you’ll avoid the cost of parsing the string every time you need a copy of the object. Just load it once and .clone() to make copies.
The goal is to do [some action] in advance, so that — much later — when the application needs to add a resource to the scene, that resource is already available (aka “preloaded”) and can be added very quickly.
Yes, you could use async/await and have callbacks to know exactly when that resource is ready, and do something then, but I think all that is more detail than has been asked for.
I I probably am lol. On that note, are all of threes loaders basically pre loaders?
With webpack I can see the scenario the op later described. Instead of copying a static asset you can embed it into the js or even the html. This would cause a truly preloaded asset in my mind, as you finish downloading the code, the asset is already available.
All other scenarios though, fall under just… loading?