【发布时间】:2018-09-09 13:39:41
【问题描述】:
我从未使用过 html、javascript 或 a-frame,我想让三个 collada 文件依次可见然后不可见(如关键帧动画序列)并循环播放该动画。 除了循环动画的可能性之外,该代码有效。
<script src="https://aframe.io/releases/0.7.1/aframe.min.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/master/dist/aframe-
extras.loaders.min.js"></script>
<script src="play-all-model-animations.js"></script>
<body>
<a-scene>
<a-assets>
<a-asset-item id="t1" src="1a.gltf"></a-asset-item>
<a-asset-item id="t2" src="2a.gltf"></a-asset-item>
<a-asset-item id="t3" src="3a.gltf"></a-asset-item>
</a-assets>
<a-gltf-model id="model1" src="#t1" visible="false">
<a-animation id="anim1" attribute="visible" begin="1000"; dur="2000";
to="false">
</a-animation>
</a-gltf-model>
<a-gltf-model id="model2" src="#t2" visible="false">
<a-animation id="anim2" attribute="visible" begin="2000"; dur="2000";
to="false">
</a-animation>
</a-gltf-model>
<a-gltf-model id="model3" src="#t3" visible="false">
<a-animation id="anim3" attribute="visible" begin="3000"; dur="2000";
to="false">
</a-animation>
</a-gltf-model>
<script>
anim1.addEventListener('animationend', function () {
model1.setAttribute('visible', 'true');
});
</script>
<script>
anim2.addEventListener('animationend', function () {
model1.setAttribute('visible', 'false');
model2.setAttribute('visible', 'true');
});
</script>
<script>
anim3.addEventListener('animationend', function () {
model2.setAttribute('visible', 'false');
model3.setAttribute('visible', 'true');
});
</script>
</a-scene>
</body>
我想我必须在“animationend 函数”中开始每个动画,而不是在“开始”时间开始动画。 有人知道如何开始吗? javascript函数的动画id =“anim1”? 我愿意提供任何帮助。
【问题讨论】:
标签: javascript html animation aframe collada