我正在尝试框架,但找不到任何有关如何拖放元素的信息,并且已经寻找了几个小时!有人熟悉a-frame吗? 谢谢
这是我到目前为止的代码:
<a-scene>
<a-cursor></a-cursor>
<a-assets>
<img id="enemy-sprite" crossorigin="" src="mustache1.jpg">
</a-assets>
<a-image look-at="#player" src="#enemy-sprite" transparent="true" position="0 1.8 -4"></a-image>
<a-camera id="player" position="0 1.8 0"></a-camera>
<a-sky src="street.jpg"></a-sky>
编辑: 浏览器/home.html:
<scene scene-id="sceneId"></scene>
浏览器/js/app/directives/screne.html:
<a-scene>
<a-sphere click-drag position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-camera look-controls-enabled="false"></a-camera>
</a-scene>
index.html
<script src="https://aframe.io/releases/0.3.0/aframe.min.js"></script>
<script src="https://unpkg.com/aframe-click-drag-component"></script>
<script> registerAframeClickDragComponent(window.AFRAME); </script>
最佳答案
这并未内置于 Aframe 中,但您可以使用第 3 方组件来获得所需的结果。
aframe-click-drag-component
允许在屏幕上单击和拖动实体:
Entities with the
click-drag
component can be click and dragged around the 3D scene. Even works while the camera is moving or rotating!<head> <script src="https://aframe.io/releases/0.3.0/aframe.min.js"></script> <script src="https://unpkg.com/aframe-click-drag-component"></script> <script> registerAframeClickDragComponent(window.AFRAME); </script> </head> <body> <a-scene> <a-sphere click-drag position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere> <a-camera look-controls-enabled="false"></a-camera> </a-scene> </body>
查看the demo .
关于aframe - a-frame vr如何拖放 Assets /元素洞察图片?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39939318/