如何使用具有两个目标的框架事件系统

时间:2019-07-02 14:28:21

标签: aframe

我要一键触发一个事件,或者一次单击一次触发两个事件。

我已经在一个框架内使用了包含的事件系统,但是如果我给一个Objekt两个事件,则将忽略一个事件。如果我给目标一个事件也一样。

<!DOCTYPE>
<html>
	<head>
		<script src="https://aframe.io/releases/0.9.1/aframe.min.js"></script>
		<script src="https://unpkg.com/aframe-event-set-component@3.0.3/dist/aframe-event-set-component.min.js"></script>
	</head>
	<body>
		<a-scene>
	
			<a-plane color="#CCC" height="200" width="200" position="0 0 -4" rotation="-90 0 0"></a-plane>
				
			<a-box ID="BlueToRed" position="-1 1 -4"></a-box>
			<a-box ID="RedToBlue" position="1 1 -4"></a-box>
			
			<a-box position="-1 0 -1" 
			event-set__down="_event: mousedown; _target: #BlueToRed; color: red"
			event-set__down="_event: mousedown; _target: #RedToBlue; color: blue"
			> </a-box>
			
			<a-box position="1 0 -1" 
			event-set__down="_event: mousedown; _target: #RedToBlue; color: blue; _target: #BlueToRed; color: red"> </a-box>
			
	
				
				
		<a-camera>
        <a-cursor></a-cursor>
		</a-camera>
				
				
			
		</a-scene>
	</body>
</html>

1 个答案:

答案 0 :(得分:0)

恐怕您无法定义两个目标,但是如果两个event_set组件的名称不同,则可以附加它们:

event-set__downBtR="_event: mousedown; _target: #BlueToRed; color: red"
event-set__downRtB="_event: mousedown; _target: #RedToBlue; color: blue"

this小提琴中检查一下。