A帧雷卡斯特不工作(需要与天空交叉点)

时间:2018-06-06 13:05:36

标签: javascript html three.js aframe virtual-reality

好的,所以我试图找到光线交叉点的坐标 与天空的施法者,但问题是a)我无法看到射线施法者,虽然我添加了showline:true b)从不访问交叉点监听器(交叉点从不 触发)

<html>
    <head>
        <script src="https://aframe.io/releases/0.8.0/aframe.min.js"> </script>
        <script src="https://npmcdn.com/aframe-animation-component@3.0.1"></script>
        <script src="https://npmcdn.com/aframe-event-set-component@3.0.1"></script>
        <script src="https://npmcdn.com/aframe-layout-component@3.0.1"></script>
        <script src="https://npmcdn.com/aframe-template-component@3.1.1"></script>

        <script type="text/javascript">
            AFRAME.registerComponent('collider-check', {
                dependencies: ['raycaster'],
                init: function () {
                this.el.addEventListener('raycaster-intersected',
                                         function (evt) {
                    alert(evt.detail.intersection.point);
                    console.log('Player hit something!');
                    });
                }
            });
        </script>
    </head>
    <body>
        <a-scene>
            <a-sky class="collidable"  src="{{asset('img/3_Entree_2.jpg')}}"> </a-sky>
            <a-camera look-control collider-check>     
                <a-entity raycaster="objects: .collidable" position="0-0.9 0"
                          rotation="90 0 0" showLine= "true"></a-entity>
            </a-camera>
        </a-scene>
    </body>
<html>        

2 个答案:

答案 0 :(得分:1)

尝试调整,以便raycaster可以到达天空。

raycaster="far: 10000"<a-sky radius="100">

答案 1 :(得分:0)

我的问题在于光线施法者的语法应该看起来更像是这样:

    <a-entity raycaster="showLine: true; far: 100" line="color: orange; 
    opacity:0.5"></a-entity> 

A-frame文档还很薄弱,语法用法不明确