playcanvas / playcanvas/engine
AssetRegistry.getByUrl() returns wrong asset type for same URL (texture vs cubemap)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Hi team,
I encountered an issue with AssetRegistry.getByUrl() when working with cubemap assets:
A PNG file URL is used for both a texture asset and a cubemap asset in the registry.
getByUrl(url) only returns the last added asset (e.g., texture instead of cubemap), even though the cubemap asset with the same URL exists.
Since _urlToAsset is a Map that overwrites entries with the same URL, getByUrl() can’t distinguish assets by type, which makes it impossible to reliably retrieve cubemap assets via URL (a common use case for skyboxes).
Is there a recommended way to get an asset by URL + type (instead of just URL) to avoid this conflict? Or could getByUrl() be enhanced to support type filtering?
Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at AssetRegistry.getByUrl() and inspect how the _urlToAsset map is populated when the same PNG URL is used by texture and cubemap assets. Reproduce the collision, then determine the intended type-filtering behavior; done means URL lookup can reliably select the requested asset type without overwriting alternatives.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100