A-frame link to url with logo

匆匆过客 提交于 2019-12-11 15:14:28

问题


I want to use a logo to link to an external URL (regular website, not VR) from inside the scene. This is what I have:

<a-entity link="highlighted: true; highlightedColor:#000000; portal:#ec1e1e; href: https://schatzkin.com; title: Back to website; image: assets/logo-lockup-black.png"></a-entity>

When I inspect the element, I see the image listed correctly under Link, and also as pano under Material. But in the actual portal, all I see is a solid magenta color.

Thanks for your help!


回答1:


1) Using the link component. Provided the image is accessible
a) the path is correct
b) there are no CORS issues

setting the image attribute should provide background for the portal which is part of the link component.

link="highlighted: true; highlightedColor:#000000; href: https://schatzkin.com;
      titleColor: black; title: Back to website;image: https://i.imgur.com/wjobVTN.jpg"

2) Making your own link. Any element can become a link with some js. You could create your own element, which will change the window.location on click:

AFRAME.registerComponent("mylink", {
  init: function() {
    this.el.addEventListener("click", (e)=> {
       window.location = this.data.href;
    })
  }
})

HTML

<a-text color="black" position="1 1 -2" value="goToSchatzkin" 
        mylink="href: https://schatzkin.com;"></a-text>

Check out both methods in my fiddle.



来源:https://stackoverflow.com/questions/51506363/a-frame-link-to-url-with-logo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!