[英]How to fix models to camera in a-frame?
我想將一個對象附加到相機上,成為相機看起來,轉彎等任何地方的對象。
<html>
<head>
<script src="https://aframe.io/releases/0.8.0/aframe.min.js"></script>
</head>
<body>
<a-scene>
<a-assets>
<a-asset-item id="gun" position="0 -1 -5" rotation="90 360 0" scale="0 0 0" src="gun.gltf"></a-asset-item>
<a-entity camera="active: true" look-controls wasd-controls position="0 0 5" data-aframe-default-camera></a-entity>
<a-entity camera look-controls>
<a-entity gltf-model="#gun" position="0 -1 -5" rotation="0 90 35" scale="0.4 0.4 0.4" id="my_gun"></a-entity>
</a-entity>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
</body>
</html>
但這始終保持在position="0 -1 -5"
,如果此時我不使用位置,則說明相機位於對象內部...如何解決此問題?
你必須改變
<a-entity camera="active: true" look-controls wasd-controls position="0 0 5" data-aframe-default-camera></a-entity>
<a-entity camera look-controls>
<a-entity gltf-model="#gun" position="0 -1 -5" rotation="0 90 35" scale="0.4 0.4 0.4" id="my_gun"></a-entity>
</a-entity>
至
<a-entity camera="active: true" look-controls wasd-controls position="0 0 5" data-aframe-default-camera>
<a-entity gltf-model="#gun" position="0 -1 -5" rotation="0 90 35" scale="0.4 0.4 0.4" id="my_gun">
</a-entity>
</a-entity>
有兩個不同的相機,我認為這是問題所在。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.