hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.13k stars 394 forks source link

MindAr not loading when setting mindar-image attribute by code #457

Closed JanNilsScheele closed 7 months ago

JanNilsScheele commented 9 months ago

Hi,

I try to set the mindar-image attribute by code:

this.document .getElementById("root") .setAttribute( "mindar-image", "imageTargetSrc: https://myDomain.com/myFile.mind; filterMinCF:0.001; filterBeta:100; missTolerance: 15;" );

This works perfectly if specified in html code, but not from javascript code. Even the camera is not starting. In Aframe inspector I can see the the element is correctly assigned to the scene, so the selector is working.

Do I need to trigger any event?

Best Regards, Jan

BostonLeeK commented 9 months ago

Problem is that you try to apply attribute after page initialisation and lib already check this attribute.

JanNilsScheele commented 9 months ago

Ok, is there a chance to re-trigger the detection, or should I add the attribute and later add the script to the page?

BostonLeeK commented 9 months ago

can u describe case why u need to async set of the mindar-image attribute? Do u use some framework for web project such like react?

JanNilsScheele commented 9 months ago

I have an angular app that gets a query / route parameter which marker to detect and which scene to render.

BostonLeeK commented 9 months ago

you have two options. Render user content only after setup url for bundle or reset and restart mindar. Last time I seen example with reset here https://github.com/hiukim/mind-ar-js/pull/338/files#diff-12f9942ebe9e0a3cefbfe0602981fdcebf38c4e9148ddefd75dd8731bf0edcbc

for myself for debug tools I update source code of mindar lib and add tracking of parameters change. After changing parameters I reset ar session and restart it.

JanNilsScheele commented 7 months ago

I am now adding the scene dynamically. That worked. Thanks!