Thark Posted September 7, 2017 Share Posted September 7, 2017 Hey everyone I just have two simple question I cannot find an answer too.First Question: The SpriteManager needs a capacity parameter, but why does it need this? Why can I not change this during runtime? What does it actually do (in the background) (except for just not showing any sprites that exceed the capacity)? Does it hurt performance at all if I just put a 'crazy' high number? Can the manager not just +1 the capacity by itself in the background whenever an instance of the sprite is created? It just seems so odd that I have to give it a number and I feel like I'm missing something here. My second question is how to exactly use the AssetsManager for sprites. The documentation gives this example: var imageTask = assetsManager.addImageTask("image task", "img.jpg"); imageTask.onSuccess = function(task) { console.log(task.image.width); } But that doesn't explain how to use it with a Sprite since the task returns an image, and a SpriteManager only requires an image url. Thank you in advance! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted September 7, 2017 Share Posted September 7, 2017 Hello! 1. Capacity Capacity is used to dimension GPU resources: https://github.com/BabylonJS/Babylon.js/blob/master/src/Sprites/babylon.spriteManager.ts#L82 It is useful because sprites rely on GPU resources like vertex buffer and we cannot just recreate one every time you add a sprite. So instead, we start with a big buffer that we fill until we reach the capacity 2. You can stil rely on the assetsManager because the image will be in the cache when onSuccess will be called Thark 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.