如何在Aframe中更改另一个对象的属性?

时间:2017-04-28 17:24:17

标签: aframe

在Javascript中我会做parent.document.sphere1.setAttribute('color','blue'); 这可能吗?

 

2 个答案:

答案 0 :(得分:0)

呀。

`document.querySelector('a-sphere')。setAttribute('color','blue');

https://aframe.io/docs/0.5.0/guides/using-javascript-and-dom-apis.html

答案 1 :(得分:0)

我在这里使用Kevin的组件解决了这个问题(他提出了这个想法): [https://github.com/ngokevin/aframe-event-set-component][1]

然后,按照他的说明或将javascript添加到您的html页面的头部并添加类似的代码:

<a-image id="map1" src="img/map.png" position="0 14 0" rotation="0 -60 0" height="1" width=".5" scale="6 6 6"
event-set__1="_event: click; _target: #mycamera; position: 0 0 -18;"
event-set__2="_event: click; _target: #secondfloor1; visible: true;"
event-set__3="_event: mouseenter; _target: #archiveTxt; visible: true;"
event-set__4="_event: mouseleave; _target: #archiveTxt; visible: false;">
</a-image>

移动相机或传送只需给你的相机id =“myCamera”。 仍然无法弄清楚这个动画,但这是一个很好的开始。事件集编号必须按上述顺序排列。

相关问题