Use "hide-in-ar-mode" component for Anime UI's background model#4356
Use "hide-in-ar-mode" component for Anime UI's background model#4356dmarcos merged 1 commit intoaframevr:masterfrom
Conversation
|
FYI, it seems that I unintentionally had an invisible background while testing this example in AR mode due to GLTF loading being broken. The background unexpectedly appeared in AR mode when that was fixed by afadd06 |
|
That sounds like a good idea |
dmarcos
left a comment
There was a problem hiding this comment.
Thanks. Wonder if this should be built-in. Not just part of examples.
|
That was one of the first things I did originally with aframe-ar since it's almost certainly what one wants... +1 for that being default from me.
null
|
|
FYI, I tweaked this a bit for https://xr-spinosaurus.glitch.me/ to save/restore visibility. Is there a best practice for mixin entity attributes to avoid potential name collisions, i.e. prefixing with the component name? Or can it do some magic internally to avoid that? Edit: deleted buggy code, see next comment. |
|
Sigh, I got the nesting wrong in the previous comment, should have been something like this: AFRAME.registerComponent('hide-in-ar-mode', {
// Set this object invisible while in AR mode.
init: function () {
this.el.sceneEl.addEventListener('enter-vr', (ev) => {
this.wasVisible = this.el.getAttribute('visible');
if (this.el.sceneEl.is('ar-mode')) {
this.el.setAttribute('visible', false);
}
});
this.el.sceneEl.addEventListener('exit-vr', (ev) => {
if (this.wasVisible) this.el.setAttribute('visible', true);
});
}
});Anyway, I'll leave best practices to the A-Frame experts :-) |
|
I just bumped THREE to r113 and officially kicks off the |
|
This should really also include the opposite action to only show in AR mode. |
|
Thank you! Merging this. I'm working on an AR example and it will be handy |
Description:
Hide Anime-UI's background while in AR mode
Changes proposed:
I'm not very familiar with best practices for components. Would this be a candidate for being added as a shipped-by-default component for easier reuse?
Known issue: it unconditionally sets the object visible on exiting AR mode. For a shared component, would it be necessary to track if the visible attribute was changed elsewhere and restore an appropriate value?