aFrame.io创建超链接和下载链接
aFrame.io creating hyperlinks and download links
你好,我刚刚开始使用A-Frame.io,我发现这个网站非常有用。然而,如果我查看一个对象,则没有关于如何使链接工作的文档。
https://aframe.io/examples/showcase/cursor/
在上面的例子中,如果你用鼠标中键将标线悬停在立方体上,它会改变形状。
有没有一种方法可以在触发多维数据集时使web链接工作。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Cursor</title>
<meta name="description" content="Cursor — A-Frame">
<script src="../../dist/aframe.js"></script>
</head>
<body>
<a-scene>
<a-entity position="0 1.8 4">
<a-camera id="camera">
<a-cursor color="#4CC3D9"></a-cursor>
</a-camera>
</a-entity>
<a-box id="orange-cube" position="0 3.5 -2" rotation="30 30 0" width="2" depth="2" height="2" color="#F16745" roughness="0.8">
<a-event name="mouseenter" scale="3 1 1" color="#FFC65D"></a-event>
<a-event name="mouseenter" target="#shadow" scale="3 2 2"></a-event>
<a-event name="mouseleave" scale="1 1 1" color="#F16745"></a-event>
<a-event name="mouseleave" target="#shadow" scale="2 2 2"></a-event>
</a-box>
<a-image id="shadow" position="0 0 -2" src="../_images/radial-shadow-2.png" opacity="0.5" rotation="-90 0 0" scale="2 2 2"></a-image>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
</body>
</html>
您可以添加一个事件侦听器,或者编写一个链接组件。
el.addEventListener('click', function () {
window.location.href = 'https://google.com';
});
组件:
AFRAME.registerComponent('link', {
schema: {default: ''},
init: function () {
var url = this.data;
this.el.addEventListener('click', function () {
window.location.href = url;
});
}
});
```
我包装了一个aframe-href-component
插件。您可以在任何a帧对象中添加href
属性以链接到url。或者,您可以使用href="#id"
来关注具有该id的其他对象。
https://gasolin.github.io/aframe-href-component/
如果你指的是让你保持虚拟现实的WebVR链接,那么截至2016年12月,这仍然是实验性的。
现在请参阅常见问题cfhttps://aframe.io/docs/0.4.0/introduction/faq.html#can-i-add-links-to-my-scene或博客文章https://blog.mozvr.com/connecting-virtual-worlds-hyperlinks-in-webvr/提供了一个使用Firefox Nightly的工作示例。
<html>
<head>
<meta name="description" content="A-Frame href">
<script src="https://aframe.io/releases/0.5.0/aframe.min.js"></script>
<script>
AFRAME.registerComponent('link', {
schema: {default: ''},
init: function () {
var url = this.data;
this.el.addEventListener('click', function () {
window.location.href = url;
});
}
});
</head>
<body>
<a-scene>
<a-camera position="-1 0 7" look-controls wasd-controls>
<a-cursor color="blue" fuse="true" timeout="2"></a-cursor>
</a-camera>
<a-light type="ambient" color="#fff"></a-light>
<a-light type="hemisphere" groundColor="#ddd;" color="#fff" intensity="1.0" position="0 10 5" ></a-light>
<a-text position="0 2 2" color="#fff" align="center" value="WASD Keys moves you on desktop.'n'nMove circle mouse pointer to red ball and wait a few seconds." width="4"></a-text>
</a-box>
</a-entity>
<a-sphere color="red" radius="1" position="-4 2 0" link="http://cablecenter.org"></a-sphere>
<a-plane color="black" rotation="-90 0 0" width="30" height="30"></a-plane>
<a-sky color="#111"></a-sky>
</a-scene>
</body>
</html>
相关文章:
- 将下载链接从web浏览器传递给第三方应用程序
- 使用angular创建JSON下载链接
- jquery对话框可见时自动下载链接问题
- aFrame.io创建超链接和下载链接
- 将屏幕截图显示为pdf下载链接
- 为什么YouTube-dl下载链接来自YouTube在meteorjs应用程序中
- 从ASP网站抓取JavaScript下载链接
- 您如何处理需要使用 Angular 的授权令牌的下载链接
- 在 Spring-MVC 中创建下载链接
- 一键下载链接并在浏览器操作中添加书签
- 设置下载文件的名称,即使下载链接重定向到另一个
- 根据移动/桌面操作系统在网站上显示不同的按钮/下载链接
- 如何在动态生成的下载链接中解析csv文件
- 单击多个 HRREF 下载链接
- 我如何使一个下载链接与两个东西下载
- Html和javascript:如何将下载链接切换到按钮
- 如何为IPFS托管的文件创建下载链接
- 单击图像下载链接
- 在javascript中的两个下载链接之间创建一条折线
- 在不下载文件的情况下检查下载链接是否正常工作