How to wait for textures to finish loading from JSON model in Three.js?

前端 未结 3 1495
说谎
说谎 2021-01-19 01:45

I have a JSON model being loaded successfully based on AlteredQualia\'s skinning example. However, I would like to not reveal the model until it is finished loading. As you

相关标签:
3条回答
  • 2021-01-19 01:53

    This is currently not properly sorted out. At the moment there is no callback or event dispatched when everything is loaded :/

    0 讨论(0)
  • 2021-01-19 02:03

    This is a bit of a hack, but at line 10362 (revision 61) of three.js you will see image.onload = function() (it's in the main THREE.Loader prototype). I managed to track that down to be the callback function for loaded textures from JSON models.

    If you add your own callback inside that function you can track when textures are loaded.

    As I said before though, this is a hack (which helped me out a lot for a particular application) and not a solution, be very careful modifying the library code. You might break stuff you don't know you're breaking.

    0 讨论(0)
  • 2021-01-19 02:03

    This is a ridiculously stupid cheat, but it will work as a hack. I agree one needs to realize image loading and everything else at least separately, so things that don't need images aren't twiddling their little electronic thumbs. That said, if optimization ain't your problem......

    var texture = THREE.ImageUtils.loadTexture(url); 
    while (texture.image.width == 0);

    0 讨论(0)
提交回复
热议问题