html动画如何设置恢复原状态,如果暂停了动画的播放,元素的样式将回到最原始设置状态...

你的问题可以这样解决,

如果暂停了动画的播放,元素的样式将回到最原始设置状态

@keyframes move {

0%{

transform: translateY(90px);

background: orange;

}

15%{

transform: translate(90px,90px);

}

30%{

transform: translate(180px,90px);

}

45%{

transform: translate(90px,90px);

}

60%{

transform: translate(90px,0);

}

75%{

transform: translate(90px,90px);

}

90%{

transform: translate(90px,180px);

}

100%{

transform: translate(90px,90px);

background: green;

}

}

div {

width: 200px;

height: 200px;

border: 1px solid red;

margin: 20px auto;

}

span{

display: inline-block;

width: 20px;

height: 20px;

background: orange;

transform: translateY(90px);

animation-name: move;

animation-play-state:paused;

}

div:hover span {

animation-name: move;

animation-duration: 10s;

animation-timing-function: ease-in;

animation-delay: .2s;

animation-iteration-count:infinite;

animation-direction:alternate;

animation-play-state:running;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在three.js中加载动画需要用到以下三个类: 1. `GLTFLoader`:用于加载gltf文件,它是three.js官方提供的一个加载器。 2. `AnimationMixer`:用于管理动画的混合器,每个模型只需创建一个AnimationMixer对象即可。 3. `AnimationAction`:用于控制动画播放、停止、暂停等操作。 下面是一个加载gltf模型并播放动画的示例代码: ```javascript import * as THREE from 'three'; import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; const loader = new GLTFLoader(); loader.load('model.gltf', function (gltf) { const model = gltf.scene; const mixer = new THREE.AnimationMixer(model); const action = mixer.clipAction(gltf.animations[0]); action.play(); scene.add(model); function animate() { requestAnimationFrame(animate); mixer.update(deltaTime); renderer.render(scene, camera); } animate(); }, undefined, function (error) { console.error(error); }); ``` 在上述代码中,我们先创建了一个GLTFLoader对象,并通过它加载了一个gltf模型。在加载成功的回调函数中,我们获取到了模型的根节点,创建了一个AnimationMixer对象,并使用它来管理模型的动画。通过clipAction方法可以获取到动画的Action对象,并对其进行播放等操作。最后,将模型添加到场景中,并在animate函数中更新AnimationMixer对象的状态。 需要注意的是,在动画播放时需要在循环渲染的函数中调用mixer.update方法来更新AnimationMixer对象的状态,同时需要传入deltaTime参数以便计算动画的进度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值