微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

一个框架如何在 VR 场景中包含表单? 示例示例

如何解决一个框架如何在 VR 场景中包含表单? 示例示例

有谁知道如何在使用 A-Frame 构建的 VR 场景中包含表单?有使用 Web2VR 的经验吗?

解决方法

如果表单是指标准 HTML 2d 表单,那么您可以简单地用任何标准 HTML 元素覆盖 3d 场景。只需使用 z-index 参数。

示例

<!DOCTYPE html>
<html lang="en">

<head>
  <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
  <meta charset="UTF-8" />
</head>

<body>
  <a-scene>
    <a-sphere position="0 2 -10"color="red"></a-sphere>
    <a-plane color="green" position="0 0 -5" rotation="-90 0 0" width="20" height="20"></a-plane>
    <a-sky color="#aaf"></a-sky>
  </a-scene>
  <div>
    <form style="z-index: 100; position: absolute; left: 10px; top: 10px">
      <input type="text"/><br/>
      <input type="number"/><br/>
      <input type="date"/><br/>
      <input type="submit"/>
    </form>
  </div>
</body>

</html>

您还可以在 embedded 上使用 a-scene 属性来指定应将场景放置在标准网页中的位置。

示例

<!DOCTYPE html>
<html lang="en">

<head>
  <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
  <meta charset="UTF-8" />
</head>

<body>
  <a-scene embedded style="width: 200px; height: 100px">
    <a-sphere position="0 2 -10"color="red"></a-sphere>
    <a-plane color="green" position="0 0 -5" rotation="-90 0 0" width="20" height="20"></a-plane>
    <a-sky color="#aaf"></a-sky>
  </a-scene>
  <div>
    <form>
      <input type="text"/><br/>
      <input type="number"/><br/>
      <input type="date"/><br/>
      <input type="submit"/>
    </form>
  </div>
</body>

</html>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。