I’m working with huge PNG’s that are used as Sprites. Then I change the UV system to show the parts I need. The problem is that I get a huge impact in memory after adding multiple sprites of this kind. I don’t know how to reuse the same texture and change the UV of each sprite.
How are you settling the UVs currently? On the Texture itself? Also how are you loading the Textures and associating them with Sprites? A few code samples may get you a more specific answer.
In the meantime, one suggestion is if you happen to be using TextureLoader multiple times for the same image, don’t do that, but instead use Texture.clone which is a shallow copy sharing the image data (but with its oen separate UVs).
Oh wow, I didn’t know that! Thanks for the tip, that’s a big deal!
So I guess now the question is how to set the UVs of either Sprite or SpriteMaterial. I don’t see an obvious way in the docs, but if you look at the Sprite.js source it has a BufferGeometry on the inside so maybe you can change the UVs there?
All sprites share the same geometry object which is located in the module scope of Sprite.js. The engine assumes that users do not touch this object. Hence, you will be on the safe side by using plane geometries.
You mean on geometry level? There are no actual uv parameters but just texture coordinates defined as instances of BufferAttribute. So you have to learn how BufferGeometry works in order to get familiar with creating custom texture coordinates.