webarkit / ARnft

A small javascript library for WebAR with NFT
GNU Lesser General Public License v3.0
219 stars 53 forks source link

Need a way to unload the existing NFT marker #129

Closed henry32144 closed 2 years ago

henry32144 commented 3 years ago

Hi, kalwalt,

Thank you for this great repo.

I am wondering that is there a way to unload the loaded NFT? I am trying to switch between different NFT markers, but when I delete the app DOM element and initialize another NFT marker, the CPU usage keeps getting higher. I guess this is because the previous NFT marker is still running in the background. So, is there a way to unload the loaded NFT or switch the NFT marker to another by calling ARnft.something()?

Thanks!

Edit: I add functions to terminate the worker and set ARControllerNFT to null, not sure whether it is the right way to solve this problem, but the CPU usage indeed reduced after loading another NFT marker. I can send a pull request if you don't mind.

kalwalt commented 3 years ago

@henry32144 yes actually is not possible, but if you want to add this feature you can send me a PR. :smile:

I add functions to terminate the worker and set ARControllerNFT to null, not sure whether it is the right way to solve this problem.

I have not another idea for now. The fact is JsartoolkitNFT does not support multiple NFT markers but @hiukim did for jsartoolkit5 you can find in our webarkit organization too https://github.com/webarkit/jsartoolkit5/pull/7 maybe we can add this in a near future?

kalwalt commented 3 years ago

i added these new methods: https://github.com/webarkit/ARnft/blob/46c40117618d0bba9351db11011bab590a37f128/src/ARnft.ts#L207-L210 https://github.com/webarkit/ARnft/blob/46c40117618d0bba9351db11011bab590a37f128/src/ARnft.ts#L215-L217 https://github.com/webarkit/ARnft/blob/46c40117618d0bba9351db11011bab590a37f128/src/ARnft.ts#L222-L224

kalwalt commented 2 years ago

The multi NFT feature is in the master now! But i think i need to improve the dispose of NFT markers.

albjeremias commented 2 years ago

close.