hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MindAr not loading when setting mindar-image attribute by code

JanNilsScheele opened this issue · comments

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

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

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

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?

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

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.

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