【发布时间】:2018-04-18 22:09:30
【问题描述】:
是否可以在帧中的天空上添加淡入或淡出动画?
当用户将光标悬停在球上时如何添加动画?
在此示例中,当您将鼠标悬停时,背景会发生变化,但没有动画。
AFRAME.registerComponent('set-sky', {
schema: {
default: ''
},
init() {
const sky = document.querySelector('a-sky');
this.el.addEventListener('click', () => {
sky.setAttribute('src', this.data);
});
}
});
<script src="https://rawgit.com/aframevr/aframe/b813db0614ac2b518e547105e810b5b6eccfe1c8/dist/aframe.min.js"></script>
<a-scene>
<a-camera position="0 2 4">
<a-cursor color="#4CC3D9" fuse="true" timeout="10"></a-cursor>
</a-camera>
<a-sphere color="#F44336" radius="1" position="-4 2 0" set-sky="https://c3.staticflickr.com/2/1475/26239222850_cabde81c39_k.jpg"></a-sphere>
<a-sphere color="#FFEB3B" radius="1" position="4 2 0" set-sky="https://c2.staticflickr.com/2/1688/25044226823_53c979f8a1_k.jpg"></a-sphere>
<a-sky></a-sky>
</a-scene>
【问题讨论】:
标签: javascript html aframe virtual-reality