防止相机通过相框对象 [英] Preventing camera from going 'through' aframe object
问题描述
可以说我有一个圆柱体模型,我加载到我的webvr场景中。我怎样才能使物体坚实?即用户(摄像机视图)不能在对象内取任何位置,也不能在对象内移动。我怎样才能做到这一点?
Lets say I have a cylinder model that I load into my webvr scene. How can I make the object solid? I.e. the user (camera view) cannot take any position within the object or move 'through' the object. How can I achieve this?
<a-scene>
<a-assets>
<a-asset-item id="cube-obj" src="cube.obj"></a-asset-item>
</a-assets>
<a-entity id="cameraWrapper" position="0 2 10" rotation="0 0 0">
<a-camera near="0.1" user-height="0" id="camera" listener></a-camera>
</a-entity>
<a-entity obj-model="obj: #cube-obj; mtl: #cube-mtl" scale="1 1 1" rotation="-90 0 0"></a-entity>
<a-plane position="0 4 4" rotation="-90 0 -90" width="4" height="4" color="#7BC8A4"></a-plane>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
推荐答案
这取决于您计划支持的设备,以及你如何让用户
导航你的场景。对于大多数VR体验,请遵循最佳做法,只有
才能按比例将相机移动到用户的动作。如果用户在房间空间中前进
并且相机被阻挡,这是非常糟糕的
体验。对于大多数VR应用程序,最好使用
teleportation ,
设计您的场景以避开障碍物,或探索更多有创意的
移动用户的方式。
This depends on what devices you plan to support, and how you allow users to navigate your scene. For most VR experiences, follow best practices and only move the camera proportionately to the user's motion. If the user steps forward in roomscale space and the camera is "blocked," this is a very bad experience. For most VR applications it's better to do locomotion with teleportation, design your scene to keep obstacles out of the way, or explore more creative ways of moving users through the world.
对于非VR桌面体验使用游戏手柄或WASD控制,或VR场景
,相机在车内时,可以添加
物理引擎至
防止通过障碍物移动。
For non-VR desktop experiences with a gamepad or WASD controls, or for VR scenes where the camera is inside a vehicle, you can add a physics engine to prevent movement through obstacles.
^ 我会尝试获取这很快添加到A-Frame FAQ或文档中。这已添加到 A-Frame常见问题解答。以下是使用检查点的示例和使用物理引擎的例子。
^I'll try to get this added to the A-Frame FAQ or documentation soon. This has been added to the A-Frame FAQ. Here's an example using checkpoints, and an example using a physics engine.
这篇关于防止相机通过相框对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!