Skip to content
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

Issue with loading Pack File of remote assets and local assets simultaneously #7041

Open
Q16solver opened this issue Feb 12, 2025 · 1 comment

Comments

@Q16solver
Copy link

Q16solver commented Feb 12, 2025

Version

  • Phaser Version: 3.88.0
  • Operating system: Windows 11
  • Browser:

Description

Existing forum discussion: https://phaser.discourse.group/t/how-to-load-packfile-with-remote-assets-and-local-assets-in-preload/15141/7

So I essentially wanted to migrate some assets from the github repo to an external source (Azure Blob Storage), and found that there's no way to set the base url to just affect the pack file (seems like adding a baseURL to the json/trying out on listeners also doesn't work). Adding https:// to the filepack json also doesn't seem to do anything, it uses the baseURL (localhost:3000/local url). setBaseURL also inevitably changes the baseURL for local assets as well, as shown in the reproduction below. Is there any way that's been exposed by phaser to properly load both remote and local assets in the preloader? I also found that the types for pack function to be incorrect, it only allows url, when it also allows the pack object which is what I need to use as I cannot just use a url due to nuxt/phaser path resolution conflicts and also code style reasons.

Example Test Code

https://stackblitz.com/edit/github-gzbuzr-udsq5dxy?file=models%2FStartScene.ts

Please ignore CORS errors and check the console, it will load (200 OK) for all the remote resources currently, but not work for local asset (a google image) as setBaseURL as overriden the local url.

Additional Information

@samme
Copy link
Contributor

samme commented Feb 16, 2025

https://phaser.io/sandbox/opYdsCZ5

In the sandbox, a file pack section has baseURL https://cdn.phaser.io/sandbox/ and a file with url square-earth.png. It should be downloaded from https://cdn.phaser.io/sandbox/square-earth.png but instead it's downloaded from https://phasersandbox.com/square-earth.png.

I think the cause is that addPack() sets the loader's baseURL temporarily while adding files from a pack section, but for File files the loader actually applies baseURL when the file starts loading. (path is applied to a File URL when added, however, so setting path in a file pack section will work as expected.) MultiFile files may work differently, I'm not sure.

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

No branches or pull requests

2 participants