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

Feat: document Assets loader option #103

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/guides/components/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ Out of the box, the following assets types can be loaded without the need for ex

More types can be added fairly easily by creating additional loader parsers.

## Working with unrecognizable URLs

With the basic syntax, asset types are recognized by their file extension - for instance `https://pixijs.com/assets/bunny.png` ends with `.png` so `Assets.load` can figure it should use the texture loader.

In some cases you may not have control over the URLs and you have to work with ambiguous URLs without recognizable extensions. In this situation, you can specify an explicit loader:

```js
promise = Assets.load({
src: 'https://example.com/ambiguous-file-name',
loader: 'loadTextures'
})
```

Here are some of the `loader` values you can use:

- Textures: `loadTextures`
- Web fonts: `loadWebFont`
- Json files: `loadJson`
- Text files: `loadTxt`

## Warning about solved promises

When an asset is downloaded, it is cached as a promise inside the `Assets` instance and if you try to download it again you will get a reference to the already resolved promise.
Expand Down
Loading