Skip to content

Conversation

@fcor
Copy link
Member

@fcor fcor commented Mar 5, 2021

What kind of change does this PR introduce?
Feature: Added custom markerFound and markerLost events to markerControls in three.js core

How can we test it?
On any three.js + ar.js app, using markers (Pattern or Barcode) add this listeners and you should see events triggered specifying which marker was found/lost.

window.addEventListener("markerFound", function (e) {
  console.log("Found")
  console.log(e.detail);
});
window.addEventListener("markerLost", function (e) {
  console.log("Lost")
  console.log(e.detail);
});

Summary
I needed to trigger some stuff based on markers visibility and found that Three.js core didn't have this custom events as A-Frame Core has.

Explored different approaches and found that this was the simpler one, since it does not require to change anything on artoolkit api when processing the frame. Visibility check is done after frame is fully processed (confidence tests are already done).

Does this PR introduce a breaking change?
No.

Please TEST your PR before proposing it. Specify here what device you have used for tests, version of OS and version of Browser
Tested with a three.js + ar.js app with 12 pattern markers in the following browsers:

  • Microsoft Edge Version 89.0.774.45 on Windows 10
  • Microsoft Edge Version 46.01.4.5140 on Android 10 - Motorola One Action
  • Firefox Version 86 on Windows 10
  • Firefox Version 86.1.1 on Android 10 - Motorola One Action
  • Google Chrome Version 89.0.4389.72 on Windows 10
  • Google Chrome Version 89.0.4389.72 on Android 10 - Motorola One Action
  • Safari Version 14.4 on iPad OS 14.14 - iPad Pro 2020

Other information
Not sure if I have to run the make/build command as part of the PR, please let me know. Also if you need a sample app or some help for running tests just let me know.

Added markerControl complete object to event detail, not sure if we want to pass all this info or just some parts of it, like the patternUrl or ID etc.

@kalwalt
Copy link
Member

kalwalt commented Mar 5, 2021

@fcor Haven't tested the code but from a first sight it seems good to me! Will see if i have a bit of time for testing...

@kalwalt kalwalt added enhancement New feature or request pattern barcode about barcode markers pattern marker about pattern markers labels Mar 5, 2021
@nicolocarpignoli
Copy link
Member

Looks good to me! Thank tou. Merging. We will build on a next release.

@nicolocarpignoli nicolocarpignoli merged commit 90425aa into AR-js-org:dev Mar 22, 2021
kalwalt added a commit that referenced this pull request Mar 31, 2021
- addded found and lost marker event to both arjs-context versions (default and with nft)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pattern barcode about barcode markers pattern marker about pattern markers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants