Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collada Loader Caching Too Much #42

Open
anlumo opened this issue Jul 10, 2011 · 2 comments
Open

Collada Loader Caching Too Much #42

anlumo opened this issue Jul 10, 2011 · 2 comments

Comments

@anlumo
Copy link

anlumo commented Jul 10, 2011

In my web application it is necessary to remove the WebGL view and create it again without reloading the page inbetween. I discovered that I can't reuse the mesh or material instances, I have to create them again.
I'm building some objects manually, and there it works fine that way. However, Collada objects don't work on the second try (no error, but nothing is displayed).

This is caused by local caches in GLGE.Collada which store old meshes and materials that aren't valid any more when creating a new rendering context. I implemented a temporary workaround:

GLGE.resetColladaCaches = function() {
    meshCache = {};
    MaterialCache = {};
    actionCache = {};
};

This has to be somewhere at the bottom of glge_collada.js. I just have to call this function after removing the old WebGL canvas, and I can load the Collada file successfully once more after the new context has been created.

However, that's only a workaround, there has to be some cleaner method of fixing this.

@anlumo
Copy link
Author

anlumo commented Jul 11, 2011

Of course, I wonder what would happen when I'd have two webgl canvas elements in use at the same time… Fortunately I don't need that right now. Maybe this should better be fixed at the GLGE.Mesh/GLGLE.Material level.

@supereggbert
Copy link
Owner

You're right it's not ideal I will take a look into it ASAP. I would link the cache to the glcontext but that isn't known until the collada group is added to a scene and the scene attached to the renderer so without restricting things it's difficult to know how best to cache. I think you're resetColladaCaches is the best way forward for know but with the addition of a cache group property of the collada object. So, It knows which cache to use for instances when multiple contexts are in use. ie:
collada.setCacheGroup("default");
GLGE.resetCacheGroup("default");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants