Skip to content

way for dynamic entity addition #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

maa105
Copy link

@maa105 maa105 commented Sep 8, 2020

if the entity is added dynamically while its marker is visible to the camera the handler will not fire as isVisible is false. so you have to remove the camera from the marker (markerLost) then scan the marker again (markerFound) so that the events fire again and you are able to rotate and scale.
to circumvent it I copied isVisible from the parent marker data attributes. so if the user wants to add dynamic content and circumvent this events not firing on first scan he should add:

      AFRAME.registerComponent('markerhandler', {
        init: function () {

          this.el.sceneEl.addEventListener('markerLost', (e) => {
            e.target.dataset.isVisible = '0';
          });

          this.el.sceneEl.addEventListener('markerFound', (e) => {
            e.targetdataset.isVisible = '1';
          });
        }
      });

and on the marker:

  <a-marker markerhandler ...> ... </a-marker>

if the entity is added dynamically while its marker is visible to the camera the handler will not fire as isVisible is false. so you have to remove the camera from the marker (markerLost) then scan the marker again (markerFound) so that the events fire again and you are able to rotate and scale.
to circumvent it I copied isVisible from the parent marker data attributes. so if the user wants to add dynamic content and circumvent this events not firing on first scan he should add:
```
      AFRAME.registerComponent('markerhandler', {
        init: function () {

          this.el.sceneEl.addEventListener('markerLost', (e) => {
            e.target.dataset.isVisible = '0';
          });

          this.el.sceneEl.addEventListener('markerFound', (e) => {
            e.targetdataset.isVisible = '1';
          });
        }
      });
``` 
and on the marker:
```
  <a-marker markerhandler ...> ... </a-marker>
```
@fcor
Copy link
Owner

fcor commented Sep 16, 2020

Hey! Thanks for contributing :)

I'm wondering if "markerhandler" component should be part of the tool in order for this to work on every use case.

Have you tried adding gesture-handler directly on the marker tag?

@maa105
Copy link
Author

maa105 commented Sep 22, 2020

@fcor no I havent. Ill give it a try and get back to you. thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants