用户:
神岛吉吉喵查看:73 回复:54 评论:73 创建时间:2022-07-01T19:02:52
最近阿吉看到不少美术场景优秀的地图作品
出现了一些之前没见过的功能
比如风车、水车的旋转
到底是怎么实现的呢?![]()



于是趁着月黑风高,阿吉偷偷潜入地图
成为了一名代码搬运工!
//旋转动画
async function loopRotateEntityZ(entityName, time = 30, angle = -Math.PI / 36) { //loopRotateEntity=90度类型
const entity = world.querySelector(`#${entityName}`)
while (1) {
await sleep(time)//数越小越快
entity.meshOrientation = entity.meshOrientation.rotateZ(angle)//PI=180度
}
}
async function loopRotateEntityX(entityName, time = 30, angle = -Math.PI / 36) { //loopRotateEntity=90度类型
const entity = world.querySelector(`#${entityName}`)
while (1) {
await sleep(time)//数越小越快
entity.meshOrientation = entity.meshOrientation.rotateX(angle)//PI=180度
}
}
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水车')) {
loopRotateEntityX(e.id, 30, Math.PI / 36)
}
})
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水动X')) {
loopRotateEntityX(e.id, 100, Math.PI / 1)
}
})
world.querySelectorAll('*').forEach(e => {
if (e.id.startsWith('水动Z')) {
loopRotateEntityZ(e.id, 100, Math.PI / 1)
}
})
loopRotateEntityZ('风车部件01-1')
loopRotateEntityZ('风格部件03-1')
悄悄提示一下:
想实现图里的效果,光代码还不够
记得善用模型的打组功能哦!
打组功能教程:https://shequ.codemao.cn/community/420951
快去地图里试一下吧!
