Lv.1
azazazi
在 【代码】和平队长皮肤代码 中回复
const bodyData = [
{ bodyPart: Box3BodyPart.TORSO, name: '躯干', mesh: 'mesh/和平队长身体部件.vb', offset: [0, 0.5, 0], rotate: [0, 90, 0], scale: [0.5, 0.5, 0.5] },
{ bodyPart: Box3BodyPart.LEFT_LOWER_ARM, name: '左下臂', mesh: 'mesh/和平队长手部件.vb', offset: [-0.15, 0.25, -0.3], rotate: [50, 50, -50], scale: [0.6, 0.6, 0.6] },
{ bodyPart: Box3BodyPart.RIGHT_LOWER_ARM, name: '右下臂', mesh: 'mesh/和平队长手部件.vb', offset: [0.15, 0.25, -0.3], rotate: [-50, -50, -50], scale: [0.6, 0.6, 0.6] },
]
world.onPlayerJoin(({ entity }) => {
// 隐藏所有身体部件!
for (const bodyPart in entity.player.skinInvisible) {
entity.player.skinInvisible[bodyPart] = true;
}
// 根据配置穿戴身体各个部件
for (const data of bodyData) {
addWearable(entity, data)
}
});
// 添加部件
function addWearable(entity, data) {
// 这一步是把角度转成弧度
const orientation = new Box3Quaternion(0, 0, 0, 1)
.rotateZ(data.rotate[2] * Math.PI / 180)
.rotateX(data.rotate[0] * Math.PI / 180)
.rotateY(data.rotate[1] * Math.PI / 180)
// 将上面声明的配置一一对应地传递给传递API
entity.player.addWearable({
bodyPart: data.bodyPart,
mesh: data.mesh,
orientation: orientation,
scale: data.scale,
offset: data.offset,
})
}2022-08-01T12:07:24 点赞:0