noname0310 / babylon-mmd

babylon.js mmd loader and runtime
https://noname0310.github.io/babylon-mmd/
MIT License
132 stars 7 forks source link

Texture load/shader compilation delay #11

Closed spencer17x closed 1 year ago

spencer17x commented 1 year ago

https://github.com/noname0310/babylon-mmd/assets/32794413/4d6939c0-af0c-4edd-8228-20df530a0945

When loading the model, he renders it white without textures.

spencer17x commented 1 year ago

Maybe you can use something like Promise.all to solve this problem?

noname0310 commented 1 year ago

use Append / AppendAsync (loading screen automatically appears):

SceneLoader.AppendAsync(
    "https://a-cdn.qbox.net/test/models/pmx/[MODELS]%20Lovesick%20girls%20ver.1/[LSG]%20Jennie%20(Miku)%20ver.1.pmx",
    undefined,
    scene
);

use ImportMesh / ImportMeshAsync (show loading screen manually):

engine.displayLoadingUI();

SceneLoader.ImportMeshAsync(
    undefined,
    "https://a-cdn.qbox.net/test/models/pmx/[MODELS]%20Lovesick%20girls%20ver.1/[LSG]%20Jennie%20(Miku)%20ver.1.pmx",
    undefined,
    scene
).then(result => result.meshes[0])
    .then(mmdMesh => {
        engine.hideLoadingUI();
        mmdMesh.receiveShadows = true;
    });

or use LoadAssetContainer / LoadAssetContainerAsync (There is a lag while loading without a loading screen)

SceneLoader.LoadAssetContainerAsync(
    "https://a-cdn.qbox.net/test/models/pmx/[MODELS]%20Lovesick%20girls%20ver.1/[LSG]%20Jennie%20(Miku)%20ver.1.pmx",
    undefined,
    scene
).then(result => {
    result.addAllToScene();
});
spencer17x commented 1 year ago

Can't importMeshAsync solve this problem?

noname0310 commented 1 year ago

It's in the answer I gave you

spencer17x commented 1 year ago

Other loader using import mesh async does not have this problem, should it also be solved?

noname0310 commented 1 year ago

Now things will go as you want. However, as it doesn't seem to be a particularly important factor, I won't update the version right now. Please let me know if this is a problem that needs to be solved urgently

spencer17x commented 1 year ago

If you think this can be fixed with pr, then I can try to bring up a pr.

noname0310 commented 1 year ago

There seems to be a misunderstanding It's already solved and I just haven't updated the npm package version yet

spencer17x commented 1 year ago

Are you referring to the problem of this issue? If yes, please inform me if there is any package to update npm, thank you

noname0310 commented 1 year ago

I mean I don't seem to need to do npm publish right now because the severity of this problem seems low

spencer17x commented 1 year ago

Yes, but I hope you'll let me know if this issue is fixed after the next npm package is released, which I think is an optimization

noname0310 commented 1 year ago

Okay, I'll let you know when 0.24.0 released

I plan to do a new release when this issue is resolved.

spencer17x commented 1 year ago

Nice bro! And i suggest that you use Link Commits to GitHub Issues, which will make it clearer which issues are resolved by which commits, and it will also help your project to be more robust and maintainable.

noname0310 commented 1 year ago

I think commit already linked this issue

https://github.com/noname0310/babylon-mmd/commit/88a059600e7776ca2a66b1c13f2bbca526cddc64

spencer17x commented 1 year ago

Nice,i saw it.

noname0310 commented 1 year ago

babylon-mmd 0.24.0 is released now. see CHANGELOG.md

spencer17x commented 1 year ago

Nice job! It is solved.