【问题标题】:How does the current version of Aframe handle "mouse" events?当前版本的 Aframe 如何处理“鼠标”事件?
【发布时间】:2019-02-04 17:49:24
【问题描述】:

Aframe 似乎改变了它处理鼠标事件的方式,而没有改变文档。你能帮我触发 mouseenter 和 mouseleave 事件吗?

我的代码在这里,在故障框架中运行: https://glitch.com/edit/#!/aframe-cursor-stuff?path=index.html:1:0

(点击“show live”(左上角)在新标签页中运行,点击“remix to edit”(右上角)对代码进行更改)

场景 出现一个圆形光标,带有一个框。如果单击并拖动屏幕,您可以将光标移动到框上。如果然后单击,该框将以 y 轴旋转动画

但是只要将光标移到框上就应该放大框 - 将光标移离框应该缩小框 - 使用“mouseenter”和“mouseleave”

事实上,如果您将 Aframe src 替换为我在代码中注释掉的早期版本 (0.2.0) - 如果您想尝试的话,这将有效。

当前版本 (0.8.0) 的文档似乎仍然支持 mouseenter 事件: https://aframe.io/docs/0.8.0/components/cursor.html 并指定:

“mouseenter:当光标与实体相交时,在光标和相交实体(如果有)上发射”

为了记录,Aframe 版本 0.8.2 的反应类似于 0.8.0

你能告诉我是什么吗?

【问题讨论】:

    标签: aframe mouseenter


    【解决方案1】:

    <a-event>deprecated since 0.4.0。使用event-set-component:

    <a-box color="#0000FF" 
           width="1" height="1" depth="1"
           position="0 0 -5"
           rotation="45 45 45"
           scale="1 1 1"
           event-set__mouseenter="scale: 2 2 2"
           event-set__mouseleave="scale: 1 1 1">
             <a-animation attribute="rotation" begin="click" repeat="indefinite" to="0 360 0"></a-animation>  
    </a-box>
    

    演示:https://glitch.com/edit/#!/rainy-camera-1?path=index.html:14:7

    【讨论】:

    • 对尝试此修复的其他人的注意事项:您还必须包含
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-03
    • 2018-08-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多