Skip to content

way for dynamic entity addition - #2

Open
maa105 wants to merge 1 commit into
fcor:masterfrom
maa105:patch-1
Open

way for dynamic entity addition#2
maa105 wants to merge 1 commit into
fcor:masterfrom
maa105:patch-1

Conversation

@maa105

@maa105 maa105 commented Sep 8, 2020

Copy link
Copy Markdown

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

fcor commented Sep 16, 2020

Copy link
Copy Markdown
Owner

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

maa105 commented Sep 22, 2020

Copy link
Copy Markdown
Author

@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