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

How to dispose the noa instance? #141

Open
Trenki opened this issue Dec 11, 2020 · 3 comments
Open

How to dispose the noa instance? #141

Trenki opened this issue Dec 11, 2020 · 3 comments

Comments

@Trenki
Copy link

Trenki commented Dec 11, 2020

I'm using VUE build the project, the game is inside a component, and I want to destroy the noa parameters when I destroy the component, so that I can open the component again and run the game.What should I do?

@fenomas
Copy link
Owner

fenomas commented Dec 11, 2020

Hi, do you mean you want to dispose the noa instance, so that it releases all its memory so you can recreate it later? It doesn't have any feature like that currently, though I don't think it would be too hard to make.

On the other hand if you just want to be able to hide/show the game, I think it would be easier to have vue show/hide noa's container element, rather than destroying/recreating it. This would run faster, since destroying/recreating would mean the whole world needs to be regenerated and remeshed, etc.

@Trenki Trenki changed the title How to remove the noa? How to dispose the noa instance? Dec 11, 2020
@Trenki
Copy link
Author

Trenki commented Dec 11, 2020

Yeah,that's what I mean.I want others to use my blockly to build games, so the game code is different every time and needs to be completely rebuilt.

If I want to dispose the noa instance, what shall I do?Looking forward to your reply,have a nice day :).

@fenomas
Copy link
Owner

fenomas commented Dec 12, 2020

Hi... so the real answer is that the library should have a dispose method, but it doesn't have one yet and I don't have plans to work on it soon. However I think it would be pretty straightforward if someone else wants to try. Basically it would mean disposing the babylon scene and releasing lots of internal references and removing some event listeners.

One alternate answer is, you may be able to use a single noa instance continuously, but just change the world data. You can do this with the noa.worldName (which is normally for things like changing from the overworld to the nether in minecraft). When you change noa.worldName to a different value, the engine will unload all its current chunks and issue events requesting voxel data for the new world.

However changing noa.worldName doesn't reset the registry, just the world's voxel data. If you need to start completely fresh and register different voxel types, then you'll need a proper dispose method.

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

No branches or pull requests

2 participants