aframe
aframe copied to clipboard
Cache Source instead of Texture instances in material system
Description:
Final part of #5449, resolving #5441, #5120, #1372. Instead of caching textures and trying to do reference counting, the underlying Sources are cached instead. Actual reference counting is done by Three.js internally, which allows the same texture source to be shared with multiple textures, even if they differ in offset or repeat (which before would result in uploads).
This PR also improves the disposing behaviour, which previously only disposed when the material unregistered itself from the material system, missing any textures that were no longer assigned to that material. This also means that since Texture instances aren't shared, they can be changed by users without affecting other textures, while still using the same underlying image.
Changes proposed:
- Let
systems/materialcacheSourceinstances instead of Textures - Let helpers in
utils/materialrequest theseSourceinstances and create/update the material'sTextureinstance
This need rebase
@dmarcos Rebased
Thanks. So much good work.