hiukim / mind-ar-js

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

[bug report] targetFound is not triggered if you call start when the phone already points at tracking #300

Open marcusx2 opened 1 year ago

marcusx2 commented 1 year ago

@hiukim If autostart is set to false, and you call start manually with the phone already pointing at the tracking, the targetFound event is fired the very first time. However, if you then call stop, and with the phone still pointing at the tracking, you call start again, the targetFound event is not fired. The same problem happens with pause/unpause. Currently targetFound can't be relied on to make the content visible/invisible because of this issue.

marcusx2 commented 1 year ago

Temporary workaround: After pause or stop, make entity invisible. This will trigger targetFound after it's unpaused/started again.

[...document.querySelectorAll('[mindar-image-target]')].forEach(target => target.object3D.visible = false);

marcusx2 commented 1 year ago

@hiukim Not sure if I explained the issue well, did you understand? The problem is that I can't rely on the targetFound event to show and hide content because if the ar engine is paused or stopped and the user unpauses or starts the ar engine while already pointing at the image tracking, the targetFound event is not fired, so the content never shows up. That is because I don't place the content under the image tracking entity, but instead check for its transform for placement, and only do so on the target found event (once the target is found I continuously check for the image's position, scale and rotation).

Right now the workaround is to manually set the target to invisible once the ar engine is paused or stopped. This forces the targetFound to trigger even if the user is already pointing at the image target right after the ar engine is unpaused/started.

jessicachrist commented 1 year ago

Maybe this helps? https://github.com/hiukim/mind-ar-js/pull/241