-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Make artoolkit.api.js node.js compliant and remove references to DOM object in typescript version and javascript #128
Comments
Inside artoolkitNFT.api.js and ARControllerNFT.ts will try to remove canvas, ctx, image, options, and orientation properties from ARControllerNFT class. Maybe i can remove other part of the code. |
This is not enough, the lib will fail while loading the camera or other resources because it is based on XMLHttpRequest that is not supported on a Node.js environment. It's needed to change the ajax function to another that use |
You can do this simple test, given this code: var Module = require('../build/artoolkitNFT_wasm.js')
Module.onRuntimeInitialized = async function(){
var ar = new ARControllerNFT(640, 480, '../examples/Data/camera_para.dat');
} You will get this error:
|
Note that also the dist lib ARToolkitNFT.js will fails under node.js with a similar error. |
We should build the dist lib with these instructions axios/axios#456 (comment) |
There few key points to solve to make artoolkitNFT.api.js (to be precise the libs compiled with artoolkitNFT.api.js -> artoolkitNFT_wasm.js and artoolkitNFT.min.js) to use on node.js. At the moment it can not be used because there are DOM objects and
self
is not recognized as globalThis:jsartoolkitNFT/js/artoolkitNFT.api.js
Lines 4 to 9 in 5a3230c
self is accepted in a worker env but not under NODE.
I think that code should add a conditional with
scope = global
for the NODE env.Plus we need to remove all references to canvas or document objects. We don't need them because we pass imageData. This is also applicable to the Typescript version and need a rewrite in this sense.
The text was updated successfully, but these errors were encountered: