aframe - 带有徽标的网址的 A 帧链接
问题描述
我想使用徽标从场景内部链接到外部 URL(常规网站,而不是 VR)。这就是我所拥有的:
<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>
当我检查元素时,我看到链接下正确列出的图像,以及材料下的全景。但在实际的门户中,我看到的只是纯洋红色。
谢谢你的帮助!
解决方案
1)使用链接组件。如果图像可访问
a) 路径正确
b) 没有 CORS 问题
设置image
属性应该为组件portal
的一部分提供背景link
。
link="highlighted: true; highlightedColor:#000000; href: https://schatzkin.com;
titleColor: black; title: Back to website;image: https://i.imgur.com/wjobVTN.jpg"
2)制作自己的链接。任何元素都可以成为一些js的链接。您可以创建自己的元素,这将改变window.location
点击:
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>
在我的fiddle或下面查看这两种方法:
<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script>
AFRAME.registerComponent("mylink", {
init: function() {
this.el.addEventListener("click", (e) => {
window.location = this.data.href;
})
}
})
</script>
<a-scene cursor="rayOrigin: mouse">
<a-text color="black" position="1 1.6 -2" value="Click the text"
mylink="href: https://schatzkin.com;"></a-text>
<a-entity position="-1 1.6 -2"
link="highlighted: true;
highlightedColor:#000000; backgroundColor: red;
href: https://schatzkin.com; titleColor: black;
title: click the image below.;
image: https://i.imgur.com/wjobVTN.jpg;
visualAspectEnabled: true"></a-entity>
</a-scene>
推荐阅读
- javascript - 当我们使用像 ab 这样的东西时,排序函数在 javascript 中如何工作(我想知道后台发生了什么)
- node.js - UnhandledPromiseRejectionWarning:TypeError:无法读取未定义的属性“MessageEmbed”
- node.js - typescript + Node 15.5.1,不能在模块外使用import语句
- reactjs - 从当前路由(功能组件)反应路由器(react-router-dom)设置页面标题?
- javascript - Discord.js - ReferenceError:未定义连接
- java - 使用 JIB 生成图像并在 GitLab CI 上使用 docker 推送时遇到问题
- terraform - 来自一个 Git 存储库的多个 terraform 环境?
- node.js - Typeorm 无法连接到 Postgres
- android - 如何将预编译的二进制文件集成到 AOSP Android 构建中?
- python - 从 NCBI 网页中提取特定的 Fasta 数据