【问题标题】:A-Frame mouseleave does not change color of cursorA-Frame mouseleave 不会改变光标的颜色
【发布时间】:2016-08-16 02:55:53
【问题描述】:

我有一个应用程序,用户必须通过单击 collada 模型上的正确区域来回答问题 - 有 2 个选项,当光标变为蓝色时,用户知道一个区域是可选的(鼠标进入圆柱体,这有可见=假)。

鼠标变成蓝色很好,但是鼠标离开圆柱体的地方,光标颜色应该返回黑色,而是保持蓝色。

提前感谢您的帮助。

<a-cursor id="myCursor" color="black"></a-cursor>

<a-entity id='questionA' geometry="primitive: cylinder; height: .01; radius: 2.5" material="color:green; opacity: 1" correctAnswer > </a-entity> 

var cursorVar = document.getElementById('myCursor');
var questionVar = document.getElementById('questionA');

questionVar.addEventListener('mouseenter', function() {
                cursorVar.setAttribute('color', 'blue');
            });
questionVar.addEventListener('mouseleave', function() {
                cursorVar.setAttribute('color', 'black');
            });

【问题讨论】:

    标签: aframe


    【解决方案1】:

    光标端也发出事件。尝试从光标监听事件作为解决方法:

    cursorEl.addEventListener('mouseleave');
    

    0.3.0 将于明天或两天后发布,改进了光标、光线投射器和针对 COLLADA 模型的光线投射。这包括限制 raycaster 测试的对象在上述解决方法中是理想的。

    你的错误可能有几个因素,我认为一旦 0.3.0 发布,我就能更清楚地说明发生了什么。

    【讨论】:

      【解决方案2】:

      this CodePen 是否按预期执行?

      在查看您的代码时看不到问题(可能与光标原语有关)。尝试用上面 CodePen 链接中使用的手动定义的光标原语替换光标原语:

        <!-- Camera with gaze cursor -->
        <a-entity position="0 1.8 5">
            <a-entity camera look-controls wasd-controls>
                <a-entity cursor
                        geometry="primitive: ring; radiusOuter: 0.025;
                                  radiusInner: 0.015; segmentsTheta: 32"
                        material="color: #283644; shader: flat"
                        raycaster="far: 30"
                        position="0 0 -0.75"
                        id='cursor'>
                </a-entity>
            </a-entity>
        </a-entity>
      

      也就是说,光线投射确实看起来有点不准确(至少 0.2.0)。

      【讨论】:

        猜你喜欢
        • 2014-07-06
        • 2018-06-10
        • 2019-09-16
        • 1970-01-01
        • 2021-08-11
        • 2017-06-12
        • 2019-12-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多