augmentmy-world / arStudio

A innovative Web editor for Augmented Reality
https://webarstudio.tripod-digital.co.nz
MIT License
53 stars 34 forks source link

[WIP] Adding WebWorker for the NFT markers #34

Closed kalwalt closed 4 years ago

kalwalt commented 4 years ago

Trying to add a WebWorker for better NFT performances.

kalwalt commented 4 years ago

@ThorstenBux netlify create also the preview! This PR is still a WIP but i hope to finish soon...

ThorstenBux commented 4 years ago

Yes, auto deploy of PRs. Awesome.

I get a 404 when I run the NFT tracking:

webWorker.js:42 GET https://5e98a11b28c3d40006ae43b8--sad-northcutt-73843d.netlify.app/editor/js/modules/artoolkit.worker.js 404
load @ webWorker.js:42
startWorker @ webWorker.js:141
(anonymous) @ arcontroller.component.js?version=0.64:168
(anonymous) @ arcontroller.component.js?version=0.64:158
(anonymous) @ artoolkit.min.js:1
writeCallback @ artoolkit.min.js:1
writeByteArrayToFS @ artoolkit.min.js:1
oReq.onload @ artoolkit.min.js:1
load (async)
ajax @ artoolkit.min.js:1
loadCamera @ artoolkit.min.js:1
ARCameraParam.load @ artoolkit.min.js:1
ARCameraParam @ artoolkit.min.js:1
(anonymous) @ arcontroller.component.js?version=0.64:129
(anonymous) @ artoolkit.min.js:1
Promise.then (async)
play @ artoolkit.min.js:1
success @ artoolkit.min.js:1
Promise.then (async)
ARController.getUserMedia @ artoolkit.min.js:1
ArControllerComponent.startAR @ arcontroller.component.js?version=0.64:125
trigger @ litegl.js?version=0.64:10617
Scene.start @ litescene.js?version=0.64:14400
changeState @ play.js?version=0.64:278
onPlay @ play.js?version=0.64:120

But it looks promising. Thank you

kalwalt commented 4 years ago

get a 404 when I run the NFT tracking:

Good to know, this not happens in localhost. I will fix this. At the moment does not load the NFT marker (probably for a wrong path) and as in AR.js two ARController are created one inside the WebWorker and another one outside (in the Component) . That is not optimal but we will see in the future for this problem.

ThorstenBux commented 4 years ago

Woohoo πŸ₯³

kalwalt commented 4 years ago

Woohoo

i haven't solved the 404 error but i made a little step ahead, and i have to found the correct method to pass the matrix transform to the renderer, maybe implementing an event listener, litescene.js should have his own system i think.

ThorstenBux commented 4 years ago

LiteScene does have its own event system yes. However js events should work too. Haven’t looked at your code yet. But can if you like.

Kind regards Thorsten Bux

Sent from my iPhone

On 23/04/2020, at 10:07 AM, Walter Perdan notifications@github.com wrote:

ο»Ώ

Woohoo

i haven't solved the 404 error but i made a little step ahead, and i have to found the correct method to pass the matrix transform to the renderer, maybe implementing an event listener, litescene.js should have his own system i think.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faugmentmy-world%2FarStudio%2Fpull%2F34%23issuecomment-618065506&data=02%7C01%7C%7C39c30fa374f4476d916908d7e7097d47%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637231900245129654&sdata=Kdv4npBzhUfWcRu0%2FYLzZiKkiGAbau8JVkCV5%2F%2F%2BwIE%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD765PBJZZWYX4ZTUUKHPKTRN5TANANCNFSM4MJ7QFHQ&data=02%7C01%7C%7C39c30fa374f4476d916908d7e7097d47%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637231900245139665&sdata=%2FqSrydZiFj5KLNyNA%2BfnoOOTnW2pW0%2Bw%2BH6t%2FB%2BiaqQ%3D&reserved=0.

kalwalt commented 4 years ago

I created the embedded worker but not solved the 404 issue, it should work, but it doesn't on the netlify services. Maybe is something related to the name of the base path? Because artooolkit.min.js should be at this path: https://deploy-preview-34--sad-northcutt-73843d.netlify.app/editor/js/modules/artoolkit.min.js but you get instead resource not available.

I also receive another error:

Uncaught (in promise) ReferenceError: ar is not defined
    at process (webWorker.js:174)
    at startWorker (webWorker.js:198)
    at arcontroller.component.js?version=0.64:168
    at Array.forEach (<anonymous>)
    at ArControllerComponent.<anonymous> (arcontroller.component.js?version=0.64:158)
    at ARCameraParam.<anonymous> (artoolkit.min.js:1)
    at writeCallback (artoolkit.min.js:1)
    at writeByteArrayToFS (artoolkit.min.js:1)
    at XMLHttpRequest.oReq.onload (artoolkit.min.js:1)
kalwalt commented 4 years ago

Maybe https://deploy-preview-34--sad-northcutt-73843d.netlify.app start from the editor project folder?

ThorstenBux commented 4 years ago

Yes it does start from the editor folder

Get Outlook for iOShttps://aka.ms/o0ukef


From: Walter Perdan notifications@github.com Sent: Thursday, April 23, 2020 10:33:42 PM To: augmentmy-world/arStudio arStudio@noreply.github.com Cc: Thorsten Bux thorsten.bux@outlook.com; Mention mention@noreply.github.com Subject: Re: [augmentmy-world/arStudio] [WIP] Adding WebWorker for the NFT markers (#34)

Maybe https://deploy-preview-34--sad-northcutt-73843d.netlify.app start from the editor project folder?

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faugmentmy-world%2FarStudio%2Fpull%2F34%23issuecomment-618323907&data=02%7C01%7C%7C6ebdf10e7b3f486775f908d7e771cbc9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232348235566644&sdata=CLjMr6OETNya4kGbLAp7pihb2nNBHODIKtnoS1AsZ%2FA%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD765PBLPCOLQ3XIOJ6IEADROAKQNANCNFSM4MJ7QFHQ&data=02%7C01%7C%7C6ebdf10e7b3f486775f908d7e771cbc9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232348235576639&sdata=wSkWJd3CTyH3xf07qbEzBFV862eAroxts50SpuT%2Fs30%3D&reserved=0.

kalwalt commented 4 years ago

@ThorstenBux with https://github.com/augmentmy-world/arStudio/pull/34/commits/952f94b6a0e6b9883790ed2b3a838da03be8aac8 fix the 404 error for the importScripts, now i have to fix the path for the camera and the marker.

kalwalt commented 4 years ago

Now WebARStudio can load artoolkit.min.js, camera_para.dat and the pinball NFT marker ! :tada: :rocket: :smile: Stopping for now, i will continue this evening.

ThorstenBux commented 4 years ago

Awesome, big shout out [Animated GIF]


From: Walter Perdan notifications@github.com Sent: Thursday, April 23, 2020 11:34 PM To: augmentmy-world/arStudio arStudio@noreply.github.com Cc: Thorsten Bux thorsten.bux@outlook.com; Mention mention@noreply.github.com Subject: Re: [augmentmy-world/arStudio] [WIP] Adding WebWorker for the NFT markers (#34)

Now WebARStudio can load artoolkit.min.js, camera_para.dat and the pinball NFT marker ! πŸŽ‰ πŸš€ πŸ˜„ Stopping for now, i will continue this evening.

β€” You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Faugmentmy-world%2FarStudio%2Fpull%2F34%23issuecomment-618350260&data=02%7C01%7C%7C5f0f2f6b143f4475a23d08d7e77a4e8c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232384791793178&sdata=f2B%2FgrW1Q%2FONfyQILwBLfHvMlNEwlF9lAG0Y%2BnC8Dgo%3D&reserved=0, or unsubscribehttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD765PCBO37P6SCBDETTRYLROARU3ANCNFSM4MJ7QFHQ&data=02%7C01%7C%7C5f0f2f6b143f4475a23d08d7e77a4e8c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637232384791803176&sdata=VGGrn8%2Bt1meN61DxrJAJ%2BXDdPn%2Fga5GpFfrgFT5JWPg%3D&reserved=0.

kalwalt commented 4 years ago

@ThorstenBux i think we are arrived at a good point, just some refinements and will be super! Tested in localhost and the netlify deploy preview :smile: If you test look at the dev console while pointing to a pinball marker.

kalwalt commented 4 years ago

I have the listener now, but it output event in this form ev.detail.data instead onTrackableFound require event.data. Not a clear idea how can i solve this problem, maybe i can try to implement for now a onTrackableNFTFound to skip this problem.

kalwalt commented 4 years ago

with the latest the NFT marker is tracked but i got this error:

artoolkit.min.js:1 [info] Tracked page 15794240 (max 0).
put_char @ artoolkit.min.js:1
write @ artoolkit.min.js:1
write @ artoolkit.min.js:1
doWritev @ artoolkit.min.js:1
_fd_write @ artoolkit.min.js:1
___wasi_fd_write @ artoolkit.min.js:1
jx @ artoolkit.min.js:10
$x @ artoolkit.min.js:10
jz @ artoolkit.min.js:10
iz @ artoolkit.min.js:10
Te @ artoolkit.min.js:6
Se @ artoolkit.min.js:6
dr @ artoolkit.min.js:12
Ws @ artoolkit.min.js:12
gP @ artoolkit.min.js:15
dynCall_iiii_32 @ VM28:4
getNFTMarker @ VM85:9
ARController.getNFTMarker @ artoolkit.min.js:1
ARController.process @ artoolkit.min.js:1
process @ cdf2cc15-8975-4de2-8582-890cf78bc384:97
self.onmessage @ cdf2cc15-8975-4de2-8582-890cf78bc384:12
arcontroller.component.js?version=0.64:357 saw a trackable with id 0
arcontroller.component.js?version=0.64:359 Uncaught ReferenceError: arTrackable is not defined
    at ArControllerComponent.onTrackableNFTFound (arcontroller.component.js?version=0.64:359)
    at found (webWorker.js:189)
    at Worker.worker.onmessage (webWorker.js:60)
ArControllerComponent.onTrackableNFTFound @ arcontroller.component.js?version=0.64:359
found @ webWorker.js:189
worker.onmessage @ webWorker.js:60
artoolkit.min.js:1 [info] Tracked page 15794240 (max 0).
kalwalt commented 4 years ago

This happens obvioulsy because the addEventListener is attached to the window, not to the arController. This is one issue to be resolved.

kalwalt commented 4 years ago

I think i will close this PR better to start a new one with jsartoolkitNFT, or maybe i can start directly with webarStudio?