codingchili Posted November 21, 2020 Share Posted November 21, 2020 Hello, I'm using pixi 5 with pixi-spine trying to load resources from a cache implemented with indexeddb. All cached files are loaded into patch.files as either blob or text with matching xhrType. let loader = PIXI.Loader.shared.pre((res, next) => { // load files that has been loaded by the patcher. if (patch.files[res.url]) { res.xhr = patch.files[res.url].xhr; res.data = patch.files[res.url].data; res.xhrType = this._xhrType(res.url); res.complete(); } else { // not loaded by patcher, load on demand using xhr. if (!res.url.startsWith(application.realm.resources)) { res.url = application.realm.resources + res.url; } } next(); }); // loader.add("resource.json"); // loader.begin(...); Haven't found any good documentation on using the pre function, my problem here is that I get a hit on the "resource.json" in the cache, but "resource.atlas" and "resource.png" is never requested. This means I cannot access either the .atlas or .png resource using PIXI.Loader.shared.resources using this method https://github.com/pixijs/pixi-spine/blob/master/examples/preloaded_json.md This works fine when "resource.json" is NOT in the cache and there are no problems loading plain images like "clouds.png". Please help me, been struggling for a few days ? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 21, 2020 Share Posted November 21, 2020 > Haven't found any good documentation on using the pre function, Just debug it. or please give full demo, i can try debug Quote Link to comment Share on other sites More sharing options...
codingchili Posted November 21, 2020 Author Share Posted November 21, 2020 (edited) Found this, https://github.com/englercj/resource-loader/blob/release/3.x/src/middleware/caching.js I'll check the implementation. Seems like complete cuts out before middleware is run, which otherwise would have queued the other resources. Maybe I should just manually set the atlas/png resources on the loader when a json file is in the cache. Edited November 21, 2020 by codingchili Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 21, 2020 Share Posted November 21, 2020 Sounds true. whole loader is smart attempt making everything easy. but resource loading is not easy, there are many strange async things, so debug is the only way ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.