【问题标题】:A-Frame Kinematic-body camera height problemA-Frame Kinematic-body 相机高度问题
【发布时间】:2020-03-06 00:05:58
【问题描述】:

我有一个问题,我需要我的相机是一个运动体并与墙壁元素发生碰撞,但是我无法让它保持在 1.6 的固定 y 轴高度。我需要一种方法来使相机保持在这个高度,同时保持其运动学体属性,因为我需要墙壁碰撞才能工作。我附上了到目前为止我一直坚持的代码。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://aframe.io/releases/1.0.3/aframe.min.js"></script>
    <script src="//cdn.rawgit.com/donmccurdy/aframe-physics-system/v4.0.1/dist/aframe-physics-system.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.0/dist/aframe-extras.min.js"></script>
    <script src="https://rawgit.com/rdub80/aframe-gui/master/dist/aframe-gui.min.js"></script> <!--GUI Library-->
    <script src="https://unpkg.com/aframe-environment-component@1.1.0/dist/aframe-environment-component.min.js"></script> <!--Environment extension-->
    <title>Courtyard and Entrance Scene</title>

</head>
<body>
    <a-scene physics="debug: true">
        
            <a-entity id="camera" position="0 1.6 0" camera look-controls wasd-controls="acceleration: 400" kinematic-body>
                <a-cursor></a-cursor>
                <a-gui-label 
                        id="playerLocation"
                        width="1" height="0.2"
                        font-size="4.5rem"
                        padding="1rem 2rem"
                        position="2 1.5 -2"
                        value="gui label"
                >
                </a-gui-label>
            </a-entity>
            
            <!-- Floor -->
            <a-plane static-body material="color: grey" width="15" height="15" rotation="-90 0 0" position="0 0 0"></a-plane>
            
            <a-box width="10" height="5" depth="0.5" static-body material="color: red" position="0 0 -5"></a-box>
            
    </a-scene>
</body>
</html>

任何对此问题的见解将不胜感激!

【问题讨论】:

    标签: javascript html aframe webvr


    【解决方案1】:

    使用钻机时会正确计算偏移量:

    <a-entity id="rig" movement-controls kinematic-body>
        <a-entity id="camera" camera position="0 1.6 0" look-controls></a-entity>
    </a-entity>
    

    this fiddle 中查看。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-24
      • 2022-01-20
      • 1970-01-01
      • 2022-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多