GameMonetize Posted October 31, 2016 Share Posted October 31, 2016 Anytime, even if I implement the cache at BJS level Quote Link to comment Share on other sites More sharing options...
royibernthal Posted October 31, 2016 Author Share Posted October 31, 2016 Why is that? If you implement my suggestion at bjs level it should be smooth from the first load no? If not, why? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 31, 2016 Share Posted October 31, 2016 The first load will sill go to the server (I cannot generate value from scratch :)) then subsequent load will be smooth (And I'm not sure we could save a lot from the browser cache) Quote Link to comment Share on other sites More sharing options...
royibernthal Posted October 31, 2016 Author Share Posted October 31, 2016 Of course, but we will be able to track the loading progress properly and avoid loading the texture twice. The raw data can be uploaded to the GPU on the first load. At the moment what's happening at the first load is, when all the assets are loaded, the CubeTexture is not really ready, so you have no true indication when you can start the game/app. The texture is being re-downloaded upon the creation of the CubeTexture instance in order to fetch the raw data which was previously ignored and upload it to the GPU. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 1, 2016 Share Posted November 1, 2016 You have an indication: myCubeTexture.isReady Quote Link to comment Share on other sites More sharing options...
royibernthal Posted November 1, 2016 Author Share Posted November 1, 2016 Does it dispatch an event when ready? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 2, 2016 Share Posted November 2, 2016 You can provide a onLoad callback: https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/Textures/babylon.cubeTexture.ts#L15 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted November 4, 2016 Author Share Posted November 4, 2016 Great, I guess this could work as a workaround. Thanks. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 7, 2018 Share Posted September 7, 2018 On 8/8/2016 at 12:59 PM, Deltakosh said: Actually Babylon.js keeps a cache of loaded texture. So if you already loaded the textures then bjs will no try to load them again as they are already in the cache. If this is not what you have please create a repro in the playground and I promise to fix it Hey DK, I seem to be running into this problem. In one scene my player must choose a texture then it needs to be present in the next scene. So what I want to happen is: I load the first scene with the textures, then my player chooses, then I load the textures in the second scene where It shows the texture again. But what actually happens is: I load the first scene with the textures, then my player chooses, then I load the textures in the second scene but the textures do not show. I believe that Babylon.js is not loading the textures for the second scene however I need the textures in that scene. Is there a way I could get around this? Note: neither of my scenes are up permanently so I cannot just leave the textures in one scene then reference them from the other scenes, since when I dispose of the scene it should dispose of the texture. Im stumped ? Maybe assetManager is what I need, I will look into that in the mean time Quote Link to comment Share on other sites More sharing options...
Guest Posted September 7, 2018 Share Posted September 7, 2018 Well, how do you load the textures in the second scene? Can you share a repro in the PG (ideally) or at least share some code? DylanD 1 Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 11, 2018 Share Posted September 11, 2018 On 9/7/2018 at 6:59 PM, Deltakosh said: Well, how do you load the textures in the second scene? Can you share a repro in the PG (ideally) or at least share some code? Hey DK, sorry for the late response. well i use the same class in both scenes for the code, i just use: this.Textures = []; this.Textures.push(new BABYLON.Texture("Textures/yellow.png",this.scene)); this.Textures.push(new BABYLON.Texture("Textures/red.png",this.scene)); this.Textures.push(new BABYLON.Texture("Textures/orange.png",this.scene)); maybe a few more into that array but that is the general idea. To explain more, this is in the constructor of a class which i call at the start of each scenes creation function. Scene 1 is created and shown then in the background i have scene two being created, which includes having this class be instantiated. So when i have these textures already instantiated i try to access them again to load into a different scene. But they don't seem to load in that scene at all. The only work around i can think of is putting these textures in my sceneManager class then just changing the scene variable in them, then passing them through the class constructor, but i'm not sure that will work, i am going to try that now. Any other ideas? Thanks, DD edit: age old problem of many scripts and it confidential Quote Link to comment Share on other sites More sharing options...
Guest Posted September 11, 2018 Share Posted September 11, 2018 Well this should work Can you repro something similar in the PG? Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 11, 2018 Share Posted September 11, 2018 6 minutes ago, Deltakosh said: Well this should work Can you repro something similar in the PG? Hey i just finished up trying to put all of the textures in my sceneManager class but i still get the problem of i cant switch the scene of the texture. You say it should work though eh? Maybe im doing something else wrong. Could it be that they are both trying to access the files at the same time and the second one cannot access it becuase the first one is currently accessing it(therefor it just doesnt load it at all)? Also i can try to make a PG but im not sure i have the time to create it. Gotta go to school soon Quote Link to comment Share on other sites More sharing options...
Guest Posted September 11, 2018 Share Posted September 11, 2018 This could not be a race condition issue (Or really hard to believe :)) Please create the repo when you can, that will be the easier way to help you Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 13, 2018 Share Posted September 13, 2018 On 9/11/2018 at 2:12 PM, Deltakosh said: This could not be a race condition issue (Or really hard to believe :)) Please create the repo when you can, that will be the easier way to help you Hey not sure if this helps you guys understand the problem, but what is really strange is that this only happens on the first go. Let me explain So i have a customization menu and they choose which texture they wear, it has a preview of the texture on your character, which works great, in the background the game scene is being loaded, after they choose a texture they can hit start then the game scene is shown but the texture does not load(although i have tested it and it tries to apply the texture but im guessing the texture hasn't loaded in time), then you lose and go back to the menu. After that first sequence the textures are applied fine if you do the same sequence again, my hypothesis is that by then they are cache somehow, so no need for new loading. Just gotta get it working for the first sequence. I believe this is just a problem with how i have my code structured but if you have any ideas let me know. Thanks, DD Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 13, 2018 Share Posted September 13, 2018 is there a way i could do something like : new texture = texture().then( new texture2 = texture() ); so that after the first textures are loaded then second textures load? Quote Link to comment Share on other sites More sharing options...
DylanD Posted September 13, 2018 Share Posted September 13, 2018 Alright the wild goose chase is over, i had depreciated code, which was i had an older function freeze the material the texture is on, to save performace(i thought that would help, from what i understand it would but not very much...) once i took out that material.freeze() it started working perfectly! Sorry everyone for the goose chase Thanks everyone for helping though! Quote Link to comment Share on other sites More sharing options...
Guest Posted September 13, 2018 Share Posted September 13, 2018 No worry! The important thing is that you found the issue DylanD 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.