webarkit / jsartoolkitNFT

jsartolkitNFT is a smaller version of jsartoolkit5 with only NFT support
GNU Lesser General Public License v3.0
131 stars 25 forks source link

import as module from npm howto #114

Closed gase12 closed 2 years ago

gase12 commented 2 years ago

hi i just found this great lib, now using the multi-marker dev branch. I use npm to import the lib in the worker as 'importscripts()' is not working in my webpack setup. import { ARToolkitNFT, ARControllerNFT } from '@webarkit/jsartoolkit-nft' i got the following error: Cannot read properties of undefined (reading 'initWithDimensions') when this line runs: ARToolkitNFT.ARControllerNFT.initWithDimensions(msg.pw, msg.ph, msg.camera_para).then(onLoad).catch(onError) if i use new ARControllerNFT.initWithDimensions(..) it goes on, but later it is not recognising ar.loadNFTMarkers() as a function... though arobject arrives in the callback.

could be a worker-level thing i am not familiar with.

maybe you know what is the best workaround. keep up the good work! thanks.

gase12 commented 2 years ago

minor update: i guess i found the reason. loadNFTMarkers() is only in the dev branch. and the initial npm install pulls the published master. w

gase12 commented 2 years ago

ok. problem solved. for furture reference with current wip dev branch: df72720

102

kalwalt commented 2 years ago

@gase12 i will publish the new npm package when i will merge the dev branch into master. Glad that you find a solution in the meantime!

kalwalt commented 2 years ago

@gase12 you can look also to ARnft, if you need an example code on how import JsartoolkitNFT with npm.

gase12 commented 2 years ago

oh thanks. i wasn't sure whats the difference in that repo. (both claims it only supports the nft marker type at the moment) and this one seemed more robust and recent with the multi marker solution i need. i already tamed this version and plugged in. so i hope i am good to go with this :)

kalwalt commented 2 years ago

The difference between ARnft and jsartoolkitNFT::dev with multi NFT support at the moment is: ARnft load one NFT marker in a single WebWorker for every NFT markers, so if you have 3 nft markers it create 3 different WebWorkers. JsartoolkitNFT (dev branch) may load every NFT markers in a single WebWorker.

gase12 commented 2 years ago

ok. so performance wise the jsartoolkit seems better? or with workers it is better to split it? i only need one marker detected at any given time, but like 12 different.

kalwalt commented 2 years ago

ok. so performance wise the jsartoolkit seems better? or with workers it is better to split it? i only need one marker detected at any given time, but like 12 different.

Please open another issue, or better open a discussions better for this kind of questions. Anyway multi nft is on master branch, see release 1.0.0 and new npm package too https://www.npmjs.com/package/@webarkit/jsartoolkit-nft

gase12 commented 2 years ago

yep, sorry. thanks for the effort. great work. best

kalwalt commented 2 years ago

yep, sorry. thanks for the effort. great work. best

No problem just to keep issues clean!