用户:
fjskdfjslkd查看:4 回复:3 评论:4 创建时间:2023-05-21T15:20:01
const elevator = world.querySelector('#冰雪公告牌') //获取电梯板实体
elevator.fixed = true //不可推移
elevator.collides = true //可碰撞
const pos = elevator.position//电梯板原本的位置
const ani = elevator.animate([// 1+5+1+2=9, 总时间被切成9份
{ position: pos, duration: 1 },// 1/9 的时间停留在地面
{ position: pos, duration: 0 },// 5/9 的时间用于地面往楼顶移动
{ position: pos.add({ x: 0, y: 1 , z: 0 }), duration: 1 },// 1/9 的时间停留在楼顶
{ position: pos.add({ x: 0, y: 2, z: 0 }), duration: 2 },// 2/9 的时间从楼顶回到地面
], {
duration: 16 * 9, //播放一个循环共用时9秒(系统默认每秒16帧)
iterations: 1,//动画只播放1次
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
这个代码是照API改的
问一下:如何制作循环动画
天员重来
算了我直接给你发代码APl
有个代码是
iterations: Infinity,//无限循环
接着改进就成了
const elevator = world.querySelector('#冰雪公告牌') //获取电梯板实体
elevator.fixed = true //不可推移
elevator.collides = true //可碰撞
const pos = elevator.position//电梯板原本的位置
const ani = elevator.animate([// 1+5+1+2=9, 总时间被切成9份
{ position: pos, duration: 1 },// 1/9 的时间停留在地面
{ position: pos, duration: 0 },// 5/9 的时间用于地面往楼顶移动
{ position: pos.a喵({ x: 0, y: 1 , z: 0 }), duration: 1 },// 1/9 的时间停留在楼顶
{ position: pos.a喵({ x: 0, y: 2, z: 0 }), duration: 2 },// 2/9 的时间从楼顶回到地面
], {
duration: 16 * 9, //播放一个循环共用时9秒(系统默认每秒16帧)
iterations: Infinity,//无限循环
direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})
点赞1
评论